๐Ÿ“š Technical Reference

Documentation on functions available in Rho SDK

setSignerAddress

public setSignerAddress(address: string)

Sets an address as signer

Parameter NameTypeDescription

address

string

New signer address


setSigner

public setSigner(signer: Wallet | JsonRpcSigner)

Sets a signer. Required for transactions writing to the blockchain

Parameter NameTypeDescription

signer

Wallet | JsonRpcSigner

Instance of Wallet or JsonRpcSigner


getBalance

public async getBalance(address: string): Promise<bigint>

Gets native token balance of an address

Parameter NameTypeDescription

address

string

Address to get balance from

Returns:

  • bigint Account's native token balance


getMarketsOraclePackages

public async getMarketsOraclePackages(): Promise<MarketOraclePackages[]>

Gets oracle packages for all active markets

Parameter NameTypeDescription

address

string

Address to get balance from

Returns:

  • MarketOraclePackages[] array containing market ids and their latest rate coming from the oracle


getOraclePackage

public async getOraclePackage(
    marketId: string
): Promise<OraclePackage | undefined>

Gets latest index from the oracle for a market id.

Parameter NameTypeDescription

address

string

Address to get balance from

Returns:

  • OraclePackage Contains latest market index from the oracle. Returns undefined if not found.


getPortfolioOraclePackages

public async getPortfolioOraclePackages(
    userAddress: string
): Promise<MarketOraclePackages[]>

Gets oracle packages for all markets in a user's portfolio

Parameter NameTypeDescription

userAddress

string

Portfolio's user address

Returns:

  • MarketOraclePackages[] array containing market ids and their latest rate coming from the oracle


getBalanceOf

public async getBalanceOf(
    contractAddress: string, 
    userAddress: string
): Promise<bigint>

Returns user's balance of an ERC20 token.

Parameter NameTypeDescription

contractAddress

string

ERC20 token address

userAddress

string

User address

Returns:

  • bigint user's ERC20 balance


getAllowance

public async getAllowance(
    contractAddress: string, 
    userAddress: string, 
    spenderAddress: string
): Promise<bigint>

Returns an user's allowance for a given spender of an ERC20 token.

Parameter NameTypeDescription

contractAddress

string

ERC20 token address

userAddress

string

User address

spenderAddress

string

Spender address

Returns:

  • bigint user's ERC20 allowance to spender


setAllowance

public async setAllowance(
    contractAddress: string,
    spenderAddress: string,
    amount: bigint
): Promise<TransactionReceipt>

Does an ERC20 approval for the current signer.

Parameter NameTypeDescription

contractAddress

string

ERC20 token address

spenderAddress

string

Spender address

amount

bigint

Amount to be approved

Returns:


getActiveMarketIds

public async getActiveMarketIds(
    params: PaginationParams = {}
): Promise<string[]>

Gets active market ids. Supports params for pagination.

Parameter NameTypeDescription

params

PaginationParams

Parameters for pagination

Returns

  • String[] Array of market ids


getPortfolioMarketIds

public async getPortfolioMarketIds(
    params: UserPaginationParams
): Promise<string[]>

Gets market ids linked to a user's portfolio

Parameter NameTypeDescription

params

UserPaginationParams

User address and Parameters for pagination

Returns

  • String[] Array of market ids


getActiveMarkets

public async getActiveMarkets(
    params: OraclePaginationParams = {}
): Promise<MarketInfo[]>

Gets active markets data.

Parameter NameTypeDescription

params

OraclePaginationParams

Object containing both oracle packages and pagination params

Returns

  • MarketInfo[] Array of market info objects


getPortfolio

public async getPortfolio(
    params: UserOraclePaginationParams
): Promise<MarketPortfolio[]> 

Gets detailed user portfolio in different markets

Parameter NameTypeDescription

params

UserOraclePaginationParams

Object containing user address, oracle packages and pagination params

Returns

  • MarketPortfolio[] Array of MarketPortfolio object for each market of the given user


getMarketPortfolio

public async getMarketPortfolio(
    params: MarketUserOracleParams
): Promise<MarketPortfolio>

Gets detailed user portfolio in a specified market

Parameter NameTypeDescription

params

MarketUserOracleParams

Object containing market identifier, user address and oracle packages params

Returns

  • MarketPortfolio MarketPortfolio with detailed user state on that market


getMarginDetails

public async getMarginDetails(
    params: MarketUserOracleParams
): Promise<MarginState>

Gets detailed user portfolio in a specified market

Parameter NameTypeDescription

params

MarketUserOracleParams

Object containing market identifier, user address and oracle packages params

Returns

  • MarginState User's margin details on that market


getWithdrawableMargin

public async getWithdrawableMargin(
    params: MarketUserOracleParams
): Promise<bigint>

Gets withdrawable margin of an user

Parameter NameTypeDescription

params

MarketUserOracleParams

Object containing market identifier, user address and oracle packages params

Returns

  • BigInt Amount that can be withdrawn


getPoolLiquidityDistribution

public async getPoolLiquidityDistribution(
    params: MarketFutureOraclePaginationParams
): Promise<LiquidityDistribution>

