diff --git a/models/liquidation.go b/models/liquidation.go index 59e64e2..c7b25ca 100644 --- a/models/liquidation.go +++ b/models/liquidation.go @@ -16,7 +16,7 @@ import ( // - BlockTimestamp: Timestamp of the block where the order was committed. type Liquidation struct { MarketID uint64 - AccountID uint64 + AccountID *big.Int AmountLiquidated *big.Int CurrentPositionSize *big.Int BlockNumber uint64 @@ -35,14 +35,9 @@ func GetLiquidationFromEvent(event *perpsMarketGoerli.PerpsMarketGoerliPositionL marketID = event.MarketId.Uint64() } - accountID := uint64(0) - if event.AccountId != nil { - accountID = event.AccountId.Uint64() - } - return &Liquidation{ MarketID: marketID, - AccountID: accountID, + AccountID: event.AccountId, AmountLiquidated: event.AmountLiquidated, CurrentPositionSize: event.CurrentPositionSize, BlockNumber: event.Raw.BlockNumber, diff --git a/models/liquidation_test.go b/models/liquidation_test.go index 1b718a7..8ab2b72 100644 --- a/models/liquidation_test.go +++ b/models/liquidation_test.go @@ -37,7 +37,7 @@ func TestGetLiquidationFromEvent(t *testing.T) { AccountId: big.NewInt(1), }, want: &Liquidation{ - AccountID: uint64(1), + AccountID: big.NewInt(1), }, }, { @@ -54,7 +54,7 @@ func TestGetLiquidationFromEvent(t *testing.T) { time: uint64(timeNow.Unix()), want: &Liquidation{ MarketID: uint64(1), - AccountID: uint64(2), + AccountID: big.NewInt(2), AmountLiquidated: big.NewInt(3), CurrentPositionSize: big.NewInt(4), BlockNumber: 5, diff --git a/models/order.go b/models/order.go index 045fac8..3697734 100644 --- a/models/order.go +++ b/models/order.go @@ -23,7 +23,7 @@ import ( // - BlockTimestamp: Timestamp of the block where the order was committed. type Order struct { MarketID uint64 - AccountID uint64 + AccountID *big.Int OrderType uint8 SizeDelta *big.Int AcceptablePrice *big.Int @@ -47,11 +47,6 @@ func GetOrderFromEvent(event *perpsMarketGoerli.PerpsMarketGoerliOrderCommitted, marketID = event.MarketId.Uint64() } - accountID := uint64(0) - if event.AccountId != nil { - accountID = event.AccountId.Uint64() - } - settlementTime := uint64(0) if event.SettlementTime != nil { settlementTime = event.SettlementTime.Uint64() @@ -64,7 +59,7 @@ func GetOrderFromEvent(event *perpsMarketGoerli.PerpsMarketGoerliOrderCommitted, return &Order{ MarketID: marketID, - AccountID: accountID, + AccountID: event.AccountId, OrderType: event.OrderType, SizeDelta: event.SizeDelta, AcceptablePrice: event.AcceptablePrice, diff --git a/models/order_test.go b/models/order_test.go index a62c077..c4b130b 100644 --- a/models/order_test.go +++ b/models/order_test.go @@ -40,7 +40,7 @@ func TestGetOrderFromEvent(t *testing.T) { AccountId: big.NewInt(1), }, want: &Order{ - AccountID: uint64(1), + AccountID: big.NewInt(1), }, }, { @@ -80,7 +80,7 @@ func TestGetOrderFromEvent(t *testing.T) { time: uint64(timeNow.Unix()), want: &Order{ MarketID: uint64(1), - AccountID: uint64(2), + AccountID: big.NewInt(2), OrderType: uint8(3), SizeDelta: big.NewInt(5), AcceptablePrice: big.NewInt(6), diff --git a/models/trade.go b/models/trade.go index 569faa7..9496dbb 100644 --- a/models/trade.go +++ b/models/trade.go @@ -28,7 +28,7 @@ import ( // - TransactionHash - Hash of the transaction where the trade was settled. type Trade struct { MarketID uint64 - AccountID uint64 + AccountID *big.Int FillPrice *big.Int PnL *big.Int AccruedFunding *big.Int @@ -57,14 +57,9 @@ func GetTradeFromEvent(event *perpsMarketGoerli.PerpsMarketGoerliOrderSettled, t marketID = event.MarketId.Uint64() } - accountID := uint64(0) - if event.AccountId != nil { - accountID = event.AccountId.Uint64() - } - return &Trade{ MarketID: marketID, - AccountID: accountID, + AccountID: event.AccountId, FillPrice: event.FillPrice, PnL: event.Pnl, AccruedFunding: event.AccruedFunding, diff --git a/models/trade_test.go b/models/trade_test.go index 5584626..143b366 100644 --- a/models/trade_test.go +++ b/models/trade_test.go @@ -41,7 +41,7 @@ func TestGetTradeFromEvent(t *testing.T) { AccountId: big.NewInt(1), }, want: &Trade{ - AccountID: uint64(1), + AccountID: big.NewInt(1), TransactionHash: "0x0000000000000000000000000000000000000000000000000000000000000000", }, }, @@ -68,7 +68,7 @@ func TestGetTradeFromEvent(t *testing.T) { time: uint64(timeNow.Unix()), want: &Trade{ MarketID: 1, - AccountID: 2, + AccountID: big.NewInt(2), FillPrice: big.NewInt(3), AccruedFunding: big.NewInt(4), SizeDelta: big.NewInt(5), diff --git a/perpsv3_test.go b/perpsv3_test.go index 21a9c60..93a3b62 100644 --- a/perpsv3_test.go +++ b/perpsv3_test.go @@ -148,7 +148,7 @@ func TestPerpsv3_RetrieveTrades(t *testing.T) { trade := &models.Trade{ MarketID: 200, - AccountID: 1692895537802, + AccountID: big.NewInt(1692895537802), FillPrice: fillPrice, PnL: pnl, AccruedFunding: accruedF, @@ -247,7 +247,7 @@ func TestPerpsv3_RetrieveTradesLimit(t *testing.T) { trade := &models.Trade{ MarketID: 200, - AccountID: 1692895537802, + AccountID: big.NewInt(1692895537802), FillPrice: fillPrice, PnL: pnl, AccruedFunding: accruedF, @@ -331,7 +331,7 @@ func TestPerpsv3_RetrieveOrders(t *testing.T) { liquidation := &models.Order{ MarketID: 100, - AccountID: 8714, + AccountID: big.NewInt(8714), OrderType: 0, SizeDelta: sizeDelta, AcceptablePrice: acceptablePrice, @@ -413,7 +413,7 @@ func TestPerpsv3_RetrieveOrdersLimit(t *testing.T) { liquidation := &models.Order{ MarketID: 100, - AccountID: 8714, + AccountID: big.NewInt(8714), OrderType: 0, SizeDelta: sizeDelta, AcceptablePrice: acceptablePrice, @@ -486,7 +486,7 @@ func TestPerpsv3_RetrieveLiquidations(t *testing.T) { liquidation := &models.Liquidation{ MarketID: 100, - AccountID: 25, + AccountID: big.NewInt(25), AmountLiquidated: big.NewInt(200000000000000000), CurrentPositionSize: big.NewInt(0), BlockNumber: 14125002, @@ -557,7 +557,7 @@ func TestPerpsv3_RetrieveLiquidations(t *testing.T) { func TestPerpsv3_RetrieveLiquidationsLimit(t *testing.T) { liquidation := &models.Liquidation{ MarketID: 100, - AccountID: 25, + AccountID: big.NewInt(25), AmountLiquidated: big.NewInt(200000000000000000), CurrentPositionSize: big.NewInt(0), BlockNumber: 14125002, diff --git a/services/luquidations_test.go b/services/luquidations_test.go index e6ded7e..628d963 100644 --- a/services/luquidations_test.go +++ b/services/luquidations_test.go @@ -45,9 +45,12 @@ func TestService_RetrieveLiquidations_OnChain(t *testing.T) { spot, _ := spotMarketGoerli.NewSpotMarketGoerli(common.HexToAddress("0x5FF4b3aacdeC86782d8c757FAa638d8790799E83"), rpcClient) perps, _ := perpsMarketGoerli.NewPerpsMarketGoerli(common.HexToAddress("0xf272382cB3BE898A8CdB1A23BE056fA2Fcf4513b"), rpcClient) + id := new(big.Int) + id.SetString("170141183460469231731687303715884105753", 10) + want := &models.Liquidation{ MarketID: 100, - AccountID: 25, + AccountID: id, AmountLiquidated: big.NewInt(200000000000000000), CurrentPositionSize: big.NewInt(0), BlockNumber: 14125002, diff --git a/services/orders_test.go b/services/orders_test.go index 0c4c8ed..ff9129c 100644 --- a/services/orders_test.go +++ b/services/orders_test.go @@ -35,7 +35,7 @@ func TestService_RetrieveOrders_OnChain(t *testing.T) { want := &models.Order{ MarketID: 100, - AccountID: 8714, + AccountID: big.NewInt(8714), OrderType: 0, SizeDelta: sizeDelta, AcceptablePrice: acceptablePrice, diff --git a/services/trades_test.go b/services/trades_test.go index a34ca48..2e8c7cf 100644 --- a/services/trades_test.go +++ b/services/trades_test.go @@ -47,7 +47,7 @@ func TestService_RetrieveTrades_OnChain(t *testing.T) { want := &models.Trade{ MarketID: 200, - AccountID: 1692895537802, + AccountID: big.NewInt(1692895537802), FillPrice: fillPrice, PnL: pnl, AccruedFunding: accruedF,