This project implements a Leveraged Liquid Re-staking Token (LRT) Lending Protocol on the Solana blockchain. It allows users to stake SOL, receive LRT tokens, and use these tokens as collateral for borrowing. The protocol also includes a lending pool where users can deposit SOL and earn interest.
- Staking: Users can stake SOL and receive LRT tokens.
- Lending Pool: Users can deposit SOL into the lending pool and receive LP tokens.
- Borrowing: LRT holders can borrow SOL using their LRT as collateral.
- Interest Accrual: Borrowers accrue interest on their loans.
- Repayment: Borrowers can repay their loans with interest.
- Interest Distribution: Lenders earn interest from borrowers' repayments.
- Rust 1.19.0 or later
- Solana CLI 1.18.0 or later
- Anchor Framework 0.30.1 or later
-
Clone the repository:
git clone https://github.com/Ozodimgba/leveraged-lrt-lending.git cd llrt
-
Install dependencies:
npm install
-
Build the project:
anchor build
-
Update the program ID in
lib.rs
andAnchor.toml
with the new program ID generated during the build. -
Test the project:
anchor test
To initialize a new lending pool:
await program.rpc.initializePool({
accounts: {
pool: poolAccount.publicKey,
lpMint: lpMintAccount.publicKey,
vault: vaultAccount.publicKey,
authority: provider.wallet.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
tokenProgram: TOKEN_PROGRAM_ID,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
});
To stake SOL and receive LRT tokens:
await program.rpc.stake(new anchor.BN(amountToStake), {
accounts: {
authority: provider.wallet.publicKey,
vault: vaultAccount.publicKey,
lsolMint: lsolMintAccount.publicKey,
userLsolAccount: userLsolAccount.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
tokenProgram: TOKEN_PROGRAM_ID,
},
});
To deposit SOL into the lending pool:
await program.rpc.deposit(new anchor.BN(amountToDeposit), {
accounts: {
pool: poolAccount.publicKey,
lpMint: lpMintAccount.publicKey,
vault: vaultAccount.publicKey,
depositorLpAccount: depositorLpAccount.publicKey,
depositor: provider.wallet.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
tokenProgram: TOKEN_PROGRAM_ID,
},
});
To borrow SOL using LRT as collateral:
await program.rpc.borrow(new anchor.BN(amountToBorrow), {
accounts: {
pool: poolAccount.publicKey,
vault: vaultAccount.publicKey,
borrowerLrtAccount: borrowerLrtAccount.publicKey,
borrowerPosition: borrowerPositionAccount.publicKey,
borrower: provider.wallet.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
tokenProgram: TOKEN_PROGRAM_ID,
},
});
To repay a loan with interest:
await program.rpc.repay(new anchor.BN(amountToRepay), {
accounts: {
pool: poolAccount.publicKey,
vault: vaultAccount.publicKey,
borrowerPosition: borrowerPositionAccount.publicKey,
borrower: provider.wallet.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
},
});
- This protocol handles financial transactions and should undergo thorough security audits before deployment to mainnet.
- Ensure proper access controls and input validation in all instructions.
- Implement safeguards against potential arithmetic overflows.
- Consider implementing a pause mechanism for emergency situations.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details. *wink