Skip to content

Commit

Permalink
change auction params for taker example
Browse files Browse the repository at this point in the history
  • Loading branch information
NourAlharithi committed Nov 4, 2024
1 parent 0eb937c commit a7c49ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/experimental-bots/swift/takerExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
BASE_PRECISION,
DriftClient,
getMarketOrderParams,
isVariant,
MarketType,
PositionDirection,
} from '@drift-labs/sdk';
Expand Down Expand Up @@ -36,14 +37,18 @@ 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 highPrice = oracleInfo.price.muln(102).divn(100);
const lowPrice = oracleInfo.price.muln(101).divn(100);
const orderMessage = {
swiftOrderParams: getMarketOrderParams({
marketIndex: 0,
marketType: MarketType.PERP,
direction,
baseAssetAmount: BASE_PRECISION,
auctionStartPrice: oracleInfo.price.muln(101).divn(100),
auctionEndPrice: oracleInfo.price.muln(102).divn(100),
auctionStartPrice: isVariant(direction, 'long')
? lowPrice
: highPrice,
auctionEndPrice: isVariant(direction, 'long') ? highPrice : lowPrice,
auctionDuration: 15,
}),
subAccountId: 0,
Expand Down

0 comments on commit a7c49ab

Please sign in to comment.