Skip to content

Commit

Permalink
receiveAmount -> demandAmount
Browse files Browse the repository at this point in the history
  • Loading branch information
albertchon committed Feb 25, 2021
1 parent 4e2d27b commit 96af996
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions spot_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import (

// SpotOrder represents an unsigned Injective Spot order
type SpotOrder struct {
ChainID int64 `json:"chainId"`
SubaccountID common.Hash `json:"subaccountID"`
Sender common.Address `json:"sender"`
FeeRecipient common.Address `json:"feeRecipient"`
Expiry uint64 `json:"expiry"`
MarketID common.Hash `json:"marketID"`
SupplyAmount *big.Int `json:"supplyAmount"`
ReceiveAmount *big.Int `json:"receiveAmount"`
Salt uint64 `json:"salt"`
OrderType uint8 `json:"orderType"`
TriggerPrice *big.Int `json:"triggerPrice"`
ChainID int64 `json:"chainId"`
SubaccountID common.Hash `json:"subaccountID"`
Sender common.Address `json:"sender"`
FeeRecipient common.Address `json:"feeRecipient"`
Expiry uint64 `json:"expiry"`
MarketID common.Hash `json:"marketID"`
SupplyAmount *big.Int `json:"supplyAmount"`
DemandAmount *big.Int `json:"demandAmount"`
Salt uint64 `json:"salt"`
OrderType uint8 `json:"orderType"`
TriggerPrice *big.Int `json:"triggerPrice"`

// Cache hash for performance
hash *common.Hash
Expand All @@ -32,8 +32,8 @@ type SpotOrder struct {

func (s *SignedSpotOrder) ComputeSpotPrice() *decimal.Decimal {
var price decimal.Decimal
supplyAmount, receiveAmount := decimal.NewFromBigInt(s.SupplyAmount, 0), decimal.NewFromBigInt(s.ReceiveAmount, 0)
if s.OrderType % 2 == 0 {
supplyAmount, receiveAmount := decimal.NewFromBigInt(s.SupplyAmount, 0), decimal.NewFromBigInt(s.DemandAmount, 0)
if s.OrderType%2 == 0 {
price = supplyAmount.Div(receiveAmount)
} else {
price = receiveAmount.Div(supplyAmount)
Expand Down Expand Up @@ -71,16 +71,16 @@ func (o *SpotOrder) ComputeOrderHash() (common.Hash, error) {
}

var message = map[string]interface{}{
"subaccountID": o.SubaccountID.Hex(),
"sender": o.Sender.Hex(),
"feeRecipient": o.FeeRecipient.Hex(),
"expiry": o.Expiry,
"marketID": o.MarketID,
"supplyAmount": o.SupplyAmount,
"receiveAmount": o.ReceiveAmount,
"salt": o.Salt,
"orderType": o.OrderType,
"triggerPrice": o.TriggerPrice,
"subaccountID": o.SubaccountID.Hex(),
"sender": o.Sender.Hex(),
"feeRecipient": o.FeeRecipient.Hex(),
"expiry": o.Expiry,
"marketID": o.MarketID,
"supplyAmount": o.SupplyAmount,
"demandAmount": o.DemandAmount,
"salt": o.Salt,
"orderType": o.OrderType,
"triggerPrice": o.TriggerPrice,
}

var typedData = typeddata.TypedData{
Expand Down

0 comments on commit 96af996

Please sign in to comment.