Perp pegged orders: Add stub max oracle staleness arg

This commit is contained in:
Christian Kamm 2022-12-01 10:43:47 +01:00
parent 9757f7a509
commit 512eef96ea
5 changed files with 42 additions and 31 deletions

View File

@ -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)

View File

@ -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,
},
}

View File

@ -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();

View File

@ -1757,6 +1757,7 @@ export class MangoClient {
reduceOnly ? reduceOnly : false,
new BN(expiryTimestamp ? expiryTimestamp : 0),
limit ? limit : 10,
-1,
)
.accounts({
group: group.publicKey,

View File

@ -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"
}
]
}