Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Client

Hierarchy

  • Client

Index

Constructors

  • new Client(algodClient: default, indexerClient: default, historicalIndexerClient: default, userAddress: string, chain: string): Client
  • This is the constructor for the Client class.

    Note, do not call this to create a new client. Instead call the static method init as there are asynchronous set up steps in creating an client and a constructor can only return an instance of the class and not a promise.

    Example

    //Correct way to instantiate new client
    const client = await Client.init(algodClient, indexerClient, historicalIndexerClient, userAddress, chain)

    //Incorrect way to instantiate new client
    const client = new Client(algodClient, indexerClient, historicalIndexerClient, userAddress, chain)

    Parameters

    • algodClient: default

      algod client

    • indexerClient: default

      indexer client

    • historicalIndexerClient: default

      indexer client

    • userAddress: string

      account address of user

    • chain: string

      specified chain we want the client to run on

    Returns Client

Properties

activeOrderedSymbols: string[]
algod: default
borrowSharesInit: number
chain: string
historicalIndexer: default
indexerClient: default
initRound: number
manager: Manager
markets: {}

Type declaration

maxAtomicOptInOrderedSymbols: string[]
maxOrderedSymbols: string[]
parameterScaleFactor: number
scaleFactor: number
stakingContractInfo: {}

Type declaration

  • [key: string]: {}
    • [key: string]: number
stakingContracts: {}

Type declaration

userAddress: string

