Skip to content

Commit

Permalink
opt
Browse files Browse the repository at this point in the history
  • Loading branch information
0xshinobii committed Mar 11, 2024
1 parent 5f4c91c commit 8b16406
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions precompile/contracts/bibliophile/amm.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ func getTraderMarginFraction(stateDB contract.StateDB, market common.Address, tr
}

func getRequiredMargin(stateDB contract.StateDB, baseAsset *big.Int, price *big.Int, marketId int64, trader *common.Address) *big.Int {
quoteAsset := hu.Div1e18(hu.Mul(new(big.Int).Abs(baseAsset), price))
quoteAsset := hu.Div1e18(hu.Mul(hu.Abs(baseAsset), price))
return getRequiredMarginForQuote(stateDB, GetMarketAddressFromMarketID(marketId, stateDB), trader, quoteAsset)
}

func getRequiredMarginForQuote(stateDB contract.StateDB, market common.Address, trader *common.Address, quote *big.Int) *big.Int {
marginFraction := getTraderMarginFraction(stateDB, market, trader)
return hu.Div1e6(new(big.Int).Mul(quote, marginFraction))
return hu.Div1e6(hu.Mul(quote, marginFraction))
}

// Utils
Expand Down
File renamed without changes.

0 comments on commit 8b16406

Please sign in to comment.