mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
limit price precision to 18 (#492)
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
parent
8511a3b165
commit
4e4bbc1120
2
package-lock.json
generated
2
package-lock.json
generated
@ -16410,7 +16410,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethereumjs-abi": {
|
"ethereumjs-abi": {
|
||||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#1a27c59c15ab1e95ee8e5c4ed6ad814c49cc439e",
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#1ce6a1d64235fabe2aaf827fd606def55693508f",
|
||||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bn.js": "^4.11.8",
|
"bn.js": "^4.11.8",
|
||||||
|
@ -129,12 +129,20 @@ function usePricing(ddo: DDO): UsePricing {
|
|||||||
setStep(1, 'buy')
|
setStep(1, 'buy')
|
||||||
|
|
||||||
Logger.log('Price found for buying', price)
|
Logger.log('Price found for buying', price)
|
||||||
|
Decimal.set({ precision: 18 })
|
||||||
|
|
||||||
switch (price?.type) {
|
switch (price?.type) {
|
||||||
case 'pool': {
|
case 'pool': {
|
||||||
const oceanAmmount = new Decimal(price.value).times(1.05).toString()
|
const oceanAmmount = new Decimal(price.value).times(1.05).toString()
|
||||||
const maxPrice = new Decimal(price.value).times(2).toString()
|
const maxPrice = new Decimal(price.value).times(2).toString()
|
||||||
setStep(2, 'buy')
|
setStep(2, 'buy')
|
||||||
Logger.log('Buying token from pool', price, accountId, price)
|
Logger.log(
|
||||||
|
'Buying token from pool',
|
||||||
|
price,
|
||||||
|
accountId,
|
||||||
|
oceanAmmount,
|
||||||
|
maxPrice
|
||||||
|
)
|
||||||
tx = await ocean.pool.buyDT(
|
tx = await ocean.pool.buyDT(
|
||||||
accountId,
|
accountId,
|
||||||
price.address,
|
price.address,
|
||||||
@ -190,6 +198,7 @@ function usePricing(ddo: DDO): UsePricing {
|
|||||||
): Promise<TransactionReceipt | void> {
|
): Promise<TransactionReceipt | void> {
|
||||||
if (!ocean || !accountId) return
|
if (!ocean || !accountId) return
|
||||||
|
|
||||||
|
Decimal.set({ precision: 18 })
|
||||||
if (!config.oceanTokenAddress) {
|
if (!config.oceanTokenAddress) {
|
||||||
Logger.error(`'oceanTokenAddress' not set in config`)
|
Logger.error(`'oceanTokenAddress' not set in config`)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user