Skip to content

Commit

Permalink
update swift bots
Browse files Browse the repository at this point in the history
  • Loading branch information
jordy25519 committed Jan 9, 2025
1 parent 2aedffa commit a7739b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/experimental-bots/swift/makerExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class SwiftMaker {

const swiftOrderParamsBuf = Buffer.from(
order['order_message'],
'base64'
'hex'
);
const {
swiftOrderParams,
Expand Down Expand Up @@ -147,8 +147,10 @@ export class SwiftMaker {
}

const ixs = await this.driftClient.getPlaceAndMakeSwiftPerpOrderIxs(
swiftOrderParamsBuf,
Buffer.from(order['order_signature'], 'base64'),
{
orderParams: order['order_message'],
signature: Buffer.from(order['order_signature'], 'base64'),
},
decodeUTF8(order['uuid']),
{
taker: takerUserPubkey,
Expand Down
9 changes: 3 additions & 6 deletions src/experimental-bots/swift/takerExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ export class SwiftTaker {
stopLossOrderParams: null,
takeProfitOrderParams: null,
};
const encodedSwiftMessage =
this.driftClient.encodeSwiftOrderParamsMessage(orderMessage);
const signature = this.driftClient.signMessage(
Buffer.from(encodedSwiftMessage.toString('hex'))
);
const { orderParams: message, signature } =
this.driftClient.signSwiftOrderParamsMessage(orderMessage);

const hash = digestSignature(Uint8Array.from(signature));
console.log(
Expand All @@ -87,7 +84,7 @@ export class SwiftTaker {
{
market_index: marketIndex,
market_type: 'perp',
message: encodedSwiftMessage.toString('base64'),
message,
signature: signature.toString('base64'),
taker_pubkey: this.driftClient.wallet.publicKey.toBase58(),
},
Expand Down

0 comments on commit a7739b4

Please sign in to comment.