Skip to main content
Avana logo

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.

Repay, debt-free withdrawal and removal, repay-all-and-withdraw, zero-credit release and fee collection read no MarketRegistry state, pause state, address freeze, breaker or price. A borrower can always exit, whatever the protocol state.

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 PositionRef made 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.

FunctionParametersPurpose
pledgemarketId, position, deadlinePledges 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.
recreditmarketId, position, topUp, deadlineCredits 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.
borrowmarketId, debtReserveId, amount, receiver, deadline, minHealthFactor, expectedNonceBorrows 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.
repayborrower, marketId, debtReserveId, maxRepaySpend, repayAll, deadlineRepays 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.
withdrawmarketId, position, units, deadline, minHealthFactorWithdraws 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.
repayAllAndWithdrawmarketId, position, units, debtReserveIds, maxRepaySpends, deadlineRepays 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.
removeLiquiditymarketId, position, units, minAmounts, deadline, minHealthFactorRemoves 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.
repayWithCollateralRepayWithCollateralParams pRepays 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.
collectFeesmarketId, position, deadlineCollects 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.
releaseZeroCreditmarketId, position, deadlineReturns the position of a record whose credit a seizure took to zero. Mints, burns and supplies nothing. Depositor of record only.

RepayWithCollateralParams

FieldMeaning
marketIdThe account's market
positionThe record whose units repay
unitsCredited units released from the record
debtReserveIdThe debt reserve repaid
minAmountsLeast raw amount of each pool token the unwind must return
minDebtRepaidSmallest repayment accepted, in debt-asset base units
deadlineLast valid block timestamp
minHealthFactorLeast 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.

FunctionPause state of the HubOther checks
pledgeRefused 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 debtRegistered market on an approved Spoke, matching integration, exact position shape, price state, caps, minimum pledge value ($10), breakers, 16-record limit
recreditSame as a pledgeTop-up checks and a new cap charge
borrowRefused unless the market's Hub and the debt reserve's funding Hub are both in state NoneReceiver 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
repayNever readNone beyond the deadline and an existing proxy
withdraw without debtNever readNone; no price is read
withdraw with debtRefused if the Hub is PausedAddress freeze, the RiskModule's withdraw checks, health factor after the withdrawal
repayAllAndWithdrawNever readEvery debt reserve must end at zero
removeLiquidityWithout debt never read; with debt refused if PausedWith debt: address freeze, withdraw checks, remaining record at least the minimum pledge value, health factor
repayWithCollateralRefused only under Paused with reason MintPathSuspect; open under Frozen and Paused with reason GeneralAddress freeze, enabled debt reserve, non-zero debt, health factor not lower than before; reads no breaker
collectFeesNever readDepositor of record only
releaseZeroCreditNever readDepositor 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 DeadlineExpired when 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 from borrowNonce(proxy). The Adapter consumes it and increments it; a mismatch reverts with BadNonce, 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 minHealthFactor in 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

ViewReturns
proxyOfThe wallet's proxy for a market, or zero
walletOfThe wallet bound to a proxy
accountOfThe binding stored at proxy creation: wallet, Spoke, market, vault token and reserve
predictProxyThe CREATE2 address of a wallet and market's proxy, deployed or not
borrowNonceThe next expected borrow nonce of a proxy

Events

EventEmitted when
UserProxyCreatedA wallet's proxy for a market is created and bound
CollateralAddedA position is pledged, credited, minted and supplied
CollateralSuppliedVault-token units are supplied to the Spoke for a proxy
CollateralRecreditedUnits added to a pledged position are credited
BorrowedA debt asset is borrowed; carries the receiver, amount, nonce and health factor after
RepaidA payer repays one debt reserve of a borrower's account; carries the amount spent and the debt after
CollateralWithdrawnA record is withdrawn and its position returned
CollateralReducedPart of a record is removed and its principal paid to the depositor
RepaidWithCollateralA debt reserve is repaid with released units; carries health factors before and after
CollateralDisabledThe vault-token reserve is disabled as collateral for a proxy whose supply reached zero
SeizedUnitsBurnedLPVaultSwap has the Adapter burn seized units during a liquidation

Main Errors

ErrorMeaning
DeadlineExpiredThe block timestamp is past the deadline
BadNonceThe expected nonce differs from the proxy's borrow nonce
ApplicationFrozenNew activity refused while the Hub is Frozen
ApplicationPausedNew activity refused while the Hub is Paused
AddressIsFrozenA frozen address tried new activity
NoProxyThe wallet has no proxy for the market
UnknownMarketThe market is not registered on an approved CDP Spoke
UnknownSpokeThe market's CDP Spoke is not approved
UnknownDebtReserveThe debt reserve is not enabled on the account's CDP Spoke
IntegrationMismatchThe position belongs to another AMM integration
InvalidReceiverThe borrow receiver is refused by the receiver rule
ZeroAmountAn amount or units argument is zero
RepayExceedsMaxA repay-all found debt above the cap; nothing moved
DebtRemainingDebt remains after a repay-all or before the withdrawal of repay-all-and-withdraw
NothingToRepayRepay with collateral named a reserve with no debt
HealthFactorNotImprovedRepay with collateral would leave a lower health factor
UnitsMismatchA verified amount differs from the expected one
BackingMismatchVault-token supply no longer matches recorded backing after the call
SupplyIncompleteSupplied shares did not rise by exactly the credited units
LengthMismatchArray 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.