diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dd85ed9b..9da9b5348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixes +- program: add add update_liquidation_margin_buffer_ratio ([#695](https://github.com/drift-labs/protocol-v2/pull/695)) - program: account for fee pool when settling positive pnl ([#687](https://github.com/drift-labs/protocol-v2/pull/687)) - sdk: fix bug which incorrectly calculated leverage after trade for a market with no position but short orders open diff --git a/programs/drift/src/instructions/admin.rs b/programs/drift/src/instructions/admin.rs index eeca06ad5..0d34c5bf7 100644 --- a/programs/drift/src/instructions/admin.rs +++ b/programs/drift/src/instructions/admin.rs @@ -1937,6 +1937,14 @@ pub fn handle_update_liquidation_duration( Ok(()) } +pub fn handle_update_liquidation_margin_buffer_ratio( + ctx: Context, + liquidation_margin_buffer_ratio: u32, +) -> Result<()> { + ctx.accounts.state.liquidation_margin_buffer_ratio = liquidation_margin_buffer_ratio; + Ok(()) +} + pub fn handle_update_oracle_guard_rails( ctx: Context, oracle_guard_rails: OracleGuardRails, diff --git a/programs/drift/src/lib.rs b/programs/drift/src/lib.rs index 3803a504f..5c34d7275 100644 --- a/programs/drift/src/lib.rs +++ b/programs/drift/src/lib.rs @@ -933,6 +933,13 @@ pub mod drift { handle_update_liquidation_duration(ctx, liquidation_duration) } + pub fn update_liquidation_margin_buffer_ratio( + ctx: Context, + liquidation_margin_buffer_ratio: u32, + ) -> Result<()> { + handle_update_liquidation_margin_buffer_ratio(ctx, liquidation_margin_buffer_ratio) + } + pub fn update_oracle_guard_rails( ctx: Context, oracle_guard_rails: OracleGuardRails, diff --git a/sdk/src/adminClient.ts b/sdk/src/adminClient.ts index 2d98bdd32..e65d8a139 100644 --- a/sdk/src/adminClient.ts +++ b/sdk/src/adminClient.ts @@ -787,6 +787,20 @@ export class AdminClient extends DriftClient { ); } + public async updateLiquidationMarginBufferRatio( + updateLiquidationMarginBufferRatio: number + ): Promise { + return await this.program.rpc.updateLiquidationMarginBufferRatio( + updateLiquidationMarginBufferRatio, + { + accounts: { + admin: this.wallet.publicKey, + state: await this.getStatePublicKey(), + }, + } + ); + } + public async updateOracleGuardRails( oracleGuardRails: OracleGuardRails ): Promise { diff --git a/sdk/src/idl/drift.json b/sdk/src/idl/drift.json index 509c47f7a..36b6d8e38 100644 --- a/sdk/src/idl/drift.json +++ b/sdk/src/idl/drift.json @@ -4098,6 +4098,27 @@ } ] }, + { + "name": "updateLiquidationMarginBufferRatio", + "accounts": [ + { + "name": "admin", + "isMut": false, + "isSigner": true + }, + { + "name": "state", + "isMut": true, + "isSigner": false + } + ], + "args": [ + { + "name": "liquidationMarginBufferRatio", + "type": "u32" + } + ] + }, { "name": "updateOracleGuardRails", "accounts": [