@algofi/lend
Version:
The official JavaScript SDK for the Algofi Lending Protocol
109 lines (108 loc) • 3.87 kB
TypeScript
import { Algodv2 } from "algosdk";
import { RewardsProgram } from "./rewardsProgram";
import { Market } from "./market";
export declare class Manager {
algod: Algodv2;
managerAppId: number;
managerAddress: string;
rewardsProgram: RewardsProgram;
/**
* This is the constructor for the Manager class.
*
* **Note, do not call this to create a new manager**. Instead call
* the static method init as there are asynchronous set up steps in
* creating an manager and a constructor can only return an instance of
* the class and not a promise.
*
* #### Example
* ```typescript
* //Correct way to instantiate new manager
* const newManager = await Manager.init(algodClient, managerAppId)
*
* //Incorrect way to instantiate new manager
* const newManager = new Manager(algodClient, managerAppId)
* ```
*
* @param algodClient - algod client
* @param managerAppId - id of the manager application
*/
constructor(algodClient: Algodv2, managerAppId: number);
/**
* This is the function that should be called when creating a new manager.
* You pass everything you would to the constructor, but to this function
* instead and this returns the new and created manager.
*
* #### Example
* ```typescript
* //Correct way to instantiate new manager
* const newManager = await Manager.init(algodClient, managerAppId)
*
* //Incorrect way to instantiate new manager
* const newManager = new Manager(algodClient, managerAppId)
* ```
*
* @param algodClient - algod client
* @param managerAppId - id of the manager application
* @returns an instance of the manager class fully constructed
*/
static init(algodClient: Algodv2, managerAppId: number): Promise<Manager>;
/**
* Method to fetch most recent manager global state
*/
updateGlobalState(): Promise<void>;
/**
* Return manager app id
*
* @returns manager app id
*/
getManagerAppId(): number;
/**
* Return manager address
*
* @returns manager address
*/
getManagerAddress(): string;
/**
* Returns rewards program
*
* @returns rewards program
*/
getRewardsProgram(): RewardsProgram;
/**
* Reeturns the storage addres for the client user
*
* @param address - address to get info for
* @returns storage account address for user
*/
getStorageAddress(address: string): Promise<string>;
/**
* Returns the market local state for the provided address
*
* @param address - address to get info for
* @returns market local state for address
*/
getUserState(address: string): Promise<{}>;
/**
* Returns the market local state for storage address
*
* @param storageAddress - storage address to get info for
* @returns market local state for storage address
*/
getStorageState(storageAddress: string): Promise<{}>;
/**
* Returns projected unrealized rewards for a user address
*
* @param address - address to get unrealized rewards for
* @param markets - list of markets
* @returns two element list of primary and secondary unrealized rewards
*/
getUserUnrealizedRewards(address: string, markets: Market[]): Promise<any[]>;
/**
* Returns projected unrealized rewards for storage address
*
* @param storageAddress - storage address to get unrealized rewards for
* @param markets - list of markets
* @returns two element list of primary and secondary unrealized rewards
*/
getStorageUnrealizedRewards(storageAddress: string, markets: Market[]): Promise<any[]>;
}