Poolpairs#

class defichain.ocean.Poolpairs(ocean)#
list(size: int = 30, next: str | None = None) [{}]#

List pool pairs

Parameters:
  • size (int) – (optional) size of PoolPairData balance to query

  • next (str) – (optional) next set of PoolPairData

Returns:

(json string) {id: str, symbol: str, displaySymbol: str, name: str, status: bool, tokenA: {id: str, name: str, symbol: str, displaySymbol: str, reserve: str, blockCommission: str, fee: {pct: str, inPct: str, outPct: str}}, tokenB: {id: str, name: str, symbol: str, displaySymbol: str, reserve: str, blockCommission: str, fee: {pct: str, inPct: str, outPct: str}}, priceRatio: {ab: str, ba: str}, commission: str, totalLiquidity: {token: str, usd: str}, tradeEnabled: bool, ownerAddress: str, rewardPct: str, rewardLoanPct: str, customRewards: str[], creation: {tx: str, height: int}, apr: {total: float, reward: float, commission: float}, volume?: {d30: float, h24: float}}

Example:

>>> ocean.poolpairs.list()
get(id: str) {}#

Get pool pair

Parameters:

id (str) – (required) id of the pool pair

Returns:

(json string) {id: str, symbol: str, displaySymbol: str, name: str, status: bool, tokenA: {id: str, name: str, symbol: str, displaySymbol: str, reserve: str, blockCommission: str, fee: {pct: str, inPct: str, outPct: str}}, tokenB: {id: str, name: str, symbol: str, displaySymbol: str, reserve: str, blockCommission: str, fee: {pct: str, inPct: str, outPct: str}}, priceRatio: {ab: str, ba: str}, commission: str, totalLiquidity: {token: str, usd: str}, tradeEnabled: bool, ownerAddress: str, rewardPct: str, rewardLoanPct: str, customRewards: str[], creation: {tx: str, height: int}, apr: {total: float, reward: float, commission: float}, volume?: {d30: float, h24: float}}

Example:

>>> ocean.poolpairs.get("4")
listPoolSwaps(id: str, size: int = 30, next: str | None = None) [{}]#

List pool swaps

Parameters:
  • id (str) – (required) id of the pool pair

  • size (int) – (optional) size of PoolSwap to query

  • next (str) – (optional) next set of PoolSwap

Returns:

(json string) {id: str, sort: str, txid: str, txno: int, poolPairId: str, fromAmount: str, fromTokenId: int, from: PoolSwapFromToData, to: PoolSwapFromToData, type: SwapType, block: {hash: str, height: int, time: int, medianTime: int}}

Example:

>>> ocean.poolpairs.listPoolSwaps("4")
listPoolSwapsVerbose(id: str, size: int = 10, next: str | None = None) [{}]#

List pool swaps with from/to

Parameters:
  • id (str) – (required) id of the pool pair

  • size (int) – (optional) of PoolSwap to query, max of 20 per page

  • next (str) – (optional) next set of PoolSwap

Returns:

(json string) {id: str, sort: str, txid: str, txno: int, poolPairId: str, fromAmount: str, fromTokenId: int, from: PoolSwapFromToData, to: PoolSwapFromToData, type: SwapType, block: {hash: str, height: int, time: int, medianTime: int}}

Example:

>>> ocean.poolpairs.listPoolSwapsVerbose("4")
listPoolSwapAggregates(id: str, interval: int, size: int = 30, next: str | None = None) [{}]#

List pool swap aggregates

Parameters:
  • id (str) – (required) id of the pool pair

  • interval (int) – (required) aggregated interval: 60 * 60, 60 * 60 * 24

  • size (str) – (optional) size of PoolSwap to query

  • next (int) – (optional) next set of PoolSwap

Returns:

(json string) {id: str, key: str, bucket: int, aggregated: {amounts: Record<str, str>, usd: float}, block: {medianTime: int}}

Example:

>>> ocean.poolpairs.listPoolSwapsVerbose("4", 3600)
getSwappableTokens(tokenId: str) {}#

Get all swappable tokens for a given token

Parameters:

tokenId (str) – (required) id of a token

Returns:

(json string) {fromToken: TokenIdentifier, swappableTokens: TokenIdentifier[]}

Example:

>>> ocean.poolpairs.getSwappableTokens("0")
getBestPath(fromTokenId: str, toTokenId: str) {}#

Get the best (estimated) swap path from one token to another

Parameters:
  • fromTokenId (str) – (required) tokenId to swap from

  • toTokenId (str) – (required) tokenId to swap to

Returns:

(json string) {fromToken: TokenIdentifier, toToken: TokenIdentifier, bestPath: SwapPathPoolPair[], estimatedReturn: str, estimatedReturnLessDexFees: str}

Example:

>>> ocean.poolpairs.getBestPath("0", "75")
getAllPaths(fromTokenId: str, toTokenId: str) {}#

Get all possible swap paths from one token to another

Parameters:
  • fromTokenId (str) – (required) tokenId to swap from

  • toTokenId (str) – (required) tokenId to swap to

Returns:

(json string) {fromToken: TokenIdentifier, toToken: TokenIdentifier, bestPath: SwapPathPoolPair[], estimatedReturn: str, estimatedReturnLessDexFees: str}

Example:

>>> ocean.poolpairs.getAllPaths("0", "75")
listDexPrices(denomination: str) {}#

Get all dex prices denominated in a given token

Parameters:

denomination (str) – (required) denomination

Returns:

(json string) {token: TokenIdentifier, denominationPrice: str}

Example:

>>> ocean.poolpairs.listDexPrices("DUSD")