From 5be709f7818ca8776fc212be56291ddd07937da3 Mon Sep 17 00:00:00 2001 From: 0xbigz Date: Fri, 24 Mar 2023 11:06:45 -0400 Subject: [PATCH] update idl / postOnlyParams --- src/driftpy/idl/drift.json | 202 +++++++++++++++++++++++++++++++++++-- src/driftpy/types.py | 12 ++- 2 files changed, 203 insertions(+), 11 deletions(-) diff --git a/src/driftpy/idl/drift.json b/src/driftpy/idl/drift.json index 44c84528..621f791a 100644 --- a/src/driftpy/idl/drift.json +++ b/src/driftpy/idl/drift.json @@ -1,5 +1,5 @@ { - "version": "2.19.0", + "version": "2.22.0", "name": "drift", "instructions": [ { @@ -90,6 +90,54 @@ ], "args": [] }, + { + "name": "initializeReferrerName", + "accounts": [ + { + "name": "referrerName", + "isMut": true, + "isSigner": false + }, + { + "name": "user", + "isMut": true, + "isSigner": false + }, + { + "name": "userStats", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "name", + "type": { + "array": ["u8", 32] + } + } + ] + }, { "name": "deposit", "accounts": [ @@ -852,6 +900,32 @@ } ] }, + { + "name": "revertFill", + "accounts": [ + { + "name": "state", + "isMut": false, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "filler", + "isMut": true, + "isSigner": false + }, + { + "name": "fillerStats", + "isMut": true, + "isSigner": false + } + ], + "args": [] + }, { "name": "fillSpotOrder", "accounts": [ @@ -966,6 +1040,32 @@ ], "args": [] }, + { + "name": "updateUserIdle", + "accounts": [ + { + "name": "state", + "isMut": false, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "filler", + "isMut": true, + "isSigner": false + }, + { + "name": "user", + "isMut": true, + "isSigner": false + } + ], + "args": [] + }, { "name": "settlePnl", "accounts": [ @@ -4447,7 +4547,7 @@ "type": "u64" }, { - "name": "liquidationStartSlot", + "name": "lastActiveSlot", "type": "u64" }, { @@ -4476,10 +4576,14 @@ "name": "isMarginTradingEnabled", "type": "bool" }, + { + "name": "idle", + "type": "bool" + }, { "name": "padding", "type": { - "array": ["u8", 26] + "array": ["u8", 25] } } ] @@ -4556,6 +4660,32 @@ } ] } + }, + { + "name": "ReferrerName", + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "publicKey" + }, + { + "name": "user", + "type": "publicKey" + }, + { + "name": "userStats", + "type": "publicKey" + }, + { + "name": "name", + "type": { + "array": ["u8", 32] + } + } + ] + } } ], "types": [ @@ -6140,11 +6270,7 @@ }, { "name": "Match", - "fields": [ - { - "defined": "usize" - } - ] + "fields": ["publicKey", "u16"] } ] } @@ -8535,6 +8661,66 @@ "code": 6227, "name": "TierViolationLiquidatingPerpPnl", "msg": "TierViolationLiquidatingPerpPnl" + }, + { + "code": 6228, + "name": "CouldNotLoadUserData", + "msg": "CouldNotLoadUserData" + }, + { + "code": 6229, + "name": "UserWrongMutability", + "msg": "UserWrongMutability" + }, + { + "code": 6230, + "name": "InvalidUserAccount", + "msg": "InvalidUserAccount" + }, + { + "code": 6231, + "name": "CouldNotLoadUserStatsData", + "msg": "CouldNotLoadUserData" + }, + { + "code": 6232, + "name": "UserStatsWrongMutability", + "msg": "UserWrongMutability" + }, + { + "code": 6233, + "name": "InvalidUserStatsAccount", + "msg": "InvalidUserAccount" + }, + { + "code": 6234, + "name": "UserNotFound", + "msg": "UserNotFound" + }, + { + "code": 6235, + "name": "UnableToLoadUserAccount", + "msg": "UnableToLoadUserAccount" + }, + { + "code": 6236, + "name": "UserStatsNotFound", + "msg": "UserStatsNotFound" + }, + { + "code": 6237, + "name": "UnableToLoadUserStatsAccount", + "msg": "UnableToLoadUserStatsAccount" + }, + { + "code": 6238, + "name": "UserNotInactive", + "msg": "User Not Inactive" + }, + { + "code": 6239, + "name": "RevertFill", + "msg": "RevertFill" } ] } diff --git a/src/driftpy/types.py b/src/driftpy/types.py index d0dd23a1..aacbdabd 100644 --- a/src/driftpy/types.py +++ b/src/driftpy/types.py @@ -236,7 +236,13 @@ class OrderTriggerCondition: class MarketType: SPOT = constructor() PERP = constructor() - + +@_rust_enum +class PostOnlyParams: + NONE = constructor() + TRY_POST_ONLY = constructor() + MUST_POST_ONLY = constructor() + @dataclass class OrderParams: order_type: OrderType @@ -247,7 +253,7 @@ class OrderParams: price: int market_index: int reduce_only: bool - post_only: bool + post_only: PostOnlyParams immediate_or_cancel: bool max_ts: Optional[int] trigger_price: Optional[int] @@ -424,7 +430,7 @@ class Order: existing_position_direction: PositionDirection direction: PositionDirection reduce_only: bool - post_only: bool + post_only: PostOnlyParams immediate_or_cancel: bool trigger_condition: OrderTriggerCondition auction_duration: int