Get account data
Get account data

Aave · Reads onchain state

Reads an address's overall position in an Aave market: collateral, debt, borrow capacity, and health factor. The pool aggregates every reserve the account uses into base-currency totals for collateral and debt, the amount still available to borrow, the position's weighted LTV and liquidation threshold, and the health factor at 18 decimals. This is the exact view the pool uses when it decides whether a borrow or withdraw is allowed and whether the position can be liquidated. Reach for it to gate any step that changes leverage: require the health factor stays above a floor, size a borrow from availableBorrows, or trigger a repay when debt drifts past a target.

Target Debt to Debt Delta

plug
aave
boolean
15actions
  1. 1·Take

    Declaring aave_market as a caller supplied parameter, this takes whichever Aave market address is passed at execution time.

  2. 2·Take

    A second caller supplied parameter, target_debt, is declared, taking the debt level the caller names at execution.

  3. 3·Get account data

    Reading the socket's overall position from the market wired in slot 0.0, this surfaces collateral, debt, borrow capacity, and health factor.

  4. 4·Compare two values

    Comparing current debt from the account data against target_debt with a greater than operator, this returns a boolean about debt sitting above target.

  5. 5·Set

    Assigning that comparison result to debt_is_over_target, this names the over-target flag for later steps.

  6. 6·Set

    Setting debt_delta to 0, this seeds the delta variable with a default before either branch overwrites it.

  7. 7·Predicate

    A predicate opens on debt_is_over_target equaling true, so the following branch runs only when debt exceeds target.

  8. 8·Calculate

    Subtracting target_debt from current debt sizes the amount by which debt overshoots the target.

  9. 9·Set

    Storing that difference in debt_delta, this records the excess debt on the over-target side.

  10. 10·Else branch

    Opening the else branch, this defines what runs when debt is at or below target.

  11. 11·Calculate

    Subtracting current debt from target_debt sizes the amount by which debt falls short of the target.

  12. 12·Set

    Holding that difference in debt_delta, this records the shortfall on the under-target side.

  13. 13·End block

    Closing the innermost open block, this ends the conditional opened above.

  14. 14·Bubble

    Surfacing debt_is_over_target as an output, this reports whether debt sits above the target.

  15. 15·Bubble

    Bubbling debt_delta as an output, this reports the absolute distance between current debt and target.

Take
Take
Get data in
Is
Set to
Set to
Calculate
Set to
Else
Calculate
Set to
End block
Bubble
Bubble
  • Target Debt to Debt Delta

    plug
    aave
    boolean
  • Wind or Unwind to Maintain Target HF

    plug
    aave
    math
  • Loop at Target HF + Borrow Rate Entry & Exit Guard

    aave
    boolean
    evm
  • Loop WETH/USDC at Target HF

    aave
    evm
    boolean
  • Loop at Target HF + Borrow Rate Exit Guard

    database
    boolean
    aave
  • Loop at Target HF + Trailing Stop Loss

    database
    boolean
    aave
  • Swarm: Loop WETH/USDC at Target HF

    boolean
    aave
    evm

On other protocols · 5