UNPKG

@algofi/lend

Version:

The official JavaScript SDK for the Algofi Lending Protocol

141 lines (140 loc) 4.57 kB
import { Algodv2, Indexer } from "algosdk"; import { RewardsProgram } from "./rewardsProgram"; import { Manager } from "./manager"; import { Market } from "./market"; import { Asset } from "./asset"; export declare class StakingContract { algodClient: Algodv2; historicalIndexerClient: Indexer; manager: Manager; market: Market; /** * This is the constructor for the StakingContract class. * * **Note, do not call this to create a new staking contract**. Instead call * the static method init as there are asynchronous set up steps in * creating an staking contract and a constructor can only return an instance of * the class and not a promise. * * #### Example * ```typescript * //Correct way to instantiate new staking contract * const newStakingContract = await StakingContract.init(algodClient, historicalIndexerClient, stakingContractInfo) * * //Incorrect way to instantiate new staking contract * const newStakingContract = new StakingContract(algodClient, historicalIndexerClient) * ``` * @param algodClient - algod client * @param historicalIndexerClient - historical indexer client */ constructor(algodClient: Algodv2, historicalIndexerClient: Indexer); /** * This is the function that should be called when creating a new staking contract. * You pass everything you would to the constructor with an additional staking contract info * dictionary, but to this function instead and this returns the new and created staking contract. * * #### Example * ```typescript * //Correct way to instantiate new staking contract * const newStakingContract = await StakingContract.init(algodClient, historicalIndexerClient, stakingContractInfo) * * //Incorrect way to instantiate new staking contract * const newStakingContract = new StakingContract(algodClient, historicalIndexerClient) * ``` * @param algodClient - algod client * @param historicalIndexerClient - historical indexer client * @param stakingContractInfo - dictionary of information on staking contract */ static init(algodClient: Algodv2, historicalIndexerClient: Indexer, stakingContractInfo: { [key: string]: number; }): Promise<StakingContract>; /** * Method to fetch most recent staking contract global state */ updateGlobalState(): Promise<void>; /** * Return staking contract manager * * @returns manager */ getManager(): Manager; /** * Return staking contract market * * @returns market */ getMarket(): Market; /** * Return asset object for this market * * @returns asset */ getAsset(): Asset; /** * Return manager app id * * @returns manager app id */ getManagerAppId(): number; /** * Return manager address * * @returns manager address */ getManagerAddress(): string; /** * Return the market app id * * @returns market app id */ getMarketAppId(): number; /** * Return the market address * * @returns market address */ getMarketAddress(): string; /** * Return oracle app id * * @returns oracle app id */ getOracleAppId(): number; /** * Return staked amount * * @returns staked */ getStaked(): number; /** * Return rewards program * * @returns rewards program */ getRewardsProgram(): RewardsProgram; /** * Return the staking contract storage address for given address or null if it does not exist * * @param address - address to get info for * @returns storage account address for user */ getStorageAddress(address: string): Promise<string>; /** * Return the staking contract local state for address * * @param address - address to get info for * @returns staking contract local state for address */ getUserState(address: string): Promise<{ [key: string]: any; }>; /** * Return the staking contract local state for storage address * * @param storageAddress -storage address to get info for * @returns staking contract local state for address */ getStorageState(storageAddress: string): Promise<{ [key: string]: any; }>; }