Skip to content

Commit

Permalink
Merge pull request #292 from InjectiveLabs/fix/add_notional_quantization
Browse files Browse the repository at this point in the history
fix/add_notional_quantization
  • Loading branch information
aarmoa authored Mar 3, 2025
2 parents 4d282a9 + 42b469e commit a1e1834
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions client/core/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func (spotMarket SpotMarket) PriceToChainFormat(humanReadableValue decimal.Decim
func (spotMarket SpotMarket) NotionalToChainFormat(humanReadableValue decimal.Decimal) sdkmath.LegacyDec {
decimals := spotMarket.QuoteToken.Decimals
chainFormattedValue := humanReadableValue.Mul(decimal.New(1, decimals))
valueInChainFormat, _ := sdkmath.LegacyNewDecFromStr(chainFormattedValue.String())
quantizedValue := chainFormattedValue.Ceil()
valueInChainFormat, _ := sdkmath.LegacyNewDecFromStr(quantizedValue.String())

return valueInChainFormat
}
Expand Down Expand Up @@ -129,7 +130,8 @@ func (derivativeMarket DerivativeMarket) CalculateMarginInChainFormat(humanReada
func (derivativeMarket DerivativeMarket) NotionalToChainFormat(humanReadableValue decimal.Decimal) sdkmath.LegacyDec {
decimals := derivativeMarket.QuoteToken.Decimals
chainFormattedValue := humanReadableValue.Mul(decimal.New(1, decimals))
valueInChainFormat, _ := sdkmath.LegacyNewDecFromStr(chainFormattedValue.String())
quantizedValue := chainFormattedValue.Ceil()
valueInChainFormat, _ := sdkmath.LegacyNewDecFromStr(quantizedValue.String())

return valueInChainFormat
}
Expand Down Expand Up @@ -225,7 +227,8 @@ func (market BinaryOptionMarket) CalculateMarginInChainFormat(humanReadableQuant
func (market BinaryOptionMarket) NotionalToChainFormat(humanReadableValue decimal.Decimal) sdkmath.LegacyDec {
decimals := market.QuoteToken.Decimals
chainFormattedValue := humanReadableValue.Mul(decimal.New(1, decimals))
valueInChainFormat, _ := sdkmath.LegacyNewDecFromStr(chainFormattedValue.String())
quantizedValue := chainFormattedValue.Ceil()
valueInChainFormat, _ := sdkmath.LegacyNewDecFromStr(quantizedValue.String())

return valueInChainFormat
}
Expand Down

0 comments on commit a1e1834

Please # to comment.