mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-14 07:26:46 +00:00
Fix limit orders
This commit is contained in:
@@ -325,7 +325,7 @@ export class SolanaLimitOrderTool extends Tool {
|
||||
const parsedInput = JSON.parse(input);
|
||||
|
||||
const tx = await this.solanaKit.limitOrder(
|
||||
parsedInput.marketId,
|
||||
new PublicKey(parsedInput.marketId),
|
||||
parsedInput.quantity,
|
||||
parsedInput.side,
|
||||
parsedInput.price,
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
WrapperPlaceOrderParamsExternal,
|
||||
} from "@cks-systems/manifest-sdk";
|
||||
import { OrderType } from "@cks-systems/manifest-sdk/client/ts/src/wrapper/types/OrderType";
|
||||
import { sleep } from "openai/core";
|
||||
|
||||
/**
|
||||
* Place limit orders using Manifest
|
||||
@@ -29,27 +28,6 @@ export async function limitOrder(
|
||||
price: number,
|
||||
): Promise<string> {
|
||||
try {
|
||||
const { setupNeeded, instructions, wrapperKeypair } =
|
||||
await ManifestClient.getSetupIxs(
|
||||
agent.connection,
|
||||
marketId,
|
||||
agent.wallet.publicKey,
|
||||
);
|
||||
|
||||
if (setupNeeded) {
|
||||
const tx = new Transaction().add(...instructions);
|
||||
const { blockhash } = await agent.connection.getLatestBlockhash();
|
||||
tx.recentBlockhash = blockhash;
|
||||
tx.feePayer = agent.wallet.publicKey!;
|
||||
if (wrapperKeypair) {
|
||||
tx.sign(wrapperKeypair);
|
||||
}
|
||||
|
||||
await sendAndConfirmTransaction(agent.connection, tx, [agent.wallet]);
|
||||
|
||||
await sleep(5_000);
|
||||
}
|
||||
|
||||
const mfxClient = await ManifestClient.getClientForMarket(
|
||||
agent.connection,
|
||||
marketId,
|
||||
@@ -59,7 +37,7 @@ export async function limitOrder(
|
||||
const orderParams: WrapperPlaceOrderParamsExternal = {
|
||||
numBaseTokens: quantity,
|
||||
tokenPrice: price,
|
||||
isBid: side === "buy",
|
||||
isBid: side === "Buy",
|
||||
lastValidSlot: 0,
|
||||
orderType: OrderType.Limit,
|
||||
clientOrderId: Number(Math.random() * 1000),
|
||||
|
||||
Reference in New Issue
Block a user