mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-15 15:10:25 +00:00
161
package.json
161
package.json
@@ -1,81 +1,84 @@
|
||||
{
|
||||
"name": "solana-agent-kit",
|
||||
"version": "1.3.8",
|
||||
"description": "connect any ai agents to solana protocols",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"docs": "typedoc src --out docs",
|
||||
"test": "ts-node test/index.ts",
|
||||
"test:vercel-ai": "ts-node test/agent_sdks/vercel_ai.ts",
|
||||
"generate": "ts-node src/utils/keypair.ts",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"lint:fix": "eslint . --ext .ts --fix",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.0.0",
|
||||
"pnpm": ">=8.0.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "sendaifun",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@3land/listings-sdk": "^0.0.4",
|
||||
"@ai-sdk/openai": "^1.0.11",
|
||||
"@bonfida/spl-name-service": "^3.0.7",
|
||||
"@cks-systems/manifest-sdk": "0.1.59",
|
||||
"@coral-xyz/anchor": "0.29",
|
||||
"@langchain/core": "^0.3.26",
|
||||
"@langchain/groq": "^0.1.2",
|
||||
"@langchain/langgraph": "^0.2.36",
|
||||
"@langchain/openai": "^0.3.16",
|
||||
"@lightprotocol/compressed-token": "^0.17.1",
|
||||
"@lightprotocol/stateless.js": "^0.17.1",
|
||||
"@metaplex-foundation/mpl-core": "^1.1.1",
|
||||
"@metaplex-foundation/mpl-token-metadata": "^3.3.0",
|
||||
"@metaplex-foundation/mpl-toolbox": "^0.9.4",
|
||||
"@metaplex-foundation/umi": "^0.9.2",
|
||||
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
|
||||
"@metaplex-foundation/umi-web3js-adapters": "^0.9.2",
|
||||
"@onsol/tldparser": "^0.6.7",
|
||||
"@orca-so/common-sdk": "0.6.4",
|
||||
"@orca-so/whirlpools-sdk": "^0.13.12",
|
||||
"@pythnetwork/hermes-client": "^1.3.0",
|
||||
"@raydium-io/raydium-sdk-v2": "0.1.95-alpha",
|
||||
"@solana/spl-token": "^0.4.9",
|
||||
"@solana/web3.js": "^1.98.0",
|
||||
"@tensor-oss/tensorswap-sdk": "^4.5.0",
|
||||
"name": "solana-agent-kit",
|
||||
"version": "1.3.8",
|
||||
"description": "connect any ai agents to solana protocols",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"docs": "typedoc src --out docs",
|
||||
"test": "ts-node test/index.ts",
|
||||
"test:vercel-ai": "ts-node test/agent_sdks/vercel_ai.ts",
|
||||
"generate": "ts-node src/utils/keypair.ts",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"lint:fix": "eslint . --ext .ts --fix",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.0.0",
|
||||
"pnpm": ">=8.0.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "sendaifun",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@3land/listings-sdk": "^0.0.4",
|
||||
"@ai-sdk/openai": "^1.0.11",
|
||||
"@bonfida/spl-name-service": "^3.0.7",
|
||||
"@cks-systems/manifest-sdk": "0.1.59",
|
||||
"@coral-xyz/anchor": "0.29",
|
||||
"@langchain/core": "^0.3.26",
|
||||
"@langchain/groq": "^0.1.2",
|
||||
"@langchain/langgraph": "^0.2.36",
|
||||
"@langchain/openai": "^0.3.16",
|
||||
"@lightprotocol/compressed-token": "^0.17.1",
|
||||
"@lightprotocol/stateless.js": "^0.17.1",
|
||||
"@metaplex-foundation/mpl-core": "^1.1.1",
|
||||
"@metaplex-foundation/mpl-token-metadata": "^3.3.0",
|
||||
"@metaplex-foundation/mpl-toolbox": "^0.9.4",
|
||||
"@metaplex-foundation/umi": "^0.9.2",
|
||||
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
|
||||
"@metaplex-foundation/umi-web3js-adapters": "^0.9.2",
|
||||
"@mercurial-finance/dynamic-amm-sdk": "^1.1.19",
|
||||
"@meteora-ag/alpha-vault": "^1.1.6",
|
||||
"@meteora-ag/dlmm": "^1.3.0",
|
||||
"@onsol/tldparser": "^0.6.7",
|
||||
"@orca-so/common-sdk": "0.6.4",
|
||||
"@orca-so/whirlpools-sdk": "^0.13.12",
|
||||
"@pythnetwork/hermes-client": "^1.3.0",
|
||||
"@raydium-io/raydium-sdk-v2": "0.1.95-alpha",
|
||||
"@solana/spl-token": "^0.4.9",
|
||||
"@solana/web3.js": "^1.98.0",
|
||||
"@tensor-oss/tensorswap-sdk": "^4.5.0",
|
||||
"@sqds/multisig": "^2.1.3",
|
||||
"@tiplink/api": "^0.3.1",
|
||||
"ai": "^4.0.22",
|
||||
"bn.js": "^5.2.1",
|
||||
"bs58": "^6.0.0",
|
||||
"chai": "^5.1.2",
|
||||
"decimal.js": "^10.4.3",
|
||||
"dotenv": "^16.4.7",
|
||||
"flash-sdk": "^2.24.3",
|
||||
"form-data": "^4.0.1",
|
||||
"langchain": "^0.3.8",
|
||||
"openai": "^4.77.0",
|
||||
"typedoc": "^0.27.6",
|
||||
"zod": "^3.24.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bn.js": "^5.1.6",
|
||||
"@types/chai": "^5.0.1",
|
||||
"@types/node": "^22.10.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.18.2",
|
||||
"@typescript-eslint/parser": "^8.18.2",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^15.3.0",
|
||||
"prettier": "^3.4.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.7.2"
|
||||
}
|
||||
}
|
||||
"@tiplink/api": "^0.3.1",
|
||||
"ai": "^4.0.22",
|
||||
"bn.js": "^5.2.1",
|
||||
"bs58": "^6.0.0",
|
||||
"chai": "^5.1.2",
|
||||
"decimal.js": "^10.4.3",
|
||||
"dotenv": "^16.4.7",
|
||||
"flash-sdk": "^2.24.3",
|
||||
"form-data": "^4.0.1",
|
||||
"langchain": "^0.3.8",
|
||||
"openai": "^4.77.0",
|
||||
"typedoc": "^0.27.6",
|
||||
"zod": "^3.24.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bn.js": "^5.1.6",
|
||||
"@types/chai": "^5.0.1",
|
||||
"@types/node": "^22.10.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.18.2",
|
||||
"@typescript-eslint/parser": "^8.18.2",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^15.3.0",
|
||||
"prettier": "^3.4.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.7.2"
|
||||
}
|
||||
}
|
||||
9289
pnpm-lock.yaml
generated
9289
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -63,6 +63,8 @@ import {
|
||||
fetchPythPriceFeedID,
|
||||
flashOpenTrade,
|
||||
flashCloseTrade,
|
||||
createMeteoraDynamicAMMPool,
|
||||
createMeteoraDlmmPool,
|
||||
} from "../tools";
|
||||
import {
|
||||
CollectionDeployment,
|
||||
@@ -339,6 +341,57 @@ export class SolanaAgentKit {
|
||||
);
|
||||
}
|
||||
|
||||
async meteoraCreateDynamicPool(
|
||||
tokenAMint: PublicKey,
|
||||
tokenBMint: PublicKey,
|
||||
tokenAAmount: BN,
|
||||
tokenBAmount: BN,
|
||||
tradeFeeNumerator: number,
|
||||
activationPoint: BN | null,
|
||||
hasAlphaVault: boolean,
|
||||
activationType: number,
|
||||
): Promise<string> {
|
||||
return createMeteoraDynamicAMMPool(
|
||||
this,
|
||||
tokenAMint,
|
||||
tokenBMint,
|
||||
tokenAAmount,
|
||||
tokenBAmount,
|
||||
{
|
||||
tradeFeeNumerator,
|
||||
activationPoint,
|
||||
hasAlphaVault,
|
||||
activationType,
|
||||
padding: new Array(90).fill(0),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async meteoraCreateDlmmPool(
|
||||
binStep: number,
|
||||
tokenAMint: PublicKey,
|
||||
tokenBMint: PublicKey,
|
||||
initialPrice: number,
|
||||
priceRoundingUp: boolean,
|
||||
feeBps: number,
|
||||
activationType: number,
|
||||
hasAlphaVault: boolean,
|
||||
activationPoint: BN | undefined,
|
||||
): Promise<string> {
|
||||
return createMeteoraDlmmPool(
|
||||
this,
|
||||
binStep,
|
||||
tokenAMint,
|
||||
tokenBMint,
|
||||
initialPrice,
|
||||
priceRoundingUp,
|
||||
feeBps,
|
||||
activationType,
|
||||
hasAlphaVault,
|
||||
activationPoint,
|
||||
);
|
||||
}
|
||||
|
||||
async orcaClosePosition(positionMintAddress: PublicKey) {
|
||||
return orcaClosePosition(this, positionMintAddress);
|
||||
}
|
||||
|
||||
@@ -33,3 +33,10 @@ export const DEFAULT_OPTIONS = {
|
||||
export const JUP_API = "https://quote-api.jup.ag/v6";
|
||||
export const JUP_REFERRAL_ADDRESS =
|
||||
"REFER4ZgmyYx9c6He5XfaTMiGfdLwRnkV4RPp9t9iF3";
|
||||
|
||||
export const METEORA_DYNAMIC_AMM_PROGRAM_ID = new PublicKey(
|
||||
"Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB",
|
||||
);
|
||||
export const METEORA_DLMM_PROGRAM_ID = new PublicKey(
|
||||
"LbVRzDTvBDEcrthxfZ4RL6yiq3uZw8bS6MwtdY6UhFQ",
|
||||
);
|
||||
|
||||
121
src/tools/create_meteora_alpha_vault.ts
Normal file
121
src/tools/create_meteora_alpha_vault.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
// import AlphaVault, { PoolType, WhitelistMode } from "@meteora-ag/alpha-vault";
|
||||
// import { SolanaAgentKit } from "../agent";
|
||||
// import { PublicKey, sendAndConfirmTransaction } from "@solana/web3.js";
|
||||
// import BN from "bn.js";
|
||||
|
||||
// /**
|
||||
// * Create Meteora FCFS alpha vault
|
||||
// * @param agent SolanaAgentKit instance
|
||||
// * @param tokenAMint Token A mint
|
||||
// * @param tokenBMint Token B mint
|
||||
// * @param poolAddress Pool mint
|
||||
// * @param poolType Either PoolType.DYNAMIC or PoolType.DLMM
|
||||
// * @param depositingPoint The point when the vault allows deposits
|
||||
// * @param startVestingPoint The point when the vault starts vesting
|
||||
// * @param endVestingPoint The point when the vault ends vesting
|
||||
// * @param maxDepositingCap Maximum number of deposit amount for vault
|
||||
// * @param individualDepositingCap Maximum number of deposit amount for individual
|
||||
// * @param escrowFee Fee to create stake escrow account
|
||||
// * @param whitelistMode Alpha vault whitelist mode
|
||||
// * @returns
|
||||
// */
|
||||
// export async function createMeteoraFcfsAlphaVault(
|
||||
// agent: SolanaAgentKit,
|
||||
// tokenAMint: PublicKey,
|
||||
// tokenBMint: PublicKey,
|
||||
// poolAddress: PublicKey,
|
||||
// poolType: PoolType,
|
||||
// depositingPoint: BN,
|
||||
// startVestingPoint: BN,
|
||||
// endVestingPoint: BN,
|
||||
// maxDepositingCap: BN,
|
||||
// individualDepositingCap: BN,
|
||||
// escrowFee: BN,
|
||||
// whitelistMode: WhitelistMode
|
||||
// ): Promise<string> {
|
||||
// const createAlphaVaultTx = await AlphaVault.createCustomizableFcfsVault(
|
||||
// agent.connection,
|
||||
// {
|
||||
// baseMint: tokenAMint,
|
||||
// quoteMint: tokenBMint,
|
||||
// poolAddress,
|
||||
// poolType,
|
||||
// depositingPoint,
|
||||
// startVestingPoint,
|
||||
// endVestingPoint,
|
||||
// maxDepositingCap,
|
||||
// individualDepositingCap,
|
||||
// escrowFee,
|
||||
// whitelistMode
|
||||
// },
|
||||
// agent.wallet_address
|
||||
// );
|
||||
|
||||
// const createAlphaVaultTxHash = await sendAndConfirmTransaction(
|
||||
// agent.connection,
|
||||
// createAlphaVaultTx,
|
||||
// [agent.wallet],
|
||||
// ).catch((err) => {
|
||||
// console.error(err);
|
||||
// throw err;
|
||||
// });
|
||||
|
||||
// return createAlphaVaultTxHash;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Create Meteora Prorata alpha vault
|
||||
// * @param agent SolanaAgentKit instance
|
||||
// * @param tokenAMint Token A mint
|
||||
// * @param tokenBMint Token B mint
|
||||
// * @param poolAddress Pool mint
|
||||
// * @param poolType Either PoolType.DYNAMIC or PoolType.DLMM
|
||||
// * @param depositingPoint The point when the vault allows deposits
|
||||
// * @param startVestingPoint The point when the vault starts vesting
|
||||
// * @param endVestingPoint The point when the vault ends vesting
|
||||
// * @param maxBuyingCap Maximum buying amount
|
||||
// * @param escrowFee Fee to create stake escrow account
|
||||
// * @param whitelistMode Alpha vault whitelist mode
|
||||
// * @returns
|
||||
// */
|
||||
// export async function createMeteoraProrataAlphaVault(
|
||||
// agent: SolanaAgentKit,
|
||||
// tokenAMint: PublicKey,
|
||||
// tokenBMint: PublicKey,
|
||||
// poolAddress: PublicKey,
|
||||
// poolType: PoolType,
|
||||
// depositingPoint: BN,
|
||||
// startVestingPoint: BN,
|
||||
// endVestingPoint: BN,
|
||||
// maxBuyingCap: BN,
|
||||
// escrowFee: BN,
|
||||
// whitelistMode: WhitelistMode
|
||||
// ): Promise<string> {
|
||||
// const createAlphaVaultTx = await AlphaVault.createCustomizableProrataVault(
|
||||
// agent.connection,
|
||||
// {
|
||||
// baseMint: tokenAMint,
|
||||
// quoteMint: tokenBMint,
|
||||
// poolAddress,
|
||||
// poolType,
|
||||
// depositingPoint,
|
||||
// startVestingPoint,
|
||||
// endVestingPoint,
|
||||
// maxBuyingCap,
|
||||
// escrowFee,
|
||||
// whitelistMode
|
||||
// },
|
||||
// agent.wallet_address
|
||||
// );
|
||||
|
||||
// const createAlphaVaultTxHash = await sendAndConfirmTransaction(
|
||||
// agent.connection,
|
||||
// createAlphaVaultTx,
|
||||
// [agent.wallet],
|
||||
// ).catch((err) => {
|
||||
// console.error(err);
|
||||
// throw err;
|
||||
// });
|
||||
|
||||
// return createAlphaVaultTxHash;
|
||||
// }
|
||||
71
src/tools/create_meteora_dlmm_pool.ts
Normal file
71
src/tools/create_meteora_dlmm_pool.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import BN from "bn.js";
|
||||
import { PublicKey, sendAndConfirmTransaction } from "@solana/web3.js";
|
||||
import DLMM, { ActivationType } from "@meteora-ag/dlmm";
|
||||
import { getMint } from "@solana/spl-token";
|
||||
|
||||
/**
|
||||
* Create Meteora DLMM pool
|
||||
* @param agent SolanaAgentKit instance
|
||||
* @param binStep DLMM pool bin step
|
||||
* @param tokenAMint Token A mint
|
||||
* @param tokenBMint Token B mint
|
||||
* @param initialPrice Initial pool price in ratio tokenA / tokenB
|
||||
* @param priceRoundingUp Whether to rounding up the initial pool price
|
||||
* @param feeBps Pool trading fee in BPS
|
||||
* @param activationType Pool activation type (ActivationType.Timestamp or ActivationType.Slot)
|
||||
* @param hasAlphaVault Whether the pool has Meteora alpha vault or not
|
||||
* @param activationPoint Activation point depending on activation type, or null if pool doesn't have an activation point
|
||||
* @returns Transaction signature
|
||||
*/
|
||||
export async function createMeteoraDlmmPool(
|
||||
agent: SolanaAgentKit,
|
||||
binStep: number,
|
||||
tokenAMint: PublicKey,
|
||||
tokenBMint: PublicKey,
|
||||
initialPrice: number,
|
||||
priceRoundingUp: boolean,
|
||||
feeBps: number,
|
||||
activationType: ActivationType,
|
||||
hasAlphaVault: boolean,
|
||||
activationPoint: BN | undefined
|
||||
): Promise<string> {
|
||||
const tokenAMintInfo = await getMint(agent.connection, tokenAMint);
|
||||
const tokenBMintInfo = await getMint(agent.connection, tokenBMint);
|
||||
|
||||
const initPrice = DLMM.getPricePerLamport(
|
||||
tokenAMintInfo.decimals,
|
||||
tokenBMintInfo.decimals,
|
||||
initialPrice,
|
||||
);
|
||||
|
||||
const activateBinId = DLMM.getBinIdFromPrice(
|
||||
initialPrice,
|
||||
binStep,
|
||||
!priceRoundingUp,
|
||||
);
|
||||
|
||||
const initPoolTx = await DLMM.createCustomizablePermissionlessLbPair(
|
||||
agent.connection,
|
||||
new BN(binStep),
|
||||
tokenAMint,
|
||||
tokenBMint,
|
||||
new BN(activateBinId.toString()),
|
||||
new BN(feeBps),
|
||||
activationType,
|
||||
hasAlphaVault,
|
||||
agent.wallet_address,
|
||||
activationPoint
|
||||
)
|
||||
|
||||
const initPoolTxHash = await sendAndConfirmTransaction(
|
||||
agent.connection,
|
||||
initPoolTx,
|
||||
[agent.wallet],
|
||||
).catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
|
||||
return initPoolTxHash;
|
||||
}
|
||||
44
src/tools/create_meteora_dynamic_amm_pool.ts
Normal file
44
src/tools/create_meteora_dynamic_amm_pool.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import AmmImpl from "@mercurial-finance/dynamic-amm-sdk";
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import BN from "bn.js";
|
||||
import { PublicKey, sendAndConfirmTransaction } from "@solana/web3.js";
|
||||
import { CustomizableParams } from "@mercurial-finance/dynamic-amm-sdk/dist/cjs/src/amm/types";
|
||||
|
||||
/**
|
||||
* Create Meteora Dynamic AMM pool
|
||||
* @param agent SolanaAgentKit instance
|
||||
* @param tokenAMint Token A mint
|
||||
* @param tokenBMint Token B mint
|
||||
* @param tokenAAmount Token A amount in lamport units
|
||||
* @param tokenBAmount Token B amount in lamport units
|
||||
* @param customizableParams Parameters to create Dynamic AMM pool
|
||||
* tradeFeeNumerator (number): Trade fee numerator, with default denominator is 100000
|
||||
* activationType (enum): Should be ActivationType.Timestamp or ActivationType.Slot
|
||||
* activationPoint (BN | null): Activation point depending on activation type, or null if pool doesn't have an activation point
|
||||
* hasAlphaVault (boolean): Whether the pool has Meteora alpha vault or not
|
||||
* padding (Array<number>): Should be set to value Array(90).fill(0)
|
||||
* @returns Transaction signature
|
||||
*/
|
||||
export async function createMeteoraDynamicAMMPool(
|
||||
agent: SolanaAgentKit,
|
||||
tokenAMint: PublicKey,
|
||||
tokenBMint: PublicKey,
|
||||
tokenAAmount: BN,
|
||||
tokenBAmount: BN,
|
||||
customizableParams: CustomizableParams
|
||||
): Promise<string> {
|
||||
const initPoolTx = await AmmImpl.createCustomizablePermissionlessConstantProductPool(
|
||||
agent.connection, agent.wallet_address, tokenAMint, tokenBMint, tokenAAmount, tokenBAmount, customizableParams
|
||||
)
|
||||
|
||||
const initPoolTxHash = await sendAndConfirmTransaction(
|
||||
agent.connection,
|
||||
initPoolTx,
|
||||
[agent.wallet],
|
||||
).catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
|
||||
return initPoolTxHash;
|
||||
}
|
||||
@@ -50,3 +50,5 @@ export * from "./flash_open_trade";
|
||||
export * from "./flash_close_trade";
|
||||
|
||||
export * from "./create_3land_collectible";
|
||||
export * from "./create_meteora_dynamic_amm_pool";
|
||||
export * from "./create_meteora_dlmm_pool";
|
||||
|
||||
35
test/tools/create_meteora_dlmm_pool.ts
Normal file
35
test/tools/create_meteora_dlmm_pool.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { SolanaAgentKit, createSolanaTools } from "../../src";
|
||||
import { deploy_token } from "../../src/tools";
|
||||
|
||||
const agent = new SolanaAgentKit(
|
||||
process.env.SOLANA_PRIVATE_KEY!,
|
||||
process.env.RPC_URL!,
|
||||
{ OPENAI_API_KEY: process.env.OPENAI_API_KEY! },
|
||||
);
|
||||
|
||||
async function main() {
|
||||
console.log("<<< Test Create Meteora DLMM pool");
|
||||
|
||||
const { mint: tokenAMint } = await deploy_token(agent, "token_a_mint", "www.example.com", "TOKEN_A", 6, 100_000);
|
||||
const { mint: tokenBMint } = await deploy_token(agent, "token_b_mint", "www.example.com", "TOKEN_B", 6, 100_000);
|
||||
|
||||
// Delay for 5 seconds
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
|
||||
const binStep = 20;
|
||||
const initialPrice = 0.25;
|
||||
const priceRoundingUp = true;
|
||||
const feeBps = 20;
|
||||
const activationType = 1; // timestamp
|
||||
const hasAlphaVault = false;
|
||||
const activationPoint = undefined;
|
||||
|
||||
const txHash = await agent.meteoraCreateDlmmPool(binStep, tokenAMint, tokenBMint, initialPrice, priceRoundingUp, feeBps, activationType, hasAlphaVault, activationPoint);
|
||||
console.log(`Tx successfully ${txHash.toString()}`);
|
||||
|
||||
console.log(">>> Test Create Meteora DLMM Pool Passed");
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
export { SolanaAgentKit, createSolanaTools };
|
||||
45
test/tools/create_meteora_dynamic_amm_pool.ts
Normal file
45
test/tools/create_meteora_dynamic_amm_pool.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { SolanaAgentKit, createSolanaTools } from "../../src";
|
||||
import { deploy_token } from "../../src/tools";
|
||||
import BN from "bn.js";
|
||||
import AmmImpl from "@mercurial-finance/dynamic-amm-sdk";
|
||||
import { deriveCustomizablePermissionlessConstantProductPoolAddress } from "@mercurial-finance/dynamic-amm-sdk/dist/cjs/src/amm/utils";
|
||||
import { METEORA_DYNAMIC_AMM_PROGRAM_ID } from "../../src/constants";
|
||||
|
||||
const agent = new SolanaAgentKit(
|
||||
process.env.SOLANA_PRIVATE_KEY!,
|
||||
process.env.RPC_URL!,
|
||||
{ OPENAI_API_KEY: process.env.OPENAI_API_KEY! },
|
||||
);
|
||||
|
||||
async function main() {
|
||||
console.log("<<< Test Create Meteora Dynamic AMM pool");
|
||||
|
||||
const { mint: tokenAMint } = await deploy_token(agent, "token_a_mint", "www.example.com", "TOKEN_A", 6, 100_000);
|
||||
const { mint: tokenBMint } = await deploy_token(agent, "token_b_mint", "www.example.com", "TOKEN_B", 6, 100_000);
|
||||
|
||||
// Delay for 5 seconds
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
|
||||
const tokenAAmount = new BN(1000);
|
||||
const tokenBAmount = new BN(5);
|
||||
const params = {
|
||||
tradeFeeNumerator: 250,
|
||||
activationPoint: null,
|
||||
hasAlphaVault: false,
|
||||
activationType: 0,
|
||||
};
|
||||
const txHash = await agent.meteoraCreateDynamicPool(tokenAMint, tokenBMint, tokenAAmount, tokenBAmount, params.tradeFeeNumerator, params.activationPoint, params.hasAlphaVault, params.activationType);
|
||||
console.log(`Tx successfully ${txHash.toString()}`);
|
||||
|
||||
const poolKey = deriveCustomizablePermissionlessConstantProductPoolAddress(
|
||||
tokenAMint, tokenBMint, METEORA_DYNAMIC_AMM_PROGRAM_ID
|
||||
);
|
||||
const pool = await AmmImpl.create(agent.connection, poolKey);
|
||||
await pool.updateState();
|
||||
|
||||
console.log(">>> Test Create Meteora Dynamic AMM Pool Passed");
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
export { SolanaAgentKit, createSolanaTools };
|
||||
Reference in New Issue
Block a user