Skip to content

Commit

Permalink
Merge pull request #11 from golos-blockchain/dev
Browse files Browse the repository at this point in the history
Exchange calc
  • Loading branch information
Lex-Ai authored Nov 28, 2023
2 parents bba58e2 + 6cebeae commit 171ceb9
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/pages/api/v1/[[...all]].js
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,14 @@ let handler = nextConnect({ attachParams: true, })

let ret, best_price, limit_price
for (const bid of (isSell ? orders.bids : orders.asks)) {
if (!ret) {
ret = await Asset(bid.order_price.quote)
ret.amount = 0
}

const price = await Price(bid.order_price)
best_price = best_price || price.clone()
limit_price = price.clone()

const orderAmount = bid.asset1
const amount = sell.min(orderAmount)
const receive = amount.mul(price)
ret = ret.plus(receive)
ret = ret ? ret.plus(receive) : receive.clone()
sell = sell.minus(orderAmount)

if (sell.lte(0)) {
Expand Down

0 comments on commit 171ceb9

Please sign in to comment.