Ocean

@dataxfi/datax.js / Exports / Ocean

Class: Ocean

Hierarchy

  • default

    Ocean

Table of contents

Constructors

  • constructor

Properties

  • bPool

  • config

  • logger

  • networkId

  • oceanPool

  • oceanTokenAddress

  • poolFactoryAddress

  • web3

Methods

  • approve

  • calculateSwapFee

  • checkIfApproved

  • getAllStakedPools

  • getAllowance

  • getBalance

  • getDtNeeded

  • getDtNeededForExactDt

  • getDtPerOcean

  • getDtReceived

  • getDtReceivedForExactDt

  • getMaxExchange

  • getMaxStakeAmount

  • getMaxUnstakeAmount

  • getMyPoolSharesForPool

  • getOceanNeeded

  • getOceanPerDt

  • getOceanReceived

  • getOceanRemovedforPoolShares

  • getPoolDetails

  • getPoolSharesRequiredToUnstake

  • getSwapFee

  • getTokenDetails

  • getTokensRemovedforPoolShares

  • getTotalPoolShares

  • stakeOcean

  • swapDtToExactDt

  • swapDtToExactOcean

  • swapExactDtToDt

  • swapExactDtToOcean

  • swapExactOceanToDt

  • swapOceanToExactDt

  • unstakeOcean

Constructors

constructor

new Ocean(web3, network, poolFactoryAddress?, oceanTokenAddress?)

Parameters

NameType

web3

any

network

any

poolFactoryAddress?

string

oceanTokenAddress?

string

Overrides

Base.constructor

Defined in

Ocean.ts:49

Properties

bPool

Private bPool: Pool = null

Defined in

Ocean.ts:45


config

config: any = null

Inherited from

Base.config

Defined in

Base.ts:5


logger

Private logger: any = null

Defined in

Ocean.ts:43


networkId

networkId: any = null

Inherited from

Base.networkId

Defined in

Base.ts:7


oceanPool

Private oceanPool: OceanPool = null

Defined in

Ocean.ts:44


oceanTokenAddress

oceanTokenAddress: string = null

Defined in

Ocean.ts:46


poolFactoryAddress

Private poolFactoryAddress: string = null

Defined in

Ocean.ts:47


web3

web3: any = null

Inherited from

Base.web3

Defined in

Base.ts:6

Methods

approve

approve(tokenAddress, spender, amount, account): Promise<TransactionReceipt>

approve spender to spend your tokens

Parameters

NameType

tokenAddress

string

spender

string

amount

string

account

string

Returns

Promise<TransactionReceipt>

Defined in

Ocean.ts:147


calculateSwapFee

calculateSwapFee(poolAddress, tokenInAmount): Promise<string>

calculates Swap Fee for a given trade

Parameters

NameType

poolAddress

string

tokenInAmount

string

Returns

Promise<string>

Defined in

Ocean.ts:409


checkIfApproved

checkIfApproved(tokenAddress, account, spender, amount): Promise<boolean>

check if token spend allowance is approved for a given spender accounts

Parameters

NameType

tokenAddress

string

account

string

spender

string

amount

string

Returns

Promise<boolean>

Defined in

Ocean.ts:106


getAllStakedPools

getAllStakedPools(account, fromBlock, toBlock): Promise<PoolShare[]>

Returns all staked pools for a given account

Parameters

NameType

account

string

fromBlock

number

toBlock

number

Returns

Promise<PoolShare[]>

Defined in

Ocean.ts:382


getAllowance

getAllowance(tokenAddress, account, spender): Promise<string>

Parameters

NameType

tokenAddress

string

account

string

spender

string

Returns

Promise<string>

user allowance for token

Defined in

Ocean.ts:127


getBalance

getBalance(tokenAddress, account): Promise<string>

returns token balance of a given account

Parameters

NameType

tokenAddress

string

account

string

Returns

Promise<string>

(in ETH denom)

Defined in

Ocean.ts:86


getDtNeeded

getDtNeeded(poolAddress, oceanAmountWanted): Promise<string>

Calculate how many data token are needed to buy a specific oceanAmount

Parameters

NameType

poolAddress

string

oceanAmountWanted

string

Returns

Promise<string>

  • amount of datatokens needed

Defined in

Ocean.ts:240


getDtNeededForExactDt

