Apricot Finance
  • Overview
  • Video Walkthrough
  • Apricot EDU
  • Relevant Links
  • Product User Guide
    • UI & Connect Wallet
    • Dashboard
    • Apricot Lend
    • X-Farm
    • In-App Swap
    • Apricot Assist
    • Glossary
    • FAQ-APYs
    • FAQ-Farming
    • FAQ-Miscellaneous
  • Cookbook
  • Protocol Details
    • Interest Rates
    • Liquidity Mining Program
    • Liquidation Threshold & LTV
    • Fees
    • Liquidation Penalty
    • Price Oracles
  • Developer Docs
    • Client Interface
    • Liquidator Interface
Powered by GitBook
On this page
  • Specific pointers
  • How to get UserInfo?

Was this helpful?

  1. Developer Docs

Client Interface

PreviousPrice OraclesNextLiquidator Interface

Last updated 3 years ago

Was this helpful?

You will be able to find more info on our repo. The JS part is now replaced by the ts sdk and samples.

We haven't updated the rust interface in a while, so some of the features might be broken. If you need help find us in our !

Specific pointers

How to get UserInfo?

rust:

// taken from apricot-client/samples-rust-client/main.rs
#[allow(unaligned_references)]
{
    let user_info_key = consts::get_user_info_k(user_wallet);
    let data = conn.get_account_data(&user_info_key).unwrap();
    let user_info = utils::cast::<state::UserInfo>(&data[..]);
    println!("Showing user with {} assets:", user_info.num_assets);
    for i in 0 .. user_info.num_assets as usize  {
        println!("=============================");
        println!("Asset PoolID: {}", user_info.user_asset_info[i].pool_id);
        println!("Asset borrow amount: {}", user_info.user_asset_info[i].borrow_amount.to_native_amount());
        println!("Asset deposit amount: {}", user_info.user_asset_info[i].deposit_amount.to_native_amount());
        println!("Asset borrow interests: {}", user_info.user_asset_info[i].borrow_interests);
        println!("Asset deposit interests: {}", user_info.user_asset_info[i].deposit_interests);
    }
}

ts:

// taken from apricot-client/samples-ts/src/samplePortfolio.ts
let portfolioLoader = createPortfolioLoader(walletKey, getConnection());
await portfolioLoader.refreshPortfolio();
console.log(await portfolioLoader.getUserInfoAddress());
console.log(await portfolioLoader.getUserAssetInfoList());
console.log(await portfolioLoader.getBorrowPowerInfo());
apricot-client
samples-ts
sdk-ts
rust
samples-rust-client
samples-rust-contract
discord