Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signed orders API #139

Merged
merged 12 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"feeConfig": {
"gasLimit": 500000000,
"targetBlockRate": 1,
"minBaseFee": 60000000000,
"minBaseFee": 30000000000,
"targetGas": 10000000,
"baseFeeChangeDenominator": 50,
"minBlockGasCost": 0,
"maxBlockGasCost": 5000000,
"blockGasCostStep": 10000
"blockGasCostStep": 0
},
"contractNativeMinterConfig": {
"blockTimestamp": 0,
Expand All @@ -30,7 +30,7 @@
"blockTimestamp": 0,
"adminAddresses": ["0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC","0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"]
},
"jurorConfig": {
"jurorV2Config": {
"blockTimestamp": 0
},
"ticksConfig": {
Expand Down Expand Up @@ -78,6 +78,10 @@
"0x03000000000000000000000000000000000000b4": {
"balance": "0x0",
"code": "0x6080604052600436106100695760003560e01c80635c60da1b116100435780635c60da1b146100d35780638f28397014610111578063f851a4401461013157610078565b80632c6eefd5146100805780633659cfe6146100a05780634f1ef286146100c057610078565b3661007857610076610146565b005b610076610146565b34801561008c57600080fd5b5061007661009b3660046109e4565b610160565b3480156100ac57600080fd5b506100766100bb3660046109e4565b6101f8565b6100766100ce3660046109ff565b610256565b3480156100df57600080fd5b506100e86102e1565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34801561011d57600080fd5b5061007661012c3660046109e4565b610336565b34801561013d57600080fd5b506100e861037a565b61014e610407565b61015e6101596104f0565b6104fa565b565b600061016a61051e565b73ffffffffffffffffffffffffffffffffffffffff16146101ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f616c726561647920696e697469616c697a65640000000000000000000000000060448201526064015b60405180910390fd5b6101f581610528565b50565b610200610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561024e576101f5816040518060200160405280600081525060006105c9565b6101f5610146565b61025e610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102d9576102d48383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506105c9915050565b505050565b6102d4610146565b60006102eb610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561032b576103266104f0565b905090565b610333610146565b90565b61033e610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561024e576101f581610528565b6000610384610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561032b57610326610589565b60606103e48383604051806060016040528060278152602001610b1c602791396105f4565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61040f610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561015e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4016101e3565b600061032661071c565b3660008037600080366000845af43d6000803e808015610519573d6000f35b3d6000fd5b6000610326610589565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610551610589565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101f581610744565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6105d283610850565b6000825111806105df5750805b156102d4576105ee83836103bf565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b61069a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016101e3565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516106c29190610aae565b600060405180830381855af49150503d80600081146106fd576040519150601f19603f3d011682016040523d82523d6000602084013e610702565b606091505b509150915061071282828661089d565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105ad565b73ffffffffffffffffffffffffffffffffffffffff81166107e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016101e3565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b610859816108f0565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156108ac5750816103e4565b8251156108bc5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e39190610aca565b73ffffffffffffffffffffffffffffffffffffffff81163b610994576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016101e3565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61080a565b803573ffffffffffffffffffffffffffffffffffffffff811681146109df57600080fd5b919050565b6000602082840312156109f657600080fd5b6103e4826109bb565b600080600060408486031215610a1457600080fd5b610a1d846109bb565b9250602084013567ffffffffffffffff80821115610a3a57600080fd5b818601915086601f830112610a4e57600080fd5b813581811115610a5d57600080fd5b876020828501011115610a6f57600080fd5b6020830194508093505050509250925092565b60005b83811015610a9d578181015183820152602001610a85565b838111156105ee5750506000910152565b60008251610ac0818460208701610a82565b9190910192915050565b6020815260008251806020840152610ae9816040850160208701610a82565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208f0bc66b8ee51a4c109376b6c4d7e171cd933a56f45ed508f31a9c3b7aa9d4eb64736f6c63430008090033"
},
"0x03000000000000000000000000000000000000b5": {
"balance": "0x0",
"code": "0x6080604052600436106100695760003560e01c80635c60da1b116100435780635c60da1b146100d35780638f28397014610111578063f851a4401461013157610078565b80632c6eefd5146100805780633659cfe6146100a05780634f1ef286146100c057610078565b3661007857610076610146565b005b610076610146565b34801561008c57600080fd5b5061007661009b3660046109e4565b610160565b3480156100ac57600080fd5b506100766100bb3660046109e4565b6101f8565b6100766100ce3660046109ff565b610256565b3480156100df57600080fd5b506100e86102e1565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34801561011d57600080fd5b5061007661012c3660046109e4565b610336565b34801561013d57600080fd5b506100e861037a565b61014e610407565b61015e6101596104f0565b6104fa565b565b600061016a61051e565b73ffffffffffffffffffffffffffffffffffffffff16146101ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f616c726561647920696e697469616c697a65640000000000000000000000000060448201526064015b60405180910390fd5b6101f581610528565b50565b610200610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561024e576101f5816040518060200160405280600081525060006105c9565b6101f5610146565b61025e610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102d9576102d48383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506105c9915050565b505050565b6102d4610146565b60006102eb610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561032b576103266104f0565b905090565b610333610146565b90565b61033e610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561024e576101f581610528565b6000610384610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561032b57610326610589565b60606103e48383604051806060016040528060278152602001610b1c602791396105f4565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61040f610589565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561015e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4016101e3565b600061032661071c565b3660008037600080366000845af43d6000803e808015610519573d6000f35b3d6000fd5b6000610326610589565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610551610589565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101f581610744565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6105d283610850565b6000825111806105df5750805b156102d4576105ee83836103bf565b50505050565b606073ffffffffffffffffffffffffffffffffffffffff84163b61069a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016101e3565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516106c29190610aae565b600060405180830381855af49150503d80600081146106fd576040519150601f19603f3d011682016040523d82523d6000602084013e610702565b606091505b509150915061071282828661089d565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105ad565b73ffffffffffffffffffffffffffffffffffffffff81166107e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016101e3565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b610859816108f0565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606083156108ac5750816103e4565b8251156108bc5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e39190610aca565b73ffffffffffffffffffffffffffffffffffffffff81163b610994576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016101e3565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61080a565b803573ffffffffffffffffffffffffffffffffffffffff811681146109df57600080fd5b919050565b6000602082840312156109f657600080fd5b6103e4826109bb565b600080600060408486031215610a1457600080fd5b610a1d846109bb565b9250602084013567ffffffffffffffff80821115610a3a57600080fd5b818601915086601f830112610a4e57600080fd5b813581811115610a5d57600080fd5b876020828501011115610a6f57600080fd5b6020830194508093505050509250925092565b60005b83811015610a9d578181015183820152602001610a85565b838111156105ee5750506000910152565b60008251610ac0818460208701610a82565b9190910192915050565b6020815260008251806020840152610ae9816040850160208701610a82565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208f0bc66b8ee51a4c109376b6c4d7e171cd933a56f45ed508f31a9c3b7aa9d4eb64736f6c63430008090033"
}
},
"nonce": "0x0",
Expand Down
29 changes: 21 additions & 8 deletions plugin/evm/orderbook/config_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type IConfigService interface {
getMinAllowableMargin() *big.Int
getMaintenanceMargin() *big.Int
getMinSizeRequirement(market Market) *big.Int
GetPriceMultiplier(market Market) *big.Int
GetActiveMarketsCount() int64
GetUnderlyingPrices() []*big.Int
GetMidPrices() []*big.Int
Expand All @@ -24,6 +25,10 @@ type IConfigService interface {
GetCumulativePremiumFraction(market Market) *big.Int
GetAcceptableBounds(market Market) (*big.Int, *big.Int)
GetAcceptableBoundsForLiquidation(market Market) (*big.Int, *big.Int)

GetSignedOrderStatus(orderHash common.Hash) int64
IsTradingAuthority(trader, signer common.Address) bool
GetSignedOrderbookContract() common.Address
}

type ConfigService struct {
Expand Down Expand Up @@ -64,16 +69,12 @@ func (cs *ConfigService) getMinSizeRequirement(market Market) *big.Int {
return bibliophile.GetMinSizeRequirement(cs.getStateAtCurrentBlock(), int64(market))
}

func (cs *ConfigService) getStateAtCurrentBlock() *state.StateDB {
stateDB, _ := cs.blockChain.StateAt(cs.blockChain.CurrentBlock().Root)
return stateDB
func (cs *ConfigService) GetPriceMultiplier(market Market) *big.Int {
return bibliophile.GetMultiplier(cs.getStateAtCurrentBlock(), int64(market))
}

func (cs *ConfigService) getStateAtBlock(number uint64) *state.StateDB {
stateDB, err := cs.blockChain.StateAt(cs.blockChain.GetHeaderByNumber(number).Root)
if err != nil {
panic(err)
}
func (cs *ConfigService) getStateAtCurrentBlock() *state.StateDB {
stateDB, _ := cs.blockChain.StateAt(cs.blockChain.CurrentBlock().Root)
return stateDB
}

Expand Down Expand Up @@ -102,3 +103,15 @@ func (cs *ConfigService) GetCumulativePremiumFraction(market Market) *big.Int {
markets := bibliophile.GetMarkets(cs.getStateAtCurrentBlock())
return bibliophile.GetCumulativePremiumFraction(cs.getStateAtCurrentBlock(), markets[market])
}

func (cs *ConfigService) GetSignedOrderStatus(orderHash common.Hash) int64 {
return bibliophile.GetSignedOrderStatus(cs.getStateAtCurrentBlock(), orderHash)
}

func (cs *ConfigService) IsTradingAuthority(trader, signer common.Address) bool {
return bibliophile.IsTradingAuthority(cs.getStateAtCurrentBlock(), trader, signer)
}

func (cs *ConfigService) GetSignedOrderbookContract() common.Address {
return bibliophile.GetSignedOrderBookAddress(cs.getStateAtCurrentBlock())
}
4 changes: 2 additions & 2 deletions plugin/evm/orderbook/contract_events_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ func (cep *ContractEventsProcessor) handleIOCOrderBookEvent(event *types.Log) {
orderId := event.Topics[2]
order := args["order"]
if !removed {
log.Info("IOCOrder/OrderRejected", "orderId", orderId.String(), "number", event.BlockNumber, "order", order)
log.Info("IOCOrder/OrderRejected", "orderId", orderId.String(), "number", event.BlockNumber, "order", order, "err", args["err"])
} else {
log.Info("IOCOrder/OrderRejected removed", "orderId", orderId.String(), "number", event.BlockNumber, "order", order)
log.Info("IOCOrder/OrderRejected removed", "orderId", orderId.String(), "number", event.BlockNumber, "order", order, args["err"])
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/orderbook/contract_events_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ func getEventFromABI(contractABI abi.ABI, eventName string) abi.Event {

func getLimitOrder(ammIndex *big.Int, traderAddress common.Address, baseAssetQuantity *big.Int, price *big.Int, salt *big.Int) LimitOrder {
return LimitOrder{
BaseOrder: BaseOrder{
BaseOrder: hu.BaseOrder{
AmmIndex: ammIndex,
Trader: traderAddress,
BaseAssetQuantity: baseAssetQuantity,
Expand Down
Loading