What you can do
| supply | Supply an asset to earn interest | for AVAX call qiAVAX.mint() with AVAX as value; for other assets approve the underlying to the qToken, then qToken.mint(amount) |
| withdraw | Redeem a supplied asset | qToken.redeem(qTokenAmount); redeem the full balance by reading balanceOf(user) on the qToken |
| use-as-collateral | Turn a supplied market on as collateral | Comptroller.enterMarkets([qToken]); Comptroller.exitMarket(qToken) to turn it off |
| borrow | Borrow against collateral | enter the collateral market, check Comptroller.getAccountLiquidity(user) shows positive liquidity, then qToken.borrow(amount) |
| repay | Repay a borrow | USDC or sAVAX: approve the underlying to the qToken, then qToken.repayBorrow(amount). AVAX: qiAVAX.repayBorrow() with AVAX value, or Maximillion.repayBehalf(user) to repay the full debt |
| claim-rewards | Claim BENQI (QI) and AVAX rewards | Comptroller.claimReward(0, user) for QI and Comptroller.claimReward(1, user) for AVAX |
| check-position | Read liquidity and shortfall for an account | Comptroller.getAccountLiquidity(user); a shortfall above 0 means the account can be liquidated |
Positions can be liquidated when the shortfall is above 0. Keep a margin and check it after each borrow or price move.
Interest accrues on each market, so read borrowBalanceCurrent rather than stored values when repaying the full amount.
The Comptroller is a Unitroller proxy and the BENQI admin can change the implementation and market parameters, including collateral factors and pause flags.
Assets that BENQI removed from core markets (for example qiBTC.e, qiBUSD and qiQI) are kept as historical records. Do not supply to them.
Contracts
Read any function, or build a write and sign it. Amounts are in base units (1 USDC = 1000000).Comptroller (Unitroller proxy)other on avalanche0x486Af39519B4Dc9a7fCcd318217352830E8AD9b4
write enterMarkets(address[])
Turn markets on as collateral for the caller. Argument: list of qToken addresses (for example qiAVAX, qiUSDC). Needed before the caller can borrow against a supplied asset.
write exitMarket(address)
Stop using a qToken as collateral. Argument: qToken address. Reverts if the caller would be undercollateralized afterwards.
read getAssetsIn(address)
qToken markets an account has entered as collateral. Argument: account.
read getAccountLiquidity(address)
Returns (error code, liquidity, shortfall) for an account across all entered markets. Error code 0 means success. Shortfall above 0 means liquidatable.
write claimReward(uint8,address)
Claim accrued rewards for a holder. Arguments: rewardType (0 for QI, 1 for AVAX), holder address. Claims across all markets.
read getAllMarkets()
All qToken market addresses listed on the Comptroller.
qiAVAX (AVAX market)pool on avalanche0x5C0401e81Bc07Ca70fAD469b451682c0d747Ef1c
write mint()
Supply AVAX. Send AVAX as msg.value. Returns qiAVAX to the caller. No approval needed.
write redeem(uint256)
Redeem qiAVAX for AVAX. Argument: qiAVAX amount (in qiToken units, 8 decimals).
write borrow(uint256)
Borrow AVAX. Argument: AVAX amount in wei. Requires the market to be entered and enough collateral.
write repayBorrow()
Repay AVAX debt. Send AVAX as msg.value. To repay the full debt without overpaying, use the Maximillion contract instead.
write borrowBalanceCurrent(address)
Accrue interest and return the account's current AVAX debt. Argument: account. Call it as a transaction, or use borrowBalanceStored for a view.
write exchangeRateCurrent()
Accrue interest and return the current exchange rate between qiAVAX and AVAX.
write balanceOfUnderlying(address)
Accrue interest and return the account's supplied AVAX balance. Argument: account.
read getAccountSnapshot(address)
Returns (error, qiToken balance, borrow balance, exchange rate) for an account, using the last accrued state.
read supplyRatePerTimestamp()
Current supply rate per second, scaled to 1e18.
read borrowRatePerTimestamp()
Current borrow rate per second, scaled to 1e18.
qiUSDC (USDC market)pool on avalanche0xBEb5d47A3f720Ec0a390d04b4d41ED7d9688bC7F
write mint(uint256)
Supply USDC. Argument: USDC amount in its 6 decimal units. Approve USDC to this qiToken first. Returns a success code (0 for success).
write redeem(uint256)
Redeem qiUSDC for USDC. Argument: qiUSDC amount (8 decimals).
write borrow(uint256)
Borrow USDC. Argument: USDC amount in 6 decimal units. Requires the market to be entered and enough collateral.
write repayBorrow(uint256)
Repay USDC debt. Argument: USDC amount. Approve USDC to this qiToken first. Pass the full debt amount from borrowBalanceCurrent to close the loan.
write borrowBalanceCurrent(address)
Accrue interest and return the account's current USDC debt. Argument: account.
write exchangeRateCurrent()
Accrue interest and return the current exchange rate between qiUSDC and USDC.
read underlying()
The underlying token address (USDC) of this market.
qisAVAX (sAVAX market)pool on avalanche0xF362feA9659cf036792c9cb02f8ff8198E21B4cB
write mint(uint256)
Supply sAVAX as collateral or to earn interest. Argument: sAVAX amount in wei. Approve sAVAX to this qiToken first. Returns a success code (0 for success).
write redeem(uint256)
Redeem qisAVAX for sAVAX. Argument: qisAVAX amount (8 decimals).
write borrow(uint256)
Borrow sAVAX. Argument: sAVAX amount in wei. Requires the market to be entered and enough collateral.
write repayBorrow(uint256)
Repay sAVAX debt. Argument: sAVAX amount. Approve sAVAX to this qiToken first.
Maximillion (AVAX repay helper)other on avalanche0xd78DEd803b28A5A9C860c2cc7A4d84F611aA4Ef8
write repayBehalf(address)
Repay a borrower's entire AVAX debt on qiAVAX. Argument: borrower address. Send AVAX as msg.value. Any excess AVAX is sent back to the caller.
write repayBehalfExplicit(address,address)
Repay a borrower's AVAX debt on a given qToken. Arguments: borrower, qToken. Send AVAX as msg.value.