diff --git a/programs/mango-v4/src/lib.rs b/programs/mango-v4/src/lib.rs index 55b47a4be..b97203fff 100644 --- a/programs/mango-v4/src/lib.rs +++ b/programs/mango-v4/src/lib.rs @@ -614,8 +614,14 @@ pub mod mango_v4 { // Use this to limit compute used during order matching. // When the limit is reached, processing stops and the instruction succeeds. limit: u8, + + // Oracle staleness limit, in slots. Set to -1 to disable. + // + // WARNING: Not currently implemented. + max_oracle_staleness_slots: i32, ) -> Result<()> { require_gte!(peg_limit, -1); + require_eq!(max_oracle_staleness_slots, -1); // unimplemented use crate::state::{Order, OrderParams}; let time_in_force = match Order::tif_from_expiry(expiry_timestamp) { @@ -636,6 +642,7 @@ pub mod mango_v4 { price_offset_lots, order_type: order_type.to_post_order_type()?, peg_limit, + max_oracle_staleness_slots, }, }; instructions::perp_place_order(ctx, order, limit) diff --git a/programs/mango-v4/src/state/orderbook/order.rs b/programs/mango-v4/src/state/orderbook/order.rs index 245ee10de..be40bab27 100644 --- a/programs/mango-v4/src/state/orderbook/order.rs +++ b/programs/mango-v4/src/state/orderbook/order.rs @@ -39,7 +39,7 @@ pub enum OrderParams { price_offset_lots: i64, order_type: PostOrderType, peg_limit: i64, - // TODO: oracle_staleness + max_oracle_staleness_slots: i32, }, } diff --git a/programs/mango-v4/tests/program_test/mango_client.rs b/programs/mango-v4/tests/program_test/mango_client.rs index 85d95e653..fb8b2ca03 100644 --- a/programs/mango-v4/tests/program_test/mango_client.rs +++ b/programs/mango-v4/tests/program_test/mango_client.rs @@ -2739,6 +2739,7 @@ impl ClientInstruction for PerpPlaceOrderPeggedInstruction { reduce_only: false, expiry_timestamp: 0, limit: 10, + max_oracle_staleness_slots: -1, }; let perp_market: PerpMarket = account_loader.load(&self.perp_market).await.unwrap(); diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 61af2b56c..61df19d63 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -1757,6 +1757,7 @@ export class MangoClient { reduceOnly ? reduceOnly : false, new BN(expiryTimestamp ? expiryTimestamp : 0), limit ? limit : 10, + -1, ) .accounts({ group: group.publicKey, diff --git a/ts/client/src/mango_v4.ts b/ts/client/src/mango_v4.ts index e32a18bc6..f2f1123cd 100644 --- a/ts/client/src/mango_v4.ts +++ b/ts/client/src/mango_v4.ts @@ -2860,6 +2860,10 @@ export type MangoV4 = { { "name": "limit", "type": "u8" + }, + { + "name": "maxOracleStalenessSlots", + "type": "i32" } ] }, @@ -4917,19 +4921,14 @@ export type MangoV4 = { } }, { - "name": "padding2", - "docs": [ - "Tracks what the position is to calculate average entry & break even price" - ], - "type": { - "array": [ - "u8", - 8 - ] - } + "name": "settlePnlLimitSettledInCurrentWindowNative", + "type": "i64" }, { "name": "quoteRunningNative", + "docs": [ + "Tracks what the position is to calculate average entry & break even price" + ], "type": "i64" }, { @@ -4999,11 +4998,9 @@ export type MangoV4 = { }, { "name": "realizedPnlNative", - "type": "i64" - }, - { - "name": "settlePnlLimitSettledInCurrentWindowNative", - "type": "i64" + "type": { + "defined": "I80F48" + } } ] } @@ -6041,6 +6038,10 @@ export type MangoV4 = { { "name": "peg_limit", "type": "i64" + }, + { + "name": "max_oracle_staleness_slots", + "type": "i32" } ] } @@ -10058,6 +10059,10 @@ export const IDL: MangoV4 = { { "name": "limit", "type": "u8" + }, + { + "name": "maxOracleStalenessSlots", + "type": "i32" } ] }, @@ -12115,19 +12120,14 @@ export const IDL: MangoV4 = { } }, { - "name": "padding2", - "docs": [ - "Tracks what the position is to calculate average entry & break even price" - ], - "type": { - "array": [ - "u8", - 8 - ] - } + "name": "settlePnlLimitSettledInCurrentWindowNative", + "type": "i64" }, { "name": "quoteRunningNative", + "docs": [ + "Tracks what the position is to calculate average entry & break even price" + ], "type": "i64" }, { @@ -12197,11 +12197,9 @@ export const IDL: MangoV4 = { }, { "name": "realizedPnlNative", - "type": "i64" - }, - { - "name": "settlePnlLimitSettledInCurrentWindowNative", - "type": "i64" + "type": { + "defined": "I80F48" + } } ] } @@ -13239,6 +13237,10 @@ export const IDL: MangoV4 = { { "name": "peg_limit", "type": "i64" + }, + { + "name": "max_oracle_staleness_slots", + "type": "i32" } ] }