mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-14 15:10:20 +00:00
fix: Update initPrice when creating DLMM pool
This commit is contained in:
@@ -40,7 +40,7 @@ export async function createMeteoraDlmmPool(
|
||||
);
|
||||
|
||||
const activateBinId = DLMM.getBinIdFromPrice(
|
||||
initialPrice,
|
||||
initPrice,
|
||||
binStep,
|
||||
!priceRoundingUp,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
|
||||
import {
|
||||
Keypair,
|
||||
PublicKey,
|
||||
Transaction,
|
||||
VersionedTransaction,
|
||||
} from "@solana/web3.js";
|
||||
import bs58 from "bs58";
|
||||
|
||||
export const keypair = Keypair.generate();
|
||||
@@ -6,7 +11,6 @@ export const keypair = Keypair.generate();
|
||||
console.log(keypair.publicKey.toString());
|
||||
console.log(bs58.encode(keypair.secretKey));
|
||||
|
||||
|
||||
export class Wallet {
|
||||
private _signer: Keypair;
|
||||
|
||||
@@ -14,7 +18,9 @@ export class Wallet {
|
||||
this._signer = signer;
|
||||
}
|
||||
|
||||
async signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T> {
|
||||
async signTransaction<T extends Transaction | VersionedTransaction>(
|
||||
tx: T,
|
||||
): Promise<T> {
|
||||
if (tx instanceof Transaction) {
|
||||
tx.sign(this._signer);
|
||||
} else if (tx instanceof VersionedTransaction) {
|
||||
@@ -25,11 +31,13 @@ export class Wallet {
|
||||
return tx;
|
||||
}
|
||||
|
||||
async signAllTransactions<T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]> {
|
||||
async signAllTransactions<T extends Transaction | VersionedTransaction>(
|
||||
txs: T[],
|
||||
): Promise<T[]> {
|
||||
return Promise.all(txs.map((tx) => this.signTransaction(tx)));
|
||||
}
|
||||
|
||||
get publicKey(): PublicKey {
|
||||
return this._signer.publicKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,25 @@ const agent = new SolanaAgentKit(
|
||||
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);
|
||||
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));
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||
|
||||
const binStep = 20;
|
||||
const initialPrice = 0.25;
|
||||
@@ -24,7 +38,17 @@ async function main() {
|
||||
const hasAlphaVault = false;
|
||||
const activationPoint = undefined;
|
||||
|
||||
const txHash = await agent.meteoraCreateDlmmPool(binStep, tokenAMint, tokenBMint, initialPrice, priceRoundingUp, feeBps, activationType, hasAlphaVault, activationPoint);
|
||||
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");
|
||||
@@ -32,4 +56,4 @@ async function main() {
|
||||
|
||||
main();
|
||||
|
||||
export { SolanaAgentKit, createSolanaTools };
|
||||
export { SolanaAgentKit, createSolanaTools };
|
||||
|
||||
@@ -14,11 +14,25 @@ const agent = new SolanaAgentKit(
|
||||
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);
|
||||
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));
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||
|
||||
const tokenAAmount = new BN(1000);
|
||||
const tokenBAmount = new BN(5);
|
||||
@@ -28,11 +42,22 @@ async function main() {
|
||||
hasAlphaVault: false,
|
||||
activationType: 0,
|
||||
};
|
||||
const txHash = await agent.meteoraCreateDynamicPool(tokenAMint, tokenBMint, tokenAAmount, tokenBAmount, params.tradeFeeNumerator, params.activationPoint, params.hasAlphaVault, params.activationType);
|
||||
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
|
||||
tokenAMint,
|
||||
tokenBMint,
|
||||
METEORA_DYNAMIC_AMM_PROGRAM_ID,
|
||||
);
|
||||
const pool = await AmmImpl.create(agent.connection, poolKey);
|
||||
await pool.updateState();
|
||||
@@ -42,4 +67,4 @@ async function main() {
|
||||
|
||||
main();
|
||||
|
||||
export { SolanaAgentKit, createSolanaTools };
|
||||
export { SolanaAgentKit, createSolanaTools };
|
||||
|
||||
Reference in New Issue
Block a user