getDtNeededForExactDt(outputDtAmountWanted, inputPoolAddress, outputPoolAddress): Promise<any>

Returns input Datatoken amount needed for swapping to exact Datatoken out

Parameters

NameType

outputDtAmountWanted

string

inputPoolAddress

string

outputPoolAddress

string

Returns

Promise<any>

Defined in

Ocean.ts:575


getDtPerOcean

getDtPerOcean(poolAddress): Promise<string>

get Dt price per OCEAN

Parameters

NameType

poolAddress

string

Returns

Promise<string>

Defined in

Ocean.ts:195


getDtReceived

getDtReceived(poolAddress, oceanAmount): Promise<string>

Calculate how many data token are you going to receive for selling a specific oceanAmount (buying Dt)

Parameters

NameType

poolAddress

string

oceanAmount

string

Returns

Promise<string>

  • amount of ocean tokens received

Defined in

Ocean.ts:227


getDtReceivedForExactDt

getDtReceivedForExactDt(inputDtAmount, inputPoolAddress, outputPoolAddress): Promise<any>

Returns output datatokens received for exact input datatokens

Parameters

NameType

inputDtAmount

string

inputPoolAddress

string

outputPoolAddress

string

Returns

Promise<any>

Defined in

Ocean.ts:756


getMaxExchange

getMaxExchange(address, getOcean): Promise<any>

Get the DT or OCEAN reserve for a pool.

Parameters

NameType

address

any

getOcean

any

Returns

Promise<any>

DT: the max exchange based on the DT amount or OCEAN: the entire ocean reserve in a pool.

Defined in

Ocean.ts:178


getMaxStakeAmount

getMaxStakeAmount(poolAddress, tokenAddress): Promise<string>

Returns max amount of tokens that you can stake to the pool

Parameters

NameType

poolAddress

string

tokenAddress

string

Returns

Promise<string>

Defined in

Ocean.ts:954


getMaxUnstakeAmount

getMaxUnstakeAmount(poolAddress, tokenAddress): Promise<string>

Returns max amount of tokens that you can unstake from the pool

Parameters

NameType

poolAddress

string

tokenAddress

string

Returns

Promise<string>

Defined in

Ocean.ts:942


getMyPoolSharesForPool

getMyPoolSharesForPool(poolAddress, account): Promise<string>

returns pool shares of a given pool for a given account

Parameters

NameType

poolAddress

string

account

string

Returns

Promise<string>

Defined in

Ocean.ts:335


getOceanNeeded

getOceanNeeded(poolAddress, dtAmountWanted): Promise<string>

Calculate how many OCEAN are needed to buy a specific amount of datatokens

Parameters

NameType

poolAddress

string

dtAmountWanted

string

Returns

Promise<string>

  • amount of Ocean needed

Defined in

Ocean.ts:253


getOceanPerDt

getOceanPerDt(poolAddress): Promise<string>

get Ocean price per Dt

Parameters

NameType

poolAddress

string

Returns

Promise<string>

Defined in

Ocean.ts:204


getOceanReceived

getOceanReceived(poolAddress, dtAmount): Promise<string>

Get Ocean Received

Parameters

NameType

poolAddress

string

dtAmount

string

Returns

Promise<string>

Defined in

Ocean.ts:214


getOceanRemovedforPoolShares

getOceanRemovedforPoolShares(poolAddress, poolShares): Promise<string>

Returns Ocean amount received after spending poolShares

Parameters

NameType

poolAddress

string

poolShares

string

Returns

Promise<string>

Defined in

Ocean.ts:986


getPoolDetails

getPoolDetails(poolAddress): Promise<any>

get pool details

Parameters

NameType

poolAddress

string

Returns

Promise<any>

  • datatoken addresses

Defined in

Ocean.ts:265


getPoolSharesRequiredToUnstake

getPoolSharesRequiredToUnstake(poolAddress, tokenAddress, tokenAmount): Promise<string>

returns no. of shares needed to unstake given token amount

Parameters

NameType

poolAddress

string

tokenAddress

string

tokenAmount

string

Returns

Promise<string>

Defined in

Ocean.ts:968


getSwapFee

getSwapFee(poolAddress): Promise<string>

returns swap fee for a given pool

Parameters

NameType

poolAddress

string

Returns

Promise<string>

Defined in

Ocean.ts:399


getTokenDetails

getTokenDetails(tokenAddress): Promise<TokenDetails>

