mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-15 07:36:46 +00:00
fix: Using sendTx function
This commit is contained in:
@@ -357,7 +357,6 @@ export class SolanaAgentKit {
|
||||
activationPoint: BN | null,
|
||||
hasAlphaVault: boolean,
|
||||
activationType: number,
|
||||
computeUnitMicroLamports: number = 100000,
|
||||
): Promise<string> {
|
||||
return createMeteoraDynamicAMMPool(
|
||||
this,
|
||||
@@ -372,7 +371,6 @@ export class SolanaAgentKit {
|
||||
activationType,
|
||||
padding: new Array(90).fill(0),
|
||||
},
|
||||
computeUnitMicroLamports,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -386,7 +384,6 @@ export class SolanaAgentKit {
|
||||
activationType: number,
|
||||
hasAlphaVault: boolean,
|
||||
activationPoint: BN | undefined,
|
||||
computeUnitMicroLamports: number = 100000,
|
||||
): Promise<string> {
|
||||
return createMeteoraDlmmPool(
|
||||
this,
|
||||
@@ -399,7 +396,6 @@ export class SolanaAgentKit {
|
||||
activationType,
|
||||
hasAlphaVault,
|
||||
activationPoint,
|
||||
computeUnitMicroLamports,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ export class SolanaMeteoraCreateDlmmPool extends Tool {
|
||||
- activationType: number, pool start trading time indicator. 0 is slot and 1 is timestamp, default is 1 for timestamp (optional).
|
||||
- activationPoint: number, pool start trading slot / timestamp, default is null means pool can start trading immediately (optional).
|
||||
- hasAlphaVault: boolean, whether the pool supports alpha vault, default is false (optional).
|
||||
- computeUnitMicroLamports: number, the priority fee in micro-lamports unit, default is 100000 (optional).
|
||||
`;
|
||||
|
||||
constructor(private solanaKit: SolanaAgentKit) {
|
||||
@@ -36,7 +35,6 @@ export class SolanaMeteoraCreateDlmmPool extends Tool {
|
||||
activationType?: number;
|
||||
activationPoint?: number;
|
||||
hasAlphaVault?: boolean;
|
||||
computeUnitMicroLamports?: number;
|
||||
}
|
||||
const inputFormat: CreateMeteoraDlmmPoolInput = JSON.parse(input);
|
||||
|
||||
@@ -51,8 +49,6 @@ export class SolanaMeteoraCreateDlmmPool extends Tool {
|
||||
? new BN(inputFormat.activationPoint)
|
||||
: undefined;
|
||||
const hasAlphaVault = inputFormat.hasAlphaVault ?? false;
|
||||
const computeUnitMicroLamports =
|
||||
inputFormat.computeUnitMicroLamports ?? 100000;
|
||||
|
||||
const txId = await this.solanaKit.meteoraCreateDlmmPool(
|
||||
tokenAMint,
|
||||
@@ -64,7 +60,6 @@ export class SolanaMeteoraCreateDlmmPool extends Tool {
|
||||
activationType,
|
||||
hasAlphaVault,
|
||||
activationPoint,
|
||||
computeUnitMicroLamports,
|
||||
);
|
||||
|
||||
return JSON.stringify({
|
||||
|
||||
@@ -16,7 +16,6 @@ export class SolanaMeteoraCreateDynamicPool extends Tool {
|
||||
- activationType: number, pool start trading time indicator, 0 is slot and 1 is timestamp, default is 1 for timestamp (optional).
|
||||
- activationPoint: number, pool start trading slot / timestamp, default is null means pool can start trading immediately (optional).
|
||||
- hasAlphaVault: boolean, whether the pool supports alpha vault, default is false (optional).
|
||||
- computeUnitMicroLamports: number, the priority fee in micro-lamports unit, default is 100000 (optional).
|
||||
`;
|
||||
|
||||
constructor(private solanaKit: SolanaAgentKit) {
|
||||
@@ -34,7 +33,6 @@ export class SolanaMeteoraCreateDynamicPool extends Tool {
|
||||
activationType?: number;
|
||||
activationPoint?: number;
|
||||
hasAlphaVault?: boolean;
|
||||
computeUnitMicroLamports?: number;
|
||||
}
|
||||
const inputFormat: CreateMeteoraDynamicAmmPoolInput = JSON.parse(input);
|
||||
|
||||
@@ -51,8 +49,6 @@ export class SolanaMeteoraCreateDynamicPool extends Tool {
|
||||
? new BN(inputFormat.activationPoint)
|
||||
: null;
|
||||
const hasAlphaVault = inputFormat.hasAlphaVault ?? false;
|
||||
const computeUnitMicroLamports =
|
||||
inputFormat.computeUnitMicroLamports ?? 100000;
|
||||
|
||||
const txId = await this.solanaKit.meteoraCreateDynamicPool(
|
||||
tokenAMint,
|
||||
@@ -63,7 +59,6 @@ export class SolanaMeteoraCreateDynamicPool extends Tool {
|
||||
activationPoint,
|
||||
hasAlphaVault,
|
||||
activationType,
|
||||
computeUnitMicroLamports,
|
||||
);
|
||||
|
||||
return JSON.stringify({
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import BN from "bn.js";
|
||||
import {
|
||||
ComputeBudgetProgram,
|
||||
PublicKey,
|
||||
sendAndConfirmTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import DLMM, { ActivationType } from "@meteora-ag/dlmm";
|
||||
import { getMint } from "@solana/spl-token";
|
||||
import { sendTx } from "../../utils/send_tx";
|
||||
|
||||
/**
|
||||
* Create Meteora DLMM pool
|
||||
@@ -33,7 +30,6 @@ export async function createMeteoraDlmmPool(
|
||||
activationType: ActivationType,
|
||||
hasAlphaVault: boolean,
|
||||
activationPoint: BN | undefined,
|
||||
computeUnitMicroLamports: number,
|
||||
): Promise<string> {
|
||||
const tokenAMintInfo = await getMint(agent.connection, tokenAMint);
|
||||
const tokenBMintInfo = await getMint(agent.connection, tokenBMint);
|
||||
@@ -65,20 +61,10 @@ export async function createMeteoraDlmmPool(
|
||||
cluster: "mainnet-beta",
|
||||
},
|
||||
);
|
||||
initPoolTx.add(
|
||||
ComputeBudgetProgram.setComputeUnitPrice({
|
||||
microLamports: computeUnitMicroLamports,
|
||||
}),
|
||||
);
|
||||
|
||||
const initPoolTxHash = await sendAndConfirmTransaction(
|
||||
agent.connection,
|
||||
initPoolTx,
|
||||
[agent.wallet],
|
||||
).catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
const initPoolTxHash = await sendTx(agent, initPoolTx.instructions, [
|
||||
agent.wallet,
|
||||
]);
|
||||
|
||||
return initPoolTxHash;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import AmmImpl from "@mercurial-finance/dynamic-amm-sdk";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import BN from "bn.js";
|
||||
import {
|
||||
ComputeBudgetProgram,
|
||||
PublicKey,
|
||||
sendAndConfirmTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { CustomizableParams } from "@mercurial-finance/dynamic-amm-sdk/dist/cjs/src/amm/types";
|
||||
import { sendTx } from "../../utils/send_tx";
|
||||
|
||||
/**
|
||||
* Create Meteora Dynamic AMM pool
|
||||
@@ -30,7 +27,6 @@ export async function createMeteoraDynamicAMMPool(
|
||||
tokenAAmount: BN,
|
||||
tokenBAmount: BN,
|
||||
customizableParams: CustomizableParams,
|
||||
computeUnitMicroLamports: number,
|
||||
): Promise<string> {
|
||||
const initPoolTx =
|
||||
await AmmImpl.createCustomizablePermissionlessConstantProductPool(
|
||||
@@ -43,20 +39,9 @@ export async function createMeteoraDynamicAMMPool(
|
||||
customizableParams,
|
||||
);
|
||||
|
||||
initPoolTx.add(
|
||||
ComputeBudgetProgram.setComputeUnitPrice({
|
||||
microLamports: computeUnitMicroLamports,
|
||||
}),
|
||||
);
|
||||
|
||||
const initPoolTxHash = await sendAndConfirmTransaction(
|
||||
agent.connection,
|
||||
initPoolTx,
|
||||
[agent.wallet],
|
||||
).catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
const initPoolTxHash = await sendTx(agent, initPoolTx.instructions, [
|
||||
agent.wallet,
|
||||
]);
|
||||
|
||||
return initPoolTxHash;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user