Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Asset

Index

Constructors

  • new Asset(algodClient: default, underlyingAssetId: number, bankAssetId: number, oracleAppId?: number, oraclePriceField?: string, oraclePriceScaleFactor?: number): Asset
  • This is the constructor for the Asset class.

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

    Example

    //Correct way to instantiate new asset
    const newAsset = await Asset.init(algodClient, underlyingAssetId, bankAssetId, oracleAppId, oraclePriceField, oraclePriceScaleFactor)

    //Incorrect way to instantiate new asset
    const newAsset = new Asset(algodClient, underlyingAssetId, bankAssetId, oracleAppId, oraclePriceField, oraclePriceScaleFactor)

    Parameters

    • algodClient: default

      algod client

    • underlyingAssetId: number

      id of underlying asset

    • bankAssetId: number

      bank asset id

    • oracleAppId: number = null

      oracle application id of underlying asset

    • oraclePriceField: string = null

      oracle price field of underlying asset

    • oraclePriceScaleFactor: number = null

      oracle price scale factor of underlying asset

    Returns Asset

Properties

algod: default
bankAssetId: number
bankAssetInfo: {}

Type declaration

    oracleAppId: number
    oraclePriceField: string
    oraclePriceScaleFactor: number
    underlyingAssetId: number
    underlyingAssetInfo: {}

    Type declaration

    • [key: string]: any

    Methods

    • getBankAssetId(): number
    • Returns bank asset id

      Returns number

      bank asset id

    • getBankAssetInfo(): {}
    • Returns bank asset info

      Returns {}

      bank asset info as a dictionary

      • getOracleAppId(): number
      • Returns oracle app id

        Returns number

        oracle app id

      • getOraclePriceField(): string
      • Returns oracle price field

        Returns string

        oracle price field

      • getOraclePriceScaleFactor(): number
      • Returns oracle price scale factor

        Returns number

        oracle price scale factor

      • getPrice(): Promise<number>
      • Returns the current oracle price

        Returns Promise<number>

        oracle price

      • getRawPrice(): Promise<number>
      • Returns the current raw oracle price

        Returns Promise<number>

        oracle price

      • getUnderlyingAssetId(): number
      • Returns underlying asset id

        Returns number

        underlying asset id

      • getUnderlyingAssetInfo(): {}
      • Returns underlying asset info

        Returns {}

        underlying asset info as a dictionary

        • getUnderlyingDecimals(): number
        • Returns decimals of asset

          Returns number

          decimals

        • toUSD(amount: number): Promise<number>
        • Returns the usd value of the underlying amount (base units)

          Parameters

          • amount: number

            integer amount of base underlying units

          Returns Promise<number>

          usd value

        • init(algodClient: default, underlyingAssetId: number, bankAssetId: number, oracleAppId?: number, oraclePriceField?: string, oraclePriceScaleFactor?: number): Promise<Asset>
        • This is the function that should be called when creating a new asset. You pass everything you would to the constructor, but to this function instead and this returns the new and created asset.

          Example

          //Correct way to instantiate new asset
          const newAsset = await Asset.init(algodClient, underlyingAssetId, bankAssetId, oracleAppId, oraclePriceField, oraclePriceScaleFactor)

          //Incorrect way to instantiate new asset
          const newAsset = new Asset(algodClient, underlyingAssetId, bankAssetId, oracleAppId, oraclePriceField, oraclePriceScaleFactor)

          Parameters

          • algodClient: default

            algod client

          • underlyingAssetId: number

            id of underlying asset

          • bankAssetId: number

            bank asset id

          • oracleAppId: number = null

            oracle application id of underlying asset

          • oraclePriceField: string = null

            oracle price field of underlying asset

          • oraclePriceScaleFactor: number = null

            oracle price scale factor of underlying asset

          Returns Promise<Asset>

          a finished instance of the asset class.

        Generated using TypeDoc