From ecc907c536a138f5e4687c0693e72e92218abf70 Mon Sep 17 00:00:00 2001 From: Chris Heaney Date: Sun, 12 Nov 2023 17:51:16 +0100 Subject: [PATCH] sdk: add referrer info to getArbPerpIx --- ts/sdk/src/jitProxyClient.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ts/sdk/src/jitProxyClient.ts b/ts/sdk/src/jitProxyClient.ts index f70ccad..650da32 100644 --- a/ts/sdk/src/jitProxyClient.ts +++ b/ts/sdk/src/jitProxyClient.ts @@ -197,9 +197,11 @@ export class JitProxyClient { public async getArbPerpIx({ makerInfos, marketIndex, + referrerInfo, }: { makerInfos: MakerInfo[]; marketIndex: number; + referrerInfo?: ReferrerInfo; }): Promise { const userAccounts = [this.driftClient.getUserAccount()]; for (const makerInfo of makerInfos) { @@ -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({