Skip to content

Commit

Permalink
add optional custom margin ratio param to initAndDeposit
Browse files Browse the repository at this point in the history
  • Loading branch information
lowkeynicc committed Jan 16, 2024
1 parent f7af999 commit 9725446
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- sdk: add ability to do placeAndTake order with bracket orders attached
- sdk: add option to cancel existing orders in market for place and take order
- sdk: add option to get signed settlePnl tx back from a market order

- program: auto derisk lp positions in settle pnl ([#766](https://github.com/drift-labs/protocol-v2/pull/766))
- program: increase full perp liquidation threshold ([#807](https://github.com/drift-labs/protocol-v2/pull/807))
- program: remove spot fee pool transfer ([#800](https://github.com/drift-labs/protocol-v2/pull/800))
- program: increase insurance tier max ([#784](https://github.com/drift-labs/protocol-v2/pull/784))
- sdk: can specify max custom margin ratio to initialize a new account with

### Fixes

Expand Down
12 changes: 11 additions & 1 deletion sdk/src/driftClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,8 @@ export class DriftClient {
fromSubAccountId?: number,
referrerInfo?: ReferrerInfo,
donateAmount?: BN,
txParams?: TxParams
txParams?: TxParams,
customMaxMarginRatio?: number
): Promise<[TransactionSignature, PublicKey]> {
const ixs = [];

Expand Down Expand Up @@ -1960,6 +1961,15 @@ export class DriftClient {
ixs.push(donateIx);
}

// Set the max margin ratio to initialize account with if passed
if (customMaxMarginRatio) {
const customMarginRatioIx = await this.getUpdateUserCustomMarginRatioIx(
customMaxMarginRatio,
subAccountId
);
ixs.push(customMarginRatioIx);
}

// Close the wrapped sol account at the end of the transaction
if (createWSOLTokenAccount) {
ixs.push(
Expand Down

0 comments on commit 9725446

Please sign in to comment.