Skip to content

Commit 7e1b469

Browse files
committed
placeAndMake respect builder codes
1 parent e1dc1b0 commit 7e1b469

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

sdk/src/driftClient.ts

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6638,15 +6638,6 @@ export class DriftClient {
66386638
});
66396639
}
66406640

6641-
remainingAccounts.push({
6642-
pubkey: getRevenueShareEscrowAccountPublicKey(
6643-
this.program.programId,
6644-
this.getUserAccount(subAccountId).authority
6645-
),
6646-
isWritable: true,
6647-
isSigner: false,
6648-
});
6649-
66506641
let optionalParams = null;
66516642
if (auctionDurationPercentage || successCondition) {
66526643
optionalParams =
@@ -6736,6 +6727,16 @@ export class DriftClient {
67366727
});
67376728

67386729
const takerOrderId = takerInfo.order.orderId;
6730+
if (hasBuilder(takerInfo.order)) {
6731+
remainingAccounts.push({
6732+
pubkey: getRevenueShareEscrowAccountPublicKey(
6733+
this.program.programId,
6734+
takerInfo.takerUserAccount.authority
6735+
),
6736+
isWritable: true,
6737+
isSigner: false,
6738+
});
6739+
}
67396740
return await this.program.instruction.placeAndMakePerpOrder(
67406741
orderParams,
67416742
takerOrderId,
@@ -7086,6 +7087,32 @@ export class DriftClient {
70867087
});
70877088
}
70887089

7090+
const isDelegateSigner = takerInfo.signingAuthority.equals(
7091+
takerInfo.takerUserAccount.delegate
7092+
);
7093+
const borshBuf = Buffer.from(
7094+
signedSignedMsgOrderParams.orderParams.toString(),
7095+
'hex'
7096+
);
7097+
7098+
const signedMessage = this.decodeSignedMsgOrderParamsMessage(
7099+
borshBuf,
7100+
isDelegateSigner
7101+
);
7102+
if (
7103+
signedMessage.builderFeeTenthBps !== null &&
7104+
signedMessage.builderIdx !== null
7105+
) {
7106+
remainingAccounts.push({
7107+
pubkey: getRevenueShareEscrowAccountPublicKey(
7108+
this.program.programId,
7109+
takerInfo.takerUserAccount.authority
7110+
),
7111+
isWritable: true,
7112+
isSigner: false,
7113+
});
7114+
}
7115+
70897116
const placeAndMakeIx =
70907117
await this.program.instruction.placeAndMakeSignedMsgPerpOrder(
70917118
orderParams,

0 commit comments

Comments
 (0)