|
7 | 7 | digestSignature, |
8 | 8 | generateSignedMsgUuid, |
9 | 9 | BN, |
| 10 | + OrderParams, |
10 | 11 | } from '@drift-labs/sdk'; |
11 | 12 | import { RuntimeSpec } from 'src/metrics'; |
12 | 13 | import * as axios from 'axios'; |
@@ -53,28 +54,27 @@ export class SwiftTaker { |
53 | 54 | const highPrice = oracleInfo.price.muln(101).divn(100); |
54 | 55 | const lowPrice = oracleInfo.price; |
55 | 56 |
|
| 57 | + const marketOrderParams = getMarketOrderParams({ |
| 58 | + marketIndex, |
| 59 | + marketType: MarketType.PERP, |
| 60 | + direction, |
| 61 | + baseAssetAmount: this.driftClient |
| 62 | + .getPerpMarketAccount(marketIndex)! |
| 63 | + .amm.minOrderSize.muln(2), |
| 64 | + auctionStartPrice: isVariant(direction, 'long') ? lowPrice : highPrice, |
| 65 | + auctionEndPrice: isVariant(direction, 'long') ? highPrice : lowPrice, |
| 66 | + auctionDuration: 50, |
| 67 | + }); |
| 68 | + |
56 | 69 | const orderMessage = { |
57 | | - signedMsgOrderParams: getMarketOrderParams({ |
58 | | - marketIndex, |
59 | | - marketType: MarketType.PERP, |
60 | | - direction, |
61 | | - baseAssetAmount: this.driftClient |
62 | | - .getPerpMarketAccount(marketIndex)! |
63 | | - .amm.minOrderSize.muln(2), |
64 | | - auctionStartPrice: isVariant(direction, 'long') |
65 | | - ? lowPrice |
66 | | - : highPrice, |
67 | | - auctionEndPrice: isVariant(direction, 'long') ? highPrice : lowPrice, |
68 | | - auctionDuration: 50, |
69 | | - }), |
| 70 | + signedMsgOrderParams: marketOrderParams as OrderParams, |
70 | 71 | subAccountId: this.driftClient.activeSubAccountId, |
71 | 72 | slot: new BN(slot), |
72 | 73 | uuid: generateSignedMsgUuid(), |
73 | 74 | stopLossOrderParams: null, |
74 | 75 | takeProfitOrderParams: null, |
75 | 76 | }; |
76 | 77 | const { orderParams: message, signature } = |
77 | | - //@ts-ignore |
78 | 78 | this.driftClient.signSignedMsgOrderParamsMessage(orderMessage); |
79 | 79 |
|
80 | 80 | const hash = digestSignature(Uint8Array.from(signature)); |
|
0 commit comments