Skip to content

Commit

Permalink
program: add update_liquidation_margin_buffer_ratio (#695)
Browse files Browse the repository at this point in the history
* program: add update_liquidation_margin_buffer_ratio

* CHANGELOG
  • Loading branch information
crispheaney authored Nov 14, 2023
1 parent 67f22a9 commit 7e55577
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions programs/drift/src/instructions/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,14 @@ pub fn handle_update_liquidation_duration(
Ok(())
}

pub fn handle_update_liquidation_margin_buffer_ratio(
ctx: Context<AdminUpdateState>,
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<AdminUpdateState>,
oracle_guard_rails: OracleGuardRails,
Expand Down
7 changes: 7 additions & 0 deletions programs/drift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,13 @@ pub mod drift {
handle_update_liquidation_duration(ctx, liquidation_duration)
}

pub fn update_liquidation_margin_buffer_ratio(
ctx: Context<AdminUpdateState>,
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<AdminUpdateState>,
oracle_guard_rails: OracleGuardRails,
Expand Down
14 changes: 14 additions & 0 deletions sdk/src/adminClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,20 @@ export class AdminClient extends DriftClient {
);
}

public async updateLiquidationMarginBufferRatio(
updateLiquidationMarginBufferRatio: number
): Promise<TransactionSignature> {
return await this.program.rpc.updateLiquidationMarginBufferRatio(
updateLiquidationMarginBufferRatio,
{
accounts: {
admin: this.wallet.publicKey,
state: await this.getStatePublicKey(),
},
}
);
}

public async updateOracleGuardRails(
oracleGuardRails: OracleGuardRails
): Promise<TransactionSignature> {
Expand Down
21 changes: 21 additions & 0 deletions sdk/src/idl/drift.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down

0 comments on commit 7e55577

Please sign in to comment.