Skip to content

Commit 535ba24

Browse files
committed
updates
1 parent fd9c483 commit 535ba24

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

sdk/src/driftClient.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,11 +1546,16 @@ export class DriftClient {
15461546
): Promise<TransactionInstruction> {
15471547
const userAccountPublicKey = getUserAccountPublicKeySync(
15481548
this.program.programId,
1549-
this.wallet.publicKey,
1549+
this.authority,
15501550
subAccountId
15511551
);
15521552

1553-
await this.addUser(subAccountId, this.wallet.publicKey);
1553+
await this.addUser(subAccountId, this.authority);
1554+
1555+
console.log('userAccountPublicKey', userAccountPublicKey.toString());
1556+
console.log('authority', this.authority.toString());
1557+
console.log('subAccountId', subAccountId);
1558+
console.log('wallet.publicKey', this.wallet.publicKey.toString());
15541559

15551560
const ix = this.program.instruction.updateUserPerpPositionCustomMarginRatio(
15561561
subAccountId,

sdk/src/user.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ export class User {
449449
public getPerpBuyingPower(
450450
marketIndex: number,
451451
collateralBuffer = ZERO,
452-
enterHighLeverageMode = undefined
452+
enterHighLeverageMode = undefined,
453+
maxMarginRatio = undefined
453454
): BN {
454455
const perpPosition = this.getPerpPositionOrEmpty(marketIndex);
455456

@@ -473,7 +474,7 @@ export class User {
473474
freeCollateral,
474475
worstCaseBaseAssetAmount,
475476
enterHighLeverageMode,
476-
perpPosition.maxMarginRatio
477+
maxMarginRatio || perpPosition.maxMarginRatio
477478
);
478479
}
479480

@@ -2398,7 +2399,8 @@ export class User {
23982399
targetMarketIndex: number,
23992400
tradeSide: PositionDirection,
24002401
isLp = false,
2401-
enterHighLeverageMode = undefined
2402+
enterHighLeverageMode = undefined,
2403+
maxMarginRatio = undefined
24022404
): { tradeSize: BN; oppositeSideTradeSize: BN } {
24032405
let tradeSize = ZERO;
24042406
let oppositeSideTradeSize = ZERO;
@@ -2437,7 +2439,8 @@ export class User {
24372439
const maxPositionSize = this.getPerpBuyingPower(
24382440
targetMarketIndex,
24392441
lpBuffer,
2440-
enterHighLeverageMode
2442+
enterHighLeverageMode,
2443+
maxMarginRatio
24412444
);
24422445

24432446
if (maxPositionSize.gte(ZERO)) {

0 commit comments

Comments
 (0)