Giter Club home page Giter Club logo

apricot-client's Introduction

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

apricot-client's People

Contributors

andrewsource147 avatar codewithgun avatar fatcat008 avatar joxc avatar kasky53 avatar laodai0x1 avatar yhou-apricot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

apricot-client's Issues

js sample does not work with other private keys

Hi there. sorry for noob question I ve just recently started learning solana.
I tried running node sample.mjs , and it works ok.
But then I just change the private key and nothing more. but it throws the error below:

Transaction simulation failed: Error processing Instruction 0: Program failed to complete 
    Program 2XaNvhxnLjym7SY2y55fLVWAtnzRNpSzByVs61y4ANM5 invoke [1]
    Program 11111111111111111111111111111111 invoke [2]
    Program 11111111111111111111111111111111 success
    Program log: panicked at 'expected size 165, actual size 0', src/state.rs:1053:5
    Program 2XaNvhxnLjym7SY2y55fLVWAtnzRNpSzByVs61y4ANM5 consumed 200000 of 200000 compute units
    Program failed to complete: BPF program panicked
    Program 2XaNvhxnLjym7SY2y55fLVWAtnzRNpSzByVs61y4ANM5 failed: Program failed to complete
/Users/path/apricot-client/samples-js/node_modules/@solana/web3.js/lib/index.cjs.js:6591
      throw new SendTransactionError('failed to send transaction: ' + res.error.message, logs);
            ^

SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete
    at Connection.sendEncodedTransaction (/Users/path/apricot-client/samples-js/node_modules/@solana/web3.js/lib/index.cjs.js:6591:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Connection.sendRawTransaction (/Users/path/apricot-client/samples-js/node_modules/@solana/web3.js/lib/index.cjs.js:6550:20)
    at async Connection.sendTransaction (/Users/path/apricot-client/samples-js/node_modules/@solana/web3.js/lib/index.cjs.js:6540:12)
    at async file:///Users/soroush/DevProjects/Jupyter%20Notebooks/Solana/apricot-client/samples-js/sample2.mjs:45:5 {
  logs: [
    'Program 2XaNvhxnLjym7SY2y55fLVWAtnzRNpSzByVs61y4ANM5 invoke [1]',
    'Program 11111111111111111111111111111111 invoke [2]',
    'Program 11111111111111111111111111111111 success',
    "Program log: panicked at 'expected size 165, actual size 0', src/state.rs:1053:5",
    'Program 2XaNvhxnLjym7SY2y55fLVWAtnzRNpSzByVs61y4ANM5 consumed 200000 of 200000 compute units',
    'Program failed to complete: BPF program panicked',
    'Program 2XaNvhxnLjym7SY2y55fLVWAtnzRNpSzByVs61y4ANM5 failed: Program failed to complete'
  ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.