Docs · Guides
Supply and redeem
Supply an asset to its lending pool for sealed shares that earn the borrow rate, and redeem them, in the app or from code.
Supplying lends an asset to its pool. You hold shares of the pool, sealed like everything else in your account, and their value rises as borrowers pay interest. The pool's totals are public.
Before you supply
You need a Mesa balance of the asset. See Deposit and withdraw.
Each pool's page on Lend shows its Supply rate, Total supplied, Total borrowed, Utilization and Share price. GET /v1/pools returns the same.
Supply
1. Open Lend and choose the asset.
2. In the "Supply" panel, with "Supply" selected, enter the amount.
3. Press "Review supply". Check the amount, the supply rate and "Shares at".
4. Press "Supply".const { share, batchNumber } = await mesa.supply({
poolId: 'USDC',
amount: 5_000_000_000n, // 5,000 USDC
})
console.log(share?.shares, share?.valueQuote)A supply goes through a batch. It is sealed until the batch closes, then the pool mints shares at the share price of that batch:
shares = amount / share priceYour shares appear under Your shares on the pool's page and under Shares on Portfolio, with their value at the current share price. Until the batch settles, the entry reads "deposit in batch N".
On the batch record, the pool's Supplied total rises by your amount, with no name on it.
What your shares earn
The pool accrues interest each time it clears a batch. Borrowers pay the borrow rate, the pool's reserve share of it goes to the protocol, and the rest raises the share price. Your number of shares stays the same and each is worth more.
The supply rate is the borrow rate times utilization, less the reserve share. Both rates move with utilization along the pool's rate curve.
Redeem
1. Open Lend and choose the asset.
2. In the "Supply" panel, select "Redeem".
3. Enter the shares to redeem. The field shows how many you hold.
4. Press "Review redeem". Check the share price and "Available in the pool".
5. Press "Redeem".const held = mesa.snapshot().shares.find((s) => s.vaultId === 'vault-lend-usdc')
if (held) await mesa.redeem({ poolId: 'USDC', shares: held.shares })A redeem also goes through a batch. It burns the shares and pays the asset to your balance at the share price of that batch.
A pool pays redeems from its cash, the part that is not lent out. Available in the pool on the review is that amount. A redeem larger than the cash the pool has when the batch clears is refused: nothing is paid, and the shares are still yours. Take them back with a reclaim, which needs no wait once the batch has cleared, then redeem up to what is available or wait for borrowers to repay. High utilization raises the borrow rate, which draws repayments and new supply.
On the pool's page, the line under "Your shares" reads "withdrawal refused in batch N". Press "Reclaim shares".const usdc = mesa.snapshot().shares.find((s) => s.vaultId === 'vault-lend-usdc')
if (usdc?.pending?.state === 'refused') {
await mesa.mesa.run({ kind: 'reclaim', orderId: usdc.pending.actionId }, console.log)
}What can stop a supply or redeem
| You see | Cause | Do |
|---|---|---|
| "Deposit into Mesa first" | No free balance of the asset | Deposit, then supply |
| "More than is available." | More than your balance, or more shares than you hold | Enter less |
No unspent share note covers the requested amount. | The shares named exceed one share note | Redeem the amount of one holding at a time |
BATCH_CLOSED, STALE_BATCH | The batch closed while the action was being proved | Send it again |
ProtocolPaused | The protocol is paused | Supplies resume when it is unpaused. Redeems run while paused. |