Deposit and withdraw
Mint nLPN by depositing LPN; burn nLPN to withdraw principal + accrued interest.
Deposit LPN (mint nLPN)
To participate as a lender in an LPP, users must hold the LPP's LPN currency (for example, USDC) in their wallet. Deposits are submitted as a transaction whose input message is processed by the Cosmos SDK bank module, which transfers the funds into the LPP smart contract.
Upon deposit, lenders receive a receipt token - a CW20 derivative called nLPN - representing their share in the pool. These tokens serve both as proof of deposit and as the mechanism to withdraw the underlying assets later.
The LPP contract tracks a price index representing the current exchange
rate between nLPN and LPN. When the pool is empty (e.g., at genesis),
the initial exchange rate is 1 nLPN = 1 LPN.
Once deposits and borrowing activity begin, the price of nLPN evolves based on:
- Newly deposited LPN tokens
- Interest payments made by borrowers
As time progresses and interest accrues, the value of each nLPN token increases relative to LPN; the lender's share of the pool grows.
The lender's current balance (in LPN terms):
Lender LPN Balance = Lender nLPN Balance × Price per nLPNThe number of nLPN tokens minted for each deposit is determined by the LPP smart contract using the current price index, tracked under the lender's wallet address.
Withdraw LPN (burn nLPN)
On withdrawal, the LPP first computes the LPN the user is entitled to based on the current nLPN-to-LPN exchange rate:
Claimable LPN = Provided nLPN × Price per nLPNOnce the claimable amount is computed:
- The user's nLPN balance is reduced accordingly.
- The LPP's LPN balance is updated to reflect the outflow.
If the user withdraws their entire nLPN balance, the contract automatically includes any accrued interest - effectively closing out their lending position. They no longer hold any nLPN, and they're no longer a participant in the pool.
If the user opts for a partial withdrawal (e.g., 50% of their position), only the corresponding portion of nLPN is burned and the remainder continues to accrue interest.