Gets liquidity distribution of a future

Parameter NameTypeDescription

params

MarketFutureOraclePaginationParams

Object containing market and future identifiers, oracle packages and pagination params

Returns

  • LiquidityDistribution Object containing total provision distribution, current future rate and array of liquidity provisions


isLiquidatable

public async isLiquidatable(
    params: MarketUserOracleParams
): Promise<boolean>

Check is a user is liquidatable

Parameter NameTypeDescription

params

MarketUserOracleParams

Object containing market identifier, user address and oracle packages params

Returns

  • boolean True if user is liquidatable


isProvisionCancellable

public async isProvisionCancellable(
    params: MarketUserOracleParams
): Promise<boolean>

Check is a user's provisions are cancellable

Parameter NameTypeDescription

params

MarketUserOracleParams

Object containing market identifier, user address and oracle packages params

Returns

  • boolean True if user's provisions are cancellable


cancelProvisions

public async cancelProvisions(
    params: MarketUserOracleParams
): Promise<TransactionReceipt>

Check is a user's provisions are cancellable

Parameter NameTypeDescription

params

MarketUserOracleParams

Object containing market identifier, user address and oracle packages params

Returns


getTradeQuote

public async getTradeQuote(
    params: TradeQuoteParams
): Promise<TradeQuote>

Gets a quote for a trade

Parameter NameTypeDescription

params

TradeQuoteParams

Object containing market and identifiers, participant address, notional amount and oracle packages params.

Returns

  • TradeQuote Object containing quote details for a trade


getLiquidityProvisionQuote

public async getLiquidityProvisionQuote(
    params: LiquidityPositionQuoteParams
): Promise<LiquidityQuote>

Gets a quote for a liquidity provision

Parameter NameTypeDescription

params

LiquidityProvisionQuoteParams

Object containing market and future identifiers, participant address, notional amount, rate bounds, operation type and oracle packages params.

Returns

  • TradeQuote Object containing quote details for a liquidity provision


liquidatePositions

public async liquidatePosition(
    params: LiquidatePositionParams
): Promise<TransactionReceipt>

Gets a quote for a liquidity provision

Parameter NameTypeDescription

params

LiquidatePositionParams

Object containing market and future identifiers, owner address, array of position percentages and oracle packages params.

Returns


persistIndexAtMaturity

public async persistIndexAtMaturity(
    params: MarketFutureOracleParams
): Promise<TransactionReceipt>

Sets an index value for a future at maturity

Parameter NameTypeDescription

params

MarketFutureOracleParams

Object containing market and future identifiers, plus oracle packages params.

Returns


executeTrade

public async executeTrade(
    params: ExecuteTradeParams
): Promise<TransactionReceipt>

Executes a trade

Parameter NameTypeDescription

params

ExecuteTradeParams

Object containing trade data to execute

Returns


deposit

public async deposit(
    params: DepositParams
): Promise<TransactionReceipt>

Performs a collateral deposit

Parameter NameTypeDescription

params

DepositParams

Object containing market identifier, recipient address, amount to be deposited, boolean to settle matured positions and oracle packages.

Returns


withdraw

public async withdraw(
    params: WithdrawParams
): Promise<TransactionReceipt>

Performs a collateral withdraw

Parameter NameTypeDescription

params

WithdrawParams

Object containing market identifier, amount to be withdrawn, boolean to unwrap as native token, boolean to settle matured positions and oracle packages.

Returns


provideLiquidity

public async provideLiquidity(
    params: LiquidityOperationParams
): Promise<TransactionReceipt>

Provides liquidity to a future

Parameter NameTypeDescription

params

LiquidityOperationParams

Object containing market and future identifiers, notional amount relative to this provision, collateral amount to be deposited, rate bounds for the provision, deadline for the transaction to be mined, a boolean to settle matured positions and oracle packages

Returns


removeLiquidity

public async removeLiquidity(
    params: LiquidityOperationParams
): Promise<TransactionReceipt>

Removes liquidity from a future

Parameter NameTypeDescription

params

LiquidityOperationParams

Object containing market and future identifiers, notional amount relative to this provision, collateral amount to be deposited, rate bounds for the provision, deadline for the transaction to be mined, a boolean to settle matured positions and oracle packages

Returns


quoteTransferOwnership

public async quoteTransferOwnership(
    params: MarketUserOracleParams
): Promise<{ transferAmount: number; depositAmount: number }>

Gets a quote for liquidating a user by novation

Parameter NameTypeDescription

params

MarketUserOracleParams

Object containing market identifier, address of user to be liquidated and oracle packages

Returns

  • number transferAmount - amount of tokens rewarded to liquidator

  • number depositAmount - amount of tokens to be deposited as collateral by liquidator


transferPositionOwnership

public async transferPositionsOwnership(
    params: TransferPositionsOwnershipParams
): Promise<TransactionReceipt>

Performs a liquidation by novation

Parameter NameTypeDescription

params

TransferPositionsOwnershipParams

Object containing market identifier, address of user to be liquidated, a boolean indicating to settle matured positions and oracle packages

Returns


Last updated