Class SdxClient

Hierarchy

  • SdxClient

Constructors

Properties

Accessors

Methods

Constructors

Properties

_assetMap: Map<AssetType, AssetDetails>
_associatedTokenAccounts: Map<string, PublicKey>
_connection: Connection
_eurosProgram: Program<EuroPrimitive>
_isInitialized: InitializeState
_placeholderOptionChain: PublicKey
_programAuthority: PublicKey
_provider: default
_sdxProgram: Program<Dsov>
_stableAsset: AssetType
_state: State
_tokenWhitelist: PublicKey
_tradingAccount: PublicKey
_tradingTokenAccounts: Map<string, PublicKey>
_volatilityFeed: PublicKey
boundBuyOptionBySeriesId: ((asset, seriesId, optionAmount, maxAmountToPay, splitTx) => Promise<string[]>)

Type declaration

    • (asset, seriesId, optionAmount, maxAmountToPay, splitTx): Promise<string[]>
    • Parameters

      • asset: AssetType
      • seriesId: number
      • optionAmount: BN
      • maxAmountToPay: BN
      • splitTx: boolean

      Returns Promise<string[]>

boundCancelVaultTransfer: ((asset, transferType) => Promise<string>)

Type declaration

    • (asset, transferType): Promise<string>
    • Parameters

      Returns Promise<string>

boundDepositToTrading: ((asset, amount, optionalAssetDetails?) => Promise<string>)

Type declaration

    • (asset, amount, optionalAssetDetails?): Promise<string>
    • Parameters

      Returns Promise<string>

boundDepositToVault: ((asset, underlyingAmount, stableAmount) => Promise<string>)

Type declaration

    • (asset, underlyingAmount, stableAmount): Promise<string>
    • Parameters

      • asset: AssetType
      • underlyingAmount: BN
      • stableAmount: BN

      Returns Promise<string>

boundLoadAccountBalances: ((fromCache?) => Promise<Map<string, number>>)

Type declaration

    • (fromCache?): Promise<Map<string, number>>
    • Parameters

      • Optional fromCache: boolean

      Returns Promise<Map<string, number>>

boundLoadOptionChain: ((asset, fromCache?, enableLogging?) => Promise<OptionChain>)

Type declaration

    • (asset, fromCache?, enableLogging?): Promise<OptionChain>
    • Parameters

      • asset: AssetType
      • Optional fromCache: boolean
      • Optional enableLogging: boolean

      Returns Promise<OptionChain>

boundLoadOptionVault: ((asset, fromCache?, enableLogging?) => Promise<OptionVault>)

Type declaration

    • (asset, fromCache?, enableLogging?): Promise<OptionVault>
    • Parameters

      • asset: AssetType
      • Optional fromCache: boolean
      • Optional enableLogging: boolean

      Returns Promise<OptionVault>

boundLoadProgramAuthority: ((enableLogging?) => Promise<ProgramAuthority>)

Type declaration

boundLoadTokenWhitelist: ((fromCache?, enableLogging?) => Promise<TokenWhitelist>)

Type declaration

    • (fromCache?, enableLogging?): Promise<TokenWhitelist>
    • Parameters

      • Optional fromCache: boolean
      • Optional enableLogging: boolean

      Returns Promise<TokenWhitelist>

boundLoadTradingAccount: ((tradingAccountKey?, fromCache?, enableLogging?) => Promise<TradingAccount>)

Type declaration

    • (tradingAccountKey?, fromCache?, enableLogging?): Promise<TradingAccount>
    • Parameters

      • Optional tradingAccountKey: PublicKey
      • Optional fromCache: boolean
      • Optional enableLogging: boolean

      Returns Promise<TradingAccount>

boundLoadTransferQueue: ((asset, transferType, fromCache?, enableLogging?) => Promise<TransferQueue>)

Type declaration

boundLoadTransferRecord: ((transferRecord, fromCache?, enableLogging?) => Promise<TransferRecord>)

Type declaration

    • (transferRecord, fromCache?, enableLogging?): Promise<TransferRecord>
    • Parameters

      • transferRecord: PublicKey
      • Optional fromCache: boolean
      • Optional enableLogging: boolean

      Returns Promise<TransferRecord>

boundLoadVolatilityFeed: ((fromCache?, enableLogging?) => Promise<VolatilityFeed>)

Type declaration

    • (fromCache?, enableLogging?): Promise<VolatilityFeed>
    • Parameters

      • Optional fromCache: boolean
      • Optional enableLogging: boolean

      Returns Promise<VolatilityFeed>

boundProcessNextTransferRecord: ((asset, transferType) => Promise<string>)

Type declaration

    • (asset, transferType): Promise<string>
    • Parameters

      Returns Promise<string>

boundSellOptionBySeriesId: ((asset, seriesId, optionAmount, minAmountToReceive, splitTx) => Promise<string[]>)

Type declaration

    • (asset, seriesId, optionAmount, minAmountToReceive, splitTx): Promise<string[]>
    • Parameters

      • asset: AssetType
      • seriesId: number
      • optionAmount: BN
      • minAmountToReceive: BN
      • splitTx: boolean

      Returns Promise<string[]>

boundSettleExpiredPosition: ((asset, seriesId, tradingAccount?) => Promise<string>)

Type declaration

    • (asset, seriesId, tradingAccount?): Promise<string>
    • Parameters

      • asset: AssetType
      • seriesId: number
      • Optional tradingAccount: PublicKey

      Returns Promise<string>

boundWithdrawFromTrading: ((asset, amount, optionalAssetDetails?) => Promise<string>)

