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
Name | Type |
---|---|
|
|
|
|
|
|
|
|
Overrides
Base.constructor
Defined in
Properties
bPool
• Private
bPool: Pool
= null
Defined in
config
• config: any
= null
Inherited from
Base.config
Defined in
logger
• Private
logger: any
= null
Defined in
networkId
• networkId: any
= null
Inherited from
Base.networkId
Defined in
oceanPool
• Private
oceanPool: OceanPool
= null
Defined in
oceanTokenAddress
• oceanTokenAddress: string
= null
Defined in
poolFactoryAddress
• Private
poolFactoryAddress: string
= null
Defined in
web3
• web3: any
= null
Inherited from
Base.web3
Defined in
Methods
approve
▸ approve(tokenAddress
, spender
, amount
, account
): Promise
<TransactionReceipt
>
approve spender to spend your tokens
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
|
|
Returns
Promise
<TransactionReceipt
>
Defined in
calculateSwapFee
▸ calculateSwapFee(poolAddress
, tokenInAmount
): Promise
<string
>
calculates Swap Fee for a given trade
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
Defined in
checkIfApproved
▸ checkIfApproved(tokenAddress
, account
, spender
, amount
): Promise
<boolean
>
check if token spend allowance is approved for a given spender accounts
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
|
|
Returns
Promise
<boolean
>
Defined in
getAllStakedPools
▸ getAllStakedPools(account
, fromBlock
, toBlock
): Promise
<PoolShare
[]>
Returns all staked pools for a given account
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
Returns
Promise
<PoolShare
[]>
Defined in
getAllowance
▸ getAllowance(tokenAddress
, account
, spender
): Promise
<string
>
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
Returns
Promise
<string
>
user allowance for token
Defined in
getBalance
▸ getBalance(tokenAddress
, account
): Promise
<string
>
returns token balance of a given account
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
(in ETH denom)
Defined in
getDtNeeded
▸ getDtNeeded(poolAddress
, oceanAmountWanted
): Promise
<string
>
Calculate how many data token are needed to buy a specific oceanAmount
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
amount of datatokens needed
Defined in
getDtNeededForExactDt
▸ getDtNeededForExactDt(outputDtAmountWanted
, inputPoolAddress
, outputPoolAddress
): Promise
<any
>
Returns input Datatoken amount needed for swapping to exact Datatoken out
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
Returns
Promise
<any
>
Defined in
getDtPerOcean
▸ getDtPerOcean(poolAddress
): Promise
<string
>
get Dt price per OCEAN
Parameters
Name | Type |
---|---|
|
|
Returns
Promise
<string
>
Defined in
getDtReceived
▸ getDtReceived(poolAddress
, oceanAmount
): Promise
<string
>
Calculate how many data token are you going to receive for selling a specific oceanAmount (buying Dt)
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
amount of ocean tokens received
Defined in
getDtReceivedForExactDt
▸ getDtReceivedForExactDt(inputDtAmount
, inputPoolAddress
, outputPoolAddress
): Promise
<any
>
Returns output datatokens received for exact input datatokens
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
Returns
Promise
<any
>
Defined in
getMaxExchange
▸ getMaxExchange(address
, getOcean
): Promise
<any
>
Get the DT or OCEAN reserve for a pool.
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<any
>
DT: the max exchange based on the DT amount or OCEAN: the entire ocean reserve in a pool.
Defined in
getMaxStakeAmount
▸ getMaxStakeAmount(poolAddress
, tokenAddress
): Promise
<string
>
Returns max amount of tokens that you can stake to the pool
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
Defined in
getMaxUnstakeAmount
▸ getMaxUnstakeAmount(poolAddress
, tokenAddress
): Promise
<string
>
Returns max amount of tokens that you can unstake from the pool
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
Defined in
getMyPoolSharesForPool
▸ getMyPoolSharesForPool(poolAddress
, account
): Promise
<string
>
returns pool shares of a given pool for a given account
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
Defined in
getOceanNeeded
▸ getOceanNeeded(poolAddress
, dtAmountWanted
): Promise
<string
>
Calculate how many OCEAN are needed to buy a specific amount of datatokens
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
amount of Ocean needed
Defined in
getOceanPerDt
▸ getOceanPerDt(poolAddress
): Promise
<string
>
get Ocean price per Dt
Parameters
Name | Type |
---|---|
|
|
Returns
Promise
<string
>
Defined in
getOceanReceived
▸ getOceanReceived(poolAddress
, dtAmount
): Promise
<string
>
Get Ocean Received
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
Defined in
getOceanRemovedforPoolShares
▸ getOceanRemovedforPoolShares(poolAddress
, poolShares
): Promise
<string
>
Returns Ocean amount received after spending poolShares
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<string
>
Defined in
getPoolDetails
▸ getPoolDetails(poolAddress
): Promise
<any
>
get pool details
Parameters
Name | Type |
---|---|
|
|
Returns
Promise
<any
>
datatoken addresses
Defined in
getPoolSharesRequiredToUnstake
▸ getPoolSharesRequiredToUnstake(poolAddress
, tokenAddress
, tokenAmount
): Promise
<string
>
returns no. of shares needed to unstake given token amount
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
Returns
Promise
<string
>
Defined in
getSwapFee
▸ getSwapFee(poolAddress
): Promise
<string
>
returns swap fee for a given pool
Parameters
Name | Type |
---|---|
|
|
Returns
Promise
<string
>
Defined in
getTokenDetails
▸ getTokenDetails(tokenAddress
): Promise
<TokenDetails
>
gets token details (NAME & SYMBOL)
Parameters
Name | Type |
---|---|
|
|
Returns
Promise
<TokenDetails
>
Defined in
getTokensRemovedforPoolShares
▸ getTokensRemovedforPoolShares(poolAddress
, poolShares
): Promise
<TokensReceived
>
Returns Datatoken & Ocean amounts received after spending given poolShares
Parameters
Name | Type |
---|---|
|
|
|
|
Returns
Promise
<TokensReceived
>
Defined in
getTotalPoolShares
▸ getTotalPoolShares(poolAddress
): Promise
<string
>
returns total shares of a given pool
Parameters
Name | Type |
---|---|
|
|
Returns
Promise
<string
>
Defined in
stakeOcean
▸ stakeOcean(account
, poolAddress
, amount
): Promise
<TransactionReceipt
>
stake OCEAN tokens in a pool
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
Returns
Promise
<TransactionReceipt
>
Defined in
swapDtToExactDt
▸ swapDtToExactDt(account
, inputDtAddress
, outputDtAddress
, outputDtAmountWanted
, maxInputDtAmount
, inputPoolAddress
, outputPoolAddress
, routerAddress?
, slippageInPercent?
): Promise
<any
>
Swaps input Datatoken for exact output Datatoken
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Promise
<any
>
Defined in
swapDtToExactOcean
▸ swapDtToExactOcean(account
, poolAddress
, oceanAmountWanted
, maxDtAmount
, slippage
): Promise
<TransactionReceipt
>
swaps datatokens to exact no. of Ocean tokens
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
Returns
Promise
<TransactionReceipt
>
Defined in
swapExactDtToDt
▸ swapExactDtToDt(account
, inputDtAddress
, outputDtAddress
, minOutputDtAmount
, inputDtAmount
, inputPoolAddress
, outputPoolAddress
, routerAddress?
, slippageInPercent?
): Promise
<any
>
Swaps exact input datatoken for minumum amount output datatoken
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Promise
<any
>
Defined in
swapExactDtToOcean
▸ swapExactDtToOcean(account
, poolAddress
, minimumOceanAmountWanted
, dtAmount
, slippage
): Promise
<TransactionReceipt
>
Swaps exact no. of datatokens to Ocean tokens
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
Returns
Promise
<TransactionReceipt
>
Defined in
swapExactOceanToDt
▸ swapExactOceanToDt(account
, poolAddress
, minimumdtAmountWanted
, OceanAmount
, slippage
): Promise
<TransactionReceipt
>
swaps exact no. of Ocean tokens to datatokens
Parameters
Name | Type | Description |
---|---|---|
|
| ] |
|
| |
|
| |
|
| |
|
| - |
Returns
Promise
<TransactionReceipt
>
Defined in
swapOceanToExactDt
▸ swapOceanToExactDt(account
, poolAddress
, dtAmountWanted
, maxOceanAmount
, slippage
): Promise
<TransactionReceipt
>
swaps Ocean tokens to exact no. of datatokens
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
Returns
Promise
<TransactionReceipt
>
Defined in
unstakeOcean
▸ unstakeOcean(account
, poolAddress
, amount
, maximumPoolShares
): Promise
<TransactionReceipt
>
unstake OCEAN tokens from pool
Parameters
Name | Type |
---|---|
|
|
|
|
|
|
|
|
Returns
Promise
<TransactionReceipt
>
Defined in
Last updated