AaveAdapter Entry Points
The AaveAdapter is the single entry point for every borrower action on every CDP Spoke of its chain. This page lists each function, what it checks and what it emits.
Overview
One AaveAdapter runs per chain behind one fixed address. Calls go from the wallet to the AaveAdapter, then to the wallet's PositionProxy for that market, then to the CDP Spoke. The Adapter creates proxies through the immutable ProxyManager, has Collateralization take custody and record backing, is the only minter and burner of every vault token, runs the RiskModule's checks and returns their errors unchanged.
Every entry point takes the protocol Lock first and releases it last, so no Avana call can re-enter another. The Adapter holds no token at the end of any call and charges no fee on borrowing or interest.
Accounts and Positions
- An account is one PositionProxy bound to one wallet, CDP Spoke and market. Its address is a CREATE2 address known before deployment; the first pledge to a market deploys it.
- Each account has its own Aave health factor. Nothing is cross-collateralized between markets of the same wallet.
- An account holds at most 16 records (pledged positions) per market, so one liquidation always fits in a block.
- Positions are named by a
PositionRefmade of the AMM integration identifier and the integration's position key, never by a bare NFT token ID. Token amount arrays follow the market's token order.
Entry Points
The borrower functions are split across two interfaces, IAaveAdapterUser and IAaveAdapterCollateral.
| Function | Parameters | Purpose |
|---|---|---|
pledge | marketId, position, deadline | Pledges one AMM position into a market. Creates the wallet's proxy on its first pledge, takes custody through the market's LPVault, mints vault tokens equal to the credited units, supplies them to the CDP Spoke and enables them as collateral. Returns the proxy, the record ID and the credited units. |
recredit | marketId, position, topUp, deadline | Credits units added to a pledged position. For an NFT position the depositor first adds liquidity on the AMM and passes empty bytes; for fungible LP shares the bytes encode the amount. Depositor of record only. |
borrow | marketId, debtReserveId, amount, receiver, deadline, minHealthFactor, expectedNonce | Borrows an approved debt asset on the caller's account for the market and sends it to the receiver. There is no minimum borrow beyond a non-zero amount and no minimum debt. |
repay | borrower, marketId, debtReserveId, maxRepaySpend, repayAll, deadline | Repays one debt reserve of any borrower's account with the caller's funds. A partial repay pulls the smaller of the cap and the debt. A repay-all pulls the full cap, repays the live debt and refunds the rest in the same call, or reverts if debt would remain. |
withdraw | marketId, position, units, deadline, minHealthFactor | Withdraws one record's credited units, burns them and returns the whole position, with its uncollected fees, to its depositor of record. With debt, the health check runs after the withdrawal. |
repayAllAndWithdraw | marketId, position, units, debtReserveIds, maxRepaySpends, deadline | Repays each named debt reserve in full under its own cap, requires every debt reserve of the account to be at zero, then makes a debt-free withdrawal of one record, in one call. |
removeLiquidity | marketId, position, units, minAmounts, deadline, minHealthFactor | Removes part of one record's credited units while the position stays in custody. The removed principal is paid to the depositor of record, each token at least its minimum. With debt, the remaining record must still be worth the market's minimum pledge value. |
repayWithCollateral | RepayWithCollateralParams p | Repays one debt reserve with units released from one record, through LPVaultSwap, with no bonus and no Avana fee. LPVaultSwap flash-borrows the debt asset, repays, unwinds and swaps the units; any leftover is paid to the caller in the debt asset. While debt remains, the health factor must not fall. |
collectFees | marketId, position, deadline | Collects the fees a custodied position has earned and pays them to the depositor of record. Principal, units and health factor are unchanged. Reverts for AMM protocols whose fees roll into the position. |
releaseZeroCredit | marketId, position, deadline | Returns the position of a record whose credit a seizure took to zero. Mints, burns and supplies nothing. Depositor of record only. |
RepayWithCollateralParams
| Field | Meaning |
|---|---|
marketId | The account's market |
position | The record whose units repay |
units | Credited units released from the record |
debtReserveId | The debt reserve repaid |
minAmounts | Least raw amount of each pool token the unwind must return |
minDebtRepaid | Smallest repayment accepted, in debt-asset base units |
deadline | Last valid block timestamp |
minHealthFactor | Least health factor after the call while debt remains, WAD |
Every swap leg also carries an oracle-derived minimum output, so the caller's minimums can only tighten it.
Gates per Function
The Adapter enforces the deadline, the nonce, the receiver rule, proxy resolution, debt-reserve enablement, the Hub's pause state and the address freeze. The RiskModule enforces the sequencer gate, price states and ages, Aave pauses and freezes, offboarding, configuration drift, Hub share accounting, liquidation halts, circuit breakers and the health factor.
| Function | Pause state of the Hub | Other checks |
|---|---|---|
pledge | Refused under Paused with reason MintPathSuspect; rescue top-ups only under Paused with reason General or for a frozen caller; refused under Frozen for an account with no debt | Registered market on an approved Spoke, matching integration, exact position shape, price state, caps, minimum pledge value ($10), breakers, 16-record limit |
recredit | Same as a pledge | Top-up checks and a new cap charge |
borrow | Refused unless the market's Hub and the debt reserve's funding Hub are both in state None | Receiver rule, address freeze of caller and receiver, nonce, every price and breaker gate over the market and every debt reserve of the account, health factor after the borrow |
repay | Never read | None beyond the deadline and an existing proxy |
withdraw without debt | Never read | None; no price is read |
withdraw with debt | Refused if the Hub is Paused | Address freeze, the RiskModule's withdraw checks, health factor after the withdrawal |
repayAllAndWithdraw | Never read | Every debt reserve must end at zero |
removeLiquidity | Without debt never read; with debt refused if Paused | With debt: address freeze, withdraw checks, remaining record at least the minimum pledge value, health factor |
repayWithCollateral | Refused only under Paused with reason MintPathSuspect; open under Frozen and Paused with reason General | Address freeze, enabled debt reserve, non-zero debt, health factor not lower than before; reads no breaker |
collectFees | Never read | Depositor of record only |
releaseZeroCredit | Never read | Depositor of record only; record at zero credited units |
The price-state rules behind each gate are on the price states page: Price States.
Deadline, Nonce and Health Factor
- Deadline: every entry point reverts with
DeadlineExpiredwhen the block timestamp is past the deadline, so a transaction held back by a builder or a congested chain cannot execute later on different terms. - Nonce: each borrow names the proxy's current borrow nonce in
expectedNonce, read fromborrowNonce(proxy). The Adapter consumes it and increments it; a mismatch reverts withBadNonce, so a signed borrow cannot be replayed or reordered. A reverted borrow leaves the nonce unchanged. - Minimum health factor: borrow, withdraw, partial removal and repay with collateral take a
minHealthFactorin WAD. After a borrow or a withdrawal with debt, the health factor excluding rescue units must be at least the larger of 1.00, the market's optional hard floor (off by default) and this value. Pass 0 for no extra bound. - The app recommends borrowing to a health factor of 1.10. No contract enforces that value; a caller who passes 1.10 as the minimum gets it enforced.
Receiver Rule and Approvals
A borrow's receiver cannot be the zero address, any registered proxy, the Adapter, Collateralization, any LPVault, LPVaultSwap, the payout escrow, the flash source, any Avana Hub, any approved CDP Spoke or any Spoke listed on the borrowed asset's funding Hub. A refused receiver reverts with InvalidReceiver before any proxy call.
Users grant only two kinds of approval:
- For a pledge, an approval of exactly one position to the immutable LPVault of that AMM protocol: a per-token ERC-721 approval or permit for Uniswap v3 and Slipstream. Never an operator approval for all tokens.
- For a repay, an approval to the AaveAdapter of exactly the repay amount in the debt asset. For a repay-all, the amount is a repay-all quote sized to the deadline; the Adapter pulls it in full and refunds the unused part in the same call, leaving zero allowance.
Views
| View | Returns |
|---|---|
proxyOf | The wallet's proxy for a market, or zero |
walletOf | The wallet bound to a proxy |
accountOf | The binding stored at proxy creation: wallet, Spoke, market, vault token and reserve |
predictProxy | The CREATE2 address of a wallet and market's proxy, deployed or not |
borrowNonce | The next expected borrow nonce of a proxy |
Events
| Event | Emitted when |
|---|---|
UserProxyCreated | A wallet's proxy for a market is created and bound |
CollateralAdded | A position is pledged, credited, minted and supplied |
CollateralSupplied | Vault-token units are supplied to the Spoke for a proxy |
CollateralRecredited | Units added to a pledged position are credited |
Borrowed | A debt asset is borrowed; carries the receiver, amount, nonce and health factor after |
Repaid | A payer repays one debt reserve of a borrower's account; carries the amount spent and the debt after |
CollateralWithdrawn | A record is withdrawn and its position returned |
CollateralReduced | Part of a record is removed and its principal paid to the depositor |
RepaidWithCollateral | A debt reserve is repaid with released units; carries health factors before and after |
CollateralDisabled | The vault-token reserve is disabled as collateral for a proxy whose supply reached zero |
SeizedUnitsBurned | LPVaultSwap has the Adapter burn seized units during a liquidation |
Main Errors
| Error | Meaning |
|---|---|
DeadlineExpired | The block timestamp is past the deadline |
BadNonce | The expected nonce differs from the proxy's borrow nonce |
ApplicationFrozen | New activity refused while the Hub is Frozen |
ApplicationPaused | New activity refused while the Hub is Paused |
AddressIsFrozen | A frozen address tried new activity |
NoProxy | The wallet has no proxy for the market |
UnknownMarket | The market is not registered on an approved CDP Spoke |
UnknownSpoke | The market's CDP Spoke is not approved |
UnknownDebtReserve | The debt reserve is not enabled on the account's CDP Spoke |
IntegrationMismatch | The position belongs to another AMM integration |
InvalidReceiver | The borrow receiver is refused by the receiver rule |
ZeroAmount | An amount or units argument is zero |
RepayExceedsMax | A repay-all found debt above the cap; nothing moved |
DebtRemaining | Debt remains after a repay-all or before the withdrawal of repay-all-and-withdraw |
NothingToRepay | Repay with collateral named a reserve with no debt |
HealthFactorNotImproved | Repay with collateral would leave a lower health factor |
UnitsMismatch | A verified amount differs from the expected one |
BackingMismatch | Vault-token supply no longer matches recorded backing after the call |
SupplyIncomplete | Supplied shares did not rise by exactly the credited units |
LengthMismatch | Array arguments differ in length from each other or from the market's token count |
Errors raised by the RiskModule, Collateralization, the LPVault and Aave pass through unchanged, for example PriceNotLive, HealthFactorTooLow, BelowMinPledge, TooManyRecords, BreakerTripped, SequencerDown.
Upgrades and Limits
- The AaveAdapter is a UUPS proxy. Its admin roles can be held only by the chain's Avana timelock; every upgrade waits the normal delay of 5 days and can be cancelled by the governance multisig, the Emergency Guardian, the Aave Protocol Guardian or the Aave governance executor. It has no setters: every address change is an upgrade.
- PositionProxies and the ProxyManager are immutable and carry no logic, so an Adapter upgrade changes account behaviour without touching any proxy.
- What a faulty Adapter could do is bounded by the Aave DAO's Hub add caps and Spoke draw caps, by exact approvals, and by the delay: a borrower who sees a harmful upgrade queued can repay and withdraw before it executes, because those paths read no gate.
- Liquidation does not go through these entry points. LPVaultSwap runs it and asks the Adapter only to burn seized units.
