NOTE
- Lite URL:
https://lite-api.jup.ag/lend/v1/earn
- Pro URL:
https://api.jup.ag/lend/v1/earn
API REFERENCETo fully utilize the Lend API, check out the Lend API Reference.
Prerequisite
Dependencies
Dependencies
RPC
RPC
Set up RPC
NOTESolana provides a default RPC endpoint. However, as your application grows, we recommend you to always use your own or provision a 3rd party provider’s RPC endpoint such as Helius or Triton.
Wallet
Wallet
Set up Development WalletTo set up a development wallet via a wallet generated via Solana CLI, you can use the following script.
NOTE
- You can paste in your private key for testing purposes but this is not recommended for production applications.
- If you want to store your private key in the project directly, you can do it via a
.env
file.
.env
file, you can use the following script.Transaction Sending Example
Transaction Sending Example
Deposit and Withdraw
Using the Deposit or Withdraw endpoint, the user can do so based on theamount
of assets to be deposited/withdrawn.
USAGE STEPS
1
User chooses the token.
2
User chooses the amount of assets to deposit or withdraw in the specific token mint.
3
Post request to get the transaction.
4
User sign and send the transaction to the network.
5
The mint authority mints/burns the vault tokens to/from the user.
Mint and Redeem
Using the Mint or Redeem endpoint, the user can do so based on the numbershares
to be minted/redeemed.
USAGE STEPS
1
User chooses the token.
2
User chooses the number of shares to deposit or withdraw in the specific token mint.
3
Post request to get the transaction.
4
User sign and send the transaction to the network.
5
The mint authority mints/burns the vault tokens to/from the user.
Build Your Own Transaction
The Lend API provides 2 ways to interface with the Earn functions in the Jupiter Lend Program. You can either make a post request to directly get the Transaction, or Instruction which can be used for CPI or composing with additional instructions.Transaction
To use the Transaction method, simply request to the endpoints without-instructions
suffix directly, as shown in the examples above. The API will respond with an unsigned base64 transaction for the signer to sign, then sent to the network for execution.
Instruction
In some use cases, you’d prefer to utilize the instructions instead of the serialized transaction, so you can utilize with CPI or compose with other instructions. You can make a post request to-instructions
endpoints instead.
Building with Instuctions Code Snippet
Building with Instuctions Code Snippet
Example code snippet of using
/deposit-instructions
endpoint and building a transaction with the instructions.CPI
- Refer to https://github.com/jup-ag/jupiter-lend/blob/main/docs/earn/cpi.md for CPI example
- Refer to https://github.com/jup-ag/jupiter-lend/blob/main/target/idl/lending.json for IDL