Skip to content

@lending:debt

Current variable-rate debt of an account in a token, in base units (grows every block as interest accrues).

⚗️ Experimental — available at next.evmcrispr.com.

Returns: number

@lending:debt(account token adapter?)
NameTypeDescription
accountaddressAccount to inspect
tokenaddressBorrowed token (use @token(SYM))
[adapter]lending-adapterLending protocol: AaveV3, Spark or CompoundV3 (default: the best available on the chain)
# Print the connected account's variable WXDAI debt
print "WXDAI debt:" @lending:debt(@me 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d)

Aave keeps the balance on a per-reserve debt token, so this is two hops with a computed target: the debt token address is word 10 of the reserve struct, and the balance is read off whatever address that word holds at assertion time. A market that migrates its debt token between building a batch and executing it is followed rather than cached.

Comet keeps the borrow on the market itself, so it is a single read.

The account may be a live value on either protocol; the token and the market resolve at composition time.