Methods

  • getActiveAssetIds(): number[]
  • Returns the active asset ids

    Returns number[]

    list of active asset ids

  • getActiveAssets(): {}
  • Returns a dictionary of the asset objects for each active market

    Returns {}

    dictionary of asset objects

  • getActiveBankAssetIds(): number[]
  • Returns the active bank asset ids

    Returns number[]

    list of active bank asset ids

  • getActiveMarketAddresses(): string[]
  • Returns the list of the active market addresses

    Returns string[]

    list of active market addresses

  • getActiveMarketAppIds(): number[]
  • Returns the list of the active market app ids

    Returns number[]

    list of active market app ids

  • getActiveMarkets(): {}
  • Returns a dictionary of active markets by symbol

    Returns {}

    markets dictionary

  • getActiveOracleAppIds(): number[]
  • Returns the list of active oracle app ids

    Returns number[]

    list of acdtive oracle app ids

  • getActiveOrderedSymbols(): string[]
  • Returns the list of symbols of the active assets

    Returns string[]

    list of symbols for active assets

  • getAsset(symbol: string): Asset
  • Returns the asset object for the requested symbol

    Parameters

    • symbol: string

      symbol of the asset

    Returns Asset

    asset object with the provided symbol

  • getDefaultParams(): Promise<SuggestedParams>
  • Initializes the transactions parameters for the client.

    Returns Promise<SuggestedParams>

    default parameters for transactions

  • Returns the manager object representing the manager of this client.

    Returns Manager

    manager

  • getMarket(symbol: string): Market
  • Returns the market object for the given symbol.

    Parameters

    • symbol: string

      market symbol

    Returns Market

    market

  • getMaxAtomicOptInMarketAppIds(): number[]
  • Returns the max opt in market application ids

    Returns number[]

    list of max opt in market application ids

  • getPrices(): {}
  • Returns a dictionary of dollarized float prices of the assets pulled from their oracles

    Returns {}

    dictionary of int prices

    • [key: string]: number
  • getRawPrices(): {}
  • Returns a dictionary of raw oracle prices of the active assets pulled from their oracles

    Returns {}

    dictionary of int prices

    • [key: string]: number
  • Returns a staking contract with the given title

    Parameters

    • title: string

      staking contract name

    Returns StakingContract

    staking contract with the given name

  • getStakingContracts(): {}
  • getStorageAccounts(stakingContractName?: string): Promise<{}[]>
  • Returns a list of storage accounts for the given manager app id

    Parameters

    • stakingContractName: string = null

      name of staking contract

    Returns Promise<{}[]>

    list of storage accounts

  • getStorageState(storageAddress?: string): Promise<{}>
  • Returns a dictionary witht he lending market state for a given storage address.

    Parameters

    • storageAddress: string = null

      address to get info for; if null will use address supplied when creating client

    Returns Promise<{}>

    dictionary that represents the storage state of a user

  • getUserBalance(assetId?: number, address?: string): Promise<number>
  • Returns amount of asset in user's balance with asset id assetId.

    Parameters

    • assetId: number = 1

      id of the asset,

    • address: string = null

      address to get info for

    Returns Promise<number>

    amount of asset that the user has

  • getUserBalances(address?: string): Promise<{}>
  • Returns a dictionary of user balances by assetid.

    Parameters

    • address: string = null

      address to get info for

    Returns Promise<{}>

    amount of asset

  • getUserInfo(address?: string): Promise<{}>
  • Returns a dictionary of information about the user.

    Parameters

    • address: string = null

      address to get info for

    Returns Promise<{}>

    a dictionary of information about the user

  • getUserStakingContractState(stakingContractName: string, address?: string): Promise<{}>
  • Returns a dictionary with the staking contract state for the named staking contract and selected address

    Parameters

    • stakingContractName: string

      name of the staking contract to query

    • address: string = null

      address to get info for; if null will use address supplied when creating client

    Returns Promise<{}>

    state representing staking contract info of user

  • getUserState(address?: string): Promise<{}>
  • Returns a dictionary with the lending market state for a given address (must be opted in).

    Parameters

    • address: string = null

      address to get info for; if null, will use address supplied when creating client

    Returns Promise<{}>

    dictionary that represents the state of user

  • isOptedIntoApp(appId: number, address?: string): Promise<boolean>
  • Returns a boolean if the user address is opted into an application with id appId.

    Parameters

    • appId: number

      id of the application

    • address: string = null

      address to get information for

    Returns Promise<boolean>

    boolean if user is opted into application with id appId

  • isOptedIntoAsset(assetId: number, address?: string): Promise<boolean>
  • Returns a boolean if the user is opted into an asset with id assetId.

    Parameters

    • assetId: number

      id of the asset

    • address: string = null

      address to get info for

    Returns Promise<boolean>

    boolean if user is opted into an asset

  • prepareAddCollateralTransactions(symbol: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns an add collateral transaction group

    Parameters

    • symbol: string

      symbol to add collateral with

    • amount: number

      amount of collateral to add

    • address: string = null

      address to send add collateral transaction group from; defaults to clint user address

    Returns Promise<TransactionGroup>

  • prepareBorrowTransactions(symbol: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns a borrow transaction group

    Parameters

    • symbol: string

      symbol to borrow

    • amount: number

      amount to borrow

    • address: string = null

      address to send borrow transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

    borrow transaction group

  • prepareBurnTransactions(symbol: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns a burn transaction group

    Parameters

    • symbol: string

      symbol to burn

    • amount: number

      amount of bAsset to burn

    • address: string = null

      address to send burn transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

    burn transaction group

  • Returns a claim rewards transaction group

    Parameters

    • address: string = null

      address to send claim rewards from; defaults to client user address

    Returns Promise<TransactionGroup>

    claim rewards transaction group

  • prepareClaimStakingRewardsTransactions(stakingContractName: string, address?: string): Promise<TransactionGroup>
  • Returns a staking contract claim rewards transaction group

    Parameters

    • stakingContractName: string

      name of staking contract to unstake on

    • address: string = null

      address to send claim rewards transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

    unstake transaction group

  • prepareLiquidateTransactions(targetStorageAddress: string, borrowSymbol: string, amount: number, collateralSymbol: string, address?: string): Promise<TransactionGroup>
  • Returns a liquidate transaction group

    Parameters

    • targetStorageAddress: string

      storage address to liquidate

    • borrowSymbol: string

      symbol to repay

    • amount: number

      amount to repay

    • collateralSymbol: string

      symbol to seize collateral from

    • address: string = null

      address to send liquidate transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

    liquidate transaction group

  • prepareMintToCollateralTransactions(symbol: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns a mint to collateral transaction group

    Parameters

    • symbol: string

      symbol to mint

    • amount: number

      amount to mint to collateral

    • address: string = null

      address to send mint to collateral transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

    mint to collateral transaction group

  • prepareMintTransactions(symbol: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns a mint transaction group

    Parameters

    • symbol: string

      symbol to mint

    • amount: number

      amount of mint

    • address: string = null

      address to send mint transacdtion group from; defaults to client user address

    Returns Promise<TransactionGroup>

    mint transaction group

  • prepareOptinTransactions(storageAddress: string, address?: string): Promise<TransactionGroup>
  • Returns an opt in transaction group

    Parameters

    • storageAddress: string

      storage address to fund and rekey

    • address: string = null

      address to send add collateral transaction group from; defulats to client user address

    Returns Promise<TransactionGroup>

  • prepareRemoveCollateralTransactions(symbol: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns a remove collateral transaction group

    Parameters

    • symbol: string

      symbol to remove collateral from

    • amount: number

      amount of collateral to remove

    • address: string = null

      address to send remove collateral transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

    remove collateral transaction group

  • prepareRemoveCollateralUnderlyingTransactions(symbol: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns a remove collateral undrlying transaction group

    Parameters

    • symbol: string

      symbol to remove collateral from

    • amount: number

      amount of collateral to remove

    • address: string = null

      address to send remove collateral underlying transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

    remove collateral underlying transaction group

  • prepareRepayBorrowTransactions(symbol: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns a repay borrow transaction group

    Parameters

    • symbol: string

      symbol to repay

    • amount: number

      amount of repay

    • address: string = null

      address to send repay borrow transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

  • prepareStakeTransactions(stakingContractName: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns a staking contract stake transaction group

    Parameters

    • stakingContractName: string

      name of staking contract to stake on

    • amount: number

      amount of stake

    • address: string = null

      address to send stake transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

    stake transacdtion group

  • prepareStakingContractOptinTransactions(stakingContractName: string, storageAddress: string, address?: string): Promise<TransactionGroup>
  • Returns a staking contract optin transaction group

    Parameters

    • stakingContractName: string

      name of staking contract to opt into

    • storageAddress: string

      storage address to fund and rekey

    • address: string = null

      address to create optin transaction group for; defaults to client user address

    Returns Promise<TransactionGroup>

    staking contract opt in transaction group

  • prepareUnstakeTransactions(stakingContractName: string, amount: number, address?: string): Promise<TransactionGroup>
  • Returns a staking contract unstake transactiong group

    Parameters

    • stakingContractName: string

      name of staking contract to unstake on

    • amount: number

      amount of unstake

    • address: string = null

      address to send unstake transaction group from; defaults to client user address

    Returns Promise<TransactionGroup>

    unstake transaction group

  • submit(transactionGroup: Uint8Array, wait?: boolean): Promise<{}>
  • Submits and waits for a transaction group to finish if specified

    Parameters

    • transactionGroup: Uint8Array

      signed transaction group

    • wait: boolean = false

      boolean to tell whether you want to wait or not

    Returns Promise<{}>

    a dictionary with the txid of the group transaction

  • init(algodClient: default, indexerClient: default, historicalIndexerClient: default, userAddress: string, chain: string): Promise<Client>
  • This is the function that should be called when creating a new client. You pass everything you would to the constructor, but to this function instead and this returns the new and created client.

    Example

    //Correct way to instantiate new client
    const client = await Client.init(algodClient, indexerClient, historicalIndexerClient, userAddress, chain)

    //Incorrect way to instantiate new client
    const client = new Client(algodClient, indexerClient, historicalIndexerClient, userAddress, chain)

    Parameters

    • algodClient: default

      algod client

    • indexerClient: default

      indexer client

    • historicalIndexerClient: default

      indexer client

    • userAddress: string

      account address of user

    • chain: string

      specified chain we want the client to run on

    Returns Promise<Client>

    an instance of the client class fully constructed

Generated using TypeDoc