A pool in which a MarginAccount can register a deposit and/or a borrow position.

Export

Hierarchy

  • Pool

Constructors

Properties

addresses: PoolAddresses
depositNoteMetadata: PositionTokenMetadata

The metadata of the Pool deposit note mint

Memberof

Pool

info?: {
    depositNoteMint: Mint;
    loanNoteMint: Mint;
    marginPool: MarginPoolData;
    tokenMetadata: TokenMetadata;
    tokenMint: Mint;
    tokenPriceOracle: PriceData;
    vault: AssociatedToken;
}

Underlying accounts associated with the Pool

Memberof

Pool

Type declaration

loanNoteMetadata: PositionTokenMetadata

The metadata of the Pool loan note mint

Memberof

Pool

programs: MarginPrograms
tokenConfig: MarginTokenConfig

Accessors

Methods

  • Send a transaction to deposit tokens into the pool.

    This function will

    • create the margin account (if required),
    • register the position (if required),
    • Wrap SOL according to the source param,
    • and update the position balance after.

    Parameters

    • args: {
          change: PoolTokenChange;
          marginAccount: MarginAccount;
          source?: TokenAddress;
      }
      • change: PoolTokenChange

        The amount of tokens to be deposited in lamports.

      • marginAccount: MarginAccount

        The margin account that will receive the deposit.

      • Optional source?: TokenAddress

        (Optional) The token account that the deposit will be transfered from. The wallet balance or associated token account will be used if unspecified.

    Returns Promise<string>

  • Create an instruction to deposit into the pool.

    This function will wrap SOL according to the source param. It is required that

    • The margin account is created,
    • a deposit position is registered
    • and the position balance is updated after.

    Returns

    Memberof

    Pool

    Parameters

    • args: {
          change: PoolTokenChange;
          instructions: TransactionInstruction[];
          marginAccount: MarginAccount;
          source?: TokenAddress;
      }
      • change: PoolTokenChange

        The amount of tokens to be deposited in lamports.

      • instructions: TransactionInstruction[]

        The array to append instructions to

      • marginAccount: MarginAccount

        The margin account that will receive the deposit.

      • Optional source?: TokenAddress

        (Optional) The token account that the deposit will be transfered from. The wallet balance or associated token account will be used if unspecified.

    Returns Promise<void>

  • Create instructions to refresh all MarginAccount pool positions so that additional borrows or withdraws can occur.

    Returns

    Memberof

    Pool

    Parameters

    • {: {
          instructions: TransactionInstruction[];
          marginAccount: MarginAccount;
          pools: Record<any, Pool> | Pool[];
      }

      instructions, pools, marginAccount }

    Returns Promise<void>

  • Create instructions to refresh all MarginAccount deposit or borrow positions associated with this Pool so that additional borrows or withdraws can occur.

    Returns

    Memberof

    Pool

    Parameters

    • {: {
          instructions: TransactionInstruction[];
          marginAccount: MarginAccount;
      }

      instructions, marginAccount }

      • instructions: TransactionInstruction[]
      • marginAccount: MarginAccount

    Returns Promise<void>

  • Create instructions to refresh MarginAccount pool positions in a prioritised manner so that additional borrows or withdraws can occur.

    Returns

    Memberof

    Pool

    Parameters

    • {: {
          instructions: TransactionInstruction[];
          marginAccount: MarginAccount;
          pools: Record<any, Pool> | Pool[];
      }

      instructions, pools, marginAccount }

    Returns Promise<void>

  • Get instruction to register new pool deposit position that is custodied by margin

    Example

    // Load the pools
    const poolManager = new PoolManager(programs, provider)
    const pools = await poolManager.loadAll()

    // Register the SOL deposit position
    const pool = pools["SOL"]
    await pool.withRegisterDepositPosition({ instructions, marginAccount })

    Returns

    Returns the instruction, and the address of the deposit note token account to be created for the position.

    Memberof

    MarginAccount

    Parameters

    • args: {
          instructions: TransactionInstruction[];
          marginAccount: MarginAccount;
      }
      • instructions: TransactionInstruction[]

        Instructions array to append to.

      • marginAccount: MarginAccount

        The margin account that will custody the position.

    Returns Promise<Address>

  • Parameters

    • __namedParameters: {
          changeKind: PoolTokenChange;
          destinationAccount: Address;
          instructions: TransactionInstruction[];
          marginAccount: MarginAccount;
          minAmountOut: TokenAmount;
          outputToken: Pool;
          sourceAccount: Address;
          swapPool: SPLSwapPool;
          transitDestinationAccount: Address;
          transitSourceAccount: Address;
      }
      • changeKind: PoolTokenChange
      • destinationAccount: Address
      • instructions: TransactionInstruction[]
      • marginAccount: MarginAccount
      • minAmountOut: TokenAmount
      • outputToken: Pool
      • sourceAccount: Address
      • swapPool: SPLSwapPool
      • transitDestinationAccount: Address
      • transitSourceAccount: Address

    Returns Promise<void>

  • Continous Compounding Rate

    Returns

    Parameters

    • reserveConfig: TypeDef<Object, Record<string, never>>
    • utilRate: number

    Returns number

  • Get continuous compounding deposit rate.

    Static

    Returns

    {number}

    Memberof

    Pool

    Parameters

    • ccRate: number
    • utilRatio: number
    • feeFraction: number

    Returns number

  • Linear interpolation between (x0, y0) and (x1, y1)

    Returns

    Parameters

    • x: number
    • x0: number
    • x1: number
    • y0: number
    • y1: number

    Returns number

Generated using TypeDoc