@meteora-ag/dynamic-bonding-curve-sdk 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,20 +5,20 @@
5
5
  var _web3js = require('@solana/web3.js');
6
6
 
7
7
  // src/types.ts
8
- var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
9
- ActivationType2[ActivationType2["Slot"] = 0] = "Slot";
10
- ActivationType2[ActivationType2["Timestamp"] = 1] = "Timestamp";
11
- return ActivationType2;
8
+ var ActivationType = /* @__PURE__ */ ((ActivationType3) => {
9
+ ActivationType3[ActivationType3["Slot"] = 0] = "Slot";
10
+ ActivationType3[ActivationType3["Timestamp"] = 1] = "Timestamp";
11
+ return ActivationType3;
12
12
  })(ActivationType || {});
13
13
  var TokenType = /* @__PURE__ */ ((TokenType2) => {
14
14
  TokenType2[TokenType2["SPL"] = 0] = "SPL";
15
15
  TokenType2[TokenType2["Token2022"] = 1] = "Token2022";
16
16
  return TokenType2;
17
17
  })(TokenType || {});
18
- var CollectFeeMode = /* @__PURE__ */ ((CollectFeeMode3) => {
19
- CollectFeeMode3[CollectFeeMode3["OnlyQuote"] = 0] = "OnlyQuote";
20
- CollectFeeMode3[CollectFeeMode3["Both"] = 1] = "Both";
21
- return CollectFeeMode3;
18
+ var CollectFeeMode = /* @__PURE__ */ ((CollectFeeMode2) => {
19
+ CollectFeeMode2[CollectFeeMode2["OnlyQuote"] = 0] = "OnlyQuote";
20
+ CollectFeeMode2[CollectFeeMode2["Both"] = 1] = "Both";
21
+ return CollectFeeMode2;
22
22
  })(CollectFeeMode || {});
23
23
  var MigrationOption = /* @__PURE__ */ ((MigrationOption2) => {
24
24
  MigrationOption2[MigrationOption2["MET_DAMM"] = 0] = "MET_DAMM";
@@ -657,11 +657,7 @@ var getPercentageSupplyOnMigration = (initialMarketCap, migrationMarketCap, lock
657
657
  return numerator.div(denominator).toNumber();
658
658
  };
659
659
  var getMigrationQuoteThreshold = (migrationMarketCap, percentageSupplyOnMigration) => {
660
- const migrationMarketCapDecimal = new (0, _decimaljs2.default)(migrationMarketCap.toString());
661
- const percentageDecimal = new (0, _decimaljs2.default)(
662
- percentageSupplyOnMigration.toString()
663
- );
664
- return migrationMarketCapDecimal.mul(percentageDecimal).div(new (0, _decimaljs2.default)(100)).toNumber();
660
+ return migrationMarketCap.mul(percentageSupplyOnMigration).div(new (0, _decimaljs2.default)(100)).toNumber();
665
661
  };
666
662
  function getBaseFeeParams(startingBaseFeeBps, endingBaseFeeBps, feeSchedulerMode, numberOfPeriod, totalDuration) {
667
663
  if (startingBaseFeeBps == endingBaseFeeBps) {
@@ -755,7 +751,7 @@ function getDynamicFeeParams(baseFeeBps, maxPriceChangeBps = MAX_PRICE_CHANGE_BP
755
751
  variableFeeControl: variableFeeControl.toNumber()
756
752
  };
757
753
  }
758
- function getLockedVestingParams(totalLockedVestingAmount, numberOfVestingPeriod, cliffUnlockAmount, totalVestingDuration, cliffDurationFromMigrationTime, tokenBaseDecimal, activationType) {
754
+ function getLockedVestingParams(totalLockedVestingAmount, numberOfVestingPeriod, cliffUnlockAmount, totalVestingDuration, cliffDurationFromMigrationTime, tokenBaseDecimal) {
759
755
  if (totalLockedVestingAmount == 0) {
760
756
  return {
761
757
  amountPerPeriod: new (0, _bnjs2.default)(0),
@@ -796,12 +792,7 @@ function getLockedVestingParams(totalLockedVestingAmount, numberOfVestingPeriod,
796
792
  const totalPeriodicAmount = roundedAmountPerPeriod * numberOfVestingPeriod;
797
793
  const remainder = totalLockedVestingAmount - (cliffUnlockAmount + totalPeriodicAmount);
798
794
  const adjustedCliffUnlockAmount = cliffUnlockAmount + remainder;
799
- let periodFrequency;
800
- if (activationType == 0 /* Slot */) {
801
- periodFrequency = new (0, _bnjs2.default)(totalVestingDuration / numberOfVestingPeriod).div(new (0, _bnjs2.default)(TIMESTAMP_DURATION)).mul(new (0, _bnjs2.default)(SLOT_DURATION));
802
- } else {
803
- periodFrequency = new (0, _bnjs2.default)(totalVestingDuration / numberOfVestingPeriod);
804
- }
795
+ const periodFrequency = new (0, _bnjs2.default)(totalVestingDuration / numberOfVestingPeriod);
805
796
  return {
806
797
  amountPerPeriod: new (0, _bnjs2.default)(roundedAmountPerPeriod.toString()).mul(
807
798
  new (0, _bnjs2.default)(10).pow(new (0, _bnjs2.default)(tokenBaseDecimal))
@@ -1380,8 +1371,7 @@ function buildCurve(buildCurveParam) {
1380
1371
  cliffUnlockAmount,
1381
1372
  totalVestingDuration,
1382
1373
  cliffDurationFromMigrationTime,
1383
- tokenBaseDecimal,
1384
- activationType
1374
+ tokenBaseDecimal
1385
1375
  );
1386
1376
  const migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
1387
1377
  const totalSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(
@@ -1470,7 +1460,6 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
1470
1460
  initialMarketCap,
1471
1461
  migrationMarketCap,
1472
1462
  totalTokenSupply,
1473
- activationType,
1474
1463
  tokenBaseDecimal
1475
1464
  } = buildCurveWithMarketCapParam;
1476
1465
  const {
@@ -1486,8 +1475,7 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
1486
1475
  cliffUnlockAmount,
1487
1476
  totalVestingDuration,
1488
1477
  cliffDurationFromMigrationTime,
1489
- tokenBaseDecimal,
1490
- activationType
1478
+ tokenBaseDecimal
1491
1479
  );
1492
1480
  const totalSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(
1493
1481
  new (0, _bnjs2.default)(10).pow(new (0, _bnjs2.default)(tokenBaseDecimal))
@@ -1499,8 +1487,8 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
1499
1487
  totalSupply
1500
1488
  );
1501
1489
  const migrationQuoteThreshold = getMigrationQuoteThreshold(
1502
- new (0, _bnjs2.default)(migrationMarketCap),
1503
- percentageSupplyOnMigration
1490
+ new (0, _decimaljs2.default)(migrationMarketCap),
1491
+ new (0, _decimaljs2.default)(percentageSupplyOnMigration)
1504
1492
  );
1505
1493
  return buildCurve({
1506
1494
  ...buildCurveWithMarketCapParam,
@@ -1556,8 +1544,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
1556
1544
  cliffUnlockAmount,
1557
1545
  totalVestingDuration,
1558
1546
  cliffDurationFromMigrationTime,
1559
- tokenBaseDecimal,
1560
- activationType
1547
+ tokenBaseDecimal
1561
1548
  );
1562
1549
  let migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
1563
1550
  let totalSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(
@@ -1593,11 +1580,15 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
1593
1580
  );
1594
1581
  let midSqrtPriceDecimal1 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString()).mul(new (0, _decimaljs2.default)(initialSqrtPrice.toString())).sqrt();
1595
1582
  let midSqrtPrice1 = new (0, _bnjs2.default)(midSqrtPriceDecimal1.floor().toFixed());
1596
- let midSqrtPriceDecimal2 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString()).pow(new (0, _decimaljs2.default)(3)).mul(new (0, _decimaljs2.default)(initialSqrtPrice.toString()).pow(0.25));
1583
+ let numerator1 = new (0, _decimaljs2.default)(initialSqrtPrice.toString());
1584
+ let numerator2 = _decimaljs2.default.pow(migrateSqrtPrice.toString(), 3);
1585
+ let product1 = numerator1.mul(numerator2);
1586
+ let midSqrtPriceDecimal2 = _decimaljs2.default.pow(product1, 0.25);
1597
1587
  let midSqrtPrice2 = new (0, _bnjs2.default)(midSqrtPriceDecimal2.floor().toFixed());
1598
- let midSqrtPriceDecimal3 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString()).mul(
1599
- new (0, _decimaljs2.default)(initialSqrtPrice.toString()).pow(new (0, _decimaljs2.default)(3)).pow(0.25)
1600
- );
1588
+ let numerator3 = _decimaljs2.default.pow(initialSqrtPrice.toString(), 3);
1589
+ let numerator4 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString());
1590
+ let product2 = numerator3.mul(numerator4);
1591
+ let midSqrtPriceDecimal3 = _decimaljs2.default.pow(product2, 0.25);
1601
1592
  let midSqrtPrice3 = new (0, _bnjs2.default)(midSqrtPriceDecimal3.floor().toFixed());
1602
1593
  let midPrices = [midSqrtPrice1, midSqrtPrice2, midSqrtPrice3];
1603
1594
  let sqrtStartPrice = new (0, _bnjs2.default)(0);
@@ -1709,8 +1700,7 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
1709
1700
  cliffUnlockAmount,
1710
1701
  totalVestingDuration,
1711
1702
  cliffDurationFromMigrationTime,
1712
- tokenBaseDecimal,
1713
- activationType
1703
+ tokenBaseDecimal
1714
1704
  );
1715
1705
  let pMin = getSqrtPriceFromMarketCap(
1716
1706
  initialMarketCap,
@@ -1868,8 +1858,7 @@ function buildCurveWithCreatorFirstBuy(buildCurveWithCreatorFirstBuyParam) {
1868
1858
  cliffUnlockAmount,
1869
1859
  totalVestingDuration,
1870
1860
  cliffDurationFromMigrationTime,
1871
- tokenBaseDecimal,
1872
- activationType
1861
+ tokenBaseDecimal
1873
1862
  );
1874
1863
  let pMin = getSqrtPriceFromMarketCap(
1875
1864
  initialMarketCap,
@@ -20431,6 +20420,7 @@ function createDammV2Program(connection, commitment = "confirmed") {
20431
20420
 
20432
20421
 
20433
20422
 
20423
+
20434
20424
  var getOrCreateATAInstruction = async (connection, tokenMint, owner, payer, allowOwnerOffCurve = true, tokenProgram) => {
20435
20425
  const toAccount = _spltoken.getAssociatedTokenAddressSync.call(void 0,
20436
20426
  tokenMint,
@@ -20519,6 +20509,43 @@ async function getTokenDecimals(connection, mintAddress) {
20519
20509
  function getTokenProgram(tokenType) {
20520
20510
  return tokenType === 0 /* SPL */ ? _spltoken.TOKEN_PROGRAM_ID : _spltoken.TOKEN_2022_PROGRAM_ID;
20521
20511
  }
20512
+ async function getTokenType(connection, tokenMint) {
20513
+ const accountInfo = await connection.getAccountInfo(tokenMint);
20514
+ if (!accountInfo) {
20515
+ return null;
20516
+ }
20517
+ return accountInfo.owner.equals(_spltoken.TOKEN_PROGRAM_ID) ? 0 /* SPL */ : 1 /* Token2022 */;
20518
+ }
20519
+ async function prepareTokenAccountTx(connection, owner, payer, tokenMint, amount, tokenProgram) {
20520
+ const instructions = [];
20521
+ const { ataPubkey: tokenAccount, ix: createAtaIx } = await getOrCreateATAInstruction(
20522
+ connection,
20523
+ tokenMint,
20524
+ owner,
20525
+ payer,
20526
+ true,
20527
+ tokenProgram
20528
+ );
20529
+ createAtaIx && instructions.push(createAtaIx);
20530
+ if (tokenMint.equals(_spltoken.NATIVE_MINT)) {
20531
+ const wrapIx = wrapSOLInstruction(owner, tokenAccount, amount);
20532
+ instructions.push(...wrapIx);
20533
+ }
20534
+ const transaction = new (0, _web3js.Transaction)();
20535
+ if (instructions.length > 0) {
20536
+ transaction.add(...instructions);
20537
+ }
20538
+ return { tokenAccount, transaction };
20539
+ }
20540
+ async function cleanUpTokenAccountTx(owner, receiver, tokenMint) {
20541
+ if (tokenMint.equals(_spltoken.NATIVE_MINT)) {
20542
+ const unwrapIx = unwrapSOLInstruction(owner, receiver);
20543
+ if (unwrapIx) {
20544
+ return { transaction: new (0, _web3js.Transaction)().add(unwrapIx) };
20545
+ }
20546
+ }
20547
+ return null;
20548
+ }
20522
20549
 
20523
20550
  // src/helpers/instructions.ts
20524
20551
 
@@ -21341,6 +21368,127 @@ var PoolService = class extends DynamicBondingCurveProgram {
21341
21368
  };
21342
21369
  }
21343
21370
  }
21371
+ /**
21372
+ * Private method to create config instruction
21373
+ * @param configParam - The config parameters
21374
+ * @param config - The config address
21375
+ * @param feeClaimer - The fee claimer address
21376
+ * @param leftoverReceiver - The leftover receiver address
21377
+ * @param quoteMint - The quote mint address
21378
+ * @param payer - The payer address
21379
+ * @returns A transaction that creates the config
21380
+ */
21381
+ async createConfigInstruction(configParam, config, feeClaimer, leftoverReceiver, quoteMint, payer) {
21382
+ return this.program.methods.createConfig(configParam).accountsPartial({
21383
+ config,
21384
+ feeClaimer,
21385
+ leftoverReceiver,
21386
+ quoteMint,
21387
+ payer
21388
+ }).transaction();
21389
+ }
21390
+ /**
21391
+ * Private method to create pool instruction
21392
+ * @param createConfigAndPoolWithFirstBuyParam - The parameters for the config and pool and buy
21393
+ * @param configKey - The config key
21394
+ * @param quoteMintToken - The quote mint token
21395
+ * @param payerAddress - The payer address
21396
+ * @returns A transaction that creates the pool
21397
+ */
21398
+ async createPoolInstruction(createConfigAndPoolWithFirstBuyParam, configKey, quoteMintToken, payerAddress) {
21399
+ const { baseMint, name, symbol, uri, poolCreator } = createConfigAndPoolWithFirstBuyParam.createPoolParam;
21400
+ const pool = deriveDbcPoolAddress(quoteMintToken, baseMint, configKey);
21401
+ const baseVault = deriveDbcTokenVaultAddress(pool, baseMint);
21402
+ const quoteVault = deriveDbcTokenVaultAddress(pool, quoteMintToken);
21403
+ const baseParams = {
21404
+ name,
21405
+ symbol,
21406
+ uri,
21407
+ pool,
21408
+ config: configKey,
21409
+ payer: payerAddress,
21410
+ poolCreator,
21411
+ baseMint,
21412
+ baseVault,
21413
+ quoteVault,
21414
+ quoteMint: quoteMintToken
21415
+ };
21416
+ if (createConfigAndPoolWithFirstBuyParam.tokenType === 0 /* SPL */) {
21417
+ const mintMetadata = deriveMintMetadata(baseMint);
21418
+ return this.initializeSplPool({
21419
+ ...baseParams,
21420
+ mintMetadata
21421
+ });
21422
+ } else {
21423
+ return this.initializeToken2022Pool(baseParams);
21424
+ }
21425
+ }
21426
+ /**
21427
+ * Private method to create first buy instruction
21428
+ * @param createConfigAndPoolWithFirstBuyParam - The parameters for the config and pool and buy
21429
+ * @param configKey - The config key
21430
+ * @param quoteMintToken - The quote mint token
21431
+ * @param payerAddress - The payer address
21432
+ * @returns Instructions for the first buy
21433
+ */
21434
+ async createFirstBuyInstruction(createConfigAndPoolWithFirstBuyParam, configKey, quoteMintToken, payerAddress) {
21435
+ const { baseMint, poolCreator } = createConfigAndPoolWithFirstBuyParam.createPoolParam;
21436
+ const {
21437
+ buyAmount,
21438
+ minimumAmountOut,
21439
+ quoteMintTokenAccount,
21440
+ referralTokenAccount
21441
+ } = createConfigAndPoolWithFirstBuyParam.swapBuyParam;
21442
+ if (!buyAmount) {
21443
+ return [];
21444
+ }
21445
+ validateSwapAmount(buyAmount);
21446
+ const quoteTokenFlag = await getTokenType(
21447
+ this.connection,
21448
+ quoteMintToken
21449
+ );
21450
+ const { outputMint, outputTokenProgram } = this.prepareSwapParams(
21451
+ false,
21452
+ {
21453
+ baseMint,
21454
+ poolType: createConfigAndPoolWithFirstBuyParam.tokenType
21455
+ },
21456
+ {
21457
+ quoteMint: quoteMintToken,
21458
+ quoteTokenFlag
21459
+ }
21460
+ );
21461
+ const pool = deriveDbcPoolAddress(quoteMintToken, baseMint, configKey);
21462
+ const baseVault = deriveDbcTokenVaultAddress(pool, baseMint);
21463
+ const quoteVault = deriveDbcTokenVaultAddress(pool, quoteMintToken);
21464
+ const { tokenAccount: outputTokenAccount, transaction: preTx } = await prepareTokenAccountTx(
21465
+ this.connection,
21466
+ poolCreator,
21467
+ payerAddress,
21468
+ outputMint,
21469
+ BigInt(buyAmount.toString()),
21470
+ outputTokenProgram
21471
+ );
21472
+ const swapIx = await this.program.methods.swap({
21473
+ amountIn: buyAmount,
21474
+ minimumAmountOut
21475
+ }).accountsPartial({
21476
+ baseMint,
21477
+ quoteMint: quoteMintToken,
21478
+ pool,
21479
+ baseVault,
21480
+ quoteVault,
21481
+ config: configKey,
21482
+ poolAuthority: this.poolAuthority,
21483
+ referralTokenAccount,
21484
+ inputTokenAccount: quoteMintTokenAccount,
21485
+ outputTokenAccount,
21486
+ payer: poolCreator,
21487
+ tokenBaseProgram: createConfigAndPoolWithFirstBuyParam.tokenType === 0 /* SPL */ ? _spltoken.TOKEN_PROGRAM_ID : _spltoken.TOKEN_2022_PROGRAM_ID,
21488
+ tokenQuoteProgram: quoteTokenFlag === 0 /* SPL */ ? _spltoken.TOKEN_PROGRAM_ID : _spltoken.TOKEN_2022_PROGRAM_ID
21489
+ }).instruction();
21490
+ return [...preTx.instructions, swapIx];
21491
+ }
21344
21492
  /**
21345
21493
  * Create a new pool
21346
21494
  * @param createPoolParam - The parameters for the pool
@@ -21430,14 +21578,60 @@ var PoolService = class extends DynamicBondingCurveProgram {
21430
21578
  }
21431
21579
  return tx;
21432
21580
  }
21581
+ /**
21582
+ * Create a new config and pool and buy tokens
21583
+ * @param createConfigAndPoolWithFirstBuyParam - The parameters for the config and pool and buy
21584
+ * @returns A transaction containing a new config key, a new token pool and the first initial buy of tokens
21585
+ */
21586
+ async createConfigAndPoolWithFirstBuy(createConfigAndPoolWithFirstBuyParam) {
21587
+ const {
21588
+ config,
21589
+ feeClaimer,
21590
+ leftoverReceiver,
21591
+ quoteMint,
21592
+ payer,
21593
+ ...configParam
21594
+ } = createConfigAndPoolWithFirstBuyParam;
21595
+ validateConfigParameters({ ...configParam, leftoverReceiver });
21596
+ const configKey = new (0, _web3js.PublicKey)(config);
21597
+ const quoteMintToken = new (0, _web3js.PublicKey)(quoteMint);
21598
+ const payerAddress = new (0, _web3js.PublicKey)(payer);
21599
+ const feeClaimerAddress = new (0, _web3js.PublicKey)(feeClaimer);
21600
+ const leftoverReceiverAddress = new (0, _web3js.PublicKey)(leftoverReceiver);
21601
+ const transaction = new (0, _web3js.Transaction)();
21602
+ const createConfigIx = await this.createConfigInstruction(
21603
+ configParam,
21604
+ configKey,
21605
+ feeClaimerAddress,
21606
+ leftoverReceiverAddress,
21607
+ quoteMintToken,
21608
+ payerAddress
21609
+ );
21610
+ transaction.add(createConfigIx);
21611
+ const createPoolIx = await this.createPoolInstruction(
21612
+ createConfigAndPoolWithFirstBuyParam,
21613
+ configKey,
21614
+ quoteMintToken,
21615
+ payerAddress
21616
+ );
21617
+ transaction.add(createPoolIx);
21618
+ const firstBuyInstruction = await this.createFirstBuyInstruction(
21619
+ createConfigAndPoolWithFirstBuyParam,
21620
+ configKey,
21621
+ quoteMintToken,
21622
+ payerAddress
21623
+ );
21624
+ transaction.add(...firstBuyInstruction);
21625
+ return transaction;
21626
+ }
21433
21627
  /**
21434
21628
  * Create a new pool and buy tokens
21435
- * @param createPoolBuyParam - The parameters for the pool and buy
21629
+ * @param createPoolWithFirstBuyParam - The parameters for the pool and buy
21436
21630
  * @returns A transaction that creates the pool and buys tokens
21437
21631
  */
21438
- async createPoolAndBuy(createPoolBuyParam) {
21439
- const { baseMint, config, name, symbol, uri, payer, poolCreator } = createPoolBuyParam.createPoolParam;
21440
- const { buyAmount, minimumAmountOut, referralTokenAccount } = createPoolBuyParam;
21632
+ async createPoolWithFirstBuy(createPoolWithFirstBuyParam) {
21633
+ const { baseMint, config, name, symbol, uri, payer, poolCreator } = createPoolWithFirstBuyParam.createPoolParam;
21634
+ const { buyAmount, minimumAmountOut, referralTokenAccount } = createPoolWithFirstBuyParam;
21441
21635
  const poolConfigState = await this.state.getPoolConfig(config);
21442
21636
  const { quoteMint, tokenType } = poolConfigState;
21443
21637
  const pool = deriveDbcPoolAddress(quoteMint, baseMint, config);
@@ -21503,7 +21697,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
21503
21697
  const unwrapIx = unwrapSOLInstruction(poolCreator, poolCreator);
21504
21698
  unwrapIx && postInstructions.push(unwrapIx);
21505
21699
  }
21506
- const swapIx = await this.program.methods.swap({
21700
+ const swapTx = await this.program.methods.swap({
21507
21701
  amountIn: buyAmount,
21508
21702
  minimumAmountOut
21509
21703
  }).accountsPartial({
@@ -21520,8 +21714,8 @@ var PoolService = class extends DynamicBondingCurveProgram {
21520
21714
  payer: poolCreator,
21521
21715
  tokenBaseProgram: tokenType === 0 /* SPL */ ? _spltoken.TOKEN_PROGRAM_ID : _spltoken.TOKEN_2022_PROGRAM_ID,
21522
21716
  tokenQuoteProgram: poolConfigState.quoteTokenFlag === 0 /* SPL */ ? _spltoken.TOKEN_PROGRAM_ID : _spltoken.TOKEN_2022_PROGRAM_ID
21523
- }).instruction();
21524
- tx.add(...preInstructions, swapIx, ...postInstructions);
21717
+ }).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
21718
+ tx.add(...swapTx.instructions);
21525
21719
  }
21526
21720
  return tx;
21527
21721
  }
@@ -21640,23 +21834,23 @@ var MigrationService = class extends DynamicBondingCurveProgram {
21640
21834
  this.state = new StateService(connection, commitment);
21641
21835
  }
21642
21836
  /**
21643
- * Get the vault program instance
21837
+ * Get vault program instance
21644
21838
  * @returns The vault program instance
21645
21839
  */
21646
21840
  getVaultProgram() {
21647
21841
  return createVaultProgram(this.connection);
21648
21842
  }
21649
21843
  /**
21650
- * Get the DAMM V1 program instance
21844
+ * Get DAMM V1 program instance
21651
21845
  * @returns The DAMM V1 program instance
21652
21846
  */
21653
21847
  getDammV1Program() {
21654
21848
  return createDammV1Program(this.connection);
21655
21849
  }
21656
21850
  /**
21657
- * Create lock escrow
21658
- * @param createLockerParam - The parameters for the lock escrow
21659
- * @returns A create lock escrow transaction
21851
+ * Create Locker (if there is lockedVesting)
21852
+ * @param createLockerParam - The parameters for the locker
21853
+ * @returns A create locker transaction
21660
21854
  */
21661
21855
  async createLocker(createLockerParam) {
21662
21856
  const poolAuthority = deriveDbcPoolAuthority();
@@ -22921,5 +23115,8 @@ var DynamicBondingCurveClient = class _DynamicBondingCurveClient {
22921
23115
 
22922
23116
 
22923
23117
 
22924
- exports.ActivationType = ActivationType; exports.BASE_ADDRESS = BASE_ADDRESS; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.CollectFeeMode = CollectFeeMode; exports.CreatorService = CreatorService; exports.DAMM_V1_MIGRATION_FEE_ADDRESS = DAMM_V1_MIGRATION_FEE_ADDRESS; exports.DAMM_V1_PROGRAM_ID = DAMM_V1_PROGRAM_ID; exports.DAMM_V2_MIGRATION_FEE_ADDRESS = DAMM_V2_MIGRATION_FEE_ADDRESS; exports.DAMM_V2_PROGRAM_ID = DAMM_V2_PROGRAM_ID; exports.DYNAMIC_BONDING_CURVE_PROGRAM_ID = DYNAMIC_BONDING_CURVE_PROGRAM_ID; exports.DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = DYNAMIC_FEE_DECAY_PERIOD_DEFAULT; exports.DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = DYNAMIC_FEE_FILTER_PERIOD_DEFAULT; exports.DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT; exports.DynamicBondingCurveClient = DynamicBondingCurveClient; exports.DynamicBondingCurveProgram = DynamicBondingCurveProgram; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeSchedulerMode = FeeSchedulerMode; exports.GetFeeMode = GetFeeMode; exports.LOCKER_PROGRAM_ID = LOCKER_PROGRAM_ID; exports.MAX_CURVE_POINT = MAX_CURVE_POINT; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_DEFAULT; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MAX_SWALLOW_PERCENTAGE = MAX_SWALLOW_PERCENTAGE; exports.METAPLEX_PROGRAM_ID = METAPLEX_PROGRAM_ID; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.MigrationFeeOption = MigrationFeeOption; exports.MigrationOption = MigrationOption; exports.MigrationService = MigrationService; exports.OFFSET = OFFSET; exports.ONE_Q64 = ONE_Q64; exports.PARTNER_SURPLUS_SHARE = PARTNER_SURPLUS_SHARE; exports.PartnerService = PartnerService; exports.PoolService = PoolService; exports.RESOLUTION = RESOLUTION; exports.Rounding = Rounding; exports.SLOT_DURATION = SLOT_DURATION; exports.SWAP_BUFFER_PERCENTAGE = SWAP_BUFFER_PERCENTAGE; exports.TIMESTAMP_DURATION = TIMESTAMP_DURATION; exports.TokenDecimal = TokenDecimal; exports.TokenType = TokenType; exports.TradeDirection = TradeDirection; exports.U64_MAX = U64_MAX; exports.VAULT_PROGRAM_ID = VAULT_PROGRAM_ID; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.buildCurve = buildCurve; exports.buildCurveWithCreatorFirstBuy = buildCurveWithCreatorFirstBuy; exports.buildCurveWithLiquidityWeights = buildCurveWithLiquidityWeights; exports.buildCurveWithMarketCap = buildCurveWithMarketCap; exports.buildCurveWithTwoSegments = buildCurveWithTwoSegments; exports.convertDecimalToBN = convertDecimalToBN; exports.createDammV1Program = createDammV1Program; exports.createDammV2Program = createDammV2Program; exports.createDbcProgram = createDbcProgram; exports.createInitializePermissionlessDynamicVaultIx = createInitializePermissionlessDynamicVaultIx; exports.createLockEscrowIx = createLockEscrowIx; exports.createProgramAccountFilter = createProgramAccountFilter; exports.createVaultProgram = createVaultProgram; exports.deriveBaseKeyForLocker = deriveBaseKeyForLocker; exports.deriveDammV1EventAuthority = deriveDammV1EventAuthority; exports.deriveDammV1LockEscrowAddress = deriveDammV1LockEscrowAddress; exports.deriveDammV1LpMintAddress = deriveDammV1LpMintAddress; exports.deriveDammV1MigrationMetadataAddress = deriveDammV1MigrationMetadataAddress; exports.deriveDammV1PoolAddress = deriveDammV1PoolAddress; exports.deriveDammV1PoolAuthority = deriveDammV1PoolAuthority; exports.deriveDammV1ProtocolFeeAddress = deriveDammV1ProtocolFeeAddress; exports.deriveDammV1VaultLPAddress = deriveDammV1VaultLPAddress; exports.deriveDammV2EventAuthority = deriveDammV2EventAuthority; exports.deriveDammV2LockEscrowAddress = deriveDammV2LockEscrowAddress; exports.deriveDammV2MigrationMetadataAddress = deriveDammV2MigrationMetadataAddress; exports.deriveDammV2PoolAddress = deriveDammV2PoolAddress; exports.deriveDammV2PoolAuthority = deriveDammV2PoolAuthority; exports.deriveDammV2TokenVaultAddress = deriveDammV2TokenVaultAddress; exports.deriveDbcEventAuthority = deriveDbcEventAuthority; exports.deriveDbcPoolAddress = deriveDbcPoolAddress; exports.deriveDbcPoolAuthority = deriveDbcPoolAuthority; exports.deriveDbcPoolMetadata = deriveDbcPoolMetadata; exports.deriveDbcTokenVaultAddress = deriveDbcTokenVaultAddress; exports.deriveEscrow = deriveEscrow; exports.deriveLockerEventAuthority = deriveLockerEventAuthority; exports.deriveMintMetadata = deriveMintMetadata; exports.derivePartnerMetadata = derivePartnerMetadata; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveTokenVaultKey = deriveTokenVaultKey; exports.deriveVaultAddress = deriveVaultAddress; exports.deriveVaultLpMintAddress = deriveVaultLpMintAddress; exports.deriveVaultPdas = deriveVaultPdas; exports.feeNumeratorToBps = feeNumeratorToBps; exports.findAssociatedTokenAddress = findAssociatedTokenAddress; exports.getAccountCreationTimestamp = getAccountCreationTimestamp; exports.getAccountCreationTimestamps = getAccountCreationTimestamps; exports.getAccountData = getAccountData; exports.getBaseFeeParams = getBaseFeeParams; exports.getBaseTokenForSwap = getBaseTokenForSwap; exports.getCurrentBaseFeeNumerator = getCurrentBaseFeeNumerator; exports.getDeltaAmountBase = getDeltaAmountBase; exports.getDeltaAmountBaseUnsigned = getDeltaAmountBaseUnsigned; exports.getDeltaAmountQuoteUnsigned = getDeltaAmountQuoteUnsigned; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getFeeInPeriod = getFeeInPeriod; exports.getFeeMode = getFeeMode; exports.getFeeOnAmount = getFeeOnAmount; exports.getFirstCurve = getFirstCurve; exports.getFirstKey = getFirstKey; exports.getInitialLiquidityFromDeltaBase = getInitialLiquidityFromDeltaBase; exports.getInitialLiquidityFromDeltaQuote = getInitialLiquidityFromDeltaQuote; exports.getInitializeAmounts = getInitializeAmounts; exports.getLiquidity = getLiquidity; exports.getLockedVestingParams = getLockedVestingParams; exports.getMigrationBaseToken = getMigrationBaseToken; exports.getMigrationQuoteThreshold = getMigrationQuoteThreshold; exports.getMigrationThresholdPrice = getMigrationThresholdPrice; exports.getMinBaseFeeBps = getMinBaseFeeBps; exports.getNextSqrtPriceFromAmountBaseRoundingUp = getNextSqrtPriceFromAmountBaseRoundingUp; exports.getNextSqrtPriceFromAmountQuoteRoundingDown = getNextSqrtPriceFromAmountQuoteRoundingDown; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPercentageSupplyOnMigration = getPercentageSupplyOnMigration; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getSecondKey = getSecondKey; exports.getSqrtPriceFromMarketCap = getSqrtPriceFromMarketCap; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapAmountFromBaseToQuote = getSwapAmountFromBaseToQuote; exports.getSwapAmountFromQuoteToBase = getSwapAmountFromQuoteToBase; exports.getSwapAmountWithBuffer = getSwapAmountWithBuffer; exports.getSwapResult = getSwapResult; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTotalSupplyFromCurve = getTotalSupplyFromCurve; exports.getTotalTokenSupply = getTotalTokenSupply; exports.getTotalVestingAmount = getTotalVestingAmount; exports.getTwoCurve = getTwoCurve; exports.getVariableFee = getVariableFee; exports.isDefaultLockedVesting = isDefaultLockedVesting; exports.isNativeSol = isNativeSol; exports.swapQuote = swapQuote; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateActivationType = validateActivationType; exports.validateBalance = validateBalance; exports.validateBaseTokenType = validateBaseTokenType; exports.validateCollectFeeMode = validateCollectFeeMode; exports.validateConfigParameters = validateConfigParameters; exports.validateCurve = validateCurve; exports.validateLPPercentages = validateLPPercentages; exports.validateMigrationAndTokenType = validateMigrationAndTokenType; exports.validateMigrationFeeOption = validateMigrationFeeOption; exports.validatePoolFees = validatePoolFees; exports.validateSwapAmount = validateSwapAmount; exports.validateTokenDecimals = validateTokenDecimals; exports.validateTokenSupply = validateTokenSupply; exports.wrapSOLInstruction = wrapSOLInstruction;
23118
+
23119
+
23120
+
23121
+ exports.ActivationType = ActivationType; exports.BASE_ADDRESS = BASE_ADDRESS; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.CollectFeeMode = CollectFeeMode; exports.CreatorService = CreatorService; exports.DAMM_V1_MIGRATION_FEE_ADDRESS = DAMM_V1_MIGRATION_FEE_ADDRESS; exports.DAMM_V1_PROGRAM_ID = DAMM_V1_PROGRAM_ID; exports.DAMM_V2_MIGRATION_FEE_ADDRESS = DAMM_V2_MIGRATION_FEE_ADDRESS; exports.DAMM_V2_PROGRAM_ID = DAMM_V2_PROGRAM_ID; exports.DYNAMIC_BONDING_CURVE_PROGRAM_ID = DYNAMIC_BONDING_CURVE_PROGRAM_ID; exports.DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = DYNAMIC_FEE_DECAY_PERIOD_DEFAULT; exports.DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = DYNAMIC_FEE_FILTER_PERIOD_DEFAULT; exports.DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT; exports.DynamicBondingCurveClient = DynamicBondingCurveClient; exports.DynamicBondingCurveProgram = DynamicBondingCurveProgram; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeSchedulerMode = FeeSchedulerMode; exports.GetFeeMode = GetFeeMode; exports.LOCKER_PROGRAM_ID = LOCKER_PROGRAM_ID; exports.MAX_CURVE_POINT = MAX_CURVE_POINT; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_DEFAULT; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MAX_SWALLOW_PERCENTAGE = MAX_SWALLOW_PERCENTAGE; exports.METAPLEX_PROGRAM_ID = METAPLEX_PROGRAM_ID; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.MigrationFeeOption = MigrationFeeOption; exports.MigrationOption = MigrationOption; exports.MigrationService = MigrationService; exports.OFFSET = OFFSET; exports.ONE_Q64 = ONE_Q64; exports.PARTNER_SURPLUS_SHARE = PARTNER_SURPLUS_SHARE; exports.PartnerService = PartnerService; exports.PoolService = PoolService; exports.RESOLUTION = RESOLUTION; exports.Rounding = Rounding; exports.SLOT_DURATION = SLOT_DURATION; exports.SWAP_BUFFER_PERCENTAGE = SWAP_BUFFER_PERCENTAGE; exports.TIMESTAMP_DURATION = TIMESTAMP_DURATION; exports.TokenDecimal = TokenDecimal; exports.TokenType = TokenType; exports.TradeDirection = TradeDirection; exports.U64_MAX = U64_MAX; exports.VAULT_PROGRAM_ID = VAULT_PROGRAM_ID; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.buildCurve = buildCurve; exports.buildCurveWithCreatorFirstBuy = buildCurveWithCreatorFirstBuy; exports.buildCurveWithLiquidityWeights = buildCurveWithLiquidityWeights; exports.buildCurveWithMarketCap = buildCurveWithMarketCap; exports.buildCurveWithTwoSegments = buildCurveWithTwoSegments; exports.cleanUpTokenAccountTx = cleanUpTokenAccountTx; exports.convertDecimalToBN = convertDecimalToBN; exports.createDammV1Program = createDammV1Program; exports.createDammV2Program = createDammV2Program; exports.createDbcProgram = createDbcProgram; exports.createInitializePermissionlessDynamicVaultIx = createInitializePermissionlessDynamicVaultIx; exports.createLockEscrowIx = createLockEscrowIx; exports.createProgramAccountFilter = createProgramAccountFilter; exports.createVaultProgram = createVaultProgram; exports.deriveBaseKeyForLocker = deriveBaseKeyForLocker; exports.deriveDammV1EventAuthority = deriveDammV1EventAuthority; exports.deriveDammV1LockEscrowAddress = deriveDammV1LockEscrowAddress; exports.deriveDammV1LpMintAddress = deriveDammV1LpMintAddress; exports.deriveDammV1MigrationMetadataAddress = deriveDammV1MigrationMetadataAddress; exports.deriveDammV1PoolAddress = deriveDammV1PoolAddress; exports.deriveDammV1PoolAuthority = deriveDammV1PoolAuthority; exports.deriveDammV1ProtocolFeeAddress = deriveDammV1ProtocolFeeAddress; exports.deriveDammV1VaultLPAddress = deriveDammV1VaultLPAddress; exports.deriveDammV2EventAuthority = deriveDammV2EventAuthority; exports.deriveDammV2LockEscrowAddress = deriveDammV2LockEscrowAddress; exports.deriveDammV2MigrationMetadataAddress = deriveDammV2MigrationMetadataAddress; exports.deriveDammV2PoolAddress = deriveDammV2PoolAddress; exports.deriveDammV2PoolAuthority = deriveDammV2PoolAuthority; exports.deriveDammV2TokenVaultAddress = deriveDammV2TokenVaultAddress; exports.deriveDbcEventAuthority = deriveDbcEventAuthority; exports.deriveDbcPoolAddress = deriveDbcPoolAddress; exports.deriveDbcPoolAuthority = deriveDbcPoolAuthority; exports.deriveDbcPoolMetadata = deriveDbcPoolMetadata; exports.deriveDbcTokenVaultAddress = deriveDbcTokenVaultAddress; exports.deriveEscrow = deriveEscrow; exports.deriveLockerEventAuthority = deriveLockerEventAuthority; exports.deriveMintMetadata = deriveMintMetadata; exports.derivePartnerMetadata = derivePartnerMetadata; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveTokenVaultKey = deriveTokenVaultKey; exports.deriveVaultAddress = deriveVaultAddress; exports.deriveVaultLpMintAddress = deriveVaultLpMintAddress; exports.deriveVaultPdas = deriveVaultPdas; exports.feeNumeratorToBps = feeNumeratorToBps; exports.findAssociatedTokenAddress = findAssociatedTokenAddress; exports.getAccountCreationTimestamp = getAccountCreationTimestamp; exports.getAccountCreationTimestamps = getAccountCreationTimestamps; exports.getAccountData = getAccountData; exports.getBaseFeeParams = getBaseFeeParams; exports.getBaseTokenForSwap = getBaseTokenForSwap; exports.getCurrentBaseFeeNumerator = getCurrentBaseFeeNumerator; exports.getDeltaAmountBase = getDeltaAmountBase; exports.getDeltaAmountBaseUnsigned = getDeltaAmountBaseUnsigned; exports.getDeltaAmountQuoteUnsigned = getDeltaAmountQuoteUnsigned; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getFeeInPeriod = getFeeInPeriod; exports.getFeeMode = getFeeMode; exports.getFeeOnAmount = getFeeOnAmount; exports.getFirstCurve = getFirstCurve; exports.getFirstKey = getFirstKey; exports.getInitialLiquidityFromDeltaBase = getInitialLiquidityFromDeltaBase; exports.getInitialLiquidityFromDeltaQuote = getInitialLiquidityFromDeltaQuote; exports.getInitializeAmounts = getInitializeAmounts; exports.getLiquidity = getLiquidity; exports.getLockedVestingParams = getLockedVestingParams; exports.getMigrationBaseToken = getMigrationBaseToken; exports.getMigrationQuoteThreshold = getMigrationQuoteThreshold; exports.getMigrationThresholdPrice = getMigrationThresholdPrice; exports.getMinBaseFeeBps = getMinBaseFeeBps; exports.getNextSqrtPriceFromAmountBaseRoundingUp = getNextSqrtPriceFromAmountBaseRoundingUp; exports.getNextSqrtPriceFromAmountQuoteRoundingDown = getNextSqrtPriceFromAmountQuoteRoundingDown; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPercentageSupplyOnMigration = getPercentageSupplyOnMigration; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getSecondKey = getSecondKey; exports.getSqrtPriceFromMarketCap = getSqrtPriceFromMarketCap; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapAmountFromBaseToQuote = getSwapAmountFromBaseToQuote; exports.getSwapAmountFromQuoteToBase = getSwapAmountFromQuoteToBase; exports.getSwapAmountWithBuffer = getSwapAmountWithBuffer; exports.getSwapResult = getSwapResult; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTokenType = getTokenType; exports.getTotalSupplyFromCurve = getTotalSupplyFromCurve; exports.getTotalTokenSupply = getTotalTokenSupply; exports.getTotalVestingAmount = getTotalVestingAmount; exports.getTwoCurve = getTwoCurve; exports.getVariableFee = getVariableFee; exports.isDefaultLockedVesting = isDefaultLockedVesting; exports.isNativeSol = isNativeSol; exports.prepareTokenAccountTx = prepareTokenAccountTx; exports.swapQuote = swapQuote; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateActivationType = validateActivationType; exports.validateBalance = validateBalance; exports.validateBaseTokenType = validateBaseTokenType; exports.validateCollectFeeMode = validateCollectFeeMode; exports.validateConfigParameters = validateConfigParameters; exports.validateCurve = validateCurve; exports.validateLPPercentages = validateLPPercentages; exports.validateMigrationAndTokenType = validateMigrationAndTokenType; exports.validateMigrationFeeOption = validateMigrationFeeOption; exports.validatePoolFees = validatePoolFees; exports.validateSwapAmount = validateSwapAmount; exports.validateTokenDecimals = validateTokenDecimals; exports.validateTokenSupply = validateTokenSupply; exports.wrapSOLInstruction = wrapSOLInstruction;
22925
23122
  //# sourceMappingURL=index.cjs.map