Type declaration

    • (asset, amount, optionalAssetDetails?): Promise<string>
    • Parameters

      Returns Promise<string>

boundWithdrawFromVault: ((asset, lpAmount) => Promise<string>)

Type declaration

    • (asset, lpAmount): Promise<string>
    • Parameters

      Returns Promise<string>

Accessors

  • get associatedTokenAccounts(): Map<string, PublicKey>
  • Returns Map<string, PublicKey>

Methods

  • See

    buyOptionBySeriesIdImpl for usage details

    Parameters

    • asset: AssetType
    • seriesId: number
    • optionAmount: BN
    • maxAmountToPay: BN
    • splitTx: boolean = false

    Returns Promise<string[]>

  • Estimates the liquidity pool tokens receivable for a deposit and provides a suggested deposit amount to minimize slippage.

    Async

    Parameters

    • underlyingAmount: number

      The amount of the underlying asset to deposit (in float).

    • stableAmount: number

      The amount of the stable token to deposit (in float).

    • asset: AssetType

      The type of the underlying asset.

    Returns Promise<DepositEstimate>

    A promise that resolves to an object that contains the estimated LP deposit amount.

  • Estimates the amounts of underlying and stable assets receivable for a liquidity pool withdrawal.

    Async

    Parameters

    • lpTokenAmount: number

      The amount of the liquidity pool tokens to withdraw (in float).

    • asset: AssetType

      The type of the underlying asset.

    Returns Promise<WithdrawalEstimate>

    A promise that resolves to estimated amounts of underlying and stable assets receivable.

  • Asynchronously calculates the price and associated fees for given series of options on a specific asset.

    Async

    Parameters

    • asset: AssetType

      The asset for which the option pricing is to be estimated.

    • seriesIds: number[]

      An array of series IDs for which the option pricing needs to be estimated.

    • sizeForUser: number

      Size of the position the user is considering, use 1 for buying and -1 for selling.

    Returns Promise<PriceAndFees[]>

    • A promise that resolves to an array of 'PriceAndFees' objects. Each object in the array provides detailed price and fee estimates for a specific option series identified by the series ID.
  • Estimates the details of a trade for a given asset, option series ID and size to trade. If user trading account does not exist, assumes that user has normal fee tier.

    Async

    Parameters

    • asset: AssetType

      The asset involved in the trade.

    • seriesId: number

      The ID of the option series involved in the trade.

    • sizeForUser: number

      The user's position size.

    • Optional fromCache: boolean

      A flag indicating whether to fetch account data from cache. Defaults to false.

    • Optional enableLogging: boolean

      A flag indicating whether to enable logging. Defaults to false.

    Returns Promise<EstimatedTradeDetails>

    • Returns a Promise that resolves to an EstimatedTradeDetails object.
  • This method is used to fetch the price of a liquidity pool (LP) token. It obtains the details of the underlying and stable assets, loads the necessary accounts (option chain, option vault, volatility feed, vault trading account), and fetches the current timestamp and underlying price. It uses these inputs to estimate and return the price of the LP token.

    Throws

    Throws an error if unable to fetch the LP token price.

    Parameters

    • lpTokenAmount: number

      The amount of LP tokens for which to fetch the price (in float)

    • asset: AssetType

      The underlying asset associated with the LP token.

    Returns Promise<TokenPriceEstimate>

    A promise that resolves to an estimate of the LP token price, values in float.

  • This method is used to fetch the market option pricing for a specified asset. It gets the details of the asset, loads the option chain, volatility feed, and underlying price of the asset. It then calculates and returns the new option pricing based on these inputs.

    Throws

    Throws an error if unable to fetch the market option pricing for the asset.

    Parameters

    • asset: AssetType

      The asset for which to fetch the market option pricing.

    Returns Promise<Map<number, OptionPricing>>

    A promise that resolves to a map where the key is a number (typically representing an option ID or similar identifier) and the value is an object representing the pricing details for that option.

  • Gets the associated token account for the given asset mint, for the current wallet.

    Parameters

    • assetMint: PublicKey

      The asset mint to get the associated token account for.

    Returns PublicKey

    The associated token account.

  • Gets the associated token account balance for the given asset mint, for the current wallet. Returns 0 if the associated token account is not initialized.

    Parameters

    • assetMint: PublicKey

      The asset mint to get the associated token account for.

    Returns Promise<number>

    Token balance of account in raw decimals

  • Gets the trading token account for the given asset mint, for the current wallet.

    Parameters

    • assetMint: PublicKey

      The asset mint to get the trading token account for.

    Returns PublicKey

    The trading token account.

  • See

    sellOptionBySeriesIdImpl for usage details

    Parameters

    • asset: AssetType
    • seriesId: number
    • optionAmount: BN
    • minAmountToReceive: BN
    • splitTx: boolean = false

    Returns Promise<string[]>

  • For a given array of mints, find the associated token account addresses, check if they are initialized, and if not, generate instructions to initialize them.

    Parameters

    • accountsMint: PublicKey[]

      The mint accounts to setup ATAs for.

    Returns Promise<[PublicKey[], TransactionInstruction[]]>

    A promise that resolves to an array of ATAs, and initialization instructions.

  • For a given array of mints, find the trading token account addresses, check if they are initialized, and if not, generate instructions to initialize them.

    Parameters

    • accountsMint: PublicKey[]

      The mint accounts to setup trading token accounts for.

    Returns Promise<[PublicKey[], TransactionInstruction[]]>

    A promise that resolves to an array of addresses, and initialization instructions.

Generated using TypeDoc