@algofi/lend
Version:
The official JavaScript SDK for the Algofi Lending Protocol
182 lines (181 loc) • 6.86 kB
TypeScript
import { Transaction, SuggestedParams, Algodv2 } from "algosdk";
export declare enum Transactions {
MINT = 1,
MINT_TO_COLLATERAL = 2,
ADD_COLLATERAL = 3,
REMOVE_COLLATERAL = 4,
BURN = 5,
REMOVE_COLLATERAL_UNDERLYING = 6,
BORROW = 7,
REPAY_BORROW = 8,
LIQUIDATE = 9,
CLAIM_REWARDS = 10
}
/**
* Wait for the specified transaction to complete
*
* @param algodClient - algod client
* @param txId - transaction id of transaction we are waiting for
*/
export declare function waitForConfirmation(algodClient: Algodv2, txId: string): Promise<void>;
export declare class TransactionGroup {
transactions: Transaction[];
signedTransactions: Uint8Array[];
/**
* This is the constructor for the TransactionGroup class.
* You pass in a list of transactions and get back a TransactionGroup object
*
* @param transactions - list of transactions
*/
constructor(transactions: Transaction[]);
/**
* Signs the transactions with specified private key and saves to class state
*
* @param address - account address of the user
* @param privateKey - private key of user
*/
signWithPrivateKey(address: string, privateKey: Uint8Array): void;
/**
* Signs the transactions with specified private keys and saves to class state
*
* @param privateKeys - private keys
*/
signWithPrivateKeys(privateKeys: Uint8Array[]): void;
/**
* Submits the signed transactions to the network using the algod client
*
* @param algod - algod client
* @param wait - wait for txn to complete; defaults to false
* @returns
*/
submit(algod: Algodv2, wait?: boolean): Promise<{
[key: string]: number;
}>;
}
/**
* Return a random integer between 0 and max
*
* @param max - max integer that we want to return
* @returns random integer between 0 and max
*/
export declare function getRandomInt(max: number): number;
/**
* Return the value for the associated key in the object passed in , or defaultValue if not found
*
* @param object - object to parse
* @param key - key to find value for
* @param defaultValue - default value to default to when we can't find key
* @returns the value for the associated key in the object passed in , or defaultValue if not found
*/
export declare function get(object: {}, key: any, defaultValue: any): any;
/**
* Return a byte representation of the passed in number
*
* @param num - number to convert to bytes
* @returns a byte representation of the passed in number
*/
export declare function intToBytes(num: number): Uint8Array;
/**
* Return a formatted version of state after taking care of decoding and unecessary key values
*
* @param state - state we are trying to format
* @returns a formatted version of state after taking care of decoding and unecessary key values
*/
export declare function formatState(state: {
[key: string]: any;
}[]): {
[key: string]: any;
};
/**
* Returns dict of local state for address for application with id appId
*
* @param client - algod clietn
* @param address - address of account for which to get state
* @param appId - is of the application
* @returns dict of local state of address for application with id appId
*/
export declare function readLocalState(client: Algodv2, address: string, appId: number): Promise<{
[key: string]: any;
}>;
/**
* Returns dict of global state for application with id appId. Address must be that of the creator.
*
* @param client - algod client
* @param address - creator address
* @param appId - id of the application
* @returns dict of global state for application with id appId
*/
export declare function readGlobalState(client: Algodv2, address: string, appId: number): Promise<{}>;
/**
* Returns dict of global state for application with the given appId
*
* @param algodClient - algod client
* @param appId - id of the application
* @returns dict of global state for application with id appId
*/
export declare function getGlobalState(algodClient: Algodv2, appId: number): Promise<{}>;
/**
* Returns list of supported staking contracts for the specified chain. Pulled from hardcoded values in contracts.ts.
*
* @param chain - network to query data for
* @returns list of supported staking contracts
*/
export declare function getStakingContracts(chain: string): {};
/**
* Returns list of supported symbols for the specified chain. Pulled from hardcoded values in contracts.ts.
*
* @param chain - network to query data for
* @param max - max assets
* @param maxAtomicOptIn - list of supported symbols for algofi's protocol on chain
* @returns
*/
export declare function getOrderedSymbols(chain: string, max?: boolean, maxAtomicOptIn?: boolean): string[];
/**
* Returns app id of manager for the specified chain. Pulled from hardcoded values in contracts.ts.
*
* @param chain - network to query data for
* @returns manager app id
*/
export declare function getManagerAppId(chain: string): number;
/**
* Returns market app id of symbol for the specified chain. Pulled from hardcoded values in contracts.ts.
*
* @param chain - network to query data for
* @param symbol - symbol to get market data for
* @returns market app id
*/
export declare function getMarketAppId(chain: string, symbol: string): number;
/**
* Returns init round of algofi protocol for a specified chain. Pulled from hardcoded values in contracts.ts.
*
* @param chain - network to query data for
* @returns init round of algofi protocol on specified chain
*/
export declare function getInitRound(chain: string): number;
/**
* Returns a transaction group object representing a payment group transaction
* for a given sender, receiver, amount and ability to rekey.
*
* @param sender - account address for sender
* @param suggestedParams - suggested transaction params
* @param receiver - account address for the receiver
* @param amount - amount of algos to send
* @returns
*/
export declare function preparePaymentTransaction(sender: string, suggestedParams: SuggestedParams, receiver: string, amount: number): TransactionGroup;
/**
* Returns a three element list with a new key, address and passphrase.
*
* @returns a three element list with a new key, address and passphrase.
*/
export declare function getNewAccount(): any[];
/**
* Returns value from the encoded global state dict of an application
*
* @param globalState - global state of an application
* @param searchKey - utf8 key of a value to search for
* @returns value for the given key
*/
export declare function searchGlobalState(globalState: {
[key: string]: any;
}[], searchKey: any): any;