Get account data
Get account data

Aave · Reads onchain state

Reads the socket's overall position in an Aave market: collateral, debt, borrow capacity, and health factor. The pool aggregates every reserve you use 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

    Declares aave_market as a caller supplied parameter, taking whichever market address is passed at execution time.

  2. 2·Take

    Declares target_debt as a second caller supplied parameter, the debt figure the caller wants measured against.

  3. 3·Get account data

    Reads the socket's overall position in the market from slot 0.0, pulling collateral, debt, borrow capacity, and health factor.

  4. 4·Compare two values

    Checks whether current debt in slot 2.1.1 is greater than the target_debt in slot 1.0, returning a boolean about debt sitting above target.

  5. 5·Set

    Stores that comparison as debt_is_over_target, the flag recording which side of the target debt falls on.

  6. 6·Set

    Initializes debt_delta to 0, seeding the running difference before either branch writes to it.

  7. 7·Predicate

    Branches on debt_is_over_target being equal to true, entering the following block only when current debt exceeds target.

  8. 8·Calculate

    Within that branch, subtracting the target_debt from current debt in slot 2.1.1 sizes how far debt overshoots.

  9. 9·Set

    That overshoot is written into debt_delta, recording the amount above target.

  10. 10·Else branch

    Opens the else branch for the case where debt sits at or below target.

  11. 11·Calculate

    On this side, subtracting current debt in slot 2.1.1 from the target_debt sizes how far debt falls short.

  12. 12·Set

    The shortfall is written into debt_delta, recording the amount below target.

  13. 13·End block

    Closes the conditional block, rejoining a single path after either branch.

  14. 14·Bubble

    Surfaces debt_is_over_target as an output, signaling whether debt is above or below the target.

  15. 15·Bubble

    Surfaces debt_delta as an output, the absolute distance between current debt and the target.

Take
Take
Get account 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 WETH/USDC at Target HF

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

    database
    boolean
    aave
  • Loop at Target HF + Borrow Rate Entry & Exit Guard

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

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

    boolean
    aave
    evm

On other protocols · 4