@meteora-ag/dynamic-bonding-curve-sdk 1.4.6 → 1.4.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
@@ -7,10 +7,10 @@
7
7
  var _web3js = require('@solana/web3.js');
8
8
 
9
9
  // src/types.ts
10
- var ActivationType = /* @__PURE__ */ ((ActivationType3) => {
11
- ActivationType3[ActivationType3["Slot"] = 0] = "Slot";
12
- ActivationType3[ActivationType3["Timestamp"] = 1] = "Timestamp";
13
- return ActivationType3;
10
+ var ActivationType = /* @__PURE__ */ ((ActivationType4) => {
11
+ ActivationType4[ActivationType4["Slot"] = 0] = "Slot";
12
+ ActivationType4[ActivationType4["Timestamp"] = 1] = "Timestamp";
13
+ return ActivationType4;
14
14
  })(ActivationType || {});
15
15
  var TokenType = /* @__PURE__ */ ((TokenType2) => {
16
16
  TokenType2[TokenType2["SPL"] = 0] = "SPL";
@@ -25148,7 +25148,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
25148
25148
  * @param quoteMint - The quote mint token
25149
25149
  * @returns Instructions for the first buy
25150
25150
  */
25151
- async swapBuyTx(firstBuyParam, baseMint, config, baseFee, swapBaseForQuote, currentPoint, tokenType, quoteMint) {
25151
+ async swapBuyTx(firstBuyParam, baseMint, config, baseFee, swapBaseForQuote, activationType, tokenType, quoteMint) {
25152
25152
  const {
25153
25153
  buyer,
25154
25154
  receiver,
@@ -25157,14 +25157,21 @@ var PoolService = class extends DynamicBondingCurveProgram {
25157
25157
  referralTokenAccount
25158
25158
  } = firstBuyParam;
25159
25159
  validateSwapAmount(buyAmount);
25160
- const rateLimiterApplied = isRateLimiterApplied(
25161
- currentPoint,
25162
- new (0, _bnjs2.default)(0),
25163
- swapBaseForQuote ? 0 /* BaseToQuote */ : 1 /* QuoteToBase */,
25164
- baseFee.secondFactor,
25165
- baseFee.thirdFactor,
25166
- new (0, _bnjs2.default)(baseFee.firstFactor)
25167
- );
25160
+ let rateLimiterApplied = false;
25161
+ if (baseFee.baseFeeMode === 2 /* RateLimiter */) {
25162
+ const currentPoint = await getCurrentPoint(
25163
+ this.connection,
25164
+ activationType
25165
+ );
25166
+ rateLimiterApplied = isRateLimiterApplied(
25167
+ currentPoint,
25168
+ new (0, _bnjs2.default)(0),
25169
+ swapBaseForQuote ? 0 /* BaseToQuote */ : 1 /* QuoteToBase */,
25170
+ baseFee.secondFactor,
25171
+ baseFee.thirdFactor,
25172
+ new (0, _bnjs2.default)(baseFee.firstFactor)
25173
+ );
25174
+ }
25168
25175
  const quoteTokenFlag = await getTokenType(this.connection, quoteMint);
25169
25176
  const { inputMint, outputMint, inputTokenProgram, outputTokenProgram } = this.prepareSwapParams(
25170
25177
  false,
@@ -25377,10 +25384,6 @@ var PoolService = class extends DynamicBondingCurveProgram {
25377
25384
  params.tokenType,
25378
25385
  quoteMintToken
25379
25386
  );
25380
- const currentPoint = await getCurrentPoint(
25381
- this.connection,
25382
- configParam.activationType
25383
- );
25384
25387
  let swapBuyTx;
25385
25388
  if (params.firstBuyParam && params.firstBuyParam.buyAmount.gt(new (0, _bnjs2.default)(0))) {
25386
25389
  swapBuyTx = await this.swapBuyTx(
@@ -25389,7 +25392,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
25389
25392
  configKey,
25390
25393
  configParam.poolFees.baseFee,
25391
25394
  false,
25392
- currentPoint,
25395
+ configParam.activationType,
25393
25396
  params.tokenType,
25394
25397
  quoteMintToken
25395
25398
  );
@@ -25419,10 +25422,6 @@ var PoolService = class extends DynamicBondingCurveProgram {
25419
25422
  tokenType,
25420
25423
  quoteMint
25421
25424
  );
25422
- const currentPoint = await getCurrentPoint(
25423
- this.connection,
25424
- poolConfigState.activationType
25425
- );
25426
25425
  let swapBuyTx;
25427
25426
  if (firstBuyParam && firstBuyParam.buyAmount.gt(new (0, _bnjs2.default)(0))) {
25428
25427
  swapBuyTx = await this.swapBuyTx(
@@ -25431,7 +25430,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
25431
25430
  config,
25432
25431
  poolConfigState.poolFees.baseFee,
25433
25432
  false,
25434
- currentPoint,
25433
+ poolConfigState.activationType,
25435
25434
  tokenType,
25436
25435
  quoteMint
25437
25436
  );
@@ -25458,10 +25457,6 @@ var PoolService = class extends DynamicBondingCurveProgram {
25458
25457
  tokenType,
25459
25458
  quoteMint
25460
25459
  );
25461
- const currentPoint = await getCurrentPoint(
25462
- this.connection,
25463
- poolConfigState.activationType
25464
- );
25465
25460
  let partnerSwapBuyTx;
25466
25461
  if (partnerFirstBuyParam && partnerFirstBuyParam.buyAmount.gt(new (0, _bnjs2.default)(0))) {
25467
25462
  partnerSwapBuyTx = await this.swapBuyTx(
@@ -25476,7 +25471,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
25476
25471
  config,
25477
25472
  poolConfigState.poolFees.baseFee,
25478
25473
  false,
25479
- currentPoint,
25474
+ poolConfigState.activationType,
25480
25475
  tokenType,
25481
25476
  quoteMint
25482
25477
  );
@@ -25495,7 +25490,7 @@ var PoolService = class extends DynamicBondingCurveProgram {
25495
25490
  config,
25496
25491
  poolConfigState.poolFees.baseFee,
25497
25492
  false,
25498
- currentPoint,
25493
+ poolConfigState.activationType,
25499
25494
  tokenType,
25500
25495
  quoteMint
25501
25496
  );
@@ -25536,18 +25531,21 @@ var PoolService = class extends DynamicBondingCurveProgram {
25536
25531
  throw new Error(`Pool config not found for virtual pool`);
25537
25532
  }
25538
25533
  validateSwapAmount(amountIn);
25539
- const currentPoint = await getCurrentPoint(
25540
- this.connection,
25541
- poolConfigState.activationType
25542
- );
25543
- const rateLimiterApplied = isRateLimiterApplied(
25544
- currentPoint,
25545
- poolState.activationPoint,
25546
- swapBaseForQuote ? 0 /* BaseToQuote */ : 1 /* QuoteToBase */,
25547
- poolConfigState.poolFees.baseFee.secondFactor,
25548
- poolConfigState.poolFees.baseFee.thirdFactor,
25549
- new (0, _bnjs2.default)(poolConfigState.poolFees.baseFee.firstFactor)
25550
- );
25534
+ let rateLimiterApplied = false;
25535
+ if (poolConfigState.poolFees.baseFee.baseFeeMode === 2 /* RateLimiter */) {
25536
+ const currentPoint = await getCurrentPoint(
25537
+ this.connection,
25538
+ poolConfigState.activationType
25539
+ );
25540
+ rateLimiterApplied = isRateLimiterApplied(
25541
+ currentPoint,
25542
+ poolState.activationPoint,
25543
+ swapBaseForQuote ? 0 /* BaseToQuote */ : 1 /* QuoteToBase */,
25544
+ poolConfigState.poolFees.baseFee.secondFactor,
25545
+ poolConfigState.poolFees.baseFee.thirdFactor,
25546
+ new (0, _bnjs2.default)(poolConfigState.poolFees.baseFee.firstFactor)
25547
+ );
25548
+ }
25551
25549
  const { inputMint, outputMint, inputTokenProgram, outputTokenProgram } = this.prepareSwapParams(swapBaseForQuote, poolState, poolConfigState);
25552
25550
  const {
25553
25551
  ataTokenA: inputTokenAccount,
@@ -25644,18 +25642,21 @@ var PoolService = class extends DynamicBondingCurveProgram {
25644
25642
  if (!poolConfigState) {
25645
25643
  throw new Error(`Pool config not found for virtual pool`);
25646
25644
  }
25647
- const currentPoint = await getCurrentPoint(
25648
- this.connection,
25649
- poolConfigState.activationType
25650
- );
25651
- const rateLimiterApplied = isRateLimiterApplied(
25652
- currentPoint,
25653
- poolState.activationPoint,
25654
- swapBaseForQuote ? 0 /* BaseToQuote */ : 1 /* QuoteToBase */,
25655
- poolConfigState.poolFees.baseFee.secondFactor,
25656
- poolConfigState.poolFees.baseFee.thirdFactor,
25657
- new (0, _bnjs2.default)(poolConfigState.poolFees.baseFee.firstFactor)
25658
- );
25645
+ let rateLimiterApplied = false;
25646
+ if (poolConfigState.poolFees.baseFee.baseFeeMode === 2 /* RateLimiter */) {
25647
+ const currentPoint = await getCurrentPoint(
25648
+ this.connection,
25649
+ poolConfigState.activationType
25650
+ );
25651
+ rateLimiterApplied = isRateLimiterApplied(
25652
+ currentPoint,
25653
+ poolState.activationPoint,
25654
+ swapBaseForQuote ? 0 /* BaseToQuote */ : 1 /* QuoteToBase */,
25655
+ poolConfigState.poolFees.baseFee.secondFactor,
25656
+ poolConfigState.poolFees.baseFee.thirdFactor,
25657
+ new (0, _bnjs2.default)(poolConfigState.poolFees.baseFee.firstFactor)
25658
+ );
25659
+ }
25659
25660
  const { inputMint, outputMint, inputTokenProgram, outputTokenProgram } = this.prepareSwapParams(swapBaseForQuote, poolState, poolConfigState);
25660
25661
  const {
25661
25662
  ataTokenA: inputTokenAccount,