gets token details (NAME & SYMBOL)

Parameters

NameType

tokenAddress

string

Returns

Promise<TokenDetails>

Defined in

Ocean.ts:274


getTokensRemovedforPoolShares

getTokensRemovedforPoolShares(poolAddress, poolShares): Promise<TokensReceived>

Returns Datatoken & Ocean amounts received after spending given poolShares

Parameters

NameType

poolAddress

string

poolShares

string

Returns

Promise<TokensReceived>

Defined in

Ocean.ts:367


getTotalPoolShares

getTotalPoolShares(poolAddress): Promise<string>

returns total shares of a given pool

Parameters

NameType

poolAddress

string

Returns

Promise<string>

Defined in

Ocean.ts:347


stakeOcean

stakeOcean(account, poolAddress, amount): Promise<TransactionReceipt>

stake OCEAN tokens in a pool

Parameters

NameType

account

string

poolAddress

string

amount

string

Returns

Promise<TransactionReceipt>

Defined in

Ocean.ts:299


swapDtToExactDt

swapDtToExactDt(account, inputDtAddress, outputDtAddress, outputDtAmountWanted, maxInputDtAmount, inputPoolAddress, outputPoolAddress, routerAddress?, slippageInPercent?): Promise<any>

Swaps input Datatoken for exact output Datatoken

Parameters

NameType

account

string

inputDtAddress

string

outputDtAddress

string

outputDtAmountWanted

string

maxInputDtAmount

string

inputPoolAddress

string

outputPoolAddress

string

routerAddress?

string

slippageInPercent?

string

Returns

Promise<any>

Defined in

Ocean.ts:614


swapDtToExactOcean

swapDtToExactOcean(account, poolAddress, oceanAmountWanted, maxDtAmount, slippage): Promise<TransactionReceipt>

swaps datatokens to exact no. of Ocean tokens

Parameters

NameType

account

string

poolAddress

string

oceanAmountWanted

string

maxDtAmount

string

slippage

string

Returns

Promise<TransactionReceipt>

Defined in

Ocean.ts:541


swapExactDtToDt

swapExactDtToDt(account, inputDtAddress, outputDtAddress, minOutputDtAmount, inputDtAmount, inputPoolAddress, outputPoolAddress, routerAddress?, slippageInPercent?): Promise<any>

Swaps exact input datatoken for minumum amount output datatoken

Parameters

NameType

account

string

inputDtAddress

string

outputDtAddress

string

minOutputDtAmount

string

inputDtAmount

string

inputPoolAddress

string

outputPoolAddress

string

routerAddress?

string

slippageInPercent?

string

Returns

Promise<any>

Defined in

Ocean.ts:796


swapExactDtToOcean

swapExactDtToOcean(account, poolAddress, minimumOceanAmountWanted, dtAmount, slippage): Promise<TransactionReceipt>

Swaps exact no. of datatokens to Ocean tokens

Parameters

NameType

account

string

poolAddress

string

minimumOceanAmountWanted

string

dtAmount

string

slippage

string

Returns

Promise<TransactionReceipt>

Defined in

Ocean.ts:502


swapExactOceanToDt

swapExactOceanToDt(account, poolAddress, minimumdtAmountWanted, OceanAmount, slippage): Promise<TransactionReceipt>

swaps exact no. of Ocean tokens to datatokens

Parameters

NameTypeDescription

account

string

]

poolAddress

string

minimumdtAmountWanted

string

OceanAmount

string

slippage

string

-

Returns

Promise<TransactionReceipt>

Defined in

Ocean.ts:465


swapOceanToExactDt

swapOceanToExactDt(account, poolAddress, dtAmountWanted, maxOceanAmount, slippage): Promise<TransactionReceipt>

swaps Ocean tokens to exact no. of datatokens

Parameters

NameType

account

string

poolAddress

string

dtAmountWanted

string

maxOceanAmount

string

slippage

string

Returns

Promise<TransactionReceipt>

Defined in

Ocean.ts:430


unstakeOcean

unstakeOcean(account, poolAddress, amount, maximumPoolShares): Promise<TransactionReceipt>

unstake OCEAN tokens from pool

Parameters

NameType

account

string

poolAddress

string

amount

string

maximumPoolShares

string

Returns

Promise<TransactionReceipt>

Defined in

Ocean.ts:315

Last updated