Options
All
  • Public
  • Public/Protected
  • All
Menu

@algofi/lend

Index

Functions

  • formatState(state: {}[]): {}
  • Return a formatted version of state after taking care of decoding and unecessary key values

    Parameters

    • state: {}[]

      state we are trying to format

    Returns {}

    a formatted version of state after taking care of decoding and unecessary key values

    • [key: string]: any
  • get(object: {}, key: any, defaultValue: any): any
  • Return the value for the associated key in the object passed in , or defaultValue if not found

    Parameters

    • object: {}

      object to parse

      • key: any

        key to find value for

      • defaultValue: any

        default value to default to when we can't find key

      Returns any

      the value for the associated key in the object passed in , or defaultValue if not found

    • getGlobalState(algodClient: default, appId: number): Promise<{}>
    • Returns dict of global state for application with the given appId

      Parameters

      • algodClient: default

        algod client

      • appId: number

        id of the application

      Returns Promise<{}>

      dict of global state for application with id appId

    • getInitRound(chain: string): number
    • Returns init round of algofi protocol for a specified chain. Pulled from hardcoded values in contracts.ts.

      Parameters

      • chain: string

        network to query data for

      Returns number

      init round of algofi protocol on specified chain

    • getInitTxns(transactionType: Transactions, sender: string, suggestedParams: SuggestedParams, managerAppId: number, supportedMarketAppIds: number[], supportedOracleAppIds: number[], storageAccount: string): Transaction[]
    • Returns a transaction group object representing the initial transactions executed by the algofi protocol during a standard group transaction. The transactions are (1) fetch market variables, (2) update prices, (3) update protocol data, and (4) degenerate ("dummy") transactions to increase the number of cost units allowed (currently each transactions affords 700 additional cost units).

      Parameters

      • transactionType: Transactions

        transactions enum representing the group transaction the init transactions are used for

      • sender: string

        account address for the sender

      • suggestedParams: SuggestedParams

        suggested transaction params

      • managerAppId: number

        id of the manager application

      • supportedMarketAppIds: number[]

        list of supported market application ids

      • supportedOracleAppIds: number[]

        list of supported oracle application ids

      • storageAccount: string

        account address for the storage account

      Returns Transaction[]

      account address for the storage account

    • getManagerAppId(chain: string): number
    • Returns app id of manager for the specified chain. Pulled from hardcoded values in contracts.ts.

      Parameters

      • chain: string

        network to query data for

      Returns number

      manager app id

    • getMarketAppId(chain: string, symbol: string): number
    • Returns market app id of symbol for the specified chain. Pulled from hardcoded values in contracts.ts.

      Parameters

      • chain: string

        network to query data for

      • symbol: string

        symbol to get market data for

      Returns number

      market app id

    • getNewAccount(): any[]
    • Returns a three element list with a new key, address and passphrase.

      Returns any[]

      a three element list with a new key, address and passphrase.

    • getOrderedSymbols(chain: string, max?: boolean, maxAtomicOptIn?: boolean): string[]
    • Returns list of supported symbols for the specified chain. Pulled from hardcoded values in contracts.ts.

      Parameters

      • chain: string

        network to query data for

      • max: boolean = false

        max assets

      • maxAtomicOptIn: boolean = false

        list of supported symbols for algofi's protocol on chain

      Returns string[]

    • getRandomInt(max: number): number
    • Return a random integer between 0 and max

      Parameters

      • max: number

        max integer that we want to return

      Returns number

      random integer between 0 and max

    • getStakingContracts(chain: string): {}
    • Returns list of supported staking contracts for the specified chain. Pulled from hardcoded values in contracts.ts.

      Parameters

      • chain: string

        network to query data for

      Returns {}

      list of supported staking contracts

      • intToBytes(num: number): Uint8Array
      • Return a byte representation of the passed in number

        Parameters

        • num: number

          number to convert to bytes

        Returns Uint8Array

        a byte representation of the passed in number

      • newAlgofiMainnetClient(algodClient?: default, indexerClient?: default, userAddress?: string): Promise<Client>
      • Creates a new generic mainnet client

        Parameters

        • algodClient: default = null

          Algod client for interacting with the network

        • indexerClient: default = null

          Indexer client for interacting with the network

        • userAddress: string = null

          address of the user

        Returns Promise<Client>

        a new and fully constructed algofi mainnet client

      • newAlgofiTestnetClient(algodClient?: default, indexerClient?: default, userAddress?: string): Promise<Client>
      • Creates a new generic testnet client

        Parameters

        • algodClient: default = null

          Algod client for interacting with the network

        • indexerClient: default = null

          Indexer client for interacting with the network

        • userAddress: string = null

          address of the user

        Returns Promise<Client>

        a new and fuilly constructed algofi testnet client

      • prepareAddCollateralTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, bankAssetId: number, managerAppId: number, marketAppId: number, marketAddress: string, supportedMarketAppIds: number[], supportedOracleAppIds: number[]): TransactionGroup
      • Returns a TransactionGroup object representing an add collateral group transaction against the algofi protocol. Sender adds bank assets to collateral by sending them to the account address of the market application that generates the bank assets.

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for the sender

        • amount: number

          amount of bank asset to add to collateral

        • bankAssetId: number

          asset ids of the bank asset

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the market application for the bank asset

        • marketAddress: string

          account address for the market application

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle application ids

        Returns TransactionGroup

        TransactionGroup object representing an add collateral group transaction

      • prepareAssetOptinTransactions(assetId: number, sender: string, suggestedParams: SuggestedParams): TransactionGroup
      • Returns a transaction group object representing an asset opt in group transaction.

        Parameters

        • assetId: number

          id of the asset to opt into

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        Returns TransactionGroup

        transaction group object representing an asset opt in group transaction

      • prepareBorrowTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, assetId: number, managerAppId: number, marketAppId: number, supportedMarketAppIds: number[], supportedOracleAppIds: number[]): TransactionGroup
      • Returns a transaction group object representing an borrow group transaction against the algofi protocol. Protocol sends requested borrow asset to the sender account provided sufficient collateral has been posted

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage address for the sender

        • amount: number

          amount of asset to borrow

        • assetId: number

          asset id of the asset to be borrowed

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the market application for the borrow asset

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle applicaiton ids

        Returns TransactionGroup

        transaction group representing a borrow group transaction

      • prepareBurnTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, assetId: number, bankAssetId: number, managerAppId: number, marketAppId: number, marketAddress: string, supportedMarketAppIds: number[], supportedOracleAppIds: number[]): TransactionGroup
      • Returns a transaction group object representing a burn group transaction against the algofi protocol. Sender burns bank assets by sending them to the account address of the market application for the bank asset which in turn converts them to their underlying asset and sends back.

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender

        • amount: number

          amount of bank asset to burn

        • assetId: number

          asset id of the bank asset's underlying asset

        • bankAssetId: number

          id of the bank asset to burn

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the amrekt application for the bank asset

        • marketAddress: string

          account address for the market application

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle app ids

        Returns TransactionGroup

        transaction group object representing a burn group transaction

      • prepareClaimRewardsTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, managerAppId: number, supportedMarketAppIds: number[], supportedOracleAppIds: number[], foreignAssets: number[]): TransactionGroup
      • Returns a :class:TransactionGroup object representing a claim rewards underlying group transaction against the algofi protocol. The sender requests to claim rewards from the manager acount. If not, the account sends back the user the amount of asset underlying their posted collateral.

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender

        • managerAppId: number

          id of the manager application

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle application ids

        • foreignAssets: number[]

          list of rewards assets in the staking contract

        Returns TransactionGroup

        transaction group object representing a claim rewards transaction

      • prepareClaimStakingRewardsTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, managerAppId: number, marketAppId: number, oracleAppId: number, foreignAssets: number[]): TransactionGroup
      • Returns a transaction group object representing a claim rewards underlying group transaction against the algofi protocol. The sender requests to claim rewards from the manager acount. If not, the account sends back the user the amount of asset underlying their posted collateral.

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          astorage account address for sender

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the market application of the collateral

        • oracleAppId: number

          id of the oracle application

        • foreignAssets: number[]

          list of reward assets in the staking contract

        Returns TransactionGroup

        transaction group obejct representing a claim rewards transaction

      • prepareLiquidateTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, liquidateeStorageAccount: string, amount: number, managerAppId: number, borrowMarketAppId: number, borrowMarketAddress: string, collateralMarketAppId: number, supportedMarketAppIds: number[], supportedOracleAppIds: number[], collateralBankAssetId: number, borrowAssetId?: number): TransactionGroup
      • Returns a transaction group object representing a liquidation group transaction against the algofi protocol. The sender (liquidator) repays up to 50% of the liquidatee's outstanding borrow and takes collateral of the liquidatee at a premium defined by the market. The liquidator first sends borrow assets to the account address of the borrow market. Then, the account of the collateral market is authorized to credit the liquidator with a greater value of the liquidatee's collateral. The liquidator can then remove collateral to underlying to convert the collateral to assets.

        Parameters

        • sender: string

          -account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender (liquidator)

        • liquidateeStorageAccount: string

          storage account address for liquidatee

        • amount: number

          amount of borrow the liquidator repays

        • managerAppId: number

          id of the manager application

        • borrowMarketAppId: number

          id of the borrow market application

        • borrowMarketAddress: string

          account address of the borrow market

        • collateralMarketAppId: number

          id of the collateral market application

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle application ids

        • collateralBankAssetId: number

          id of the collateral bank asset

        • borrowAssetId: number = null

          id of the borrow asset, defaults to algo

        Returns TransactionGroup

        transaction group object representing a liquidate group transaction

      • prepareManagerAppOptinTransactions(managerAppId: number, getMaxAtomicOptInMarketAppIds: number[], sender: string, storageAddress: string, suggestedParams: SuggestedParams): TransactionGroup
      • Returns a transactiong roup object representing a manager opt in group transaction. The sender and storage account opt in to the manager application and the storage account is rekeyed to the manager account address, rendering it unable to be transacted against by the sender and therefore immutable.

        Parameters

        • managerAppId: number

          id of the manager application

        • getMaxAtomicOptInMarketAppIds: number[]

          max opt in market app ids

        • sender: string

          account address for the sender

        • storageAddress: string

          address of the storage account

        • suggestedParams: SuggestedParams

          suggested transaction params

        Returns TransactionGroup

        transaction group object representing a managet opt in group transaction

      • prepareMarketAppOptinTransactions(marketAppId: number, sender: string, suggestedParams: SuggestedParams): TransactionGroup
      • Returns a transaction group object representing a market opt in group transaction.

        Parameters

        • marketAppId: number

          -id of the market application

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        Returns TransactionGroup

        transaction group object representing a market opt in group transaction

      • prepareMintToCollateralTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, managerAppId: number, marketAppId: number, marketAddress: string, supportedMarketAppIds: number[], supportedOracleAppIds: number[], assetId?: number): TransactionGroup
      • Returns a transaction group object representing a mint to collateral group transaction against the algofi protocol. Functionality equivalent to mint + add_collateral. The sender sends assets to the account of the asset market application which then calculates and credits the user with an amount of collateral.

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender

        • amount: number

          amount of asset to supply for minting collateral

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the asset market application

        • marketAddress: string

          account address for the market application

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle application ids

        • assetId: number = null

          asset id of the asset being supplied, defaults to algo

        Returns TransactionGroup

        transaction group representing a mitn to collateral group transaction

      • prepareMintTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, bankAssetId: number, managerAppId: number, marketAppId: number, marketAddress: string, supportedMarketAppIds: number[], supportedOracleAppIds: number[], assetId?: number): TransactionGroup
      • Returns a transaction group object representing a mint group transaction against the algofi protocol. bAssets are not automatically posted to collateral as in prepare_mint_to_collateral_transactions. Sender sends assets to the account of the asset market application which then sends an amount of market bank assets to the user.

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender

        • amount: number

          amount of asset to supply for minting bank assets

        • bankAssetId: number

          asset id of the bank asset to be minted

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the market application for the bank asset

        • marketAddress: string

          account address for the market application

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle application ids

        • assetId: number = null

          asset id of the asset being supplied, defaults to algo

        Returns TransactionGroup

        transaction group object representing a mint group transaction

      • preparePaymentTransaction(sender: string, suggestedParams: SuggestedParams, receiver: string, amount: number): TransactionGroup
      • Returns a transaction group object representing a payment group transaction for a given sender, receiver, amount and ability to rekey.

        Parameters

        • sender: string

          account address for sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • receiver: string

          account address for the receiver

        • amount: number

          amount of algos to send

        Returns TransactionGroup

      • prepareRemoveCollateralTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, bankAssetId: number, managerAppId: number, marketAppId: number, supportedMarketAppIds: number[], supportedOracleAppIds: number[]): TransactionGroup
      • Returns a transaction group object representing a remove collateral group transaction against the algofi protocol. The sender requests to remove collateral from a market acount after which the application determines if the removal puts the sender's health ratio below 1. If not, the account sends back the user the amount of bank assets requested.

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender

        • amount: number

          amount of bank asset collateral to remove from market

        • bankAssetId: number

          asset id of bank asset collateral

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the market application of the collateral

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle application ids

        Returns TransactionGroup

        transaction group object representing a remove collateral group transaction

      • prepareRemoveCollateralUnderlyingTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, assetId: number, managerAppId: number, marketAppId: number, supportedMarketAppIds: number[], supportedOracleAppIds: number[]): TransactionGroup
      • Returns a transaction group object representing a remove collateral underlying group transaction against the algofi protocol. Functionally equivalent to remove collateral + burn. The sender requests to remove collateral from a market acount after which the application determines if the removal puts the sender's health ratio below 1. If not, the account sends back the user the amount of asset underlying their posted collateral.

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender

        • amount: number

          amount of collateral to remove from the market

        • assetId: number

          asset id of the asset underlying the collateral

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the market application of the collateral

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle application ids

        Returns TransactionGroup

        transaction group object representing a remove collateral underlying group transaction

      • prepareRepayBorrowTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, managerAppId: number, marketAppId: number, marketAddress: string, supportedMarketAppIds: number[], supportedOracleAppIds: number[], assetId?: number): TransactionGroup
      • Returns a transaction group object representing a repay borrow group transaction against the algofi protocol. The sender repays assets to the market of the borrow asset after which the market application decreases the outstanding borrow amount for the sender.

        Parameters

        • sender: string

          account address for sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender

        • amount: number

          amoutn of borrow asset to repay

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the market application of the borrow asset

        • marketAddress: string

          account address for the market application

        • supportedMarketAppIds: number[]

          list of supported market application ids

        • supportedOracleAppIds: number[]

          list of supported oracle application ids

        • assetId: number = null

          asset id of the borrow asset, defaults to algo

        Returns TransactionGroup

        transaction group object representing a repay borrow group transaction

      • prepareStakeTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, managerAppId: number, marketAppId: number, marketAddress: string, oracleAppId: number, assetId?: number): TransactionGroup
      • Returns a transaction group object representing a stake transaction against the algofi protocol. The sender sends assets to the staking account and is credited with a stake.

        Parameters

        • sender: string

          account address for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender

        • amount: number

          amount of asset to supply for minting collateral

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the asset market application

        • marketAddress: string

          account address for the market application

        • oracleAppId: number

          id of the aset market application

        • assetId: number = null

          asset id of the asset being supplied, defaults to algo

        Returns TransactionGroup

        transaction group object representing a mint to collateral group transaction

      • prepareStakingContractOptinTransactions(managerAppId: number, marketAppId: number, sender: string, storageAddress: string, suggestedParams: SuggestedParams): TransactionGroup
      • Returns a transaction group object representing a staking contract opt in group transaction. The sender and storage account opt in to the staking application and the storage account is rekeyed to the manager account address, rendering it unable to be transacted against by the sender and therefore immutable.

        Parameters

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the market application

        • sender: string

          account address of the sender

        • storageAddress: string

          address of the storage account

        • suggestedParams: SuggestedParams

          suggested transaction params

        Returns TransactionGroup

        transaction group object representing a manger opt in group transaction

      • prepareUnstakeTransactions(sender: string, suggestedParams: SuggestedParams, storageAccount: string, amount: number, managerAppId: number, marketAppId: number, oracleAppId: number, assetId?: number): TransactionGroup
      • Returns a :class:TransactionGroup object representing a remove stake group transaction against the algofi protocol. The sender requests to remove stake from a stake acount and if successful, the stake is removed.

        Parameters

        • sender: string

          account addres for the sender

        • suggestedParams: SuggestedParams

          suggested transaction params

        • storageAccount: string

          storage account address for sender

        • amount: number

          amount of collateral to remove from the market

        • managerAppId: number

          id of the manager application

        • marketAppId: number

          id of the market application of the collateral

        • oracleAppId: number

          id of the oracle application of the collateral

        • assetId: number = null

          id of the asset to unstake

        Returns TransactionGroup

        transaction group object representing a unstake group transaction

      • readGlobalState(client: default, address: string, appId: number): Promise<{}>
      • Returns dict of global state for application with id appId. Address must be that of the creator.

        Parameters

        • client: default

          algod client

        • address: string

          creator address

        • appId: number

          id of the application

        Returns Promise<{}>

        dict of global state for application with id appId

      • readLocalState(client: default, address: string, appId: number): Promise<{}>
      • Returns dict of local state for address for application with id appId

        Parameters

        • client: default

          algod clietn

        • address: string

          address of account for which to get state

        • appId: number

          is of the application

        Returns Promise<{}>

        dict of local state of address for application with id appId

      • searchGlobalState(globalState: {}[], searchKey: any): any
      • Returns value from the encoded global state dict of an application

        Parameters

        • globalState: {}[]

          global state of an application

        • searchKey: any

          utf8 key of a value to search for

        Returns any

        value for the given key

      • waitForConfirmation(algodClient: default, txId: string): Promise<void>
      • Wait for the specified transaction to complete

        Parameters

        • algodClient: default

          algod client

        • txId: string

          transaction id of transaction we are waiting for

        Returns Promise<void>

      Generated using TypeDoc