UNPKG

@algofi/js-sdk

Version:

The official Algofi JavaScript SDK

100 lines (99 loc) 3.82 kB
import { Algodv2, Transaction } from "algosdk"; import AlgofiUser from "../../algofiUser"; import AssetDataClient from "../../assetData/assetDataClient"; import AssetAmount from "../../assetData/assetAmount"; import StakingClient from "./stakingClient"; import StakingConfig from "./stakingConfig"; import RewardsProgramState from "./rewardsProgramState"; export declare class StakingQuote { newAPR: number; newBoost: number; newAnnualBankPer1k: number; newTotalAnnualBank: number; constructor(newAPR: number, newBoost: number, newAnnualBankPer1k: number, newTotalAnnualBank: number); } export default class Staking { algod: Algodv2; stakingClient: StakingClient; assetDataClient: AssetDataClient; name: string; appId: number; address: string; assetId: number; latestTime: number; rewardsEscrowAccount: string; votingEscrowAppId: number; totalStaked: number; scaledTotalStaked: number; rewardsManagerAppId: number; rewardsProgramCount: number; rewardsProgramStates: { [key: number]: RewardsProgramState; }; baseAPR: number; annualBankPer1k: number; /** * Constructor for the staking object. * * @param algod - algod client * @param stakingClient - staking client * @param rewardsManagerAppId - rewards manager app id * @param stakingConfig - stakingConfig object with information on the staking */ constructor(algod: Algodv2, stakingClient: StakingClient, rewardsManagerAppId: number, stakingConfig: StakingConfig); /** * Loads in the global state of the specific staking contract and sets relevant * fields on the class. */ loadState(): Promise<void>; getTotalStaked(): AssetAmount; getScaledTotalStaked(): AssetAmount; getStakingAPRQuote(user: AlgofiUser, amountToStake: number): StakingQuote; getLockingAPRQuote(user: AlgofiUser, newBoostMultiplier: number): StakingQuote; /** * Constructs a series of transactions that opt a user into the staking * contract. * * @param user - user who is opting in * @returns a series of transactions that opt a user into the staking * contract. */ getUserOptInTxns(user: AlgofiUser): Promise<Transaction[]>; /** * Constructs a series of transactions that opt a user into the staking * contract. * * @param user - user who is opting in * @returns a series of transactions that opt a user into the staking * contract. */ getUserCloseOutTxns(user: AlgofiUser): Promise<Transaction[]>; /** * Constructs a series of transactions to stake user's assets in the staking * contract. * * @param user - user who is staking * @param amount - amount they are staking * @returns a series of transactions to stake user's assets in the staking * contract. */ getStakeTxns(user: AlgofiUser, amount: number): Promise<Transaction[]>; /** * Constructs a series of transactions that unstake a user's current stake * from the staking contract. * * @param user - user who is unstaking * @param amount - amount they are unstaking * @returns a series of transactions that unstake a user's current stake * from the staking contract. */ getUnstakeTxns(user: AlgofiUser, amount: number): Promise<Transaction[]>; /** * Constructs a series of transactions that claim a user's staked assets. * * @param user - user who is claiming * @returns a series of transactions that claim a user's staked assets. */ getClaimTxns(user: AlgofiUser): Promise<any>; getUpdateTargetUserTxn(user: AlgofiUser): Promise<any>; }