From c0a4b76bc84858c52fe60fdd488e36b587741953 Mon Sep 17 00:00:00 2001 From: wphan Date: Thu, 31 Oct 2024 16:52:57 -0700 Subject: [PATCH] master -> mainnet (#282) * send taker message that hashes before signing * prettify * Bumping sdk and jit dependencies to 2.98.0-beta.17 and 0.11.18 --------- Co-authored-by: Nour Alharithi Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> --- package.json | 4 ++-- src/experimental-bots/swift/takerExample.ts | 11 +++++++---- yarn.lock | 18 +++++++++--------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 96bc814d..54100557 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "main": "lib/index.js", "license": "Apache-2.0", "dependencies": { - "@drift-labs/jit-proxy": "0.11.17", - "@drift-labs/sdk": "2.98.0-beta.16", + "@drift-labs/jit-proxy": "0.11.18", + "@drift-labs/sdk": "2.98.0-beta.17", "@opentelemetry/api": "^1.1.0", "@opentelemetry/auto-instrumentations-node": "^0.31.1", "@opentelemetry/exporter-prometheus": "^0.31.0", diff --git a/src/experimental-bots/swift/takerExample.ts b/src/experimental-bots/swift/takerExample.ts index 7377e8ee..5763d464 100644 --- a/src/experimental-bots/swift/takerExample.ts +++ b/src/experimental-bots/swift/takerExample.ts @@ -36,7 +36,7 @@ export class SwiftTaker { Math.random() > 0.5 ? PositionDirection.LONG : PositionDirection.SHORT; console.log('Sending order in slot:', slot, Date.now()); const oracleInfo = this.driftClient.getOracleDataForPerpMarket(0); - const orderMessage = this.driftClient.encodeSwiftOrderParamsMessage({ + const orderMessage = { swiftOrderParams: getMarketOrderParams({ marketIndex: 0, marketType: MarketType.PERP, @@ -47,15 +47,18 @@ export class SwiftTaker { subAccountId: 0, stopLossOrderParams: null, takeProfitOrderParams: null, - }); + }; + const signature = + this.driftClient.signSwiftOrderParamsMessage(orderMessage); - const signature = this.driftClient.signMessage(orderMessage); const response = await axios.default.post( 'https://master.swift.drift.trade/orders', { market_index: 0, market_type: 'perp', - message: orderMessage.toString('base64'), + message: this.driftClient + .encodeSwiftOrderParamsMessage(orderMessage) + .toString('base64'), signature: signature.toString('base64'), taker_pubkey: this.driftClient.wallet.publicKey.toBase58(), }, diff --git a/yarn.lock b/yarn.lock index 24ad00af..351c6968 100644 --- a/yarn.lock +++ b/yarn.lock @@ -197,19 +197,19 @@ enabled "2.0.x" kuler "^2.0.0" -"@drift-labs/jit-proxy@0.11.17": - version "0.11.17" - resolved "https://registry.yarnpkg.com/@drift-labs/jit-proxy/-/jit-proxy-0.11.17.tgz#664960671e151e2d01502965ba81e3438d36e8c3" - integrity sha512-82+vvLJ1H0v8XrBpAgeSd+9hChIXlJ/eCefxLOif5jOSM7DRFwTmPER9deF55FfdwdHtDKwmpiLIv7IvpOOOCg== +"@drift-labs/jit-proxy@0.11.18": + version "0.11.18" + resolved "https://registry.yarnpkg.com/@drift-labs/jit-proxy/-/jit-proxy-0.11.18.tgz#7500f61332d9243e96a2602646b400dcee580432" + integrity sha512-2zE1F9LiIuO1XZzngjl+NG5ZjeCWEtW1VgV37KGBZo0KusUhfDLfcRnmPf+lDoTrnIPrdJ7smwMJaEELnXpyWA== dependencies: "@coral-xyz/anchor" "^0.26.0" - "@drift-labs/sdk" "2.98.0-beta.16" + "@drift-labs/sdk" "2.98.0-beta.17" "@solana/web3.js" "1.91.7" -"@drift-labs/sdk@2.98.0-beta.16": - version "2.98.0-beta.16" - resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.98.0-beta.16.tgz#9dc0bcfef98adb4dd22a28859db083e143f07c85" - integrity sha512-ErL1H057BvjaotsccvRRWiFuof0wVGp7QhmfDi0Tbz0fRRS+eVQ1aIFkCzEfIfRbuhhcC7/Dk3u8mJ89tmVkVw== +"@drift-labs/sdk@2.98.0-beta.17": + version "2.98.0-beta.17" + resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.98.0-beta.17.tgz#d0855ed6485190150fc93b6bd84d252521fef0f8" + integrity sha512-+6gOd1RARxN8z5PjHVih6JiVC0Z7JWPFmjsLOqtCfR3Ll96XEPEddM1VpuzLEuFykKdlP/uyshwSa5Oq/UpeSg== dependencies: "@coral-xyz/anchor" "0.28.0" "@coral-xyz/anchor-30" "npm:@coral-xyz/anchor@0.30.1"