solana-program-library/token-lending
dependabot[bot] 0432c19e80
build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1990)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.28.0 to 4.28.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-29 10:05:12 +00:00
..
cli Update all solana dependencies to 1.7.3, fix issues (#1958) 2021-06-25 00:39:08 +02:00
js build(deps-dev): bump @typescript-eslint/parser in /token-lending/js (#1990) 2021-06-29 10:05:12 +00:00
program Update all solana dependencies to 1.7.3, fix issues (#1958) 2021-06-25 00:39:08 +02:00
README.md lending: Command Line Interface (#1676) 2021-06-23 16:04:43 -05:00
flash_loan_design.md Flashloan for token lending (#1444) 2021-05-06 23:27:41 -05:00

README.md

Token Lending program

A lending protocol for the Token program on the Solana blockchain inspired by Aave and Compound.

Full documentation is available at https://spl.solana.com/token-lending

Web3 bindings are available in the ./js directory.

On-chain programs

Please note that only the lending program deployed to devnet is currently operational.

Cluster Program Address
Mainnet Beta LendZqTs8gn5CTSJU1jWKhKuVpjJGom45nnwPb2AMTi
Testnet 6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH
Devnet 6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH

Deploy a lending program (optional)

This is optional! You can skip these steps and use the Token Lending CLI with one of the on-chain programs listed above to create a lending market and add reserves to it.

  1. Install the Solana CLI

  2. Install the Token and Token Lending CLIs:

    cargo install spl-token-cli
    cargo install spl-token-lending-cli
    
  3. Clone the SPL repo:

    git clone https://github.com/solana-labs/solana-program-library.git
    
  4. Go to the new directory:

    cd solana-program-library
    
  5. Generate a keypair for yourself:

    solana-keygen new -o owner.json
    
    # Wrote new keypair to owner.json
    # ================================================================================
    # pubkey: JAgN4SZLNeCo9KTnr8EWt4FzEV1UDgHkcZwkVtWtfp6P
    # ================================================================================
    # Save this seed phrase and your BIP39 passphrase to recover your new keypair:
    # your seed words here never share them not even with your mom
    # ================================================================================
    

    This pubkey will be the owner of the lending market that can add reserves to it.

  6. Generate a keypair for the program:

    solana-keygen new -o lending.json
    
    # Wrote new keypair to lending.json
    # ============================================================================
    # pubkey: 6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH
    # ============================================================================
    # Save this seed phrase and your BIP39 passphrase to recover your new keypair:
    # your seed words here never share them not even with your mom
    # ============================================================================
    

    This pubkey will be your Program ID.

  7. Open ./token-lending/program/src/lib.rs in your editor. In the line

    solana_program::declare_id!("6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH");
    

    replace the Program ID with yours.

  8. Build the program binaries:

    cargo build
    cargo build-bpf
    
  9. Prepare to deploy to devnet:

    solana config set --url https://api.devnet.solana.com
    
  10. Score yourself some sweet SOL:

    solana airdrop -k owner.json 10
    solana airdrop -k owner.json 10
    solana airdrop -k owner.json 10
    

    You'll use this for transaction fees, rent for your program accounts, and initial reserve liquidity.

  11. Deploy the program:

    solana program deploy \
      -k owner.json \
      --program-id lending.json \
      target/deploy/spl_token_lending.so
    
    # Program Id: 6TvznH3B2e3p2mbhufNBpgSrLx6UkgvxtVQvopEZ2kuH
    

    If the deployment doesn't succeed, follow this guide to resume it.

  12. Wrap some of your SOL as an SPL Token:

    spl-token wrap \
       --fee-payer owner.json \
       10.0 \
       -- owner.json
    
    # Wrapping 10 SOL into AJ2sgpgj6ZeQazPPiDyTYqN9vbj58QMaZQykB9Sr6XY
    

    You'll use this for initial reserve liquidity. Note the SPL Token account pubkey (e.g. AJ2sgpgj6ZeQazPPiDyTYqN9vbj58QMaZQykB9Sr6XY).

  13. Use the Token Lending CLI to create a lending market and add reserves to it.