mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add optional decimals parameter at joinswapExternAmountIn() and exitswapPoolAmountIn() (#1461)
This commit is contained in:
parent
1d327bf100
commit
b66fffc635
@ -1153,13 +1153,15 @@ export class Pool {
|
|||||||
* @param {String} poolAddress
|
* @param {String} poolAddress
|
||||||
* @param {String} tokenAmountIn exact number of base tokens to spend
|
* @param {String} tokenAmountIn exact number of base tokens to spend
|
||||||
* @param {String} minPoolAmountOut minimum of pool shares expectex
|
* @param {String} minPoolAmountOut minimum of pool shares expectex
|
||||||
|
* @param {number} tokenInDecimals optional number of decimals of the token
|
||||||
* @return {TransactionReceipt}
|
* @return {TransactionReceipt}
|
||||||
*/
|
*/
|
||||||
async joinswapExternAmountIn(
|
async joinswapExternAmountIn(
|
||||||
account: string,
|
account: string,
|
||||||
poolAddress: string,
|
poolAddress: string,
|
||||||
tokenAmountIn: string,
|
tokenAmountIn: string,
|
||||||
minPoolAmountOut: string
|
minPoolAmountOut: string,
|
||||||
|
tokenInDecimals?: number
|
||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const pool = setContractDefaults(
|
const pool = setContractDefaults(
|
||||||
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
||||||
@ -1172,7 +1174,11 @@ export class Pool {
|
|||||||
throw new Error(`tokenAmountOut is greater than ${maxSwap.toString()}`)
|
throw new Error(`tokenAmountOut is greater than ${maxSwap.toString()}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const amountInFormatted = await this.amountToUnits(tokenIn, tokenAmountIn)
|
const amountInFormatted = await this.amountToUnits(
|
||||||
|
tokenIn,
|
||||||
|
tokenAmountIn,
|
||||||
|
tokenInDecimals
|
||||||
|
)
|
||||||
const estGas = await this.estJoinswapExternAmountIn(
|
const estGas = await this.estJoinswapExternAmountIn(
|
||||||
account,
|
account,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
@ -1241,13 +1247,15 @@ export class Pool {
|
|||||||
* @param {String} poolAddress
|
* @param {String} poolAddress
|
||||||
* @param {String} poolAmountIn exact number of pool shares to spend
|
* @param {String} poolAmountIn exact number of pool shares to spend
|
||||||
* @param {String} minTokenAmountOut minimum amount of basetokens expected
|
* @param {String} minTokenAmountOut minimum amount of basetokens expected
|
||||||
|
* @param {number} poolDecimals optional number of decimals of the poool
|
||||||
* @return {TransactionReceipt}
|
* @return {TransactionReceipt}
|
||||||
*/
|
*/
|
||||||
async exitswapPoolAmountIn(
|
async exitswapPoolAmountIn(
|
||||||
account: string,
|
account: string,
|
||||||
poolAddress: string,
|
poolAddress: string,
|
||||||
poolAmountIn: string,
|
poolAmountIn: string,
|
||||||
minTokenAmountOut: string
|
minTokenAmountOut: string,
|
||||||
|
poolDecimals?: number
|
||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const pool = setContractDefaults(
|
const pool = setContractDefaults(
|
||||||
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
new this.web3.eth.Contract(this.poolAbi, poolAddress),
|
||||||
@ -1269,7 +1277,8 @@ export class Pool {
|
|||||||
|
|
||||||
const minTokenOutFormatted = await this.amountToUnits(
|
const minTokenOutFormatted = await this.amountToUnits(
|
||||||
await this.getBaseToken(poolAddress),
|
await this.getBaseToken(poolAddress),
|
||||||
minTokenAmountOut
|
minTokenAmountOut,
|
||||||
|
poolDecimals
|
||||||
)
|
)
|
||||||
const estGas = await this.estExitswapPoolAmountIn(
|
const estGas = await this.estExitswapPoolAmountIn(
|
||||||
account,
|
account,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user