@algofi/js-sdk
Version:
The official Algofi JavaScript SDK
66 lines (65 loc) • 2.4 kB
TypeScript
import { Algodv2, Transaction } from "algosdk";
import ParsedTransaction from "../../parsedTransaction";
import LendingClient from "./lendingClient";
import UserMarketState from "./userMarketState";
export default class User {
algod: Algodv2;
address: string;
storageAddress: string;
lendingClient: LendingClient;
storageBalances: {};
storageMinBalance: number;
optedInToManager: boolean;
optedInMarkets: any[];
userMarketStates: {
[key: number]: UserMarketState;
};
netSupplied: number;
netScaledCollateral: number;
netSupplyAPR: number;
netBorrowed: number;
netScaledBorrow: number;
netBorrowAPR: number;
netUnclaimedRewards: {};
netRewardsPerYear: {};
netSupplyRewardsPerYear: number;
netBorrowRewardsPerYear: number;
netSupplyRewardsAPR: number;
netBorrowRewardsAPR: number;
/**
* Constructor for the lending user class.
*
* @param lendingClient - lending client
* @param address - address for user
*/
constructor(lendingClient: LendingClient, address: string);
/**
* Functino which updates the lending user object to match the user's actual
* lending local state.
*
* @param userLocalStates - a list of all of the user's local states
*/
loadState(userLocalStates: {}): Promise<void>;
/**
* Returns whether or not the user is opted into the market.
*
* @param marketAppId - application id of the market
* @returns whether or not the user is opted into the market.
*/
isUserOptedIntoMarket(marketAppId: number): boolean;
/**
* Returns page offset for a market.
*
* @param marketAppId - application id of the market
* @returns an array of the page and offset that the market is stored at.
*/
getMarketPageOffset(marketAppId: number): [number, number];
/**
* Constructs a series of transactions that calculate a user's positions in a market.
*
* @param targetMarketAppId - an instance of an algofi client
* @returns a series of transactions that calculate a user's positions in a market.
*/
getCalcUserPositionTransactions(targetMarketAppId: number): Promise<Transaction[]>;
parseTransaction(txns: {}[], txnIdx: number, parsedTransactions: ParsedTransaction[]): void;
}