mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Proper conversion to wei of base token when ordering (#1527)
* proper conversion to wei Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix conversion in pool Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix test Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix lint Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
parent
50527fa24a
commit
237e948107
@ -15,6 +15,8 @@ export interface FreOrderParams {
|
||||
exchangeContract: string
|
||||
exchangeId: string
|
||||
maxBaseTokenAmount: string
|
||||
baseTokenAddress: string
|
||||
baseTokenDecimals?: number
|
||||
swapMarketFee: string
|
||||
marketFeeAddress: string
|
||||
}
|
||||
|
@ -1363,7 +1363,7 @@ export class Pool {
|
||||
tokenAmount: await this.unitsToAmount(
|
||||
tokenOut,
|
||||
result.tokenAmountIn,
|
||||
tokenOutDecimals
|
||||
tokenInDecimals
|
||||
),
|
||||
liquidityProviderSwapFeeAmount: await this.unitsToAmount(
|
||||
tokenIn,
|
||||
|
@ -1037,7 +1037,7 @@ export class Datatoken {
|
||||
): Promise<TransactionReceipt> {
|
||||
const dtContract = new this.web3.eth.Contract(this.datatokensEnterpriseAbi, dtAddress)
|
||||
try {
|
||||
const freContractParams = getFreOrderParams(freParams)
|
||||
const freContractParams = await getFreOrderParams(this.web3, freParams)
|
||||
|
||||
const estGas = await estimateGas(
|
||||
address,
|
||||
|
@ -55,12 +55,25 @@ export function getErcCreationParams(ercParams: Erc20CreateParams): any {
|
||||
}
|
||||
}
|
||||
|
||||
export function getFreOrderParams(freParams: FreOrderParams): any {
|
||||
export async function getFreOrderParams(
|
||||
web3: Web3,
|
||||
freParams: FreOrderParams
|
||||
): Promise<any> {
|
||||
return {
|
||||
exchangeContract: freParams.exchangeContract,
|
||||
exchangeId: freParams.exchangeId,
|
||||
maxBaseTokenAmount: Web3.utils.toWei(freParams.maxBaseTokenAmount),
|
||||
swapMarketFee: Web3.utils.toWei(freParams.swapMarketFee),
|
||||
maxBaseTokenAmount: await amountToUnits(
|
||||
web3,
|
||||
freParams.baseTokenAddress,
|
||||
freParams.maxBaseTokenAmount,
|
||||
freParams.baseTokenDecimals
|
||||
),
|
||||
swapMarketFee: await amountToUnits(
|
||||
web3,
|
||||
freParams.baseTokenAddress,
|
||||
freParams.swapMarketFee,
|
||||
freParams.baseTokenDecimals
|
||||
),
|
||||
marketFeeAddress: freParams.marketFeeAddress
|
||||
}
|
||||
}
|
||||
|
@ -486,6 +486,8 @@ describe('Datatoken', () => {
|
||||
exchangeContract: fixedRateAddress,
|
||||
exchangeId: exchangeId,
|
||||
maxBaseTokenAmount: '1',
|
||||
baseTokenAddress: contracts.daiAddress,
|
||||
baseTokenDecimals: 18,
|
||||
swapMarketFee: '0.1',
|
||||
marketFeeAddress: ZERO_ADDRESS
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user