Skip to content

Commit

Permalink
sdk: add referrer info to getArbPerpIx
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Nov 13, 2023
1 parent 1e4d0bd commit ecc907c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ts/sdk/src/jitProxyClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,11 @@ export class JitProxyClient {
public async getArbPerpIx({
makerInfos,
marketIndex,
referrerInfo,
}: {
makerInfos: MakerInfo[];
marketIndex: number;
referrerInfo?: ReferrerInfo;
}): Promise<TransactionInstruction> {
const userAccounts = [this.driftClient.getUserAccount()];
for (const makerInfo of makerInfos) {
Expand All @@ -224,6 +226,25 @@ export class JitProxyClient {
});
}

if (referrerInfo) {
const referrerIsMaker =
makerInfos.find((maker) =>
maker.maker.equals(referrerInfo.referrer)
) !== undefined;
if (!referrerIsMaker) {
remainingAccounts.push({
pubkey: referrerInfo.referrer,
isWritable: true,
isSigner: false,
});
remainingAccounts.push({
pubkey: referrerInfo.referrerStats,
isWritable: true,
isSigner: false,
});
}
}

return this.program.methods
.arbPerp(marketIndex)
.accounts({
Expand Down

0 comments on commit ecc907c

Please sign in to comment.