10 releases

0.15.1 Jul 22, 2022
0.15.0 May 9, 2022
0.14.0 Sep 1, 2021
0.10.4 Jul 20, 2021
0.9.0 Jun 29, 2021

#5 in #defi

37 downloads per month
Used in apricot-anchor

MIT license

60KB
1.5K SLoC

apricot-client

Integrating with Apricot on Solana is super easy! We have specifically designed our interface to be as easy-to-use as possible.

Consider these snippets for integrating with Apricot at client-side:

Typescrip:

// get shared connection object
let connection = getConnection();

// pool info
let tokenId = TokenID.USDC;
let assetPoolLoader = await createAssetPoolLoader(connection);
console.log(await assetPoolLoader.getAssetPool(tokenId));

// user portfolio info
let walletKey = new PublicKey(walletAddress);
let portfolioLoader = createPortfolioLoader(walletKey, connection);
await portfolioLoader.refreshPortfolio();
console.log(await portfolioLoader.getUserInfoAddress());
console.log(await portfolioLoader.getUserAssetInfoList());
console.log(await portfolioLoader.getBorrowPowerInfo());

Javascript:

await wrapper.deposit(user_account, user_spl, mints.fake_btc, deposit_amount);

Rust:

let ix = instructions::deposit(user_wallet, &user_spl, deposit_amount, btc_pool_id);
let blockhash = conn.get_recent_blockhash().unwrap();
let tx = Transaction::new_signed_with_payer(&[ix], Some(user_wallet), &[&user_wallet_keypair], blockhash.0);
let result = conn.send_and_confirm_transaction_with_spinner(&tx).unwrap();

For more details and examples of usage, check out our crate/package and samples! Or feel free to come to the #developer channel on our discord!

Directories:

  • ts: @apricot-lend/sdk-ts npm package
  • rust: apricot-client rust crate
  • js: @apricot-lend/apricot npm package
  • samples-ts: a few examples to fetch pool and user portfolio info
  • samples-rust-client: a rust client that demonstrates deposit/withdraw
  • samples-rust-contract: a single solana contract that uses the apricot-client rust crate to invoke Apricot
  • samples-js: a JS sample that uses the @apricot-lend/apricot package to deposit/borrow on Apricot

Dependencies

~17–27MB
~437K SLoC