From c626e7d4c879ec4aedda26062b8bdcbf8e10cd46 Mon Sep 17 00:00:00 2001 From: Jay Yu <103467857+jayy04@users.noreply.github.com> Date: Mon, 4 Dec 2023 22:44:34 -0500 Subject: [PATCH] [DEC-2196] deprecate non-linear margin requirements --- .../dydxprotocol/indexer/events/events.proto | 2 +- proto/dydxprotocol/perpetuals/perpetual.proto | 2 +- protocol/indexer/events/events.pb.go | 249 +++++++++--------- protocol/indexer/events/liquidity_tier.go | 2 - .../indexer/events/liquidity_tier_test.go | 2 - protocol/mocks/PerpetualsKeeper.go | 14 +- protocol/testing/e2e/gov/perpetuals_test.go | 21 -- protocol/testutil/constants/perpetuals.go | 13 - protocol/testutil/keeper/perpetuals.go | 4 +- .../testutil/liquidity_tier/liquidity_tier.go | 7 - .../sim_helpers/genesis_parameters.go | 9 - .../clob/e2e/liquidation_deleveraging_test.go | 128 --------- .../client/cli/query_perpetual_test.go | 1 - protocol/x/perpetuals/genesis.go | 1 - protocol/x/perpetuals/genesis_test.go | 28 -- .../keeper/msg_server_set_liquidity_tier.go | 1 - .../msg_server_set_liquidity_tier_test.go | 12 +- protocol/x/perpetuals/keeper/perpetual.go | 11 +- .../x/perpetuals/keeper/perpetual_test.go | 142 ++-------- protocol/x/perpetuals/simulation/genesis.go | 13 - protocol/x/perpetuals/types/errors.go | 5 - protocol/x/perpetuals/types/genesis_test.go | 10 - protocol/x/perpetuals/types/liquidity_tier.go | 53 +--- .../x/perpetuals/types/liquidity_tier_test.go | 145 ++-------- .../types/message_set_liquidity_tier_test.go | 18 -- protocol/x/perpetuals/types/perpetual.pb.go | 80 +++--- protocol/x/perpetuals/types/types.go | 1 - 27 files changed, 238 insertions(+), 736 deletions(-) diff --git a/proto/dydxprotocol/indexer/events/events.proto b/proto/dydxprotocol/indexer/events/events.proto index c7a55a1bc8..476a42cb2b 100644 --- a/proto/dydxprotocol/indexer/events/events.proto +++ b/proto/dydxprotocol/indexer/events/events.proto @@ -369,7 +369,7 @@ message LiquidityTierUpsertEventV1 { // The maximum position size at which the margin requirements are // not increased over the default values. Above this position size, // the margin requirements increase at a rate of sqrt(size). - uint64 base_position_notional = 5; + uint64 base_position_notional = 5 [ deprecated = true ]; } // UpdateClobPairEventV1 message contains all the information about an update to diff --git a/proto/dydxprotocol/perpetuals/perpetual.proto b/proto/dydxprotocol/perpetuals/perpetual.proto index 5f79acd6b9..5032ab26d7 100644 --- a/proto/dydxprotocol/perpetuals/perpetual.proto +++ b/proto/dydxprotocol/perpetuals/perpetual.proto @@ -96,7 +96,7 @@ message LiquidityTier { // The maximum position size at which the margin requirements are // not increased over the default values. Above this position size, // the margin requirements increase at a rate of sqrt(size). - uint64 base_position_notional = 5; + uint64 base_position_notional = 5 [ deprecated = true ]; // The impact notional amount (in quote quantums) is used to determine impact // bid/ask prices and its recommended value is 500 USDC / initial margin diff --git a/protocol/indexer/events/events.pb.go b/protocol/indexer/events/events.pb.go index e9bb3e3dfd..b5560fb707 100644 --- a/protocol/indexer/events/events.pb.go +++ b/protocol/indexer/events/events.pb.go @@ -1739,7 +1739,7 @@ type LiquidityTierUpsertEventV1 struct { // The maximum position size at which the margin requirements are // not increased over the default values. Above this position size, // the margin requirements increase at a rate of sqrt(size). - BasePositionNotional uint64 `protobuf:"varint,5,opt,name=base_position_notional,json=basePositionNotional,proto3" json:"base_position_notional,omitempty"` + BasePositionNotional uint64 `protobuf:"varint,5,opt,name=base_position_notional,json=basePositionNotional,proto3" json:"base_position_notional,omitempty"` // Deprecated: Do not use. } func (m *LiquidityTierUpsertEventV1) Reset() { *m = LiquidityTierUpsertEventV1{} } @@ -1803,6 +1803,7 @@ func (m *LiquidityTierUpsertEventV1) GetMaintenanceFractionPpm() uint32 { return 0 } +// Deprecated: Do not use. func (m *LiquidityTierUpsertEventV1) GetBasePositionNotional() uint64 { if m != nil { return m.BasePositionNotional @@ -2025,131 +2026,131 @@ func init() { } var fileDescriptor_6331dfb59c6fd2bb = []byte{ - // 1971 bytes of a gzipped FileDescriptorProto + // 1974 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0xcd, 0x4f, 0x23, 0xc9, 0x15, 0xc7, 0x76, 0x63, 0xe0, 0x81, 0x19, 0xbb, 0x06, 0x18, 0x03, 0x09, 0x43, 0x5a, 0x8a, 0x84, - 0xf6, 0xc3, 0x0c, 0x93, 0x49, 0xb4, 0xca, 0x21, 0x0a, 0x06, 0xb3, 0x78, 0x04, 0x8c, 0xd3, 0x98, - 0xd9, 0xdd, 0x49, 0xb4, 0x9d, 0xa2, 0xbb, 0x6c, 0x4a, 0xf4, 0xd7, 0x76, 0x95, 0xc9, 0x30, 0x52, - 0xce, 0xc9, 0x2d, 0x91, 0x72, 0xce, 0x21, 0x87, 0x5c, 0x22, 0xe5, 0x10, 0x29, 0xd7, 0x95, 0x22, - 0xe5, 0xb2, 0xb7, 0xac, 0x72, 0x49, 0x94, 0xc3, 0x28, 0x9a, 0x39, 0xe4, 0xdf, 0x88, 0xea, 0xa3, - 0xdb, 0x36, 0xb6, 0x19, 0xcf, 0xc0, 0x9e, 0x70, 0xbd, 0x57, 0xef, 0xf7, 0x3e, 0xab, 0xde, 0xab, - 0x06, 0x36, 0xdc, 0x4b, 0xf7, 0x79, 0x14, 0x87, 0x3c, 0x74, 0x42, 0x6f, 0x93, 0x06, 0x2e, 0x79, - 0x4e, 0xe2, 0x4d, 0x72, 0x41, 0x02, 0xce, 0xf4, 0x9f, 0x8a, 0x64, 0xa3, 0xd5, 0xde, 0x9d, 0x15, - 0xbd, 0xb3, 0xa2, 0xb6, 0xac, 0x2c, 0x3b, 0x21, 0xf3, 0x43, 0x66, 0x4b, 0xfe, 0xa6, 0x5a, 0x28, - 0xb9, 0x95, 0x85, 0x76, 0xd8, 0x0e, 0x15, 0x5d, 0xfc, 0xd2, 0xd4, 0x07, 0x43, 0xf5, 0xb2, 0x33, - 0x1c, 0x13, 0x77, 0x33, 0x26, 0x7e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, 0x28, 0x68, 0xc5, 0x4e, 0x4c, 0x04, 0x78, 0x4e, 0x82, 0x3f, 0x18, 0x03, 0x7c, - 0x47, 0x0a, 0x74, 0x71, 0xe7, 0xfc, 0x1e, 0x72, 0x0f, 0xb0, 0x1f, 0xba, 0xb4, 0x75, 0x59, 0x36, - 0xc6, 0x06, 0x3e, 0x94, 0x02, 0x03, 0xc0, 0x8a, 0x5c, 0x9d, 0x82, 0x49, 0xb9, 0xdb, 0x7c, 0x0c, - 0xe5, 0x51, 0x5e, 0xa2, 0x0a, 0xdc, 0x55, 0x21, 0xfb, 0x05, 0xe5, 0x67, 0x36, 0x79, 0x1e, 0x85, - 0x01, 0x09, 0xb8, 0x8c, 0xac, 0x61, 0x95, 0x24, 0xeb, 0x13, 0xca, 0xcf, 0x6a, 0x9a, 0x61, 0x7e, - 0x0a, 0x25, 0x85, 0x55, 0xc5, 0x2c, 0x05, 0x41, 0x60, 0x44, 0x98, 0xc6, 0x52, 0x6a, 0xc6, 0x92, - 0xbf, 0xd1, 0x26, 0x2c, 0xf8, 0x34, 0xb0, 0x15, 0xb8, 0x73, 0x86, 0x83, 0x76, 0xf7, 0xb8, 0x15, - 0xac, 0x92, 0x4f, 0x03, 0x69, 0xcd, 0x8e, 0xe4, 0x34, 0x22, 0xdf, 0xec, 0xc0, 0xdd, 0x21, 0xe1, - 0x42, 0x55, 0x30, 0x4e, 0x31, 0x23, 0x12, 0x7b, 0xf6, 0x61, 0x65, 0x8c, 0xa8, 0xf4, 0x58, 0x66, - 0x49, 0x59, 0xb4, 0x02, 0xd3, 0xa9, 0x67, 0x42, 0x7f, 0xc9, 0x4a, 0xd7, 0xe6, 0x67, 0x89, 0xda, - 0xbe, 0x60, 0xde, 0x86, 0x5a, 0xf3, 0xcf, 0x19, 0x28, 0x1c, 0x87, 0x9d, 0xd8, 0x21, 0x4f, 0x5a, - 0xe2, 0x48, 0x31, 0xf4, 0x33, 0x28, 0x74, 0xef, 0xb2, 0xa4, 0x82, 0x47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0x9d, 0x31, 0x90, 0xba, 0x05, 0x98, 0x94, 0xbd, - 0x44, 0xa6, 0xcd, 0xb0, 0xd4, 0x02, 0x2d, 0x42, 0x9e, 0x32, 0xfb, 0xb4, 0x73, 0x29, 0x13, 0x36, - 0x6d, 0x4d, 0x52, 0x56, 0xed, 0x5c, 0x9a, 0xbf, 0xce, 0x02, 0x1a, 0xac, 0x99, 0x6f, 0x36, 0x82, - 0xeb, 0x30, 0x27, 0x86, 0x5a, 0x5b, 0x74, 0xbf, 0xe4, 0xd6, 0x2a, 0x58, 0x20, 0x68, 0x0d, 0x4c, - 0xe3, 0xba, 0x3b, 0x4e, 0x18, 0xbe, 0x0d, 0xa0, 0x0a, 0x87, 0xd1, 0x17, 0x44, 0x47, 0x61, 0x46, - 0x52, 0x8e, 0xe9, 0x8b, 0x5e, 0x77, 0x27, 0x7b, 0xdc, 0x15, 0xfd, 0x8d, 0x75, 0x4e, 0x39, 0x75, - 0xce, 0x99, 0x8c, 0x83, 0x61, 0xa5, 0x6b, 0xf3, 0x7f, 0x59, 0xb8, 0xd7, 0xb5, 0xbc, 0xbf, 0xf9, - 0x3f, 0xbb, 0xcd, 0x76, 0x74, 0xa5, 0x19, 0xbd, 0x80, 0x55, 0x35, 0x85, 0xb9, 0x76, 0xd7, 0xe9, - 0x28, 0x64, 0x54, 0x24, 0x84, 0x95, 0x73, 0x72, 0xa2, 0xfd, 0xe1, 0xd8, 0x9a, 0x1a, 0x09, 0x46, - 0x43, 0x43, 0x58, 0xcb, 0x1a, 0x7e, 0x80, 0xc3, 0x50, 0x00, 0xf7, 0x12, 0xdd, 0xea, 0x92, 0xef, - 0xea, 0x35, 0xa4, 0xde, 0x1f, 0x8c, 0xad, 0x77, 0x5b, 0xc8, 0xa7, 0x3a, 0x17, 0x35, 0x6c, 0x1f, - 0x95, 0x3d, 0x36, 0xa6, 0xb3, 0xc5, 0x9c, 0xf9, 0x07, 0x80, 0x85, 0x63, 0x8e, 0x39, 0x69, 0x75, - 0x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4, 0xad, 0x52, 0x28, 0xbb, 0x87, 0x88, 0x4f, 0x8b, 0x10, 0x99, 0x45, + 0x24, 0xba, 0xc7, 0x39, 0x89, 0xf7, 0x08, 0x11, 0x4c, 0x9e, 0x32, 0xf3, 0x8a, 0xc9, 0x13, 0xe6, + 0xfb, 0x80, 0x78, 0xc8, 0xb1, 0x67, 0x0b, 0x34, 0xe2, 0xda, 0x52, 0xaa, 0x3c, 0x25, 0x35, 0x14, + 0x25, 0x67, 0x4f, 0x32, 0x0e, 0x05, 0x7d, 0x60, 0xb7, 0x84, 0x29, 0x4f, 0x0f, 0xec, 0x6e, 0x0a, + 0x7a, 0xb5, 0x00, 0xb3, 0xbc, 0x9b, 0x35, 0xf3, 0x6f, 0x59, 0xb8, 0xbb, 0x4b, 0x3c, 0x72, 0x41, + 0x62, 0xdc, 0xee, 0x99, 0x07, 0x7e, 0x0a, 0x90, 0x78, 0x4c, 0x6e, 0x76, 0x00, 0x93, 0x14, 0x77, + 0xe1, 0x04, 0x78, 0xd8, 0x6a, 0x31, 0xc2, 0x39, 0x0d, 0xda, 0x37, 0x3a, 0x71, 0x09, 0x78, 0x17, + 0x6e, 0x60, 0x34, 0xcb, 0x0d, 0x8e, 0x66, 0x57, 0x52, 0x67, 0x0c, 0xa4, 0x6e, 0x01, 0x26, 0x65, + 0x2f, 0x91, 0x69, 0x33, 0x2c, 0xb5, 0x40, 0x8b, 0x90, 0xa7, 0xcc, 0x3e, 0xed, 0x5c, 0xca, 0x84, + 0x4d, 0x5b, 0x93, 0x94, 0x55, 0x3b, 0x97, 0xe6, 0xaf, 0xb3, 0x80, 0x06, 0x6b, 0xe6, 0xdd, 0x46, + 0x70, 0x1d, 0xe6, 0xc4, 0x50, 0x6b, 0x8b, 0xee, 0x97, 0xdc, 0x5a, 0x05, 0x0b, 0x04, 0xad, 0x81, + 0x69, 0x5c, 0x77, 0xc7, 0x09, 0xc3, 0xb7, 0x01, 0x54, 0xe1, 0x30, 0xfa, 0x82, 0xe8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49, 0x8f, 0xf2, 0x35, 0x17, 0x8e, 0x3e, 0x9c, 0xd9, 0xd1, 0x87, + 0x33, 0x37, 0xce, 0x8d, 0x62, 0x8c, 0x38, 0x12, 0x83, 0x85, 0x3b, 0x39, 0xa4, 0x70, 0xab, 0xd6, + 0x57, 0x2f, 0xd7, 0x32, 0x5f, 0xbf, 0x5c, 0xcb, 0xfc, 0xf7, 0xe5, 0x5a, 0xe6, 0xb7, 0xaf, 0xd6, + 0x26, 0xbe, 0x7e, 0xb5, 0x36, 0xf1, 0xef, 0x57, 0x6b, 0x13, 0xcf, 0x3e, 0x1a, 0xff, 0x8b, 0x73, + 0xff, 0xbf, 0x06, 0x4e, 0xf3, 0x92, 0xf1, 0xbd, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x72, 0xef, + 0x8e, 0xce, 0x40, 0x18, 0x00, 0x00, } func (m *FundingUpdateV1) Marshal() (dAtA []byte, err error) { diff --git a/protocol/indexer/events/liquidity_tier.go b/protocol/indexer/events/liquidity_tier.go index 43d86cde97..14b77c754f 100644 --- a/protocol/indexer/events/liquidity_tier.go +++ b/protocol/indexer/events/liquidity_tier.go @@ -7,13 +7,11 @@ func NewLiquidityTierUpsertEvent( name string, initialMarginPpm uint32, maintenanceFractionPpm uint32, - basePositionNotional uint64, ) *LiquidityTierUpsertEventV1 { return &LiquidityTierUpsertEventV1{ Id: id, Name: name, InitialMarginPpm: initialMarginPpm, MaintenanceFractionPpm: maintenanceFractionPpm, - BasePositionNotional: basePositionNotional, } } diff --git a/protocol/indexer/events/liquidity_tier_test.go b/protocol/indexer/events/liquidity_tier_test.go index 305e890a4e..64e1718392 100644 --- a/protocol/indexer/events/liquidity_tier_test.go +++ b/protocol/indexer/events/liquidity_tier_test.go @@ -12,14 +12,12 @@ func TestNewLiquidityTierUpsertEvent_Success(t *testing.T) { "Large-Cap", 50000, 600000, - 1000000000000, ) expectedLiquidityTierUpsertEventProto := &LiquidityTierUpsertEventV1{ Id: 0, Name: "Large-Cap", InitialMarginPpm: 50000, MaintenanceFractionPpm: 600000, - BasePositionNotional: 1000000000000, } require.Equal(t, expectedLiquidityTierUpsertEventProto, liquidityTierUpsertEvent) } diff --git a/protocol/mocks/PerpetualsKeeper.go b/protocol/mocks/PerpetualsKeeper.go index f8c22c387c..ca2b84212d 100644 --- a/protocol/mocks/PerpetualsKeeper.go +++ b/protocol/mocks/PerpetualsKeeper.go @@ -227,20 +227,20 @@ func (_m *PerpetualsKeeper) PerformStatefulPremiumVotesValidation(ctx types.Cont return r0 } -// SetLiquidityTier provides a mock function with given fields: ctx, id, name, initialMarginPpm, maintenanceFractionPpm, basePositionNotional, impactNotional -func (_m *PerpetualsKeeper) SetLiquidityTier(ctx types.Context, id uint32, name string, initialMarginPpm uint32, maintenanceFractionPpm uint32, basePositionNotional uint64, impactNotional uint64) (perpetualstypes.LiquidityTier, error) { - ret := _m.Called(ctx, id, name, initialMarginPpm, maintenanceFractionPpm, basePositionNotional, impactNotional) +// SetLiquidityTier provides a mock function with given fields: ctx, id, name, initialMarginPpm, maintenanceFractionPpm, impactNotional +func (_m *PerpetualsKeeper) SetLiquidityTier(ctx types.Context, id uint32, name string, initialMarginPpm uint32, maintenanceFractionPpm uint32, impactNotional uint64) (perpetualstypes.LiquidityTier, error) { + ret := _m.Called(ctx, id, name, initialMarginPpm, maintenanceFractionPpm, impactNotional) var r0 perpetualstypes.LiquidityTier - if rf, ok := ret.Get(0).(func(types.Context, uint32, string, uint32, uint32, uint64, uint64) perpetualstypes.LiquidityTier); ok { - r0 = rf(ctx, id, name, initialMarginPpm, maintenanceFractionPpm, basePositionNotional, impactNotional) + if rf, ok := ret.Get(0).(func(types.Context, uint32, string, uint32, uint32, uint64) perpetualstypes.LiquidityTier); ok { + r0 = rf(ctx, id, name, initialMarginPpm, maintenanceFractionPpm, impactNotional) } else { r0 = ret.Get(0).(perpetualstypes.LiquidityTier) } var r1 error - if rf, ok := ret.Get(1).(func(types.Context, uint32, string, uint32, uint32, uint64, uint64) error); ok { - r1 = rf(ctx, id, name, initialMarginPpm, maintenanceFractionPpm, basePositionNotional, impactNotional) + if rf, ok := ret.Get(1).(func(types.Context, uint32, string, uint32, uint32, uint64) error); ok { + r1 = rf(ctx, id, name, initialMarginPpm, maintenanceFractionPpm, impactNotional) } else { r1 = ret.Error(1) } diff --git a/protocol/testing/e2e/gov/perpetuals_test.go b/protocol/testing/e2e/gov/perpetuals_test.go index 1ac90df2c2..e2286a5301 100644 --- a/protocol/testing/e2e/gov/perpetuals_test.go +++ b/protocol/testing/e2e/gov/perpetuals_test.go @@ -31,7 +31,6 @@ var ( Name: "Test Tier", InitialMarginPpm: 765_432, MaintenanceFractionPpm: 345_678, - BasePositionNotional: 123_456, ImpactNotional: 654_321, } ) @@ -355,7 +354,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: TEST_LIQUIDITY_TIER.Name, InitialMarginPpm: TEST_LIQUIDITY_TIER.InitialMarginPpm, MaintenanceFractionPpm: TEST_LIQUIDITY_TIER.MaintenanceFractionPpm, - BasePositionNotional: TEST_LIQUIDITY_TIER.BasePositionNotional, ImpactNotional: TEST_LIQUIDITY_TIER.ImpactNotional, }, }, @@ -369,7 +367,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: TEST_LIQUIDITY_TIER.Name, InitialMarginPpm: TEST_LIQUIDITY_TIER.InitialMarginPpm, MaintenanceFractionPpm: TEST_LIQUIDITY_TIER.MaintenanceFractionPpm, - BasePositionNotional: TEST_LIQUIDITY_TIER.BasePositionNotional, ImpactNotional: TEST_LIQUIDITY_TIER.ImpactNotional, }, }, @@ -384,7 +381,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: TEST_LIQUIDITY_TIER.Name, InitialMarginPpm: 1_000_001, MaintenanceFractionPpm: TEST_LIQUIDITY_TIER.MaintenanceFractionPpm, - BasePositionNotional: TEST_LIQUIDITY_TIER.BasePositionNotional, ImpactNotional: TEST_LIQUIDITY_TIER.ImpactNotional, }, }, @@ -398,21 +394,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: TEST_LIQUIDITY_TIER.Name, InitialMarginPpm: TEST_LIQUIDITY_TIER.InitialMarginPpm, MaintenanceFractionPpm: 1_000_001, - BasePositionNotional: TEST_LIQUIDITY_TIER.BasePositionNotional, - ImpactNotional: TEST_LIQUIDITY_TIER.ImpactNotional, - }, - }, - expectCheckTxFails: true, - }, - "Failure: base position notional is 0": { - msg: &perptypes.MsgSetLiquidityTier{ - Authority: authtypes.NewModuleAddress(perptypes.ModuleName).String(), - LiquidityTier: perptypes.LiquidityTier{ - Id: 5678, - Name: TEST_LIQUIDITY_TIER.Name, - InitialMarginPpm: TEST_LIQUIDITY_TIER.InitialMarginPpm, - MaintenanceFractionPpm: TEST_LIQUIDITY_TIER.MaintenanceFractionPpm, - BasePositionNotional: 0, ImpactNotional: TEST_LIQUIDITY_TIER.ImpactNotional, }, }, @@ -426,7 +407,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: TEST_LIQUIDITY_TIER.Name, InitialMarginPpm: TEST_LIQUIDITY_TIER.InitialMarginPpm, MaintenanceFractionPpm: TEST_LIQUIDITY_TIER.MaintenanceFractionPpm, - BasePositionNotional: TEST_LIQUIDITY_TIER.BasePositionNotional, ImpactNotional: 0, }, }, @@ -440,7 +420,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: "Test Tier", InitialMarginPpm: 765_432, MaintenanceFractionPpm: 345_678, - BasePositionNotional: 123_456, ImpactNotional: 654_321, }, }, diff --git a/protocol/testutil/constants/perpetuals.go b/protocol/testutil/constants/perpetuals.go index 21b17dbe41..ccf11f1189 100644 --- a/protocol/testutil/constants/perpetuals.go +++ b/protocol/testutil/constants/perpetuals.go @@ -23,7 +23,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "0", InitialMarginPpm: 1_000_000, MaintenanceFractionPpm: 1_000_000, - BasePositionNotional: 1_000_000, ImpactNotional: 500_000_000, }, { @@ -31,7 +30,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "1", InitialMarginPpm: 1_000_000, MaintenanceFractionPpm: 750_000, - BasePositionNotional: 1_000_000, ImpactNotional: 500_000_000, }, { @@ -39,7 +37,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "2", InitialMarginPpm: 1_000_000, MaintenanceFractionPpm: 0, - BasePositionNotional: 1_000_000, ImpactNotional: 500_000_000, }, { @@ -47,7 +44,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "3", InitialMarginPpm: 200_000, MaintenanceFractionPpm: 500_000, - BasePositionNotional: 100_000_000_000, ImpactNotional: 2_500_000_000, }, { @@ -55,7 +51,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "4", InitialMarginPpm: 500_000, MaintenanceFractionPpm: 800_000, - BasePositionNotional: 100_000_000_000, ImpactNotional: 1_000_000_000, }, { @@ -63,7 +58,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "5", InitialMarginPpm: 500_000, MaintenanceFractionPpm: 600_000, - BasePositionNotional: 1_000_000, ImpactNotional: 1_000_000_000, }, { @@ -71,7 +65,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "6", InitialMarginPpm: 200_000, MaintenanceFractionPpm: 900_000, - BasePositionNotional: 1_000_000, ImpactNotional: 2_500_000_000, }, { @@ -79,7 +72,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "7", InitialMarginPpm: 0, MaintenanceFractionPpm: 0, - BasePositionNotional: 100_000_000_000, ImpactNotional: 1_000_000_000, }, { @@ -87,7 +79,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "8", InitialMarginPpm: 9_910, // 0.9910% MaintenanceFractionPpm: 1_000_000, - BasePositionNotional: 100_000_000_000, ImpactNotional: 50_454_000_000, }, { @@ -95,7 +86,6 @@ var LiquidityTiers = []perptypes.LiquidityTier{ Name: "101", InitialMarginPpm: 200_000, MaintenanceFractionPpm: 500_000, - BasePositionNotional: 1_000_000, ImpactNotional: 2_500_000_000, }, } @@ -331,7 +321,6 @@ var ( Name: "Large-Cap", InitialMarginPpm: 200_000, MaintenanceFractionPpm: 500_000, - BasePositionNotional: 1000_000_000, ImpactNotional: 2_500_000_000, }, { @@ -339,7 +328,6 @@ var ( Name: "Mid-Cap", InitialMarginPpm: 300_000, MaintenanceFractionPpm: 600_000, - BasePositionNotional: 500_000_000, ImpactNotional: 1_667_000_000, }, { @@ -347,7 +335,6 @@ var ( Name: "Small-Cap", InitialMarginPpm: 400_000, MaintenanceFractionPpm: 700_000, - BasePositionNotional: 250_000_000, ImpactNotional: 1_250_000_000, }, }, diff --git a/protocol/testutil/keeper/perpetuals.go b/protocol/testutil/keeper/perpetuals.go index 35eeecfd1a..23a77efd8a 100644 --- a/protocol/testutil/keeper/perpetuals.go +++ b/protocol/testutil/keeper/perpetuals.go @@ -2,9 +2,10 @@ package keeper import ( "fmt" - "github.com/dydxprotocol/v4-chain/protocol/lib" "testing" + "github.com/dydxprotocol/v4-chain/protocol/lib" + pricefeedserver_types "github.com/dydxprotocol/v4-chain/protocol/daemons/server/types/pricefeed" "github.com/dydxprotocol/v4-chain/protocol/indexer/common" indexerevents "github.com/dydxprotocol/v4-chain/protocol/indexer/events" @@ -174,7 +175,6 @@ func CreateTestLiquidityTiers(t *testing.T, ctx sdk.Context, k *keeper.Keeper) { l.Name, l.InitialMarginPpm, l.MaintenanceFractionPpm, - l.BasePositionNotional, l.ImpactNotional, ) diff --git a/protocol/testutil/liquidity_tier/liquidity_tier.go b/protocol/testutil/liquidity_tier/liquidity_tier.go index 66753b7bd2..77989d5b2d 100644 --- a/protocol/testutil/liquidity_tier/liquidity_tier.go +++ b/protocol/testutil/liquidity_tier/liquidity_tier.go @@ -30,12 +30,6 @@ func WithMaintenanceFractionPpm(maintenanceFractionPpm uint32) LtModifierOption } } -func WithBasePositionNotional(basePositionNotional uint64) LtModifierOption { - return func(lt *perptypes.LiquidityTier) { - lt.BasePositionNotional = basePositionNotional - } -} - func WithImpactNotional(impactNotional uint64) LtModifierOption { return func(lt *perptypes.LiquidityTier) { lt.ImpactNotional = impactNotional @@ -57,7 +51,6 @@ func GenerateLiquidityTier(optionalModifications ...LtModifierOption) *perptypes Name: "Large-Cap", InitialMarginPpm: 1_000_000, MaintenanceFractionPpm: 1_000_000, - BasePositionNotional: 1_000_000, ImpactNotional: 500_000_000, } diff --git a/protocol/testutil/sim_helpers/genesis_parameters.go b/protocol/testutil/sim_helpers/genesis_parameters.go index ac2f950078..e27a26469a 100644 --- a/protocol/testutil/sim_helpers/genesis_parameters.go +++ b/protocol/testutil/sim_helpers/genesis_parameters.go @@ -133,15 +133,6 @@ var ( Valid: MaxNumPerpetuals.Valid, } - MinBasePositionNotional = GenesisParameters[int]{ - Reasonable: 10_000_000_000, // 10_000 USDC - Valid: 50_000_000_000, // 50_000 USDC - } - MaxBasePositionNotional = GenesisParameters[int]{ - Reasonable: MinBasePositionNotional.Reasonable * 100, - Valid: MinBasePositionNotional.Valid * 100, - } - MinFundingRateClampFactorPpm = GenesisParameters[int]{ Reasonable: 4_000_000, // 400% Valid: 1_000_000, // 100% diff --git a/protocol/x/clob/e2e/liquidation_deleveraging_test.go b/protocol/x/clob/e2e/liquidation_deleveraging_test.go index 6d67a3510f..d5aa68d78d 100644 --- a/protocol/x/clob/e2e/liquidation_deleveraging_test.go +++ b/protocol/x/clob/e2e/liquidation_deleveraging_test.go @@ -694,134 +694,6 @@ func TestPlacePerpetualLiquidation_Deleveraging(t *testing.T) { }, }, }, - `Can place and match liquidation order for subaccount with non-linear margin requirement`: { - liquidityTiers: []perptypes.LiquidityTier{ - { - Id: 3, - Name: "3", - InitialMarginPpm: 200_000, // 20% IMF - MaintenanceFractionPpm: 500_000, // 10% MMF - BasePositionNotional: 12_500_000_000, // $12.5k - ImpactNotional: 2_500_000_000, - }, - }, - perpetuals: []perptypes.Perpetual{ - // Uses liquidity tier id 3 - constants.BtcUsd_20PercentInitial_10PercentMaintenance, - }, - subaccounts: []satypes.Subaccount{ - // When below basePositionNotional, marginAdjustmentPpm is 1e^6 but at 1 BTC is 1e^6 * sqrt(50k/12.25k) = 2e^6 - // This means maintenanceMarginPpm is 1e^5 * 2 = 2e^5. Maintenance margin is now 20%. - // A subaccount with a 1 BTC position must then have .20*50k = $10k in TNC to be well collateralized. - { // TNC = $9,999, undercollateralized - Id: &constants.Carl_Num0, - AssetPositions: []*satypes.AssetPosition{ - { - AssetId: 0, - Quantums: dtypes.NewInt(-40_001_000_000), // $-40,001 - }, - }, - PerpetualPositions: []*satypes.PerpetualPosition{ - { - PerpetualId: 0, - Quantums: dtypes.NewInt(100_000_000), // 1 BTC - }, - }, - }, - constants.Dave_Num0_1BTC_Long_50000USD, - }, - placedMatchableOrders: []clobtypes.MatchableOrder{ - &constants.LongTermOrder_Dave_Num0_Id0_Clob0_Buy1BTC_Price50000_GTBT10, - }, - liquidatableSubaccountIds: []satypes.SubaccountId{constants.Carl_Num0}, - liquidationConfig: constants.LiquidationsConfig_FillablePrice_Max_Smmr, - clobPairs: []clobtypes.ClobPair{constants.ClobPair_Btc}, - - expectedSubaccounts: []satypes.Subaccount{ - { - Id: &constants.Carl_Num0, - AssetPositions: []*satypes.AssetPosition{ - { - AssetId: 0, - // Asset position + fill price - liquidation insurance fund fee - Quantums: dtypes.NewInt(-40_001_000_000 + 50_000_000_000 - 250_000_000), - }, - }, - }, - { - Id: &constants.Dave_Num0, - PerpetualPositions: []*satypes.PerpetualPosition{ - { - PerpetualId: 0, - Quantums: dtypes.NewInt(200_000_000), - FundingIndex: dtypes.NewInt(0), - }, - }, - }, - }, - }, - `Skip liquidating subaccount when TNC equals MMR with non-linear margin requirement`: { - liquidityTiers: []perptypes.LiquidityTier{ - { - Id: 3, - Name: "3", - InitialMarginPpm: 200_000, // 20% IMF - MaintenanceFractionPpm: 500_000, // 10% MMF - BasePositionNotional: 12_500_000_000, // $12.5k - ImpactNotional: 2_500_000_000, - }, - }, - perpetuals: []perptypes.Perpetual{ - // Uses liquidity tier id 3 - constants.BtcUsd_20PercentInitial_10PercentMaintenance, - }, - subaccounts: []satypes.Subaccount{ - { // TNC = $10k, MMR = $10k - Id: &constants.Carl_Num0, - AssetPositions: []*satypes.AssetPosition{ - { - AssetId: 0, - Quantums: dtypes.NewInt(-40_000_000_000), // $-40,000 - }, - }, - PerpetualPositions: []*satypes.PerpetualPosition{ - { - PerpetualId: 0, - Quantums: dtypes.NewInt(100_000_000), // 1 BTC - }, - }, - }, - constants.Dave_Num0_1BTC_Long_50000USD, - }, - placedMatchableOrders: []clobtypes.MatchableOrder{ - &constants.LongTermOrder_Dave_Num0_Id0_Clob0_Buy1BTC_Price50000_GTBT10, - }, - liquidatableSubaccountIds: []satypes.SubaccountId{constants.Carl_Num0}, - liquidationConfig: constants.LiquidationsConfig_FillablePrice_Max_Smmr, - clobPairs: []clobtypes.ClobPair{constants.ClobPair_Btc}, - - // Provided liquidatable subaccount should be skipped in PrepareCheckState for not being liquidatable. - // This means no liquidation order placement / match will occur. - expectedSubaccounts: []satypes.Subaccount{ - { - Id: &constants.Carl_Num0, - AssetPositions: []*satypes.AssetPosition{ - { - AssetId: 0, - Quantums: dtypes.NewInt(-40_000_000_000), // $-40,000 - }, - }, - PerpetualPositions: []*satypes.PerpetualPosition{ - { - PerpetualId: 0, - Quantums: dtypes.NewInt(100_000_000), // 1 BTC - FundingIndex: dtypes.NewInt(0), - }, - }, - }, - constants.Dave_Num0_1BTC_Long_50000USD, - }, - }, `Can place a liquidation order that is partially filled and does not require deleveraging`: { subaccounts: []satypes.Subaccount{ constants.Carl_Num0_1BTC_Short_50499USD, diff --git a/protocol/x/perpetuals/client/cli/query_perpetual_test.go b/protocol/x/perpetuals/client/cli/query_perpetual_test.go index bef9977b2a..b6b6f30ae6 100644 --- a/protocol/x/perpetuals/client/cli/query_perpetual_test.go +++ b/protocol/x/perpetuals/client/cli/query_perpetual_test.go @@ -53,7 +53,6 @@ func networkWithLiquidityTierAndPerpetualObjects( Name: fmt.Sprintf("test_liquidity_tier_name_%d", i), InitialMarginPpm: uint32(1_000_000 / (i + 1)), MaintenanceFractionPpm: uint32(1_000_000 / (i + 1)), - BasePositionNotional: uint64(1_000_000_000 * (i + 1)), ImpactNotional: uint64(500_000_000 * (i + 1)), } nullify.Fill(&liquidityTier) //nolint:staticcheck diff --git a/protocol/x/perpetuals/genesis.go b/protocol/x/perpetuals/genesis.go index 4f67c3b378..373e51daa2 100644 --- a/protocol/x/perpetuals/genesis.go +++ b/protocol/x/perpetuals/genesis.go @@ -25,7 +25,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) elem.Name, elem.InitialMarginPpm, elem.MaintenanceFractionPpm, - elem.BasePositionNotional, elem.ImpactNotional, ) diff --git a/protocol/x/perpetuals/genesis_test.go b/protocol/x/perpetuals/genesis_test.go index 21ebf78124..7ec28797ee 100644 --- a/protocol/x/perpetuals/genesis_test.go +++ b/protocol/x/perpetuals/genesis_test.go @@ -41,7 +41,6 @@ func TestGenesis_Failure(t *testing.T) { ticker string initialMarginPpm uint32 maintenanceFractionPpm uint32 - basePositionNotional uint64 impactNotional uint64 fundingRateClampFactorPpm uint32 premiumVoteClampFactorPpm uint32 @@ -52,7 +51,6 @@ func TestGenesis_Failure(t *testing.T) { ticker: "genesis_ticker", initialMarginPpm: 0, maintenanceFractionPpm: 0, - basePositionNotional: 1, impactNotional: 1, fundingRateClampFactorPpm: 1, premiumVoteClampFactorPpm: 1, @@ -63,7 +61,6 @@ func TestGenesis_Failure(t *testing.T) { ticker: "", initialMarginPpm: 0, maintenanceFractionPpm: 0, - basePositionNotional: 1, impactNotional: 1, fundingRateClampFactorPpm: 1, premiumVoteClampFactorPpm: 1, @@ -74,7 +71,6 @@ func TestGenesis_Failure(t *testing.T) { ticker: "genesis_ticker", initialMarginPpm: lib.OneMillion + 1, maintenanceFractionPpm: 0, - basePositionNotional: 1, impactNotional: 1, fundingRateClampFactorPpm: 1, premiumVoteClampFactorPpm: 1, @@ -85,28 +81,16 @@ func TestGenesis_Failure(t *testing.T) { ticker: "genesis_ticker", initialMarginPpm: 0, maintenanceFractionPpm: lib.OneMillion + 1, - basePositionNotional: 1, impactNotional: 1, fundingRateClampFactorPpm: 1, premiumVoteClampFactorPpm: 1, minNumVotesPerSample: 0, }, - "Base Position Notional is zero": { - marketId: 0, - ticker: "genesis_ticker", - initialMarginPpm: 0, - maintenanceFractionPpm: lib.OneMillion + 1, - basePositionNotional: 0, - impactNotional: 1, - fundingRateClampFactorPpm: 1, - premiumVoteClampFactorPpm: 1, - }, "Impact Notional is zero": { marketId: 0, ticker: "genesis_ticker", initialMarginPpm: 0, maintenanceFractionPpm: lib.OneMillion + 1, - basePositionNotional: 1, impactNotional: 0, fundingRateClampFactorPpm: 1, premiumVoteClampFactorPpm: 1, @@ -117,7 +101,6 @@ func TestGenesis_Failure(t *testing.T) { ticker: "genesis_ticker", initialMarginPpm: 0, maintenanceFractionPpm: lib.OneMillion, - basePositionNotional: 1, impactNotional: 1, fundingRateClampFactorPpm: 0, premiumVoteClampFactorPpm: 1, @@ -128,7 +111,6 @@ func TestGenesis_Failure(t *testing.T) { ticker: "genesis_ticker", initialMarginPpm: 0, maintenanceFractionPpm: lib.OneMillion, - basePositionNotional: 1, impactNotional: 1, fundingRateClampFactorPpm: 1, premiumVoteClampFactorPpm: 0, @@ -151,7 +133,6 @@ func TestGenesis_Failure(t *testing.T) { Name: "", InitialMarginPpm: tc.initialMarginPpm, MaintenanceFractionPpm: tc.maintenanceFractionPpm, - BasePositionNotional: tc.basePositionNotional, ImpactNotional: tc.impactNotional, }, }, @@ -231,14 +212,5 @@ func assertLiquidityTierUpsertEventsInIndexerBlock( i, ) } - - if event.BasePositionNotional != liquidityTiers[i].BasePositionNotional { - t.Fatalf( - "Expected LiquidityTierUpsertEvent with BasePositionNotional %d, but got %d at index %d", - liquidityTiers[i].BasePositionNotional, - event.BasePositionNotional, - i, - ) - } } } diff --git a/protocol/x/perpetuals/keeper/msg_server_set_liquidity_tier.go b/protocol/x/perpetuals/keeper/msg_server_set_liquidity_tier.go index 96ab16cfc2..9266628707 100644 --- a/protocol/x/perpetuals/keeper/msg_server_set_liquidity_tier.go +++ b/protocol/x/perpetuals/keeper/msg_server_set_liquidity_tier.go @@ -29,7 +29,6 @@ func (k msgServer) SetLiquidityTier( msg.LiquidityTier.Name, msg.LiquidityTier.InitialMarginPpm, msg.LiquidityTier.MaintenanceFractionPpm, - msg.LiquidityTier.BasePositionNotional, msg.LiquidityTier.ImpactNotional, ); err != nil { return nil, err diff --git a/protocol/x/perpetuals/keeper/msg_server_set_liquidity_tier_test.go b/protocol/x/perpetuals/keeper/msg_server_set_liquidity_tier_test.go index 7274248eb8..e477624818 100644 --- a/protocol/x/perpetuals/keeper/msg_server_set_liquidity_tier_test.go +++ b/protocol/x/perpetuals/keeper/msg_server_set_liquidity_tier_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - "github.com/dydxprotocol/v4-chain/protocol/lib" "testing" + "github.com/dydxprotocol/v4-chain/protocol/lib" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" keepertest "github.com/dydxprotocol/v4-chain/protocol/testutil/keeper" @@ -19,7 +20,6 @@ func TestSetLiquidityTier(t *testing.T) { lttest.WithName("test"), lttest.WithInitialMarginPpm(1_000), lttest.WithMaintenanceFractionPpm(2_000), - lttest.WithBasePositionNotional(3_000), lttest.WithImpactNotional(4_000), ) @@ -35,7 +35,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: "large-cap", InitialMarginPpm: 123_432, MaintenanceFractionPpm: testLt.MaintenanceFractionPpm, - BasePositionNotional: testLt.BasePositionNotional, ImpactNotional: testLt.ImpactNotional, }, }, @@ -48,7 +47,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: "medium-cap", InitialMarginPpm: 567_123, MaintenanceFractionPpm: 500_001, - BasePositionNotional: 400_202, ImpactNotional: 1_300_303, }, }, @@ -61,7 +59,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: "medium-cap", InitialMarginPpm: 567_123, MaintenanceFractionPpm: 500_001, - BasePositionNotional: 400_202, ImpactNotional: 1_300_303, }, }, @@ -74,7 +71,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: "medium-cap", InitialMarginPpm: 1_000_001, MaintenanceFractionPpm: 500_001, - BasePositionNotional: 400_202, ImpactNotional: 1_300_303, }, }, @@ -88,7 +84,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: "medium-cap", InitialMarginPpm: 500_001, MaintenanceFractionPpm: 1_000_001, - BasePositionNotional: 400_202, ImpactNotional: 1_300_303, }, }, @@ -102,7 +97,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: "medium-cap", InitialMarginPpm: 567_123, MaintenanceFractionPpm: 500_001, - BasePositionNotional: 400_202, ImpactNotional: 1_300_303, }, }, @@ -116,7 +110,6 @@ func TestSetLiquidityTier(t *testing.T) { Name: "medium-cap", InitialMarginPpm: 567_123, MaintenanceFractionPpm: 500_001, - BasePositionNotional: 400_202, ImpactNotional: 1_300_303, }, }, @@ -133,7 +126,6 @@ func TestSetLiquidityTier(t *testing.T) { testLt.Name, testLt.InitialMarginPpm, testLt.MaintenanceFractionPpm, - testLt.BasePositionNotional, testLt.ImpactNotional, ) require.NoError(t, err) diff --git a/protocol/x/perpetuals/keeper/perpetual.go b/protocol/x/perpetuals/keeper/perpetual.go index 26fa55e14d..9d03408c48 100644 --- a/protocol/x/perpetuals/keeper/perpetual.go +++ b/protocol/x/perpetuals/keeper/perpetual.go @@ -836,9 +836,7 @@ func (k Keeper) GetNetCollateral( // // Margin requirements are a function of the absolute value of the open notional of the position as well as // the parameters of the relevant `LiquidityTier` of the perpetual. -// Initial margin requirement is determined by multiplying `InitialMarginPpm` by `marginAdjustmentPpm`, -// then limited to a maximum of 100%. `marginAdjustmentPpm“ is given by the equation -// `sqrt(notionalValue / liquidityTier.BasePositionNotional)` limited to a minimum of 100%. +// Initial margin requirement is determined by multiplying `InitialMarginPpm` and `notionalValue`. // `notionalValue` is determined by multiplying the size of the position by the oracle price of the position. // Maintenance margin requirement is then simply a fraction (`maintenanceFractionPpm`) of initial margin requirement. // @@ -891,8 +889,8 @@ func (k Keeper) GetMarginRequirements( marketPrice.Exponent, ) - // Initial margin requirement quote quantums = size in quote quantums * adjusted initial margin PPM. - bigInitialMarginQuoteQuantums = liquidityTier.GetAdjustedInitialMarginQuoteQuantums(bigQuoteQuantums) + // Initial margin requirement quote quantums = size in quote quantums * initial margin PPM. + bigInitialMarginQuoteQuantums = liquidityTier.GetInitialMarginQuoteQuantums(bigQuoteQuantums) // Maintenance margin requirement quote quantums = IM in quote quantums * maintenance fraction PPM. bigMaintenanceMarginQuoteQuantums = lib.BigRatRound( @@ -1297,7 +1295,6 @@ func (k Keeper) SetLiquidityTier( name string, initialMarginPpm uint32, maintenanceFractionPpm uint32, - basePositionNotional uint64, impactNotional uint64, ) ( liquidityTier types.LiquidityTier, @@ -1309,7 +1306,6 @@ func (k Keeper) SetLiquidityTier( Name: name, InitialMarginPpm: initialMarginPpm, MaintenanceFractionPpm: maintenanceFractionPpm, - BasePositionNotional: basePositionNotional, ImpactNotional: impactNotional, } @@ -1332,7 +1328,6 @@ func (k Keeper) SetLiquidityTier( name, initialMarginPpm, maintenanceFractionPpm, - basePositionNotional, ), ), ) diff --git a/protocol/x/perpetuals/keeper/perpetual_test.go b/protocol/x/perpetuals/keeper/perpetual_test.go index b3ce8f6f37..9de721b8e9 100644 --- a/protocol/x/perpetuals/keeper/perpetual_test.go +++ b/protocol/x/perpetuals/keeper/perpetual_test.go @@ -442,7 +442,6 @@ func TestGetAllPerpetuals_Sorted(t *testing.T) { func TestGetMarginRequirements_Success(t *testing.T) { oneBip := math.Pow10(2) - oneTrillion := 1_000_000_000_000 tests := map[string]struct { price uint64 exponent int32 @@ -450,7 +449,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums *big.Int initialMarginPpm uint32 maintenanceFractionPpm uint32 - basePositionNotional uint64 bigExpectedInitialMarginPpm *big.Int bigExpectedMaintenanceMarginPpm *big.Int }{ @@ -461,7 +459,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums: big.NewInt(7_000), initialMarginPpm: uint32(oneBip * 2), maintenanceFractionPpm: uint32(500_000), // 50% of IM - basePositionNotional: uint64(oneTrillion), bigExpectedInitialMarginPpm: big.NewInt(7_777), bigExpectedMaintenanceMarginPpm: big.NewInt(3_889), }, @@ -472,7 +469,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums: big.NewInt(7_000), initialMarginPpm: uint32(oneBip * 100), maintenanceFractionPpm: uint32(500_000), // 50% of IM - basePositionNotional: uint64(oneTrillion), bigExpectedInitialMarginPpm: big.NewInt(38_885_000), bigExpectedMaintenanceMarginPpm: big.NewInt(19_442_500), }, @@ -482,8 +478,7 @@ func TestGetMarginRequirements_Success(t *testing.T) { baseCurrencyAtomicResolution: -0, bigBaseQuantums: big.NewInt(88), initialMarginPpm: uint32(oneBip * 100), - maintenanceFractionPpm: uint32(500_000), // 50% of IM - basePositionNotional: uint64(369_600_000_000_000), // same as quote quantums + maintenanceFractionPpm: uint32(500_000), // 50% of IM bigExpectedInitialMarginPpm: big.NewInt(3_696_000_000_000), bigExpectedMaintenanceMarginPpm: big.NewInt(1_848_000_000_000), }, @@ -494,7 +489,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums: big.NewInt(-5_000), initialMarginPpm: uint32(oneBip * 100), maintenanceFractionPpm: uint32(500_000), // 50% of IM - basePositionNotional: uint64(oneTrillion), bigExpectedInitialMarginPpm: big.NewInt(21_000_000), bigExpectedMaintenanceMarginPpm: big.NewInt(10_500_000), }, @@ -505,7 +499,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums: big.NewInt(7_000), initialMarginPpm: uint32(oneBip * 10_000), maintenanceFractionPpm: uint32(1_000_000), // 100% of IM - basePositionNotional: uint64(oneTrillion), bigExpectedInitialMarginPpm: big.NewInt(38_885_000), bigExpectedMaintenanceMarginPpm: big.NewInt(38_885_000), }, @@ -516,7 +509,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums: big.NewInt(7_000), initialMarginPpm: uint32(oneBip * 100), maintenanceFractionPpm: uint32(1_000_000), // 100% of IM - basePositionNotional: uint64(oneTrillion), bigExpectedInitialMarginPpm: big.NewInt(388_850), bigExpectedMaintenanceMarginPpm: big.NewInt(388_850), }, @@ -527,7 +519,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums: big.NewInt(-7_000), initialMarginPpm: uint32(oneBip * 0.02), maintenanceFractionPpm: uint32(500_000), // 50% of IM - basePositionNotional: uint64(oneTrillion), bigExpectedInitialMarginPpm: big.NewInt(77_770), bigExpectedMaintenanceMarginPpm: big.NewInt(38_885), }, @@ -538,7 +529,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums: big.NewInt(7_000), initialMarginPpm: uint32(oneBip * 0), maintenanceFractionPpm: uint32(1_000_000), // 100% of IM, - basePositionNotional: uint64(oneTrillion), bigExpectedInitialMarginPpm: big.NewInt(0), bigExpectedMaintenanceMarginPpm: big.NewInt(0), }, @@ -549,7 +539,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums: big.NewInt(-7_000), initialMarginPpm: uint32(oneBip * 1), maintenanceFractionPpm: uint32(1_000_000), // 100% of IM, - basePositionNotional: uint64(oneTrillion), bigExpectedInitialMarginPpm: big.NewInt(0), bigExpectedMaintenanceMarginPpm: big.NewInt(0), }, @@ -560,103 +549,61 @@ func TestGetMarginRequirements_Success(t *testing.T) { bigBaseQuantums: new(big.Int).SetUint64(math.MaxUint64), initialMarginPpm: uint32(oneBip * 1), maintenanceFractionPpm: uint32(1_000_000), // 100% of IM, - basePositionNotional: math.MaxUint64, - // As both `price` and `bigBaseQuantums` are `MaxUint64`, `bigQuoteQuantums` (`= price * bigBaseQuantums`) - // has a value much higher than `MaxUint64` (3402823669209384634264811192843491082250). - // Now that `bigQuoteQuantums` has a much higher value than `basePositionNotional`, which is - // only the max value of a `uint64`, `marginAdjustmentPpm` is a very big value (13_581_879_131_294_591). - // Thus, adjusted initial margin (initial margin * margin adjustment) is capped at 100%, - // so adjusted initial margin in quote quantums = `100% * bigQuoteQuantums` = `bigQuoteQuantums`. bigExpectedInitialMarginPpm: big_testutil.MustFirst( - new(big.Int).SetString("3402823669209384634264811192843491082250", 10), + new(big.Int).SetString("340282366920938463426481119284349108", 10), ), bigExpectedMaintenanceMarginPpm: big_testutil.MustFirst( - new(big.Int).SetString("3402823669209384634264811192843491082250", 10), + new(big.Int).SetString("340282366920938463426481119284349108", 10), ), }, - "InitialMargin 100 BIPs, MaintenanceMargin 50 BIPs, atomic resolution 6, margin adjusted": { + "InitialMargin 100 BIPs, MaintenanceMargin 50 BIPs, atomic resolution 6": { price: 5_555, exponent: 0, baseCurrencyAtomicResolution: -6, bigBaseQuantums: big.NewInt(7_000), initialMarginPpm: uint32(oneBip * 100), maintenanceFractionPpm: uint32(500_000), // 50% of IM - basePositionNotional: uint64(1_000_000), - // marginAdjustmentPpm = sqrt(quoteQuantums * (OneMillion * OneMillion) / basePositionNotional) - // = sqrt(38_885_000 * 1_000_000) ~= 6235783 - // initialMarginPpmQuoteQuantums = initialMarginPpm * quoteQuantums * marginAdjustmentPpm / 1_000_000 / 1_000_000 - // = 10_000 * 38_885_000 * 6235783 / 1_000_000 / 1_000_000 ~= 2_424_785 (rounded up). - bigExpectedInitialMarginPpm: big.NewInt(2_424_785), - bigExpectedMaintenanceMarginPpm: big.NewInt(1_212_393), - }, - "InitialMargin 20%, MaintenanceMargin 10%, atomic resolution 6, margin adjusted": { + // initialMarginPpmQuoteQuantums = initialMarginPpm * quoteQuantums / 1_000_000 + // = 10_000 * 38_885_000 / 1_000_000 ~= 388_850. + bigExpectedInitialMarginPpm: big.NewInt(388_850), + bigExpectedMaintenanceMarginPpm: big.NewInt(388_850 / 2), + }, + "InitialMargin 20%, MaintenanceMargin 10%, atomic resolution 6": { price: 36_750, exponent: 0, baseCurrencyAtomicResolution: -6, bigBaseQuantums: big.NewInt(12_000), initialMarginPpm: uint32(200_000), maintenanceFractionPpm: uint32(500_000), // 50% of IM - basePositionNotional: uint64(100_000_000), // quoteQuantums = 36_750 * 12_000 = 441_000_000 - // marginAdjustmentPpm = sqrt(quoteQuantums * (OneMillion * OneMillion) / basePositionNotional) - // = sqrt(441_000_000 * (OneMillion * OneMillion) / 100_000_000) ~= 2_100_000 - // initialMarginPpmQuoteQuantums = initialMarginPpm * quoteQuantums * marginAdjustmentPpm / 1_000_000 / 1_000_000 - // = 200_000 * 441_000_000 * 2_100_000 / 1_000_000 / 1_000_000 ~= 185_220_000 - bigExpectedInitialMarginPpm: big.NewInt(185_220_000), - bigExpectedMaintenanceMarginPpm: big.NewInt(92_610_000), - }, - "InitialMargin 5%, MaintenanceMargin 3%, atomic resolution 6, margin adjusted": { + // initialMarginPpmQuoteQuantums = initialMarginPpm * quoteQuantums / 1_000_000 + // = 200_000 * 441_000_000 / 1_000_000 ~= 88_200_000 + bigExpectedInitialMarginPpm: big.NewInt(88_200_000), + bigExpectedMaintenanceMarginPpm: big.NewInt(88_200_000 / 2), + }, + "InitialMargin 5%, MaintenanceMargin 3%, atomic resolution 6": { price: 123_456, exponent: 0, baseCurrencyAtomicResolution: -6, bigBaseQuantums: big.NewInt(74_523), initialMarginPpm: uint32(50_000), maintenanceFractionPpm: uint32(600_000), // 60% of IM - basePositionNotional: uint64(100_000_000), // quoteQuantums = 123_456 * 74_523 = 9_200_311_488 - // marginAdjustmentPpm = sqrt(quoteQuantums * (OneMillion * OneMillion) / basePositionNotional) - // = sqrt(9_200_311_488 * (OneMillion * OneMillion) / 100_000_000) ~= 9_591_825 - // initialMarginPpmQuoteQuantums = initialMarginPpm * quoteQuantums * marginAdjustmentPpm / 1_000_000 / 1_000_000 - // = 50_000 * 9_200_311_488 * 9_591_825 / 1_000_000 / 1_000_000 ~= 4_412_388_887 (rounded up) - bigExpectedInitialMarginPpm: big.NewInt(4_412_388_887), - bigExpectedMaintenanceMarginPpm: big.NewInt(2_647_433_333), - }, - "InitialMargin 25%, MaintenanceMargin 15%, atomic resolution 6, margin adjusted and IM capped at 100% of notional": { + // initialMarginPpmQuoteQuantums = initialMarginPpm * quoteQuantums / 1_000_000 + // = 50_000 * 9_200_311_488 / 1_000_000 ~= 460_015_574 + bigExpectedInitialMarginPpm: big.NewInt(460_015_574), + bigExpectedMaintenanceMarginPpm: big.NewInt(276_009_345), + }, + "InitialMargin 25%, MaintenanceMargin 15%, atomic resolution 6": { price: 123_456, exponent: 0, baseCurrencyAtomicResolution: -6, bigBaseQuantums: big.NewInt(74_523), initialMarginPpm: uint32(250_000), maintenanceFractionPpm: uint32(600_000), // 60% of IM - basePositionNotional: uint64(100_000_000), // quoteQuantums = 123_456 * 74_523 = 9_200_311_488 - // marginAdjustmentPpm = sqrt(quoteQuantums * (OneMillion * OneMillion) / basePositionNotional) - // = sqrt(9_200_311_488 * (OneMillion * OneMillion) / 100_000_000) ~= 9_591_825 - // After adjustment, initial margin is capped at 100% of notional (quote quantums). - bigExpectedInitialMarginPpm: big.NewInt(9_200_311_488), - bigExpectedMaintenanceMarginPpm: big.NewInt(5_520_186_893), - }, - "InitialMargin 10_000 BIPs (max), MaintenanceMargin 10_000 BIPs (max), atomic resolution 6, margin adjusted": { - price: 5_555, - exponent: 0, - baseCurrencyAtomicResolution: -6, - bigBaseQuantums: big.NewInt(7_000), - initialMarginPpm: uint32(oneBip * 10_000), - maintenanceFractionPpm: uint32(1_000_000), // 100% of IM - basePositionNotional: uint64(oneTrillion), - bigExpectedInitialMarginPpm: big.NewInt(38_885_000), - bigExpectedMaintenanceMarginPpm: big.NewInt(38_885_000), - }, - "InitialMargin 0 BIPs (min), MaintenanceMargin 0 BIPs (min), atomic resolution 6, margin adjusted": { - price: 5_555, - exponent: 0, - baseCurrencyAtomicResolution: -6, - bigBaseQuantums: big.NewInt(7_000), - initialMarginPpm: uint32(oneBip * 0), - maintenanceFractionPpm: uint32(1_000_000), // 100% of IM, - basePositionNotional: uint64(1_000_000), - bigExpectedInitialMarginPpm: big.NewInt(0), - bigExpectedMaintenanceMarginPpm: big.NewInt(0), + bigExpectedInitialMarginPpm: big.NewInt(2_300_077_872), + bigExpectedMaintenanceMarginPpm: big.NewInt(1_380_046_724), // Rounded up }, } @@ -703,7 +650,6 @@ func TestGetMarginRequirements_Success(t *testing.T) { "name", tc.initialMarginPpm, tc.maintenanceFractionPpm, - tc.basePositionNotional, 1, // dummy impact notional value ) require.NoError(t, err) @@ -2845,7 +2791,6 @@ func TestGetAllLiquidityTiers_Sorted(t *testing.T) { lt.Name, lt.InitialMarginPpm, lt.MaintenanceFractionPpm, - lt.BasePositionNotional, lt.ImpactNotional, ) require.NoError(t, err) @@ -2884,7 +2829,6 @@ func TestHasLiquidityTier(t *testing.T) { lt.Name, lt.InitialMarginPpm, lt.MaintenanceFractionPpm, - lt.BasePositionNotional, lt.ImpactNotional, ) require.NoError(t, err) @@ -2909,7 +2853,6 @@ func TestCreateLiquidityTier_Success(t *testing.T) { lt.Name, lt.InitialMarginPpm, lt.MaintenanceFractionPpm, - lt.BasePositionNotional, lt.ImpactNotional, ) require.NoError(t, err) @@ -2924,7 +2867,6 @@ func TestCreateLiquidityTier_Success(t *testing.T) { require.Equal(t, lt.Name, liquidityTier.Name) require.Equal(t, lt.InitialMarginPpm, liquidityTier.InitialMarginPpm) require.Equal(t, lt.MaintenanceFractionPpm, liquidityTier.MaintenanceFractionPpm) - require.Equal(t, lt.BasePositionNotional, liquidityTier.BasePositionNotional) require.Equal(t, lt.ImpactNotional, liquidityTier.ImpactNotional) } } @@ -2935,7 +2877,6 @@ func TestSetLiquidityTier_New_Failure(t *testing.T) { name string initialMarginPpm uint32 maintenanceFractionPpm uint32 - basePositionNotional uint64 impactNotional uint64 expectedError error }{ @@ -2944,7 +2885,6 @@ func TestSetLiquidityTier_New_Failure(t *testing.T) { name: "Large-Cap", initialMarginPpm: lib.OneMillion + 1, maintenanceFractionPpm: 500_000, - basePositionNotional: uint64(lib.OneMillion), impactNotional: uint64(lib.OneMillion), expectedError: errorsmod.Wrap(types.ErrInitialMarginPpmExceedsMax, fmt.Sprint(lib.OneMillion+1)), }, @@ -2953,25 +2893,14 @@ func TestSetLiquidityTier_New_Failure(t *testing.T) { name: "Medium-Cap", initialMarginPpm: 500_000, maintenanceFractionPpm: lib.OneMillion + 1, - basePositionNotional: uint64(lib.OneMillion), impactNotional: uint64(lib.OneMillion), expectedError: errorsmod.Wrap(types.ErrMaintenanceFractionPpmExceedsMax, fmt.Sprint(lib.OneMillion+1)), }, - "Base Position Notional is zero": { - id: 1, - name: "Small-Cap", - initialMarginPpm: 500_000, - maintenanceFractionPpm: lib.OneMillion, - basePositionNotional: uint64(0), - impactNotional: uint64(lib.OneMillion), - expectedError: types.ErrBasePositionNotionalIsZero, - }, "Impact Notional is zero": { id: 1, name: "Small-Cap", initialMarginPpm: 500_000, maintenanceFractionPpm: lib.OneMillion, - basePositionNotional: uint64(lib.OneMillion), impactNotional: uint64(0), expectedError: types.ErrImpactNotionalIsZero, }, @@ -2989,7 +2918,6 @@ func TestSetLiquidityTier_New_Failure(t *testing.T) { tc.name, tc.initialMarginPpm, tc.maintenanceFractionPpm, - tc.basePositionNotional, tc.impactNotional, ) @@ -3008,7 +2936,6 @@ func TestModifyLiquidityTier_Success(t *testing.T) { lt.Name, lt.InitialMarginPpm, lt.MaintenanceFractionPpm, - lt.BasePositionNotional, lt.ImpactNotional, ) require.NoError(t, err) @@ -3020,7 +2947,6 @@ func TestModifyLiquidityTier_Success(t *testing.T) { name := fmt.Sprintf("foo_%v", i) initialMarginPpm := uint32(i * 2) maintenanceFractionPpm := uint32(i * 2) - basePositionNotional := uint64((i + 1) * 1_000_000) impactNotional := uint64((i + 1) * 500_000_000) modifiedLt, err := pc.PerpetualsKeeper.SetLiquidityTier( pc.Ctx, @@ -3028,7 +2954,6 @@ func TestModifyLiquidityTier_Success(t *testing.T) { name, initialMarginPpm, maintenanceFractionPpm, - basePositionNotional, impactNotional, ) require.NoError(t, err) @@ -3054,11 +2979,6 @@ func TestModifyLiquidityTier_Success(t *testing.T) { maintenanceFractionPpm, obtainedLt.MaintenanceFractionPpm, ) - require.Equal( - t, - basePositionNotional, - obtainedLt.BasePositionNotional, - ) require.Equal( t, impactNotional, @@ -3075,7 +2995,6 @@ func TestSetLiquidityTier_Existing_Failure(t *testing.T) { name string initialMarginPpm uint32 maintenanceFractionPpm uint32 - basePositionNotional uint64 impactNotional uint64 expectedError error }{ @@ -3084,7 +3003,6 @@ func TestSetLiquidityTier_Existing_Failure(t *testing.T) { name: "Large-Cap", initialMarginPpm: lib.OneMillion + 1, maintenanceFractionPpm: 500_000, - basePositionNotional: uint64(lib.OneMillion), impactNotional: uint64(lib.OneMillion), expectedError: errorsmod.Wrap(types.ErrInitialMarginPpmExceedsMax, fmt.Sprint(lib.OneMillion+1)), }, @@ -3093,25 +3011,14 @@ func TestSetLiquidityTier_Existing_Failure(t *testing.T) { name: "Medium-Cap", initialMarginPpm: 500_000, maintenanceFractionPpm: lib.OneMillion + 1, - basePositionNotional: uint64(lib.OneMillion), impactNotional: uint64(lib.OneMillion), expectedError: errorsmod.Wrap(types.ErrMaintenanceFractionPpmExceedsMax, fmt.Sprint(lib.OneMillion+1)), }, - "Base Position Notional is zero": { - id: 1, - name: "Small-Cap", - initialMarginPpm: 500_000, - maintenanceFractionPpm: lib.OneMillion, - basePositionNotional: uint64(0), - impactNotional: uint64(lib.OneMillion), - expectedError: types.ErrBasePositionNotionalIsZero, - }, "Impact Notional is zero": { id: 1, name: "Small-Cap", initialMarginPpm: 500_000, maintenanceFractionPpm: lib.OneMillion, - basePositionNotional: uint64(lib.OneMillion), impactNotional: uint64(0), expectedError: types.ErrImpactNotionalIsZero, }, @@ -3130,7 +3037,6 @@ func TestSetLiquidityTier_Existing_Failure(t *testing.T) { tc.name, tc.initialMarginPpm, tc.maintenanceFractionPpm, - tc.basePositionNotional, tc.impactNotional, ) diff --git a/protocol/x/perpetuals/simulation/genesis.go b/protocol/x/perpetuals/simulation/genesis.go index c1d4a9a403..f7a920971d 100644 --- a/protocol/x/perpetuals/simulation/genesis.go +++ b/protocol/x/perpetuals/simulation/genesis.go @@ -91,17 +91,6 @@ func genInitialAndMaintenanceFraction(r *rand.Rand) (uint32, uint32) { return uint32(initialMargin), uint32(maintenanceFraction) } -// genBasePositionNotional returns a randomized notional value of base position. -func genBasePositionNotional(r *rand.Rand, isReasonableGenesis bool) uint64 { - return uint64( - simtypes.RandIntBetween( - r, - sim_helpers.PickGenesisParameter(sim_helpers.MinBasePositionNotional, isReasonableGenesis), - sim_helpers.PickGenesisParameter(sim_helpers.MaxBasePositionNotional, isReasonableGenesis)+1, - ), - ) -} - // calculateImpactNotional calculates impact notional as 500 USDC / initial margin fraction. func calculateImpactNotional(initialMarginPpm uint32) uint64 { // If initial margin is 0, return max uint64. @@ -167,14 +156,12 @@ func RandomizedGenState(simState *module.SimulationState) { liquidityTiers := make([]types.LiquidityTier, numLiquidityTiers) for i := 0; i < numLiquidityTiers; i++ { initialMarginPpm, maintenanceFractionPpm := genInitialAndMaintenanceFraction(r) - basePositionNotional := genBasePositionNotional(r, isReasonableGenesis) impactNotional := calculateImpactNotional(initialMarginPpm) liquidityTiers[i] = types.LiquidityTier{ Id: uint32(i), Name: fmt.Sprintf("%d", i), InitialMarginPpm: initialMarginPpm, MaintenanceFractionPpm: maintenanceFractionPpm, - BasePositionNotional: basePositionNotional, ImpactNotional: impactNotional, } } diff --git a/protocol/x/perpetuals/types/errors.go b/protocol/x/perpetuals/types/errors.go index 0d24550744..a7efb2dd26 100644 --- a/protocol/x/perpetuals/types/errors.go +++ b/protocol/x/perpetuals/types/errors.go @@ -62,11 +62,6 @@ var ( 12, "Liquidity Tier does not exist", ) - ErrBasePositionNotionalIsZero = errorsmod.Register( - ModuleName, - 13, - "Base position notional is zero", - ) ErrFundingRateClampFactorPpmIsZero = errorsmod.Register( ModuleName, 14, diff --git a/protocol/x/perpetuals/types/genesis_test.go b/protocol/x/perpetuals/types/genesis_test.go index deb30b6c85..8919ff6183 100644 --- a/protocol/x/perpetuals/types/genesis_test.go +++ b/protocol/x/perpetuals/types/genesis_test.go @@ -36,7 +36,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 500_000, MaintenanceFractionPpm: 750_000, - BasePositionNotional: 100, ImpactNotional: 1_000_000_000, }, }, @@ -74,7 +73,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 500_000, MaintenanceFractionPpm: 750_000, - BasePositionNotional: 100, ImpactNotional: 1_000_000_000, }, }, @@ -112,7 +110,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 500_000, MaintenanceFractionPpm: 750_000, - BasePositionNotional: 100, ImpactNotional: 1_000_000_000, }, }, @@ -142,7 +139,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 500_000, MaintenanceFractionPpm: 750_000, - BasePositionNotional: 100, ImpactNotional: 1_000_000_000, }, }, @@ -172,7 +168,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 1_000_001, MaintenanceFractionPpm: 750_000, - BasePositionNotional: 100, ImpactNotional: 1_000_000_000, }, }, @@ -202,7 +197,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 1_000, MaintenanceFractionPpm: 1_000_001, - BasePositionNotional: 100, ImpactNotional: 1_000_000_000, }, }, @@ -232,7 +226,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 200_000, MaintenanceFractionPpm: 1_000_000, - BasePositionNotional: 100, ImpactNotional: 2_500_000_000, }, }, @@ -262,7 +255,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 200_000, MaintenanceFractionPpm: 1_000_000, - BasePositionNotional: 100, ImpactNotional: 2_500_000_000, }, }, @@ -292,7 +284,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 200_000, MaintenanceFractionPpm: 1_000_000, - BasePositionNotional: 100, ImpactNotional: 2_500_000_000, }, }, @@ -322,7 +313,6 @@ func TestGenesisState_Validate(t *testing.T) { Name: "Large-Cap", InitialMarginPpm: 200_000, MaintenanceFractionPpm: 1_000_000, - BasePositionNotional: 100, ImpactNotional: 0, }, }, diff --git a/protocol/x/perpetuals/types/liquidity_tier.go b/protocol/x/perpetuals/types/liquidity_tier.go index 2e49b1899a..957e5dfd87 100644 --- a/protocol/x/perpetuals/types/liquidity_tier.go +++ b/protocol/x/perpetuals/types/liquidity_tier.go @@ -10,7 +10,6 @@ import ( // - Initial margin is less than or equal to 1. // - Maintenance fraction is less than or equal to 1. -// - Base position notional is not 0. func (liquidityTier LiquidityTier) Validate() error { if liquidityTier.InitialMarginPpm > MaxInitialMarginPpm { return errorsmod.Wrap(ErrInitialMarginPpmExceedsMax, lib.UintToString(liquidityTier.InitialMarginPpm)) @@ -21,10 +20,6 @@ func (liquidityTier LiquidityTier) Validate() error { lib.UintToString(liquidityTier.MaintenanceFractionPpm)) } - if liquidityTier.BasePositionNotional == 0 { - return ErrBasePositionNotionalIsZero - } - if liquidityTier.ImpactNotional == 0 { return ErrImpactNotionalIsZero } @@ -68,52 +63,14 @@ func (liquidityTier LiquidityTier) GetMaxAbsFundingClampPpm(clampFactorPpm uint3 ) } -// GetMarginAdjustmentPpm calculates margin adjustment (in ppm) given quote quantums -// and `liquidityTier`'s base position notional. -// -// The idea is to have margin requirement increase as amount of notional increases. Adjustment -// is `1` for any position smaller than `basePositionNotional` and sqrt of position size -// for larger positions. Formula for marginAdjustmentPpm is: +// GetInitialMarginQuoteQuantums returns initial margin in quote quantums. // -// marginAdjustmentPpm = max( -// -// oneMillion, -// sqrt( -// quoteQuantums * (oneMillion * oneMillion) / basePositionNotional -// ) -// -// ) -func (liquidityTier LiquidityTier) GetMarginAdjustmentPpm(bigQuoteQuantums *big.Int) *big.Int { - bigBasePositionNotional := new(big.Int).SetUint64(liquidityTier.BasePositionNotional) - if bigQuoteQuantums.Cmp(bigBasePositionNotional) <= 0 { - return lib.BigIntOneMillion() - } - adjustmentFactor := new(big.Int).Mul(bigQuoteQuantums, lib.BigIntOneTrillion()) - adjustmentFactor.Quo(adjustmentFactor, bigBasePositionNotional) - return adjustmentFactor.Sqrt(adjustmentFactor) -} - -// GetAdjustedInitialMarginQuoteQuantums returns adjusted initial margin in quote quantums -// (capped at 100% of notional). -// -// marginQuoteQuantums = adjustedMarginPpm * quoteQuantums / 1_000_000 -// = min(1_000_000, marginAdjustmentPpm * marginPpm / 1_000_000) * quoteQuantums / 1_000_000 -// = min(quoteQuantums, marginPpm * quoteQuantums * marginAdjustmentPpm / 1_000_000 / 1_000_000) +// marginQuoteQuantums = initialMarginPpm * quoteQuantums / 1_000_000 // // note: divisions are delayed for precision purposes. -func (liquidityTier LiquidityTier) GetAdjustedInitialMarginQuoteQuantums(bigQuoteQuantums *big.Int) *big.Int { - marginAdjustmentPpm := liquidityTier.GetMarginAdjustmentPpm(bigQuoteQuantums) - - result := new(big.Rat).SetInt(marginAdjustmentPpm) - // Multiply `marginAdjustmentPpm` with `quoteQuantums`. - result = result.Mul(result, new(big.Rat).SetInt(bigQuoteQuantums)) +func (liquidityTier LiquidityTier) GetInitialMarginQuoteQuantums(bigQuoteQuantums *big.Int) *big.Int { + result := new(big.Rat).SetInt(bigQuoteQuantums) // Multiply above result with `initialMarginPpm` and divide by 1 million. result = lib.BigRatMulPpm(result, liquidityTier.InitialMarginPpm) - // Further divide above result by 1 million. - result = result.Quo(result, lib.BigRatOneMillion()) - // Cap adjusted initial margin at 100% of notional. - return lib.BigMin( - bigQuoteQuantums, - lib.BigRatRound(result, true), // Round up initial margin. - ) + return lib.BigRatRound(result, true) // Round up initial margin. } diff --git a/protocol/x/perpetuals/types/liquidity_tier_test.go b/protocol/x/perpetuals/types/liquidity_tier_test.go index ef5fbfe01f..04cbcf5f37 100644 --- a/protocol/x/perpetuals/types/liquidity_tier_test.go +++ b/protocol/x/perpetuals/types/liquidity_tier_test.go @@ -5,7 +5,6 @@ import ( "math/big" "testing" - "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" "github.com/stretchr/testify/require" ) @@ -14,43 +13,31 @@ func TestLiquidityTierValidate(t *testing.T) { tests := map[string]struct { initialMarginPpm uint32 maintenanceFractionPpm uint32 - BasePositionNotional uint64 ImpactNotional uint64 expectedError error }{ "Validates successfully": { - initialMarginPpm: 150_000, // 15% - maintenanceFractionPpm: 800_000, // 80% of IM - BasePositionNotional: 1_000_000_000_000, // 1 million USDC - ImpactNotional: 3_333_000_000, // 3_333 USDC + initialMarginPpm: 150_000, // 15% + maintenanceFractionPpm: 800_000, // 80% of IM + ImpactNotional: 3_333_000_000, // 3_333 USDC expectedError: nil, }, "Failure: initial margin ppm exceeds max": { - initialMarginPpm: 1_000_001, // above 100% - maintenanceFractionPpm: 800_000, // 80% of IM - BasePositionNotional: 1_000_000_000_000, // 1 million USDC - ImpactNotional: 1_000_000_000, // 1_000 USDC + initialMarginPpm: 1_000_001, // above 100% + maintenanceFractionPpm: 800_000, // 80% of IM + ImpactNotional: 1_000_000_000, // 1_000 USDC expectedError: types.ErrInitialMarginPpmExceedsMax, }, "Failure: maintenance fraction ppm exceeds max": { - initialMarginPpm: 1_000_000, // 100% - maintenanceFractionPpm: 1_000_001, // above 100% - BasePositionNotional: 1_000_000_000_000, // 1 million USDC - ImpactNotional: 1_000_000_000, // 1_000 USDC + initialMarginPpm: 1_000_000, // 100% + maintenanceFractionPpm: 1_000_001, // above 100% + ImpactNotional: 1_000_000_000, // 1_000 USDC expectedError: types.ErrMaintenanceFractionPpmExceedsMax, }, - "Failure: base position notional is zero": { - initialMarginPpm: 1_000_000, // 100% - maintenanceFractionPpm: 1_000_000, // 100% - BasePositionNotional: 0, // 0 - ImpactNotional: 500_000_000, // 500 USDC - expectedError: types.ErrBasePositionNotionalIsZero, - }, "Failure: impact notional is zero": { - initialMarginPpm: 1_000_000, // 100% - maintenanceFractionPpm: 1_000_000, // 100% - BasePositionNotional: 1_000_000_000_000, // 1 million USDC - ImpactNotional: 0, // 0 + initialMarginPpm: 1_000_000, // 100% + maintenanceFractionPpm: 1_000_000, // 100% + ImpactNotional: 0, // 0 expectedError: types.ErrImpactNotionalIsZero, }, } @@ -61,7 +48,6 @@ func TestLiquidityTierValidate(t *testing.T) { liquidityTier := &types.LiquidityTier{ InitialMarginPpm: tc.initialMarginPpm, MaintenanceFractionPpm: tc.maintenanceFractionPpm, - BasePositionNotional: tc.BasePositionNotional, ImpactNotional: tc.ImpactNotional, } @@ -213,115 +199,39 @@ func TestLiquidityTierGetMaxAbsFundingClampPpm(t *testing.T) { } } -func TestGetMarginAdjustmentPpm(t *testing.T) { - tests := map[string]struct { - bigQuoteQuantums *big.Int - basePositionNotional uint64 - expectedMarginAdjustmentPpm *big.Int - }{ - "position size in quote quantums less than base position notional": { - bigQuoteQuantums: big.NewInt(10), - basePositionNotional: 100, - expectedMarginAdjustmentPpm: lib.BigIntOneMillion(), - }, - "position size in quote quantums equal to base position notional": { - bigQuoteQuantums: big.NewInt(1000), - basePositionNotional: 1000, - expectedMarginAdjustmentPpm: lib.BigIntOneMillion(), - }, - "position size in quote quantums larger than base position notional": { - bigQuoteQuantums: big.NewInt(500_000), - basePositionNotional: 350_000, - // sqrt(500_000 * 1_000_000 * 1_000_000 / 350_000) ~= 1_195_228.609 - // floored integer value is 1_195_228. - expectedMarginAdjustmentPpm: big.NewInt(1_195_228), - }, - "position size in quote quantums is 0": { - bigQuoteQuantums: big.NewInt(0), - basePositionNotional: 350_000, - expectedMarginAdjustmentPpm: lib.BigIntOneMillion(), - }, - "position size in quote quantums and base position notional are both max": { - bigQuoteQuantums: new(big.Int).SetUint64(math.MaxUint64), - basePositionNotional: math.MaxUint64, - expectedMarginAdjustmentPpm: lib.BigIntOneMillion(), - }, - } - for name, tc := range tests { - t.Run(name, func(t *testing.T) { - liquidityTier := &types.LiquidityTier{ - BasePositionNotional: tc.basePositionNotional, - } - marginAdjustmentPpm := liquidityTier.GetMarginAdjustmentPpm(tc.bigQuoteQuantums) - - require.Equal(t, tc.expectedMarginAdjustmentPpm, marginAdjustmentPpm) - }) - } -} - -func TestGetAdjustedInitialMarginQuoteQuantums(t *testing.T) { +func TestGetInitialMarginQuoteQuantums(t *testing.T) { tests := map[string]struct { initialMarginPpm uint32 bigQuoteQuantums *big.Int - basePositionNotional uint64 expectedInitialMarginQuoteQuantums *big.Int }{ - "initial margin 20%, quote quantums < base position notional": { - initialMarginPpm: uint32(200_000), // 20% - bigQuoteQuantums: big.NewInt(500_000), - basePositionNotional: uint64(1_000_000), - // initial margin * margin adjustment * quote quantums + "initial margin 20%": { + initialMarginPpm: uint32(200_000), // 20% + bigQuoteQuantums: big.NewInt(500_000), + // initial margin * quote quantums // = 20% * 100% * 500_000 // = 100_000 expectedInitialMarginQuoteQuantums: big.NewInt(100_000), }, - "initial margin 50%, quote quantums == base position notional": { - initialMarginPpm: uint32(500_000), // 50% - bigQuoteQuantums: big.NewInt(1_000_000), - basePositionNotional: uint64(1_000_000), - // initial margin * margin adjustment * quote quantums + "initial margin 50%": { + initialMarginPpm: uint32(500_000), // 50% + bigQuoteQuantums: big.NewInt(1_000_000), + // initial margin * quote quantums // = 50% * 100% * 1_000_000 // = 500_000 expectedInitialMarginQuoteQuantums: big.NewInt(500_000), }, - "initial margin 40%, quote quantums > base position notional": { - initialMarginPpm: uint32(400_000), // 40% - bigQuoteQuantums: big.NewInt(4_000_000), - basePositionNotional: uint64(1_000_000), - // initial margin * margin adjustment * quote quantums - // = 40% * sqrt(4) * 4_000_000 - // = 3_200_000 - expectedInitialMarginQuoteQuantums: big.NewInt(3_200_000), - }, - "initial margin 60%, quote quantums > base position notional, adjusted margin capped at 100%": { - initialMarginPpm: uint32(600_000), // 60% - bigQuoteQuantums: big.NewInt(4_000_000), - basePositionNotional: uint64(1_000_000), - // initial margin * margin adjustment * quote quantums - // = 60% * sqrt(4) * 4_000_000 - // = 100% * 4_000_000 (adjusted margin capped at 100%) - // = 4_000_000 - expectedInitialMarginQuoteQuantums: big.NewInt(4_000_000), - }, - "initial margin 0%, quote quantums > base position notional": { - initialMarginPpm: uint32(0), // 0% - bigQuoteQuantums: big.NewInt(1_000_000_000_000), - basePositionNotional: uint64(1_000_000), - expectedInitialMarginQuoteQuantums: big.NewInt(0), - }, "initial margin 10%, quote quantums = 1, should round up to 1": { - initialMarginPpm: uint32(100_000), // 10% - bigQuoteQuantums: big.NewInt(1), - basePositionNotional: uint64(1_000_000), + initialMarginPpm: uint32(100_000), // 10% + bigQuoteQuantums: big.NewInt(1), // initial margin * margin adjustment * quote quantums // = 10% * 100% * 1 // = 0.1 -> round up to 1 expectedInitialMarginQuoteQuantums: big.NewInt(1), }, "initial margin 56.7243%, quote quantums = 123_456, should round up to 70_030": { - initialMarginPpm: uint32(567_243), // 56.7243% - bigQuoteQuantums: big.NewInt(123_456), - basePositionNotional: uint64(1_000_000), + initialMarginPpm: uint32(567_243), // 56.7243% + bigQuoteQuantums: big.NewInt(123_456), // initial margin * margin adjustment * quote quantums // = 56.7243% * 100% * 123_456 // ~= 70029.5518 -> round up to 70030 @@ -331,10 +241,9 @@ func TestGetAdjustedInitialMarginQuoteQuantums(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { liquidityTier := &types.LiquidityTier{ - InitialMarginPpm: tc.initialMarginPpm, - BasePositionNotional: tc.basePositionNotional, + InitialMarginPpm: tc.initialMarginPpm, } - adjustedIMQuoteQuantums := liquidityTier.GetAdjustedInitialMarginQuoteQuantums(tc.bigQuoteQuantums) + adjustedIMQuoteQuantums := liquidityTier.GetInitialMarginQuoteQuantums(tc.bigQuoteQuantums) require.Equal(t, tc.expectedInitialMarginQuoteQuantums, adjustedIMQuoteQuantums) }) diff --git a/protocol/x/perpetuals/types/message_set_liquidity_tier_test.go b/protocol/x/perpetuals/types/message_set_liquidity_tier_test.go index 7412da2a42..00aa96055e 100644 --- a/protocol/x/perpetuals/types/message_set_liquidity_tier_test.go +++ b/protocol/x/perpetuals/types/message_set_liquidity_tier_test.go @@ -29,7 +29,6 @@ func TestMsgSetLiquidityTier_ValidateBasic(t *testing.T) { Name: "test", InitialMarginPpm: 217, MaintenanceFractionPpm: 217, - BasePositionNotional: 1_000, ImpactNotional: 5_000, }, }, @@ -48,7 +47,6 @@ func TestMsgSetLiquidityTier_ValidateBasic(t *testing.T) { Name: "test", InitialMarginPpm: 1_000_001, MaintenanceFractionPpm: 217, - BasePositionNotional: 1_000, ImpactNotional: 5_000, }, }, @@ -62,26 +60,11 @@ func TestMsgSetLiquidityTier_ValidateBasic(t *testing.T) { Name: "test", InitialMarginPpm: 217, MaintenanceFractionPpm: 1_000_001, - BasePositionNotional: 1_000, ImpactNotional: 5_000, }, }, expectedErr: "MaintenanceFractionPpm exceeds maximum value of 1e6", }, - "Failure: base position notional is zero": { - msg: types.MsgSetLiquidityTier{ - Authority: validAuthority, - LiquidityTier: types.LiquidityTier{ - Id: 1, - Name: "test", - InitialMarginPpm: 217, - MaintenanceFractionPpm: 217, - BasePositionNotional: 0, - ImpactNotional: 5_000, - }, - }, - expectedErr: "Base position notional is zero", - }, "Failure: impact notional is zero": { msg: types.MsgSetLiquidityTier{ Authority: validAuthority, @@ -90,7 +73,6 @@ func TestMsgSetLiquidityTier_ValidateBasic(t *testing.T) { Name: "test", InitialMarginPpm: 217, MaintenanceFractionPpm: 217, - BasePositionNotional: 1_000, ImpactNotional: 0, }, }, diff --git a/protocol/x/perpetuals/types/perpetual.pb.go b/protocol/x/perpetuals/types/perpetual.pb.go index bc5c72d689..671559b595 100644 --- a/protocol/x/perpetuals/types/perpetual.pb.go +++ b/protocol/x/perpetuals/types/perpetual.pb.go @@ -309,7 +309,7 @@ type LiquidityTier struct { // The maximum position size at which the margin requirements are // not increased over the default values. Above this position size, // the margin requirements increase at a rate of sqrt(size). - BasePositionNotional uint64 `protobuf:"varint,5,opt,name=base_position_notional,json=basePositionNotional,proto3" json:"base_position_notional,omitempty"` + BasePositionNotional uint64 `protobuf:"varint,5,opt,name=base_position_notional,json=basePositionNotional,proto3" json:"base_position_notional,omitempty"` // Deprecated: Do not use. // The impact notional amount (in quote quantums) is used to determine impact // bid/ask prices and its recommended value is 500 USDC / initial margin // fraction. @@ -381,6 +381,7 @@ func (m *LiquidityTier) GetMaintenanceFractionPpm() uint32 { return 0 } +// Deprecated: Do not use. func (m *LiquidityTier) GetBasePositionNotional() uint64 { if m != nil { return m.BasePositionNotional @@ -408,44 +409,45 @@ func init() { } var fileDescriptor_ce7204eee10038be = []byte{ - // 592 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xcf, 0x4b, 0x1b, 0x41, - 0x14, 0xc7, 0xb3, 0x31, 0x0d, 0x3a, 0x26, 0xd1, 0x8c, 0x62, 0x17, 0x0b, 0x31, 0x0d, 0x14, 0x03, - 0x6d, 0x37, 0x60, 0x3d, 0xf4, 0xd0, 0x43, 0xf1, 0x20, 0x0d, 0xd4, 0x36, 0xac, 0xa5, 0x87, 0x42, - 0x59, 0x26, 0x3b, 0x63, 0x7c, 0x38, 0x3f, 0xb6, 0xb3, 0xb3, 0x45, 0xfb, 0x57, 0xf8, 0x37, 0xf5, - 0xe4, 0xd1, 0x63, 0xf1, 0x20, 0x45, 0xff, 0x8b, 0x9e, 0xca, 0xce, 0x4e, 0x36, 0xb1, 0x22, 0xf4, - 0x94, 0x99, 0xf7, 0xfd, 0xbc, 0x97, 0xef, 0x9b, 0x37, 0xb3, 0x68, 0x9b, 0x9e, 0xd1, 0xd3, 0x44, - 0x2b, 0xa3, 0x62, 0xc5, 0x07, 0x09, 0xd3, 0x09, 0x33, 0x19, 0xe1, 0xe9, 0x6c, 0x19, 0x58, 0x15, - 0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, 0xab, 0x85, 0x10, 0x96, 0x71, 0x1c, 0xa0, 0x35, - 0xca, 0x8e, 0x48, 0xc6, 0x4d, 0x34, 0x6d, 0x3e, 0x49, 0x84, 0xff, 0xc8, 0xe2, 0x6d, 0x27, 0xed, - 0x17, 0xca, 0x28, 0x11, 0xf8, 0x19, 0x6a, 0x71, 0xf8, 0x96, 0x01, 0x05, 0x73, 0x16, 0x19, 0x60, - 0xda, 0xaf, 0xdb, 0xbf, 0x6f, 0x96, 0xd1, 0x4f, 0xc0, 0x74, 0xef, 0x23, 0x6a, 0x1d, 0x58, 0x3f, - 0x23, 0xcd, 0x04, 0x64, 0x22, 0xc5, 0x4f, 0x51, 0xa3, 0x9c, 0x44, 0x54, 0x36, 0xb9, 0x5c, 0xc6, - 0x86, 0x14, 0x6f, 0xa2, 0xc5, 0xc4, 0xe1, 0x7e, 0xb5, 0xbb, 0xd0, 0x6f, 0x87, 0xe5, 0xbe, 0x77, - 0xee, 0xa1, 0x86, 0xab, 0x75, 0x68, 0x94, 0x66, 0xf8, 0x2b, 0x5a, 0x23, 0x9c, 0x47, 0xee, 0x18, - 0xca, 0x3c, 0xaf, 0xbb, 0xd0, 0x5f, 0xde, 0xd9, 0x7e, 0xf0, 0x0a, 0xdc, 0x75, 0xe5, 0x6e, 0x40, - 0x9b, 0x70, 0x7e, 0xdf, 0xae, 0xcc, 0x44, 0x34, 0xe7, 0xc7, 0xda, 0x95, 0x99, 0x98, 0x22, 0xbd, - 0x3f, 0x1e, 0x6a, 0xbe, 0x9f, 0xef, 0xfa, 0xde, 0xf8, 0x30, 0xaa, 0x49, 0x22, 0x98, 0x1b, 0x9e, - 0x5d, 0xe3, 0x17, 0x08, 0x83, 0x04, 0x03, 0xc4, 0x7a, 0x9f, 0x80, 0xb4, 0xe7, 0x5d, 0xcc, 0x70, - 0xd5, 0x29, 0x07, 0x56, 0xc8, 0x8f, 0xfb, 0x35, 0xf2, 0x05, 0x01, 0x69, 0x98, 0x24, 0x32, 0x66, - 0xd1, 0x91, 0x26, 0x71, 0x3e, 0x36, 0x9b, 0x53, 0xb3, 0x39, 0x1b, 0x73, 0xfa, 0xbe, 0x93, 0xf3, - 0xcc, 0x5d, 0xb4, 0x31, 0x26, 0x29, 0x8b, 0x12, 0x95, 0x82, 0x4d, 0x91, 0x2a, 0xff, 0x21, 0xdc, - 0xce, 0xb6, 0x16, 0xae, 0xe7, 0xea, 0xc8, 0x89, 0x1f, 0x9c, 0x86, 0xb7, 0xd1, 0x0a, 0x88, 0x84, - 0xc4, 0x66, 0x86, 0xd7, 0x2d, 0xde, 0x2a, 0xc2, 0x53, 0x70, 0xef, 0xf3, 0xc5, 0x4d, 0xc7, 0xbb, - 0xbc, 0xe9, 0x78, 0xbf, 0x6f, 0x3a, 0xde, 0xf9, 0x6d, 0xa7, 0x72, 0x79, 0xdb, 0xa9, 0xfc, 0xba, - 0xed, 0x54, 0xbe, 0xbc, 0xf9, 0xff, 0x77, 0x72, 0x3a, 0xff, 0x4d, 0xb0, 0x6f, 0x66, 0x5c, 0xb7, - 0xe2, 0xab, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x2e, 0x21, 0x26, 0x3b, 0x04, 0x00, 0x00, + // 595 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4f, 0x4b, 0x1b, 0x4f, + 0x18, 0xce, 0xc4, 0xfc, 0x82, 0x8e, 0x49, 0x34, 0xa3, 0xf8, 0x5b, 0x2c, 0xc4, 0x34, 0x50, 0x0c, + 0xb4, 0xdd, 0x80, 0xed, 0xa1, 0x87, 0x1e, 0x4a, 0x0e, 0xd2, 0x40, 0x6d, 0xc3, 0x5a, 0x7a, 0x28, + 0x94, 0x65, 0xb2, 0x3b, 0xc6, 0x17, 0xe7, 0xcf, 0x76, 0x76, 0xb6, 0x68, 0x3f, 0x85, 0x9f, 0xa9, + 0x27, 0x8f, 0x1e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4, 0x7e, 0x23, 0xdc, 0x7c, 0xb7, 0x38, 0xf5, 0xbd, 0xf8, 0x08, 0xae, 0x49, 0x2a, 0x98, 0x0b, + 0xcf, 0xae, 0xc9, 0x33, 0x4c, 0x40, 0x82, 0x01, 0x6a, 0xbd, 0x4f, 0x41, 0xda, 0xf3, 0x2e, 0x32, + 0x5c, 0x77, 0xc8, 0x81, 0x05, 0xf2, 0xe3, 0x7e, 0x85, 0x3d, 0x41, 0x41, 0x1a, 0x26, 0xa9, 0x8c, + 0x58, 0x78, 0xa4, 0x69, 0x94, 0xc7, 0x66, 0x35, 0x35, 0xab, 0xd9, 0x5a, 0xc0, 0xf7, 0x1d, 0x5c, + 0x28, 0xb7, 0x26, 0x34, 0x65, 0x61, 0xa2, 0x52, 0xb0, 0x12, 0xa9, 0xf2, 0x1f, 0xca, 0x6d, 0xb6, + 0xb5, 0x61, 0xd5, 0x43, 0xc1, 0x66, 0xce, 0x18, 0x3b, 0xc2, 0x7b, 0x87, 0x93, 0x5d, 0xbc, 0x06, + 0x22, 0xa1, 0x91, 0x99, 0x4b, 0xf2, 0x8c, 0x6b, 0x41, 0xab, 0x28, 0xcf, 0x88, 0xc3, 0x4f, 0x17, + 0x37, 0x1d, 0x74, 0x79, 0xd3, 0x41, 0xbf, 0x6e, 0x3a, 0xe8, 0xfc, 0xb6, 0x53, 0xb9, 0xbc, 0xed, + 0x54, 0x7e, 0xde, 0x76, 0x2a, 0x9f, 0x5f, 0xff, 0xfb, 0x5b, 0x39, 0x5d, 0xfc, 0x2e, 0xd8, 0x77, + 0x33, 0xa9, 0x5b, 0xf0, 0xc5, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xc0, 0xd9, 0x87, 0x3f, + 0x04, 0x00, 0x00, } func (m *Perpetual) Marshal() (dAtA []byte, err error) { diff --git a/protocol/x/perpetuals/types/types.go b/protocol/x/perpetuals/types/types.go index 8a79cc08f7..f9a97f1a68 100644 --- a/protocol/x/perpetuals/types/types.go +++ b/protocol/x/perpetuals/types/types.go @@ -91,7 +91,6 @@ type PerpetualsKeeper interface { name string, initialMarginPpm uint32, maintenanceFractionPpm uint32, - basePositionNotional uint64, impactNotional uint64, ) ( liquidityTier LiquidityTier,