Skip to content

Commit

Permalink
sdk: update fillPerpOrder to take fillerAuthority (backwards compatib…
Browse files Browse the repository at this point in the history
…le) (#1398)

* sdk: update fillPerpOrder to take fillerAuthority (backwards compatible)

* fix prettify
  • Loading branch information
lowkeynicc authored Dec 23, 2024
1 parent bec61a6 commit a930c78
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions sdk/src/driftClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4006,7 +4006,8 @@ export class DriftClient {
makerInfo?: MakerInfo | MakerInfo[],
referrerInfo?: ReferrerInfo,
txParams?: TxParams,
fillerPublicKey?: number
fillerSubAccountId?: number,
fillerAuthority?: PublicKey
): Promise<TransactionSignature> {
const { txSig } = await this.sendTransaction(
await this.buildTransaction(
Expand All @@ -4016,7 +4017,9 @@ export class DriftClient {
order,
makerInfo,
referrerInfo,
fillerPublicKey
fillerSubAccountId,
undefined,
fillerAuthority
),
txParams
),
Expand All @@ -4033,15 +4036,36 @@ export class DriftClient {
makerInfo?: MakerInfo | MakerInfo[],
referrerInfo?: ReferrerInfo,
fillerSubAccountId?: number,
isSwift?: boolean
isSwift?: boolean,
fillerAuthority?: PublicKey
): Promise<TransactionInstruction> {
const userStatsPublicKey = getUserStatsAccountPublicKey(
this.program.programId,
userAccount.authority
);

const filler = await this.getUserAccountPublicKey(fillerSubAccountId);
const fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
let filler;

if (fillerAuthority) {
filler = getUserAccountPublicKeySync(
this.program.programId,
fillerAuthority,
fillerSubAccountId
);
} else {
filler = await this.getUserAccountPublicKey(fillerSubAccountId);
}

let fillerStatsPublicKey;

if (fillerAuthority) {
fillerStatsPublicKey = getUserStatsAccountPublicKey(
this.program.programId,
fillerAuthority
);
} else {
fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
}

const marketIndex = order
? order.marketIndex
Expand Down

0 comments on commit a930c78

Please sign in to comment.