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

    The plug opens by declaring aave_market as a caller supplied parameter, taking whichever market address is passed in at execution.

  2. 2·Take

    Next it declares target_debt as a second caller supplied parameter, the debt level the caller wants to measure against.

  3. 3·Get account data

    Reading the socket's Aave position in the market from slot 0.0, this step pulls collateral, debt, borrow capacity, and health factor.

  4. 4·Compare two values

    This comparison checks whether the current debt in slot 2.1.1 is greater than the target_debt in slot 1.0, returning a boolean.

  5. 5·Set

    The boolean result is stored in a named variable called debt_is_over_target so later steps can reference it.

  6. 6·Set

    A variable named debt_delta is initialized to 0, giving the difference a default value before either branch runs.

  7. 7·Predicate

    Control flow branches here on whether debt_is_over_target equals true, entering the following block only when current debt exceeds the target.

  8. 8·Calculate

    Inside that branch, it subtracts the target_debt in slot 1.0 from the current debt in slot 2.1.1, computing how far debt sits above target.

  9. 9·Set

    That difference is written into debt_delta, replacing the initialized zero when debt is over target.

  10. 10·Else branch

    Should the condition fail, the else branch opens for the case where debt is not over target.

  11. 11·Calculate

    In this branch it subtracts the current debt in slot 2.1.1 from the target_debt in slot 1.0, computing the gap below target.

  12. 12·Set

    That gap is written into debt_delta, covering the case where current debt is at or under the target.

  13. 13·End block

    The conditional block is closed here, rejoining a single path after either branch.

  14. 14·Bubble

    The plug surfaces debt_is_over_target as an output, telling the caller which side of the target the debt fell on.

  15. 15·Bubble

    Finally it surfaces debt_delta as an output, reporting 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
  • Swarm: Loop WETH/USDC at Target HF

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

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

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

    aave
    boolean
    evm

On other protocols · 4