Skip to content

Commit

Permalink
fix validatePlaceLimitOrderV2 and rename trader to sender in validate…
Browse files Browse the repository at this point in the history
…CancelLimitOrderV2 and validatePlaceLimitOrderV2
  • Loading branch information
vipulsharma21 committed Aug 31, 2023
1 parent c73dfcf commit e2c911b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion precompile/contracts/bibliophile/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type BibliophileClient interface {
GetLongOpenOrdersAmount(trader common.Address, ammIndex *big.Int) *big.Int
GetShortOpenOrdersAmount(trader common.Address, ammIndex *big.Int) *big.Int
GetReduceOnlyAmount(trader common.Address, ammIndex *big.Int) *big.Int
IsTradingAuthority(senderOrSigner, trader common.Address) bool
IsTradingAuthority(trader, senderOrSigner common.Address) bool
// Limit Order
GetBlockPlaced(orderHash [32]byte) *big.Int
GetOrderFilledAmount(orderHash [32]byte) *big.Int
Expand Down
10 changes: 6 additions & 4 deletions precompile/contracts/juror/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,10 @@ func ValidateCancelLimitOrderV2(bibliophile b.BibliophileClient, inputStruct *Va
}
}

func validateCancelLimitOrderV2(bibliophile b.BibliophileClient, order ILimitOrderBookOrderV2, trader common.Address, assertLowMargin bool) (errorString string, orderHash [32]byte, ammAddress common.Address, unfilledAmount *big.Int) {
func validateCancelLimitOrderV2(bibliophile b.BibliophileClient, order ILimitOrderBookOrderV2, sender common.Address, assertLowMargin bool) (errorString string, orderHash [32]byte, ammAddress common.Address, unfilledAmount *big.Int) {
unfilledAmount = big.NewInt(0)
if order.Trader != trader && !bibliophile.IsTradingAuthority(order.Trader, trader) {
trader := order.Trader
if trader != sender && !bibliophile.IsTradingAuthority(trader, sender) {
errorString = ErrNoTradingAuthority.Error()
return
}
Expand Down Expand Up @@ -552,14 +553,15 @@ func ValidatePlaceLimitOrderV2(bibliophile b.BibliophileClient, order ILimitOrde
}
}

func validatePlaceLimitOrderV2(bibliophile b.BibliophileClient, order ILimitOrderBookOrderV2, trader common.Address) (errorString string, orderHash [32]byte, ammAddress common.Address, reserveAmount *big.Int) {
func validatePlaceLimitOrderV2(bibliophile b.BibliophileClient, order ILimitOrderBookOrderV2, sender common.Address) (errorString string, orderHash [32]byte, ammAddress common.Address, reserveAmount *big.Int) {
reserveAmount = big.NewInt(0)
orderHash, err := GetLimitOrderV2Hash(&order)
if err != nil {
errorString = err.Error()
return
}
if order.Trader != trader && !bibliophile.IsTradingAuthority(order.Trader, trader) {
trader := order.Trader
if trader != sender && !bibliophile.IsTradingAuthority(trader, sender) {
errorString = ErrNoTradingAuthority.Error()
return
}
Expand Down

0 comments on commit e2c911b

Please sign in to comment.