|
1 |
| -# Token-lending program |
| 1 | +# Token Lending program |
2 | 2 |
|
3 | 3 | A lending protocol for the Token program on the Solana blockchain inspired by Aave and Compound.
|
4 | 4 |
|
5 | 5 | Full documentation is available at https://spl.solana.com/token-lending
|
6 | 6 |
|
7 | 7 | Web3 bindings are available in the `./js` directory.
|
8 | 8 |
|
9 |
| -### On-Chain Programs |
| 9 | +### On-chain programs |
| 10 | + |
| 11 | +Please note that only the lending program deployed to devnet is currently operational. |
10 | 12 |
|
11 | 13 | | Cluster | Program Address |
|
12 | 14 | | --- | --- |
|
13 | 15 | | Mainnet Beta | [`LendZqTs8gn5CTSJU1jWKhKuVpjJGom45nnwPb2AMTi`](https://explorer.solana.com/address/LendZqTs7gn5CTSJU1jWKhKuVpjJGom45nnwPb2AMTi) |
|
14 |
| -| Testnet | [`LendZqTs8gn5CTSJU1jWKhKuVpjJGom45nnwPb2AMTi`](https://explorer.solana.com/address/LendZqTs8gn5CTSJU1jWKhKuVpjJGom45nnwPb2AMTi?cluster=testnet) | |
15 |
| -| Devnet | [`LendZqTs8gn5CTSJU1jWKhKuVpjJGom45nnwPb2AMTi`](https://explorer.solana.com/address/LendZqTs8gn5CTSJU1jWKhKuVpjJGom45nnwPb2AMTi?cluster=devnet) | |
| 16 | +| Testnet | [`6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH`](https://explorer.solana.com/address/6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH?cluster=testnet) | |
| 17 | +| Devnet | [`6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH`](https://explorer.solana.com/address/6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH?cluster=devnet) | |
| 18 | + |
| 19 | +### Deploy a lending program (optional) |
| 20 | + |
| 21 | +This is optional! You can skip these steps and use the [Token Lending CLI](./cli/README.md) with one of the on-chain programs listed above to create a lending market and add reserves to it. |
| 22 | + |
| 23 | +1. [Install the Solana CLI](https://docs.solana.com/cli/install-solana-cli-tools) |
| 24 | + |
| 25 | +1. Install the Token and Token Lending CLIs: |
| 26 | + ```shell |
| 27 | + cargo install spl-token-cli |
| 28 | + cargo install spl-token-lending-cli |
| 29 | + ``` |
| 30 | + |
| 31 | +1. Clone the SPL repo: |
| 32 | + ```shell |
| 33 | + git clone https://github.com/solana-labs/solana-program-library.git |
| 34 | + ``` |
| 35 | + |
| 36 | +1. Go to the new directory: |
| 37 | + ```shell |
| 38 | + cd solana-program-library |
| 39 | + ``` |
| 40 | + |
| 41 | +1. Generate a keypair for yourself: |
| 42 | + ```shell |
| 43 | + solana-keygen new -o owner.json |
| 44 | + |
| 45 | + # Wrote new keypair to owner.json |
| 46 | + # ================================================================================ |
| 47 | + # pubkey: JAgN4SZLNeCo9KTnr8EWt4FzEV1UDgHkcZwkVtWtfp6P |
| 48 | + # ================================================================================ |
| 49 | + # Save this seed phrase and your BIP39 passphrase to recover your new keypair: |
| 50 | + # your seed words here never share them not even with your mom |
| 51 | + # ================================================================================ |
| 52 | + ``` |
| 53 | + This pubkey will be the owner of the lending market that can add reserves to it. |
| 54 | + |
| 55 | +1. Generate a keypair for the program: |
| 56 | + ```shell |
| 57 | + solana-keygen new -o lending.json |
| 58 | + |
| 59 | + # Wrote new keypair to lending.json |
| 60 | + # ============================================================================ |
| 61 | + # pubkey: 6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH |
| 62 | + # ============================================================================ |
| 63 | + # Save this seed phrase and your BIP39 passphrase to recover your new keypair: |
| 64 | + # your seed words here never share them not even with your mom |
| 65 | + # ============================================================================ |
| 66 | + ``` |
| 67 | + This pubkey will be your Program ID. |
| 68 | + |
| 69 | +1. Open `./token-lending/program/src/lib.rs` in your editor. In the line |
| 70 | + ```rust |
| 71 | + solana_program::declare_id!("6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH"); |
| 72 | + ``` |
| 73 | + replace the Program ID with yours. |
| 74 | + |
| 75 | +1. Build the program binaries: |
| 76 | + ```shell |
| 77 | + cargo build |
| 78 | + cargo build-bpf |
| 79 | + ``` |
| 80 | + |
| 81 | +1. Prepare to deploy to devnet: |
| 82 | + ```shell |
| 83 | + solana config set --url https://api.devnet.solana.com |
| 84 | + ``` |
| 85 | + |
| 86 | +1. Score yourself some sweet SOL: |
| 87 | + ```shell |
| 88 | + solana airdrop -k owner.json 10 |
| 89 | + solana airdrop -k owner.json 10 |
| 90 | + solana airdrop -k owner.json 10 |
| 91 | + ``` |
| 92 | + You'll use this for transaction fees, rent for your program accounts, and initial reserve liquidity. |
| 93 | + |
| 94 | +1. Deploy the program: |
| 95 | + ```shell |
| 96 | + solana program deploy \ |
| 97 | + -k owner.json \ |
| 98 | + --program-id lending.json \ |
| 99 | + target/deploy/spl_token_lending.so |
| 100 | + |
| 101 | + # Program Id: 6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH |
| 102 | + ``` |
| 103 | + If the deployment doesn't succeed, follow [this guide](https://docs.solana.com/cli/deploy-a-program#resuming-a-failed-deploy) to resume it. |
| 104 | + |
| 105 | +1. Wrap some of your SOL as an SPL Token: |
| 106 | + ```shell |
| 107 | + spl-token wrap \ |
| 108 | + --fee-payer owner.json \ |
| 109 | + 10.0 \ |
| 110 | + -- owner.json |
| 111 | + |
| 112 | + # Wrapping 10 SOL into AJ2sgpgj6ZeQazPPiDyTYqN9vbj58QMaZQykB9Sr6XY |
| 113 | + ``` |
| 114 | + You'll use this for initial reserve liquidity. Note the SPL Token account pubkey (e.g. `AJ2sgpgj6ZeQazPPiDyTYqN9vbj58QMaZQykB9Sr6XY`). |
| 115 | + |
| 116 | +1. Use the [Token Lending CLI](./cli/README.md) to create a lending market and add reserves to it. |
0 commit comments