Skip to content

Commit

Permalink
Multi-step exchange - more fixes (all?)
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed May 28, 2024
1 parent ea450ab commit aaeef98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
19 changes: 14 additions & 5 deletions app/components/modules/ConvertAssets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,24 @@ class ConvertAssets extends React.Component {
return null
}

let res = (parseFloat(buyAmount.amountFloat) / parseFloat(sellAmount.amountFloat)).toString()
const dot = res.indexOf(res)
if (dot != -1) {
res = res.substring(0, dot + 9)
const price = Price(buyAmount, sellAmount)
const a = sellAmount.clone()
a.amountFloat = '1'
let res = a.mul(price)

let str = res.amountFloat
const dot = str.indexOf('.')
if (dot !== -1) {
str = str.substring(0, dot + 1 + Math.min(res.precision, 6))
}

res = Asset(str + ' ' + res.symbol)
if (res.eq(0)) res.amount = 1
res = res.toString()

return <div style={{ marginTop: '0.25rem' }}>
{tt('convert_assets_jsx.price')} {'1 ' + sellAmount.symbol}:<br/>
<b>{' ~' + res + ' ' + buyAmount.symbol}</b>
<b>{' ~' + res}</b>
</div>
}

Expand Down
4 changes: 2 additions & 2 deletions app/utils/market/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ export async function getExchange(sellAmount, buyAmount, myBalance,
}
} else {
const step = chain.steps[0]
const bp = Price(step.best_price)
const bp = Price(chain.best_price)
if (!isDir) {
bestPrice = bp
limitPrice = Price(step.limit_price)
limitPrice = Price(chain.limit_price)
}
amMul = Asset(chain.res)
const remain = step.remain ? Asset(step.remain) : undefined
Expand Down

0 comments on commit aaeef98

Please sign in to comment.