@meteora-ag/dynamic-bonding-curve-sdk 1.4.9 → 1.4.10-rc.0

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
@@ -83,29 +83,44 @@ var SwapMode = /* @__PURE__ */ ((SwapMode2) => {
83
83
  // src/constants.ts
84
84
  var _bnjs = require('bn.js'); var _bnjs2 = _interopRequireDefault(_bnjs);
85
85
 
86
+ var MAX_CURVE_POINT = 16;
86
87
  var OFFSET = 64;
87
- var U128_MAX = new (0, _bnjs2.default)("340282366920938463463374607431768211455");
88
- var U64_MAX = new (0, _bnjs2.default)("18446744073709551615");
89
- var U16_MAX = 65535;
90
- var MIN_SQRT_PRICE = new (0, _bnjs2.default)("4295048016");
91
- var MAX_SQRT_PRICE = new (0, _bnjs2.default)("79226673521066979257578248091");
92
88
  var RESOLUTION = 64;
93
89
  var ONE_Q64 = new (0, _bnjs2.default)(1).shln(RESOLUTION);
94
90
  var FEE_DENOMINATOR = 1e9;
91
+ var MAX_BASIS_POINT = 1e4;
92
+ var U16_MAX = 65535;
93
+ var U64_MAX = new (0, _bnjs2.default)("18446744073709551615");
94
+ var U128_MAX = new (0, _bnjs2.default)("340282366920938463463374607431768211455");
95
+ var MIN_SQRT_PRICE = new (0, _bnjs2.default)("4295048016");
96
+ var MAX_SQRT_PRICE = new (0, _bnjs2.default)("79226673521066979257578248091");
95
97
  var MIN_FEE_BPS = 25;
96
98
  var MAX_FEE_BPS = 9900;
97
99
  var MIN_FEE_NUMERATOR = 25e5;
98
100
  var MAX_FEE_NUMERATOR = 99e7;
99
- var BASIS_POINT_MAX = 1e4;
100
- var MAX_CURVE_POINT = 16;
101
- var PARTNER_SURPLUS_SHARE = 80;
101
+ var MAX_RATE_LIMITER_DURATION_IN_SECONDS = 43200;
102
+ var MAX_RATE_LIMITER_DURATION_IN_SLOTS = 108e3;
103
+ var DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = 10;
104
+ var DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = 120;
105
+ var DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = 5e3;
106
+ var DYNAMIC_FEE_SCALING_FACTOR = new (0, _bnjs2.default)(1e11);
107
+ var DYNAMIC_FEE_ROUNDING_OFFSET = new (0, _bnjs2.default)(99999999999);
108
+ var BIN_STEP_BPS_DEFAULT = 1;
109
+ var BIN_STEP_BPS_U128_DEFAULT = new (0, _bnjs2.default)("1844674407370955");
110
+ var MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT = 20;
111
+ var PROTOCOL_FEE_PERCENT = 20;
112
+ var HOST_FEE_PERCENT = 20;
102
113
  var SWAP_BUFFER_PERCENTAGE = 25;
103
114
  var MAX_MIGRATION_FEE_PERCENTAGE = 99;
104
115
  var MAX_CREATOR_MIGRATION_FEE_PERCENTAGE = 100;
105
- var MAX_RATE_LIMITER_DURATION_IN_SECONDS = 43200;
106
- var MAX_RATE_LIMITER_DURATION_IN_SLOTS = 108e3;
107
- var SLOT_DURATION = 400;
108
- var TIMESTAMP_DURATION = 1e3;
116
+ var MIN_LOCKED_LIQUIDITY_BPS = 1e3;
117
+ var SECONDS_PER_DAY = 86400;
118
+ var MAX_LOCK_DURATION_IN_SECONDS = 63072e3;
119
+ var PROTOCOL_POOL_CREATION_FEE_PERCENT = 10;
120
+ var MIN_POOL_CREATION_FEE = 1e6;
121
+ var MAX_POOL_CREATION_FEE = 1e11;
122
+ var MIN_MIGRATED_POOL_FEE_BPS = 10;
123
+ var MAX_MIGRATED_POOL_FEE_BPS = 1e3;
109
124
  var DYNAMIC_BONDING_CURVE_PROGRAM_ID = new (0, _web3js.PublicKey)(
110
125
  "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN"
111
126
  );
@@ -127,17 +142,6 @@ var LOCKER_PROGRAM_ID = new (0, _web3js.PublicKey)(
127
142
  var BASE_ADDRESS = new (0, _web3js.PublicKey)(
128
143
  "HWzXGcGHy4tcpYfaRDCyLNzXqBTv3E6BttpCH2vJxArv"
129
144
  );
130
- var DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = 10;
131
- var DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = 120;
132
- var DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = 5e3;
133
- var MAX_DYNAMIC_FEE_PERCENTAGE = 20;
134
- var DYNAMIC_FEE_SCALING_FACTOR = new (0, _bnjs2.default)(1e11);
135
- var DYNAMIC_FEE_ROUNDING_OFFSET = new (0, _bnjs2.default)(99999999999);
136
- var BIN_STEP_BPS_DEFAULT = 1;
137
- var BIN_STEP_BPS_U128_DEFAULT = new (0, _bnjs2.default)("1844674407370955");
138
- var MAX_PRICE_CHANGE_BPS_DEFAULT = 1500;
139
- var MIN_MIGRATED_POOL_FEE_BPS = 10;
140
- var MAX_MIGRATED_POOL_FEE_BPS = 1e3;
141
145
  var DAMM_V1_MIGRATION_FEE_ADDRESS = [
142
146
  new (0, _web3js.PublicKey)("8f848CEy8eY6PhJ3VcemtBDzPPSD4Vq7aJczLZ3o8MmX"),
143
147
  // FixedBps25
@@ -168,6 +172,13 @@ var DAMM_V2_MIGRATION_FEE_ADDRESS = [
168
172
  new (0, _web3js.PublicKey)("A8gMrEPJkacWkcb3DGwtJwTe16HktSEfvwtuDh2MCtck")
169
173
  // Customizable
170
174
  ];
175
+ var DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS = {
176
+ vestingPercentage: 0,
177
+ bpsPerPeriod: 0,
178
+ numberOfPeriods: 0,
179
+ cliffDurationFromMigrationTime: 0,
180
+ totalDuration: 0
181
+ };
171
182
 
172
183
  // src/helpers/common.ts
173
184
 
@@ -512,10 +523,10 @@ function convertDecimalToBN(value) {
512
523
  return new (0, _bnjs2.default)(value.floor().toFixed());
513
524
  }
514
525
  function bpsToFeeNumerator(bps) {
515
- return new (0, _bnjs2.default)(bps * FEE_DENOMINATOR).divn(BASIS_POINT_MAX);
526
+ return new (0, _bnjs2.default)(bps * FEE_DENOMINATOR).divn(MAX_BASIS_POINT);
516
527
  }
517
528
  function feeNumeratorToBps(feeNumerator) {
518
- return feeNumerator.muln(BASIS_POINT_MAX).div(new (0, _bnjs2.default)(FEE_DENOMINATOR)).toNumber();
529
+ return feeNumerator.muln(MAX_BASIS_POINT).div(new (0, _bnjs2.default)(FEE_DENOMINATOR)).toNumber();
519
530
  }
520
531
 
521
532
  // src/helpers/token.ts
@@ -717,7 +728,7 @@ function getTotalTokenSupply(swapBaseAmount, migrationBaseThreshold, lockedVesti
717
728
  }
718
729
  return totalAmount;
719
730
  } catch (error) {
720
- throw new Error("Math overflow");
731
+ throw new Error(`Math overflow: ${error}`);
721
732
  }
722
733
  }
723
734
  function getPriceFromSqrtPrice(sqrtPrice, tokenBaseDecimal, tokenQuoteDecimal) {
@@ -737,8 +748,17 @@ var getSqrtPriceFromPrice = (price, tokenADecimal, tokenBDecimal) => {
737
748
  const sqrtValueQ64 = sqrtValue.mul(_decimaljs2.default.pow(2, 64));
738
749
  return new (0, _bnjs2.default)(sqrtValueQ64.floor().toFixed());
739
750
  };
751
+ var createSqrtPrices = (prices, tokenBaseDecimal, tokenQuoteDecimal) => {
752
+ return prices.map(
753
+ (price) => getSqrtPriceFromPrice(
754
+ price.toString(),
755
+ tokenBaseDecimal,
756
+ tokenQuoteDecimal
757
+ )
758
+ );
759
+ };
740
760
  var getSqrtPriceFromMarketCap = (marketCap, totalSupply, tokenBaseDecimal, tokenQuoteDecimal) => {
741
- let price = new (0, _decimaljs2.default)(marketCap).div(new (0, _decimaljs2.default)(totalSupply));
761
+ const price = new (0, _decimaljs2.default)(marketCap).div(new (0, _decimaljs2.default)(totalSupply));
742
762
  return getSqrtPriceFromPrice(
743
763
  price.toString(),
744
764
  tokenBaseDecimal,
@@ -924,8 +944,8 @@ var getMigrationThresholdPrice = (migrationThreshold, sqrtStartPrice, curve) =>
924
944
  }
925
945
  }
926
946
  if (!amountLeft.isZero()) {
927
- let migrationThresholdStr = migrationThreshold.toString();
928
- let amountLeftStr = amountLeft.toString();
947
+ const migrationThresholdStr = migrationThreshold.toString();
948
+ const amountLeftStr = amountLeft.toString();
929
949
  throw Error(
930
950
  `Not enough liquidity, migrationThreshold: ${migrationThresholdStr} amountLeft: ${amountLeftStr}`
931
951
  );
@@ -1004,6 +1024,21 @@ var getPercentageSupplyOnMigration = (initialMarketCap, migrationMarketCap, lock
1004
1024
  const denominator = new (0, _decimaljs2.default)(1).add(sqrtRatio);
1005
1025
  return numerator.div(denominator).toNumber();
1006
1026
  };
1027
+ function calculateAdjustedPercentageSupplyOnMigration(initialMarketCap, migrationMarketCap, migrationFee, lockedVesting, totalLeftover, totalTokenSupply) {
1028
+ const D = new (0, _decimaljs2.default)(initialMarketCap);
1029
+ const M = new (0, _decimaljs2.default)(migrationMarketCap);
1030
+ const f = new (0, _decimaljs2.default)(migrationFee.feePercentage).div(100);
1031
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
1032
+ const V = new (0, _decimaljs2.default)(totalVestingAmount.toString()).mul(100).div(new (0, _decimaljs2.default)(totalTokenSupply.toString()));
1033
+ const L = new (0, _decimaljs2.default)(totalLeftover.toString()).mul(100).div(new (0, _decimaljs2.default)(totalTokenSupply.toString()));
1034
+ const requiredRatio = _decimaljs2.default.sqrt(D.div(M));
1035
+ const oneMinusF = new (0, _decimaljs2.default)(1).sub(f);
1036
+ const availablePercentage = new (0, _decimaljs2.default)(100).sub(V).sub(L);
1037
+ const numerator = requiredRatio.mul(oneMinusF).mul(availablePercentage);
1038
+ const denominator = new (0, _decimaljs2.default)(1).add(requiredRatio.mul(oneMinusF));
1039
+ const percentageSupplyOnMigration = numerator.div(denominator).toNumber();
1040
+ return percentageSupplyOnMigration;
1041
+ }
1007
1042
  var getMigrationQuoteAmount = (migrationMarketCap, percentageSupplyOnMigration) => {
1008
1043
  return migrationMarketCap.mul(percentageSupplyOnMigration).div(new (0, _decimaljs2.default)(100));
1009
1044
  };
@@ -1030,6 +1065,11 @@ function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode
1030
1065
  `startingBaseFeeBps (${startingBaseFeeBps} bps) exceeds maximum allowed value of ${MAX_FEE_BPS} bps`
1031
1066
  );
1032
1067
  }
1068
+ if (endingBaseFeeBps < MIN_FEE_BPS) {
1069
+ throw new Error(
1070
+ `endingBaseFeeBps (${endingBaseFeeBps} bps) is less than minimum allowed value of ${MIN_FEE_BPS} bps`
1071
+ );
1072
+ }
1033
1073
  if (endingBaseFeeBps > startingBaseFeeBps) {
1034
1074
  throw new Error(
1035
1075
  "endingBaseFeeBps bps must be less than or equal to startingBaseFeeBps bps"
@@ -1050,7 +1090,7 @@ function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode
1050
1090
  } else {
1051
1091
  const ratio = minBaseFeeNumerator.toNumber() / maxBaseFeeNumerator.toNumber();
1052
1092
  const decayBase = Math.pow(ratio, 1 / numberOfPeriod);
1053
- reductionFactor = new (0, _bnjs2.default)(BASIS_POINT_MAX * (1 - decayBase));
1093
+ reductionFactor = new (0, _bnjs2.default)(MAX_BASIS_POINT * (1 - decayBase));
1054
1094
  }
1055
1095
  return {
1056
1096
  cliffFeeNumerator: maxBaseFeeNumerator,
@@ -1062,16 +1102,16 @@ function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode
1062
1102
  }
1063
1103
  function calculateFeeSchedulerEndingBaseFeeBps(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, baseFeeMode) {
1064
1104
  if (numberOfPeriod === 0 || periodFrequency === 0) {
1065
- return cliffFeeNumerator / FEE_DENOMINATOR * BASIS_POINT_MAX;
1105
+ return cliffFeeNumerator / FEE_DENOMINATOR * MAX_BASIS_POINT;
1066
1106
  }
1067
1107
  let baseFeeNumerator;
1068
1108
  if (baseFeeMode == 0 /* FeeSchedulerLinear */) {
1069
1109
  baseFeeNumerator = cliffFeeNumerator - numberOfPeriod * reductionFactor;
1070
1110
  } else {
1071
- const decayRate = 1 - reductionFactor / BASIS_POINT_MAX;
1111
+ const decayRate = 1 - reductionFactor / MAX_BASIS_POINT;
1072
1112
  baseFeeNumerator = cliffFeeNumerator * Math.pow(decayRate, numberOfPeriod);
1073
1113
  }
1074
- return Math.max(0, baseFeeNumerator / FEE_DENOMINATOR * BASIS_POINT_MAX);
1114
+ return Math.max(0, baseFeeNumerator / FEE_DENOMINATOR * MAX_BASIS_POINT);
1075
1115
  }
1076
1116
  function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxLimiterDuration, tokenQuoteDecimal, activationType) {
1077
1117
  const cliffFeeNumerator = bpsToFeeNumerator(baseFeeBps);
@@ -1084,6 +1124,11 @@ function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxL
1084
1124
  `Base fee (${baseFeeBps} bps) exceeds maximum allowed value of ${MAX_FEE_BPS} bps`
1085
1125
  );
1086
1126
  }
1127
+ if (baseFeeBps < MIN_FEE_BPS) {
1128
+ throw new Error(
1129
+ `Base fee (${baseFeeBps} bps) is less than minimum allowed value of ${MIN_FEE_BPS} bps`
1130
+ );
1131
+ }
1087
1132
  if (feeIncrementBps > MAX_FEE_BPS) {
1088
1133
  throw new Error(
1089
1134
  `Fee increment (${feeIncrementBps} bps) exceeds maximum allowed value of ${MAX_FEE_BPS} bps`
@@ -1120,21 +1165,21 @@ function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxL
1120
1165
  baseFeeMode: 2 /* RateLimiter */
1121
1166
  };
1122
1167
  }
1123
- function getDynamicFeeParams(baseFeeBps, maxPriceChangeBps = MAX_PRICE_CHANGE_BPS_DEFAULT) {
1124
- if (maxPriceChangeBps > MAX_PRICE_CHANGE_BPS_DEFAULT) {
1168
+ function getDynamicFeeParams(baseFeeBps, maxPriceChangePercentage = MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT) {
1169
+ if (maxPriceChangePercentage > MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT) {
1125
1170
  throw new Error(
1126
- `maxPriceChangeBps (${maxPriceChangeBps} bps) must be less than or equal to ${MAX_PRICE_CHANGE_BPS_DEFAULT}`
1171
+ `maxPriceChangePercentage (${maxPriceChangePercentage}%) must be less than or equal to ${MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT}`
1127
1172
  );
1128
1173
  }
1129
- const priceRatio = maxPriceChangeBps / BASIS_POINT_MAX + 1;
1174
+ const priceRatio = maxPriceChangePercentage / MAX_BASIS_POINT + 1;
1130
1175
  const sqrtPriceRatioQ64 = new (0, _bnjs2.default)(
1131
1176
  _decimaljs2.default.sqrt(priceRatio.toString()).mul(_decimaljs2.default.pow(2, 64)).floor().toFixed()
1132
1177
  );
1133
1178
  const deltaBinId = sqrtPriceRatioQ64.sub(ONE_Q64).div(BIN_STEP_BPS_U128_DEFAULT).muln(2);
1134
- const maxVolatilityAccumulator = new (0, _bnjs2.default)(deltaBinId.muln(BASIS_POINT_MAX));
1179
+ const maxVolatilityAccumulator = new (0, _bnjs2.default)(deltaBinId.muln(MAX_BASIS_POINT));
1135
1180
  const squareVfaBin = maxVolatilityAccumulator.mul(new (0, _bnjs2.default)(BIN_STEP_BPS_DEFAULT)).pow(new (0, _bnjs2.default)(2));
1136
1181
  const baseFeeNumerator = new (0, _bnjs2.default)(bpsToFeeNumerator(baseFeeBps));
1137
- const maxDynamicFeeNumerator = baseFeeNumerator.muln(20).divn(100);
1182
+ const maxDynamicFeeNumerator = baseFeeNumerator.muln(maxPriceChangePercentage).divn(100);
1138
1183
  const vFee = maxDynamicFeeNumerator.mul(new (0, _bnjs2.default)(1e11)).sub(new (0, _bnjs2.default)(99999999999));
1139
1184
  const variableFeeControl = vFee.div(squareVfaBin);
1140
1185
  return {
@@ -1204,20 +1249,83 @@ function getLockedVestingParams(totalLockedVestingAmount, numberOfVestingPeriod,
1204
1249
  )
1205
1250
  };
1206
1251
  }
1252
+ var getLiquidityVestingInfoParams = (vestingPercentage, bpsPerPeriod, numberOfPeriods, cliffDurationFromMigrationTime, totalDuration) => {
1253
+ if (vestingPercentage < 0 || vestingPercentage > 100) {
1254
+ throw new Error("vestingPercentage must be between 0 and 100");
1255
+ }
1256
+ if (vestingPercentage === 0) {
1257
+ if (bpsPerPeriod !== 0 || numberOfPeriods !== 0 || cliffDurationFromMigrationTime !== 0 || totalDuration !== 0) {
1258
+ throw new Error(
1259
+ "If vestingPercentage is 0, all other parameters must be 0"
1260
+ );
1261
+ }
1262
+ return {
1263
+ vestingPercentage: 0,
1264
+ bpsPerPeriod: 0,
1265
+ numberOfPeriods: 0,
1266
+ cliffDurationFromMigrationTime: 0,
1267
+ frequency: 0
1268
+ };
1269
+ }
1270
+ if (bpsPerPeriod < 0 || bpsPerPeriod > MAX_BASIS_POINT) {
1271
+ throw new Error(`bpsPerPeriod must be between 0 and ${MAX_BASIS_POINT}`);
1272
+ }
1273
+ if (numberOfPeriods <= 0) {
1274
+ throw new Error(
1275
+ "numberOfPeriods must be greater than zero when vestingPercentage > 0"
1276
+ );
1277
+ }
1278
+ if (cliffDurationFromMigrationTime < 0) {
1279
+ throw new Error("cliffDurationFromMigrationTime must be >= 0");
1280
+ }
1281
+ if (totalDuration <= 0) {
1282
+ throw new Error("totalDuration must be greater than zero");
1283
+ }
1284
+ const frequency = totalDuration / numberOfPeriods;
1285
+ if (frequency <= 0) {
1286
+ throw new Error(
1287
+ "frequency must be greater than zero (totalDuration / numberOfPeriods must be > 0)"
1288
+ );
1289
+ }
1290
+ const totalBps = bpsPerPeriod * numberOfPeriods;
1291
+ if (totalBps > MAX_BASIS_POINT) {
1292
+ throw new Error(
1293
+ `Total BPS (bpsPerPeriod * numberOfPeriods = ${totalBps}) must not exceed ${MAX_BASIS_POINT}`
1294
+ );
1295
+ }
1296
+ const totalVestingDuration = cliffDurationFromMigrationTime + numberOfPeriods * frequency;
1297
+ if (totalVestingDuration > MAX_LOCK_DURATION_IN_SECONDS) {
1298
+ throw new Error(
1299
+ `Total vesting duration (${totalVestingDuration}s) must not exceed ${MAX_LOCK_DURATION_IN_SECONDS}s (2 years)`
1300
+ );
1301
+ }
1302
+ if (cliffDurationFromMigrationTime === 0 && numberOfPeriods === 0) {
1303
+ throw new Error(
1304
+ "If cliffDurationFromMigrationTime is 0, numberOfPeriods must be > 0"
1305
+ );
1306
+ }
1307
+ return {
1308
+ vestingPercentage,
1309
+ bpsPerPeriod,
1310
+ numberOfPeriods,
1311
+ cliffDurationFromMigrationTime,
1312
+ frequency: Math.round(frequency)
1313
+ };
1314
+ };
1207
1315
  var getTwoCurve = (migrationSqrtPrice, midSqrtPrice, initialSqrtPrice, swapAmount, migrationQuoteThreshold) => {
1208
- let p0 = new (0, _decimaljs2.default)(initialSqrtPrice.toString());
1209
- let p1 = new (0, _decimaljs2.default)(midSqrtPrice.toString());
1210
- let p2 = new (0, _decimaljs2.default)(migrationSqrtPrice.toString());
1211
- let a1 = new (0, _decimaljs2.default)(1).div(p0).sub(new (0, _decimaljs2.default)(1).div(p1));
1212
- let b1 = new (0, _decimaljs2.default)(1).div(p1).sub(new (0, _decimaljs2.default)(1).div(p2));
1213
- let c1 = new (0, _decimaljs2.default)(swapAmount.toString());
1214
- let a2 = p1.sub(p0);
1215
- let b2 = p2.sub(p1);
1216
- let c2 = new (0, _decimaljs2.default)(migrationQuoteThreshold.toString()).mul(
1316
+ const p0 = new (0, _decimaljs2.default)(initialSqrtPrice.toString());
1317
+ const p1 = new (0, _decimaljs2.default)(midSqrtPrice.toString());
1318
+ const p2 = new (0, _decimaljs2.default)(migrationSqrtPrice.toString());
1319
+ const a1 = new (0, _decimaljs2.default)(1).div(p0).sub(new (0, _decimaljs2.default)(1).div(p1));
1320
+ const b1 = new (0, _decimaljs2.default)(1).div(p1).sub(new (0, _decimaljs2.default)(1).div(p2));
1321
+ const c1 = new (0, _decimaljs2.default)(swapAmount.toString());
1322
+ const a2 = p1.sub(p0);
1323
+ const b2 = p2.sub(p1);
1324
+ const c2 = new (0, _decimaljs2.default)(migrationQuoteThreshold.toString()).mul(
1217
1325
  _decimaljs2.default.pow(2, 128)
1218
1326
  );
1219
- let l0 = c1.mul(b2).sub(c2.mul(b1)).div(a1.mul(b2).sub(a2.mul(b1)));
1220
- let l1 = c1.mul(a2).sub(c2.mul(a1)).div(b1.mul(a2).sub(b2.mul(a1)));
1327
+ const l0 = c1.mul(b2).sub(c2.mul(b1)).div(a1.mul(b2).sub(a2.mul(b1)));
1328
+ const l1 = c1.mul(a2).sub(c2.mul(a1)).div(b1.mul(a2).sub(b2.mul(a1)));
1221
1329
  if (l0.isNeg() || l1.isNeg()) {
1222
1330
  return {
1223
1331
  isOk: false,
@@ -1344,8 +1452,72 @@ async function prepareSwapAmountParam(amount, mintAddress, connection) {
1344
1452
  const mintTokenDecimals = await getTokenDecimals(connection, mintAddress);
1345
1453
  return convertToLamports(amount, mintTokenDecimals);
1346
1454
  }
1455
+ function getVestingLockedLiquidityBpsAtNSeconds(vestingInfo, nSeconds) {
1456
+ if (!vestingInfo || vestingInfo.vestingPercentage === 0) {
1457
+ return 0;
1458
+ }
1459
+ const totalLiquidity = U128_MAX;
1460
+ const totalVestedLiquidity = totalLiquidity.mul(new (0, _bnjs2.default)(vestingInfo.vestingPercentage)).div(new (0, _bnjs2.default)(100));
1461
+ const bpsPerPeriod = vestingInfo.bpsPerPeriod;
1462
+ const numberOfPeriods = vestingInfo.numberOfPeriods;
1463
+ const frequency = vestingInfo.frequency;
1464
+ const cliffDuration = vestingInfo.cliffDurationFromMigrationTime;
1465
+ const totalBpsAfterCliff = bpsPerPeriod * numberOfPeriods;
1466
+ const totalVestingLiquidityAfterCliff = totalVestedLiquidity.mul(new (0, _bnjs2.default)(totalBpsAfterCliff)).div(new (0, _bnjs2.default)(MAX_BASIS_POINT));
1467
+ let liquidityPerPeriod = new (0, _bnjs2.default)(0);
1468
+ let adjustedFrequency = frequency;
1469
+ let adjustedNumberOfPeriods = numberOfPeriods;
1470
+ let adjustedCliffDuration = cliffDuration;
1471
+ if (numberOfPeriods > 0) {
1472
+ liquidityPerPeriod = totalVestingLiquidityAfterCliff.div(
1473
+ new (0, _bnjs2.default)(numberOfPeriods)
1474
+ );
1475
+ }
1476
+ if (liquidityPerPeriod.isZero()) {
1477
+ adjustedNumberOfPeriods = 0;
1478
+ adjustedFrequency = 0;
1479
+ adjustedCliffDuration = Math.max(cliffDuration, 1);
1480
+ }
1481
+ const cliffUnlockLiquidity = totalVestedLiquidity.sub(
1482
+ liquidityPerPeriod.mul(new (0, _bnjs2.default)(adjustedNumberOfPeriods))
1483
+ );
1484
+ const cliffPoint = new (0, _bnjs2.default)(adjustedCliffDuration);
1485
+ const currentPoint = new (0, _bnjs2.default)(nSeconds);
1486
+ let unlockedLiquidity = new (0, _bnjs2.default)(0);
1487
+ if (currentPoint.gte(cliffPoint)) {
1488
+ unlockedLiquidity = cliffUnlockLiquidity;
1489
+ if (adjustedFrequency > 0 && adjustedNumberOfPeriods > 0) {
1490
+ const timeAfterCliff = currentPoint.sub(cliffPoint);
1491
+ const periodsElapsed = timeAfterCliff.div(new (0, _bnjs2.default)(adjustedFrequency)).toNumber();
1492
+ const actualPeriodsElapsed = Math.min(
1493
+ periodsElapsed,
1494
+ adjustedNumberOfPeriods
1495
+ );
1496
+ unlockedLiquidity = unlockedLiquidity.add(
1497
+ liquidityPerPeriod.mul(new (0, _bnjs2.default)(actualPeriodsElapsed))
1498
+ );
1499
+ }
1500
+ }
1501
+ const lockedLiquidity = totalVestedLiquidity.sub(unlockedLiquidity);
1502
+ const liquidityLockedBps = lockedLiquidity.mul(new (0, _bnjs2.default)(MAX_BASIS_POINT)).div(totalLiquidity);
1503
+ return liquidityLockedBps.toNumber();
1504
+ }
1505
+ function calculateLockedLiquidityBpsAtTime(partnerPermanentLockedLiquidityPercentage, creatorPermanentLockedLiquidityPercentage, partnerLiquidityVestingInfo, creatorLiquidityVestingInfo, elapsedSeconds) {
1506
+ const partnerVestedLockedLiquidityBps = getVestingLockedLiquidityBpsAtNSeconds(
1507
+ partnerLiquidityVestingInfo,
1508
+ elapsedSeconds
1509
+ );
1510
+ const creatorVestedLockedLiquidityBps = getVestingLockedLiquidityBpsAtNSeconds(
1511
+ creatorLiquidityVestingInfo,
1512
+ elapsedSeconds
1513
+ );
1514
+ const partnerPermanentLockedLiquidityBps = partnerPermanentLockedLiquidityPercentage * 100;
1515
+ const creatorPermanentLockedLiquidityBps = creatorPermanentLockedLiquidityPercentage * 100;
1516
+ const totalLockedLiquidityBpsAtNSeconds = partnerVestedLockedLiquidityBps + partnerPermanentLockedLiquidityBps + creatorVestedLockedLiquidityBps + creatorPermanentLockedLiquidityBps;
1517
+ return totalLockedLiquidityBpsAtNSeconds;
1518
+ }
1347
1519
 
1348
- // src/helpers/accounts.ts
1520
+ // src/helpers/pda.ts
1349
1521
 
1350
1522
  var SEED = Object.freeze({
1351
1523
  POOL_AUTHORITY: "pool_authority",
@@ -1604,6 +1776,12 @@ function deriveBaseKeyForLocker(virtualPool) {
1604
1776
  DYNAMIC_BONDING_CURVE_PROGRAM_ID
1605
1777
  )[0];
1606
1778
  }
1779
+ function deriveDammV2PositionVestingAccount(position) {
1780
+ return _web3js.PublicKey.findProgramAddressSync(
1781
+ [Buffer.from("position_vesting"), position.toBuffer()],
1782
+ DYNAMIC_BONDING_CURVE_PROGRAM_ID
1783
+ )[0];
1784
+ }
1607
1785
 
1608
1786
  // src/helpers/validation.ts
1609
1787
 
@@ -1869,7 +2047,7 @@ function getFeeNumeratorOnExponentialFeeScheduler(cliffFeeNumerator, reductionFa
1869
2047
  if (period === 0) {
1870
2048
  return cliffFeeNumerator;
1871
2049
  }
1872
- const basisPointMax = new (0, _bnjs2.default)(BASIS_POINT_MAX);
2050
+ const basisPointMax = new (0, _bnjs2.default)(MAX_BASIS_POINT);
1873
2051
  const ONE_Q642 = new (0, _bnjs2.default)(1).shln(64);
1874
2052
  const bps = SafeMath.div(SafeMath.shl(reductionFactor, 64), basisPointMax);
1875
2053
  const base = SafeMath.sub(ONE_Q642, bps);
@@ -1955,7 +2133,7 @@ var FeeScheduler = class {
1955
2133
  this.reductionFactor = reductionFactor;
1956
2134
  this.feeSchedulerMode = feeSchedulerMode;
1957
2135
  }
1958
- validate(collectFeeMode, activationType) {
2136
+ validate() {
1959
2137
  return validateFeeScheduler(
1960
2138
  this.numberOfPeriod,
1961
2139
  this.periodFrequency,
@@ -2048,13 +2226,13 @@ function toNumerator(bps, feeDenominator) {
2048
2226
  const numerator = mulDiv(
2049
2227
  bps,
2050
2228
  feeDenominator,
2051
- new (0, _bnjs2.default)(BASIS_POINT_MAX),
2229
+ new (0, _bnjs2.default)(MAX_BASIS_POINT),
2052
2230
  1 /* Down */
2053
2231
  );
2054
2232
  return numerator;
2055
2233
  } catch (error) {
2056
2234
  throw new Error(
2057
- "Type cast failed or calculation overflow in toNumerator"
2235
+ `Type cast failed or calculation overflow in toNumerator ${error}`
2058
2236
  );
2059
2237
  }
2060
2238
  }
@@ -2144,14 +2322,14 @@ function getFeeOnAmount(tradeFeeNumerator, amount, poolFees, hasReferral) {
2144
2322
  );
2145
2323
  const protocolFee = mulDiv(
2146
2324
  tradingFee,
2147
- new (0, _bnjs2.default)(poolFees.protocolFeePercent),
2325
+ new (0, _bnjs2.default)(PROTOCOL_FEE_PERCENT),
2148
2326
  new (0, _bnjs2.default)(100),
2149
2327
  1 /* Down */
2150
2328
  );
2151
2329
  const updatedTradingFee = SafeMath.sub(tradingFee, protocolFee);
2152
2330
  const referralFee = hasReferral ? mulDiv(
2153
2331
  protocolFee,
2154
- new (0, _bnjs2.default)(poolFees.referralFeePercent),
2332
+ new (0, _bnjs2.default)(HOST_FEE_PERCENT),
2155
2333
  new (0, _bnjs2.default)(100),
2156
2334
  1 /* Down */
2157
2335
  ) : new (0, _bnjs2.default)(0);
@@ -2186,14 +2364,14 @@ function getIncludedFeeAmount(tradeFeeNumerator, excludedFeeAmount) {
2186
2364
  function splitFees(poolFees, feeAmount, hasReferral) {
2187
2365
  const protocolFee = mulDiv(
2188
2366
  feeAmount,
2189
- new (0, _bnjs2.default)(poolFees.protocolFeePercent),
2367
+ new (0, _bnjs2.default)(PROTOCOL_FEE_PERCENT),
2190
2368
  new (0, _bnjs2.default)(100),
2191
2369
  1 /* Down */
2192
2370
  );
2193
2371
  const tradingFee = SafeMath.sub(feeAmount, protocolFee);
2194
2372
  const referralFee = hasReferral ? mulDiv(
2195
2373
  protocolFee,
2196
- new (0, _bnjs2.default)(poolFees.referralFeePercent),
2374
+ new (0, _bnjs2.default)(HOST_FEE_PERCENT),
2197
2375
  new (0, _bnjs2.default)(100),
2198
2376
  1 /* Down */
2199
2377
  ) : new (0, _bnjs2.default)(0);
@@ -3027,8 +3205,8 @@ function validateMigrationFeeOption(migrationFeeOption, migrationOption) {
3027
3205
  function validateTokenDecimals(tokenDecimal) {
3028
3206
  return tokenDecimal >= 6 /* SIX */ && tokenDecimal <= 9 /* NINE */;
3029
3207
  }
3030
- function validateLPPercentages(partnerLpPercentage, partnerLockedLpPercentage, creatorLpPercentage, creatorLockedLpPercentage) {
3031
- const totalLPPercentage = partnerLpPercentage + partnerLockedLpPercentage + creatorLpPercentage + creatorLockedLpPercentage;
3208
+ function validateLPPercentages(partnerLiquidityPercentage, partnerPermanentLockedLiquidityPercentage, creatorLiquidityPercentage, creatorPermanentLockedLiquidityPercentage, partnerVestingPercentage, creatorVestingPercentage) {
3209
+ const totalLPPercentage = partnerLiquidityPercentage + partnerPermanentLockedLiquidityPercentage + creatorLiquidityPercentage + creatorPermanentLockedLiquidityPercentage + partnerVestingPercentage + creatorVestingPercentage;
3032
3210
  return totalLPPercentage === 100;
3033
3211
  }
3034
3212
  function validateCurve(curve, sqrtStartPrice) {
@@ -3088,6 +3266,35 @@ function validateTokenUpdateAuthorityOptions(option) {
3088
3266
  4 /* PartnerUpdateAndMintAuthority */
3089
3267
  ].includes(option);
3090
3268
  }
3269
+ function validatePoolCreationFee(poolCreationFee) {
3270
+ if (poolCreationFee.eq(new (0, _bnjs2.default)(0))) {
3271
+ return true;
3272
+ }
3273
+ return poolCreationFee.gte(new (0, _bnjs2.default)(MIN_POOL_CREATION_FEE)) && poolCreationFee.lte(new (0, _bnjs2.default)(MAX_POOL_CREATION_FEE));
3274
+ }
3275
+ function validateLiquidityVestingInfo(vestingInfo) {
3276
+ const isZero = vestingInfo.vestingPercentage === 0 && vestingInfo.bpsPerPeriod === 0 && vestingInfo.numberOfPeriods === 0 && vestingInfo.cliffDurationFromMigrationTime === 0 && vestingInfo.frequency === 0;
3277
+ if (isZero) {
3278
+ return true;
3279
+ }
3280
+ if (vestingInfo.vestingPercentage < 0 || vestingInfo.vestingPercentage > 100) {
3281
+ return false;
3282
+ }
3283
+ if (vestingInfo.vestingPercentage > 0 && vestingInfo.frequency === 0) {
3284
+ return false;
3285
+ }
3286
+ return true;
3287
+ }
3288
+ function validateMinimumLockedLiquidity(partnerPermanentLockedLiquidityPercentage, creatorPermanentLockedLiquidityPercentage, partnerLiquidityVestingInfo, creatorLiquidityVestingInfo) {
3289
+ const lockedBpsAtDay1 = calculateLockedLiquidityBpsAtTime(
3290
+ partnerPermanentLockedLiquidityPercentage,
3291
+ creatorPermanentLockedLiquidityPercentage,
3292
+ partnerLiquidityVestingInfo,
3293
+ creatorLiquidityVestingInfo,
3294
+ SECONDS_PER_DAY
3295
+ );
3296
+ return lockedBpsAtDay1 >= MIN_LOCKED_LIQUIDITY_BPS;
3297
+ }
3091
3298
  function validateMigratedPoolFee(migratedPoolFee, migrationOption, migrationFeeOption) {
3092
3299
  const isEmpty = () => {
3093
3300
  return migratedPoolFee.collectFeeMode === 0 && migratedPoolFee.dynamicFee === 0 && migratedPoolFee.poolFeeBps === 0;
@@ -3151,17 +3358,72 @@ function validateConfigParameters(configParam) {
3151
3358
  if (!validateMigrationFee(configParam.migrationFee)) {
3152
3359
  throw new Error("Invalid migration fee");
3153
3360
  }
3361
+ if (configParam.creatorTradingFeePercentage < 0 || configParam.creatorTradingFeePercentage > 100) {
3362
+ throw new Error(
3363
+ "Creator trading fee percentage must be between 0 and 100"
3364
+ );
3365
+ }
3154
3366
  if (!validateTokenDecimals(configParam.tokenDecimal)) {
3155
3367
  throw new Error("Token decimal must be between 6 and 9");
3156
3368
  }
3369
+ const partnerVestingPercentage = _nullishCoalesce(_optionalChain([configParam, 'access', _19 => _19.partnerLiquidityVestingInfo, 'optionalAccess', _20 => _20.vestingPercentage]), () => ( 0));
3370
+ const creatorVestingPercentage = _nullishCoalesce(_optionalChain([configParam, 'access', _21 => _21.creatorLiquidityVestingInfo, 'optionalAccess', _22 => _22.vestingPercentage]), () => ( 0));
3157
3371
  if (!validateLPPercentages(
3158
- configParam.partnerLpPercentage,
3159
- configParam.partnerLockedLpPercentage,
3160
- configParam.creatorLpPercentage,
3161
- configParam.creatorLockedLpPercentage
3372
+ configParam.partnerLiquidityPercentage,
3373
+ configParam.partnerPermanentLockedLiquidityPercentage,
3374
+ configParam.creatorLiquidityPercentage,
3375
+ configParam.creatorPermanentLockedLiquidityPercentage,
3376
+ partnerVestingPercentage,
3377
+ creatorVestingPercentage
3162
3378
  )) {
3163
3379
  throw new Error("Sum of LP percentages must equal 100");
3164
3380
  }
3381
+ if (!validatePoolCreationFee(configParam.poolCreationFee)) {
3382
+ throw new Error(
3383
+ `Pool creation fee must be 0 or between ${MIN_POOL_CREATION_FEE} and ${MAX_POOL_CREATION_FEE} lamports`
3384
+ );
3385
+ }
3386
+ if (configParam.migrationOption === 0 /* MET_DAMM */) {
3387
+ const isPartnerVestingZero = !configParam.partnerLiquidityVestingInfo || configParam.partnerLiquidityVestingInfo.vestingPercentage === 0 && configParam.partnerLiquidityVestingInfo.bpsPerPeriod === 0 && configParam.partnerLiquidityVestingInfo.numberOfPeriods === 0 && configParam.partnerLiquidityVestingInfo.cliffDurationFromMigrationTime === 0 && configParam.partnerLiquidityVestingInfo.frequency === 0;
3388
+ const isCreatorVestingZero = !configParam.creatorLiquidityVestingInfo || configParam.creatorLiquidityVestingInfo.vestingPercentage === 0 && configParam.creatorLiquidityVestingInfo.bpsPerPeriod === 0 && configParam.creatorLiquidityVestingInfo.numberOfPeriods === 0 && configParam.creatorLiquidityVestingInfo.cliffDurationFromMigrationTime === 0 && configParam.creatorLiquidityVestingInfo.frequency === 0;
3389
+ if (!isPartnerVestingZero || !isCreatorVestingZero) {
3390
+ throw new Error(
3391
+ "Liquidity vesting is not supported for MeteoraDamm migration"
3392
+ );
3393
+ }
3394
+ } else if (configParam.migrationOption === 1 /* MET_DAMM_V2 */) {
3395
+ if (configParam.partnerLiquidityVestingInfo) {
3396
+ if (!validateLiquidityVestingInfo(
3397
+ configParam.partnerLiquidityVestingInfo
3398
+ )) {
3399
+ throw new Error("Invalid partner liquidity vesting info");
3400
+ }
3401
+ }
3402
+ if (configParam.creatorLiquidityVestingInfo) {
3403
+ if (!validateLiquidityVestingInfo(
3404
+ configParam.creatorLiquidityVestingInfo
3405
+ )) {
3406
+ throw new Error("Invalid creator liquidity vesting info");
3407
+ }
3408
+ }
3409
+ }
3410
+ if (!validateMinimumLockedLiquidity(
3411
+ configParam.partnerPermanentLockedLiquidityPercentage,
3412
+ configParam.creatorPermanentLockedLiquidityPercentage,
3413
+ configParam.partnerLiquidityVestingInfo,
3414
+ configParam.creatorLiquidityVestingInfo
3415
+ )) {
3416
+ const lockedBpsAtDay1 = calculateLockedLiquidityBpsAtTime(
3417
+ configParam.partnerPermanentLockedLiquidityPercentage,
3418
+ configParam.creatorPermanentLockedLiquidityPercentage,
3419
+ configParam.partnerLiquidityVestingInfo,
3420
+ configParam.creatorLiquidityVestingInfo,
3421
+ SECONDS_PER_DAY
3422
+ );
3423
+ throw new Error(
3424
+ `Invalid migration locked liquidity. At least ${MIN_LOCKED_LIQUIDITY_BPS} BPS (10%) must be locked at day 1. Current locked liquidity at day 1: ${lockedBpsAtDay1} BPS. Consider increasing permanent locked liquidity percentage or extending vesting duration/cliff.`
3425
+ );
3426
+ }
3165
3427
  if (configParam.migrationQuoteThreshold.lte(new (0, _bnjs2.default)(0))) {
3166
3428
  throw new Error("Migration quote threshold must be greater than 0");
3167
3429
  }
@@ -3191,7 +3453,7 @@ function validateConfigParameters(configParam) {
3191
3453
  throw new Error("Invalid vesting parameters");
3192
3454
  }
3193
3455
  } catch (error) {
3194
- throw new Error("Invalid vesting parameters");
3456
+ throw new Error(`Invalid vesting parameters ${error}`);
3195
3457
  }
3196
3458
  }
3197
3459
  if (configParam.tokenSupply) {
@@ -3256,7 +3518,7 @@ async function validateBalance(connection, owner, inputMint, amountIn, inputToke
3256
3518
  }
3257
3519
  } catch (error) {
3258
3520
  throw new Error(
3259
- `Failed to fetch token balance or token account doesn't exist`
3521
+ `Failed to fetch token balance or token account doesn't exist ${error}`
3260
3522
  );
3261
3523
  }
3262
3524
  }
@@ -3291,28 +3553,32 @@ function validateMigrationFee(migrationFee) {
3291
3553
 
3292
3554
 
3293
3555
  function buildCurve(buildCurveParam) {
3294
- let {
3556
+ const {
3295
3557
  totalTokenSupply,
3296
- percentageSupplyOnMigration,
3297
- migrationQuoteThreshold,
3298
- migrationOption,
3558
+ tokenType,
3299
3559
  tokenBaseDecimal,
3300
3560
  tokenQuoteDecimal,
3561
+ tokenUpdateAuthority,
3562
+ lockedVestingParams,
3563
+ leftover,
3564
+ baseFeeParams,
3301
3565
  dynamicFeeEnabled,
3302
3566
  activationType,
3303
3567
  collectFeeMode,
3304
- migrationFeeOption,
3305
- tokenType,
3306
- partnerLpPercentage,
3307
- creatorLpPercentage,
3308
- partnerLockedLpPercentage,
3309
- creatorLockedLpPercentage,
3310
3568
  creatorTradingFeePercentage,
3311
- leftover,
3312
- tokenUpdateAuthority,
3569
+ poolCreationFee,
3570
+ migrationOption,
3571
+ migrationFeeOption,
3313
3572
  migrationFee,
3314
- baseFeeParams,
3315
- migratedPoolFee
3573
+ partnerPermanentLockedLiquidityPercentage,
3574
+ partnerLiquidityPercentage,
3575
+ creatorPermanentLockedLiquidityPercentage,
3576
+ creatorLiquidityPercentage,
3577
+ partnerLiquidityVestingInfoParams,
3578
+ creatorLiquidityVestingInfoParams,
3579
+ migratedPoolFee,
3580
+ percentageSupplyOnMigration,
3581
+ migrationQuoteThreshold
3316
3582
  } = buildCurveParam;
3317
3583
  const baseFee = getBaseFeeParams(
3318
3584
  baseFeeParams,
@@ -3325,7 +3591,7 @@ function buildCurve(buildCurveParam) {
3325
3591
  cliffUnlockAmount,
3326
3592
  totalVestingDuration,
3327
3593
  cliffDurationFromMigrationTime
3328
- } = buildCurveParam.lockedVestingParam;
3594
+ } = lockedVestingParams;
3329
3595
  const lockedVesting = getLockedVestingParams(
3330
3596
  totalLockedVestingAmount,
3331
3597
  numberOfVestingPeriod,
@@ -3334,6 +3600,40 @@ function buildCurve(buildCurveParam) {
3334
3600
  cliffDurationFromMigrationTime,
3335
3601
  tokenBaseDecimal
3336
3602
  );
3603
+ const partnerVestingParams = _nullishCoalesce(partnerLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
3604
+ const {
3605
+ vestingPercentage: partnerVestingPercentage,
3606
+ bpsPerPeriod: partnerBpsPerPeriod,
3607
+ numberOfPeriods: partnerNumberOfPeriods,
3608
+ cliffDurationFromMigrationTime: partnerCliffDurationFromMigrationTime,
3609
+ totalDuration: partnerTotalDuration
3610
+ } = partnerVestingParams;
3611
+ const partnerLiquidityVestingInfo = getLiquidityVestingInfoParams(
3612
+ partnerVestingPercentage,
3613
+ partnerBpsPerPeriod,
3614
+ partnerNumberOfPeriods,
3615
+ partnerCliffDurationFromMigrationTime,
3616
+ partnerTotalDuration
3617
+ );
3618
+ const creatorVestingParams = _nullishCoalesce(creatorLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
3619
+ const {
3620
+ vestingPercentage: creatorVestingPercentage,
3621
+ bpsPerPeriod: creatorBpsPerPeriod,
3622
+ numberOfPeriods: creatorNumberOfPeriods,
3623
+ cliffDurationFromMigrationTime: creatorCliffDurationFromMigrationTime,
3624
+ totalDuration: creatorTotalDuration
3625
+ } = creatorVestingParams;
3626
+ const creatorLiquidityVestingInfo = getLiquidityVestingInfoParams(
3627
+ creatorVestingPercentage,
3628
+ creatorBpsPerPeriod,
3629
+ creatorNumberOfPeriods,
3630
+ creatorCliffDurationFromMigrationTime,
3631
+ creatorTotalDuration
3632
+ );
3633
+ const poolCreationFeeInLamports = convertToLamports(
3634
+ poolCreationFee,
3635
+ 9 /* NINE */
3636
+ );
3337
3637
  const migratedPoolFeeParams = getMigratedPoolFeeParams(
3338
3638
  migrationOption,
3339
3639
  migrationFeeOption,
@@ -3348,7 +3648,7 @@ function buildCurve(buildCurveParam) {
3348
3648
  const migrationPrice = new (0, _decimaljs2.default)(migrationQuoteAmount.toString()).div(
3349
3649
  new (0, _decimaljs2.default)(migrationBaseSupply.toString())
3350
3650
  );
3351
- let migrationQuoteThresholdInLamport = convertToLamports(
3651
+ const migrationQuoteThresholdInLamport = convertToLamports(
3352
3652
  migrationQuoteThreshold,
3353
3653
  tokenQuoteDecimal
3354
3654
  );
@@ -3358,7 +3658,7 @@ function buildCurve(buildCurveParam) {
3358
3658
  tokenBaseDecimal,
3359
3659
  tokenQuoteDecimal
3360
3660
  );
3361
- let migrationQuoteAmountInLamport = fromDecimalToBN(
3661
+ const migrationQuoteAmountInLamport = fromDecimalToBN(
3362
3662
  migrationQuoteAmount.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3363
3663
  );
3364
3664
  const migrationBaseAmount = getMigrationBaseToken(
@@ -3405,16 +3705,16 @@ function buildCurve(buildCurveParam) {
3405
3705
  baseFeeParams.baseFeeMode === 2 /* RateLimiter */ ? baseFeeParams.rateLimiterParam.baseFeeBps : baseFeeParams.feeSchedulerParam.endingFeeBps
3406
3706
  ) : null
3407
3707
  },
3408
- activationType,
3409
3708
  collectFeeMode,
3410
3709
  migrationOption,
3710
+ activationType,
3411
3711
  tokenType,
3412
3712
  tokenDecimal: tokenBaseDecimal,
3713
+ partnerLiquidityPercentage,
3714
+ partnerPermanentLockedLiquidityPercentage,
3715
+ creatorLiquidityPercentage,
3716
+ creatorPermanentLockedLiquidityPercentage,
3413
3717
  migrationQuoteThreshold: migrationQuoteThresholdInLamport,
3414
- partnerLpPercentage,
3415
- creatorLpPercentage,
3416
- partnerLockedLpPercentage,
3417
- creatorLockedLpPercentage,
3418
3718
  sqrtStartPrice,
3419
3719
  lockedVesting,
3420
3720
  migrationFeeOption,
@@ -3430,6 +3730,9 @@ function buildCurve(buildCurveParam) {
3430
3730
  dynamicFee: migratedPoolFeeParams.dynamicFee,
3431
3731
  poolFeeBps: migratedPoolFeeParams.poolFeeBps
3432
3732
  },
3733
+ poolCreationFee: poolCreationFeeInLamports,
3734
+ partnerLiquidityVestingInfo,
3735
+ creatorLiquidityVestingInfo,
3433
3736
  padding: [],
3434
3737
  curve
3435
3738
  };
@@ -3437,12 +3740,13 @@ function buildCurve(buildCurveParam) {
3437
3740
  }
3438
3741
  function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
3439
3742
  const {
3440
- initialMarketCap,
3441
- migrationMarketCap,
3442
3743
  totalTokenSupply,
3443
3744
  tokenBaseDecimal,
3745
+ lockedVestingParams,
3746
+ leftover,
3444
3747
  migrationFee,
3445
- leftover
3748
+ initialMarketCap,
3749
+ migrationMarketCap
3446
3750
  } = buildCurveWithMarketCapParam;
3447
3751
  const {
3448
3752
  totalLockedVestingAmount,
@@ -3450,7 +3754,7 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
3450
3754
  cliffUnlockAmount,
3451
3755
  totalVestingDuration,
3452
3756
  cliffDurationFromMigrationTime
3453
- } = buildCurveWithMarketCapParam.lockedVestingParam;
3757
+ } = lockedVestingParams;
3454
3758
  const lockedVesting = getLockedVestingParams(
3455
3759
  totalLockedVestingAmount,
3456
3760
  numberOfVestingPeriod,
@@ -3461,7 +3765,14 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
3461
3765
  );
3462
3766
  const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3463
3767
  const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3464
- const percentageSupplyOnMigration = getPercentageSupplyOnMigration(
3768
+ const percentageSupplyOnMigration = migrationFee.feePercentage > 0 ? calculateAdjustedPercentageSupplyOnMigration(
3769
+ initialMarketCap,
3770
+ migrationMarketCap,
3771
+ migrationFee,
3772
+ lockedVesting,
3773
+ totalLeftover,
3774
+ totalSupply
3775
+ ) : getPercentageSupplyOnMigration(
3465
3776
  new (0, _decimaljs2.default)(initialMarketCap),
3466
3777
  new (0, _decimaljs2.default)(migrationMarketCap),
3467
3778
  lockedVesting,
@@ -3485,27 +3796,31 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
3485
3796
  function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3486
3797
  const {
3487
3798
  totalTokenSupply,
3488
- initialMarketCap,
3489
- migrationMarketCap,
3490
- percentageSupplyOnMigration,
3491
- migrationOption,
3799
+ tokenType,
3492
3800
  tokenBaseDecimal,
3493
3801
  tokenQuoteDecimal,
3494
- creatorTradingFeePercentage,
3495
- collectFeeMode,
3802
+ tokenUpdateAuthority,
3496
3803
  leftover,
3497
- tokenType,
3498
- partnerLpPercentage,
3499
- creatorLpPercentage,
3500
- partnerLockedLpPercentage,
3501
- creatorLockedLpPercentage,
3502
- activationType,
3804
+ lockedVestingParams,
3805
+ baseFeeParams,
3503
3806
  dynamicFeeEnabled,
3807
+ activationType,
3808
+ collectFeeMode,
3809
+ creatorTradingFeePercentage,
3810
+ poolCreationFee,
3811
+ migrationOption,
3504
3812
  migrationFeeOption,
3505
3813
  migrationFee,
3506
- tokenUpdateAuthority,
3507
- baseFeeParams,
3508
- migratedPoolFee
3814
+ partnerPermanentLockedLiquidityPercentage,
3815
+ partnerLiquidityPercentage,
3816
+ creatorPermanentLockedLiquidityPercentage,
3817
+ creatorLiquidityPercentage,
3818
+ partnerLiquidityVestingInfoParams,
3819
+ creatorLiquidityVestingInfoParams,
3820
+ migratedPoolFee,
3821
+ initialMarketCap,
3822
+ migrationMarketCap,
3823
+ percentageSupplyOnMigration
3509
3824
  } = buildCurveWithTwoSegmentsParam;
3510
3825
  const baseFee = getBaseFeeParams(
3511
3826
  baseFeeParams,
@@ -3518,7 +3833,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3518
3833
  cliffUnlockAmount,
3519
3834
  totalVestingDuration,
3520
3835
  cliffDurationFromMigrationTime
3521
- } = buildCurveWithTwoSegmentsParam.lockedVestingParam;
3836
+ } = lockedVestingParams;
3522
3837
  const lockedVesting = getLockedVestingParams(
3523
3838
  totalLockedVestingAmount,
3524
3839
  numberOfVestingPeriod,
@@ -3527,62 +3842,96 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3527
3842
  cliffDurationFromMigrationTime,
3528
3843
  tokenBaseDecimal
3529
3844
  );
3845
+ const partnerVestingParams = _nullishCoalesce(partnerLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
3846
+ const {
3847
+ vestingPercentage: partnerVestingPercentage,
3848
+ bpsPerPeriod: partnerBpsPerPeriod,
3849
+ numberOfPeriods: partnerNumberOfPeriods,
3850
+ cliffDurationFromMigrationTime: partnerCliffDurationFromMigrationTime,
3851
+ totalDuration: partnerTotalDuration
3852
+ } = partnerVestingParams;
3853
+ const partnerLiquidityVestingInfo = getLiquidityVestingInfoParams(
3854
+ partnerVestingPercentage,
3855
+ partnerBpsPerPeriod,
3856
+ partnerNumberOfPeriods,
3857
+ partnerCliffDurationFromMigrationTime,
3858
+ partnerTotalDuration
3859
+ );
3860
+ const creatorVestingParams = _nullishCoalesce(creatorLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
3861
+ const {
3862
+ vestingPercentage: creatorVestingPercentage,
3863
+ bpsPerPeriod: creatorBpsPerPeriod,
3864
+ numberOfPeriods: creatorNumberOfPeriods,
3865
+ cliffDurationFromMigrationTime: creatorCliffDurationFromMigrationTime,
3866
+ totalDuration: creatorTotalDuration
3867
+ } = creatorVestingParams;
3868
+ const creatorLiquidityVestingInfo = getLiquidityVestingInfoParams(
3869
+ creatorVestingPercentage,
3870
+ creatorBpsPerPeriod,
3871
+ creatorNumberOfPeriods,
3872
+ creatorCliffDurationFromMigrationTime,
3873
+ creatorTotalDuration
3874
+ );
3875
+ const poolCreationFeeInLamports = convertToLamports(
3876
+ poolCreationFee,
3877
+ 9 /* NINE */
3878
+ );
3530
3879
  const migratedPoolFeeParams = getMigratedPoolFeeParams(
3531
3880
  migrationOption,
3532
3881
  migrationFeeOption,
3533
3882
  migratedPoolFee
3534
3883
  );
3535
- let migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
3536
- let totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3537
- let migrationQuoteAmount = getMigrationQuoteAmount(
3884
+ const migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
3885
+ const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3886
+ const migrationQuoteAmount = getMigrationQuoteAmount(
3538
3887
  new (0, _decimaljs2.default)(migrationMarketCap),
3539
3888
  new (0, _decimaljs2.default)(percentageSupplyOnMigration)
3540
3889
  );
3541
- let migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3890
+ const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3542
3891
  migrationQuoteAmount,
3543
3892
  new (0, _decimaljs2.default)(migrationFee.feePercentage)
3544
3893
  );
3545
- let migrationPrice = migrationQuoteAmount.div(
3894
+ const migrationPrice = migrationQuoteAmount.div(
3546
3895
  new (0, _decimaljs2.default)(migrationBaseSupply.toString())
3547
3896
  );
3548
- let migrationQuoteThresholdInLamport = fromDecimalToBN(
3897
+ const migrationQuoteThresholdInLamport = fromDecimalToBN(
3549
3898
  migrationQuoteThreshold.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3550
3899
  );
3551
- let migrationQuoteAmountInLamport = fromDecimalToBN(
3900
+ const migrationQuoteAmountInLamport = fromDecimalToBN(
3552
3901
  migrationQuoteAmount.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3553
3902
  );
3554
- let migrateSqrtPrice = getSqrtPriceFromPrice(
3903
+ const migrateSqrtPrice = getSqrtPriceFromPrice(
3555
3904
  migrationPrice.toString(),
3556
3905
  tokenBaseDecimal,
3557
3906
  tokenQuoteDecimal
3558
3907
  );
3559
- let migrationBaseAmount = getMigrationBaseToken(
3908
+ const migrationBaseAmount = getMigrationBaseToken(
3560
3909
  migrationQuoteAmountInLamport,
3561
3910
  migrateSqrtPrice,
3562
3911
  migrationOption
3563
3912
  );
3564
- let totalVestingAmount = getTotalVestingAmount(lockedVesting);
3565
- let totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3566
- let swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
3567
- let initialSqrtPrice = getSqrtPriceFromMarketCap(
3913
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
3914
+ const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3915
+ const swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
3916
+ const initialSqrtPrice = getSqrtPriceFromMarketCap(
3568
3917
  initialMarketCap,
3569
3918
  totalTokenSupply,
3570
3919
  tokenBaseDecimal,
3571
3920
  tokenQuoteDecimal
3572
3921
  );
3573
- let midSqrtPriceDecimal1 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString()).mul(new (0, _decimaljs2.default)(initialSqrtPrice.toString())).sqrt();
3574
- let midSqrtPrice1 = new (0, _bnjs2.default)(midSqrtPriceDecimal1.floor().toFixed());
3575
- let numerator1 = new (0, _decimaljs2.default)(initialSqrtPrice.toString());
3576
- let numerator2 = _decimaljs2.default.pow(migrateSqrtPrice.toString(), 3);
3577
- let product1 = numerator1.mul(numerator2);
3578
- let midSqrtPriceDecimal2 = _decimaljs2.default.pow(product1, 0.25);
3579
- let midSqrtPrice2 = new (0, _bnjs2.default)(midSqrtPriceDecimal2.floor().toFixed());
3580
- let numerator3 = _decimaljs2.default.pow(initialSqrtPrice.toString(), 3);
3581
- let numerator4 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString());
3582
- let product2 = numerator3.mul(numerator4);
3583
- let midSqrtPriceDecimal3 = _decimaljs2.default.pow(product2, 0.25);
3584
- let midSqrtPrice3 = new (0, _bnjs2.default)(midSqrtPriceDecimal3.floor().toFixed());
3585
- let midPrices = [midSqrtPrice3, midSqrtPrice2, midSqrtPrice1];
3922
+ const midSqrtPriceDecimal1 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString()).mul(new (0, _decimaljs2.default)(initialSqrtPrice.toString())).sqrt();
3923
+ const midSqrtPrice1 = new (0, _bnjs2.default)(midSqrtPriceDecimal1.floor().toFixed());
3924
+ const numerator1 = new (0, _decimaljs2.default)(initialSqrtPrice.toString());
3925
+ const numerator2 = _decimaljs2.default.pow(migrateSqrtPrice.toString(), 3);
3926
+ const product1 = numerator1.mul(numerator2);
3927
+ const midSqrtPriceDecimal2 = _decimaljs2.default.pow(product1, 0.25);
3928
+ const midSqrtPrice2 = new (0, _bnjs2.default)(midSqrtPriceDecimal2.floor().toFixed());
3929
+ const numerator3 = _decimaljs2.default.pow(initialSqrtPrice.toString(), 3);
3930
+ const numerator4 = new (0, _decimaljs2.default)(migrateSqrtPrice.toString());
3931
+ const product2 = numerator3.mul(numerator4);
3932
+ const midSqrtPriceDecimal3 = _decimaljs2.default.pow(product2, 0.25);
3933
+ const midSqrtPrice3 = new (0, _bnjs2.default)(midSqrtPriceDecimal3.floor().toFixed());
3934
+ const midPrices = [midSqrtPrice3, midSqrtPrice2, midSqrtPrice1];
3586
3935
  let sqrtStartPrice = new (0, _bnjs2.default)(0);
3587
3936
  let curve = [];
3588
3937
  for (let i = 0; i < midPrices.length; i++) {
@@ -3599,7 +3948,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3599
3948
  break;
3600
3949
  }
3601
3950
  }
3602
- let totalDynamicSupply = getTotalSupplyFromCurve(
3951
+ const totalDynamicSupply = getTotalSupplyFromCurve(
3603
3952
  migrationQuoteThresholdInLamport,
3604
3953
  sqrtStartPrice,
3605
3954
  curve,
@@ -3609,7 +3958,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3609
3958
  migrationFee.feePercentage
3610
3959
  );
3611
3960
  if (totalDynamicSupply.gt(totalSupply)) {
3612
- let leftOverDelta = totalDynamicSupply.sub(totalSupply);
3961
+ const leftOverDelta = totalDynamicSupply.sub(totalSupply);
3613
3962
  if (!leftOverDelta.lt(totalLeftover)) {
3614
3963
  throw new Error("leftOverDelta must be less than totalLeftover");
3615
3964
  }
@@ -3629,10 +3978,10 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3629
3978
  tokenType,
3630
3979
  tokenDecimal: tokenBaseDecimal,
3631
3980
  migrationQuoteThreshold: migrationQuoteThresholdInLamport,
3632
- partnerLpPercentage,
3633
- creatorLpPercentage,
3634
- partnerLockedLpPercentage,
3635
- creatorLockedLpPercentage,
3981
+ partnerLiquidityPercentage,
3982
+ partnerPermanentLockedLiquidityPercentage,
3983
+ creatorLiquidityPercentage,
3984
+ creatorPermanentLockedLiquidityPercentage,
3636
3985
  sqrtStartPrice,
3637
3986
  lockedVesting,
3638
3987
  migrationFeeOption,
@@ -3646,6 +3995,9 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3646
3995
  dynamicFee: migratedPoolFeeParams.dynamicFee,
3647
3996
  poolFeeBps: migratedPoolFeeParams.poolFeeBps
3648
3997
  },
3998
+ poolCreationFee: poolCreationFeeInLamports,
3999
+ partnerLiquidityVestingInfo,
4000
+ creatorLiquidityVestingInfo,
3649
4001
  padding: [],
3650
4002
  curve,
3651
4003
  tokenUpdateAuthority,
@@ -3656,28 +4008,32 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
3656
4008
  function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3657
4009
  const {
3658
4010
  totalTokenSupply,
3659
- initialMarketCap,
3660
- migrationMarketCap,
3661
- midPrice,
3662
- percentageSupplyOnMigration,
3663
- migrationOption,
4011
+ tokenType,
3664
4012
  tokenBaseDecimal,
3665
4013
  tokenQuoteDecimal,
3666
- creatorTradingFeePercentage,
3667
- collectFeeMode,
4014
+ tokenUpdateAuthority,
4015
+ lockedVestingParams,
3668
4016
  leftover,
3669
- tokenType,
3670
- partnerLpPercentage,
3671
- creatorLpPercentage,
3672
- partnerLockedLpPercentage,
3673
- creatorLockedLpPercentage,
3674
- activationType,
4017
+ baseFeeParams,
3675
4018
  dynamicFeeEnabled,
4019
+ activationType,
4020
+ collectFeeMode,
4021
+ creatorTradingFeePercentage,
4022
+ poolCreationFee,
4023
+ migrationOption,
3676
4024
  migrationFeeOption,
3677
4025
  migrationFee,
3678
- tokenUpdateAuthority,
3679
- baseFeeParams,
3680
- migratedPoolFee
4026
+ partnerPermanentLockedLiquidityPercentage,
4027
+ partnerLiquidityPercentage,
4028
+ creatorPermanentLockedLiquidityPercentage,
4029
+ creatorLiquidityPercentage,
4030
+ partnerLiquidityVestingInfoParams,
4031
+ creatorLiquidityVestingInfoParams,
4032
+ migratedPoolFee,
4033
+ initialMarketCap,
4034
+ migrationMarketCap,
4035
+ midPrice,
4036
+ percentageSupplyOnMigration
3681
4037
  } = buildCurveWithMidPriceParam;
3682
4038
  const baseFee = getBaseFeeParams(
3683
4039
  baseFeeParams,
@@ -3690,7 +4046,7 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3690
4046
  cliffUnlockAmount,
3691
4047
  totalVestingDuration,
3692
4048
  cliffDurationFromMigrationTime
3693
- } = buildCurveWithMidPriceParam.lockedVestingParam;
4049
+ } = lockedVestingParams;
3694
4050
  const lockedVesting = getLockedVestingParams(
3695
4051
  totalLockedVestingAmount,
3696
4052
  numberOfVestingPeriod,
@@ -3699,44 +4055,78 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3699
4055
  cliffDurationFromMigrationTime,
3700
4056
  tokenBaseDecimal
3701
4057
  );
4058
+ const partnerVestingParams = _nullishCoalesce(partnerLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
4059
+ const {
4060
+ vestingPercentage: partnerVestingPercentage,
4061
+ bpsPerPeriod: partnerBpsPerPeriod,
4062
+ numberOfPeriods: partnerNumberOfPeriods,
4063
+ cliffDurationFromMigrationTime: partnerCliffDurationFromMigrationTime,
4064
+ totalDuration: partnerTotalDuration
4065
+ } = partnerVestingParams;
4066
+ const partnerLiquidityVestingInfo = getLiquidityVestingInfoParams(
4067
+ partnerVestingPercentage,
4068
+ partnerBpsPerPeriod,
4069
+ partnerNumberOfPeriods,
4070
+ partnerCliffDurationFromMigrationTime,
4071
+ partnerTotalDuration
4072
+ );
4073
+ const creatorVestingParams = _nullishCoalesce(creatorLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
4074
+ const {
4075
+ vestingPercentage: creatorVestingPercentage,
4076
+ bpsPerPeriod: creatorBpsPerPeriod,
4077
+ numberOfPeriods: creatorNumberOfPeriods,
4078
+ cliffDurationFromMigrationTime: creatorCliffDurationFromMigrationTime,
4079
+ totalDuration: creatorTotalDuration
4080
+ } = creatorVestingParams;
4081
+ const creatorLiquidityVestingInfo = getLiquidityVestingInfoParams(
4082
+ creatorVestingPercentage,
4083
+ creatorBpsPerPeriod,
4084
+ creatorNumberOfPeriods,
4085
+ creatorCliffDurationFromMigrationTime,
4086
+ creatorTotalDuration
4087
+ );
4088
+ const poolCreationFeeInLamports = convertToLamports(
4089
+ poolCreationFee,
4090
+ 9 /* NINE */
4091
+ );
3702
4092
  const migratedPoolFeeParams = getMigratedPoolFeeParams(
3703
4093
  migrationOption,
3704
4094
  migrationFeeOption,
3705
4095
  migratedPoolFee
3706
4096
  );
3707
- let migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
3708
- let totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3709
- let migrationQuoteAmount = getMigrationQuoteAmount(
4097
+ const migrationBaseSupply = new (0, _bnjs2.default)(totalTokenSupply).mul(new (0, _bnjs2.default)(percentageSupplyOnMigration)).div(new (0, _bnjs2.default)(100));
4098
+ const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
4099
+ const migrationQuoteAmount = getMigrationQuoteAmount(
3710
4100
  new (0, _decimaljs2.default)(migrationMarketCap),
3711
4101
  new (0, _decimaljs2.default)(percentageSupplyOnMigration)
3712
4102
  );
3713
- let migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
4103
+ const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3714
4104
  migrationQuoteAmount,
3715
4105
  new (0, _decimaljs2.default)(migrationFee.feePercentage)
3716
4106
  );
3717
- let migrationPrice = migrationQuoteAmount.div(
4107
+ const migrationPrice = migrationQuoteAmount.div(
3718
4108
  new (0, _decimaljs2.default)(migrationBaseSupply.toString())
3719
4109
  );
3720
- let migrationQuoteThresholdInLamport = fromDecimalToBN(
4110
+ const migrationQuoteThresholdInLamport = fromDecimalToBN(
3721
4111
  migrationQuoteThreshold.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3722
4112
  );
3723
- let migrationQuoteAmountInLamport = fromDecimalToBN(
4113
+ const migrationQuoteAmountInLamport = fromDecimalToBN(
3724
4114
  migrationQuoteAmount.mul(new (0, _decimaljs2.default)(10 ** tokenQuoteDecimal))
3725
4115
  );
3726
- let migrateSqrtPrice = getSqrtPriceFromPrice(
4116
+ const migrateSqrtPrice = getSqrtPriceFromPrice(
3727
4117
  migrationPrice.toString(),
3728
4118
  tokenBaseDecimal,
3729
4119
  tokenQuoteDecimal
3730
4120
  );
3731
- let migrationBaseAmount = getMigrationBaseToken(
4121
+ const migrationBaseAmount = getMigrationBaseToken(
3732
4122
  migrationQuoteAmountInLamport,
3733
4123
  migrateSqrtPrice,
3734
4124
  migrationOption
3735
4125
  );
3736
- let totalVestingAmount = getTotalVestingAmount(lockedVesting);
3737
- let totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3738
- let swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
3739
- let initialSqrtPrice = getSqrtPriceFromMarketCap(
4126
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
4127
+ const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
4128
+ const swapAmount = totalSupply.sub(migrationBaseAmount).sub(totalVestingAmount).sub(totalLeftover);
4129
+ const initialSqrtPrice = getSqrtPriceFromMarketCap(
3740
4130
  initialMarketCap,
3741
4131
  totalTokenSupply,
3742
4132
  tokenBaseDecimal,
@@ -3758,7 +4148,7 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3758
4148
  );
3759
4149
  curve = result.curve;
3760
4150
  sqrtStartPrice = result.sqrtStartPrice;
3761
- let totalDynamicSupply = getTotalSupplyFromCurve(
4151
+ const totalDynamicSupply = getTotalSupplyFromCurve(
3762
4152
  migrationQuoteThresholdInLamport,
3763
4153
  sqrtStartPrice,
3764
4154
  curve,
@@ -3768,7 +4158,7 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3768
4158
  migrationFee.feePercentage
3769
4159
  );
3770
4160
  if (totalDynamicSupply.gt(totalSupply)) {
3771
- let leftOverDelta = totalDynamicSupply.sub(totalSupply);
4161
+ const leftOverDelta = totalDynamicSupply.sub(totalSupply);
3772
4162
  if (!leftOverDelta.lt(totalLeftover)) {
3773
4163
  throw new Error("leftOverDelta must be less than totalLeftover");
3774
4164
  }
@@ -3788,10 +4178,10 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3788
4178
  tokenType,
3789
4179
  tokenDecimal: tokenBaseDecimal,
3790
4180
  migrationQuoteThreshold: migrationQuoteThresholdInLamport,
3791
- partnerLpPercentage,
3792
- creatorLpPercentage,
3793
- partnerLockedLpPercentage,
3794
- creatorLockedLpPercentage,
4181
+ partnerLiquidityPercentage,
4182
+ partnerPermanentLockedLiquidityPercentage,
4183
+ creatorLiquidityPercentage,
4184
+ creatorPermanentLockedLiquidityPercentage,
3795
4185
  sqrtStartPrice,
3796
4186
  lockedVesting,
3797
4187
  migrationFeeOption,
@@ -3805,6 +4195,9 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3805
4195
  dynamicFee: migratedPoolFeeParams.dynamicFee,
3806
4196
  poolFeeBps: migratedPoolFeeParams.poolFeeBps
3807
4197
  },
4198
+ poolCreationFee: poolCreationFeeInLamports,
4199
+ partnerLiquidityVestingInfo,
4200
+ creatorLiquidityVestingInfo,
3808
4201
  padding: [],
3809
4202
  curve,
3810
4203
  tokenUpdateAuthority,
@@ -3813,29 +4206,33 @@ function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
3813
4206
  return instructionParams;
3814
4207
  }
3815
4208
  function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3816
- let {
4209
+ const {
3817
4210
  totalTokenSupply,
3818
- migrationOption,
4211
+ tokenType,
3819
4212
  tokenBaseDecimal,
3820
4213
  tokenQuoteDecimal,
4214
+ tokenUpdateAuthority,
4215
+ lockedVestingParams,
4216
+ leftover,
4217
+ baseFeeParams,
3821
4218
  dynamicFeeEnabled,
3822
4219
  activationType,
3823
4220
  collectFeeMode,
3824
- migrationFeeOption,
3825
- tokenType,
3826
- partnerLpPercentage,
3827
- creatorLpPercentage,
3828
- partnerLockedLpPercentage,
3829
- creatorLockedLpPercentage,
3830
4221
  creatorTradingFeePercentage,
3831
- leftover,
4222
+ poolCreationFee,
4223
+ migrationOption,
4224
+ migrationFeeOption,
4225
+ migrationFee,
4226
+ partnerPermanentLockedLiquidityPercentage,
4227
+ partnerLiquidityPercentage,
4228
+ creatorPermanentLockedLiquidityPercentage,
4229
+ creatorLiquidityPercentage,
4230
+ partnerLiquidityVestingInfoParams,
4231
+ creatorLiquidityVestingInfoParams,
4232
+ migratedPoolFee,
3832
4233
  initialMarketCap,
3833
4234
  migrationMarketCap,
3834
- liquidityWeights,
3835
- migrationFee,
3836
- tokenUpdateAuthority,
3837
- baseFeeParams,
3838
- migratedPoolFee
4235
+ liquidityWeights
3839
4236
  } = buildCurveWithLiquidityWeightsParam;
3840
4237
  const baseFee = getBaseFeeParams(
3841
4238
  baseFeeParams,
@@ -3848,7 +4245,7 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3848
4245
  cliffUnlockAmount,
3849
4246
  totalVestingDuration,
3850
4247
  cliffDurationFromMigrationTime
3851
- } = buildCurveWithLiquidityWeightsParam.lockedVestingParam;
4248
+ } = lockedVestingParams;
3852
4249
  const lockedVesting = getLockedVestingParams(
3853
4250
  totalLockedVestingAmount,
3854
4251
  numberOfVestingPeriod,
@@ -3857,28 +4254,62 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3857
4254
  cliffDurationFromMigrationTime,
3858
4255
  tokenBaseDecimal
3859
4256
  );
4257
+ const partnerVestingParams = _nullishCoalesce(partnerLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
4258
+ const {
4259
+ vestingPercentage: partnerVestingPercentage,
4260
+ bpsPerPeriod: partnerBpsPerPeriod,
4261
+ numberOfPeriods: partnerNumberOfPeriods,
4262
+ cliffDurationFromMigrationTime: partnerCliffDurationFromMigrationTime,
4263
+ totalDuration: partnerTotalDuration
4264
+ } = partnerVestingParams;
4265
+ const partnerLiquidityVestingInfo = getLiquidityVestingInfoParams(
4266
+ partnerVestingPercentage,
4267
+ partnerBpsPerPeriod,
4268
+ partnerNumberOfPeriods,
4269
+ partnerCliffDurationFromMigrationTime,
4270
+ partnerTotalDuration
4271
+ );
4272
+ const creatorVestingParams = _nullishCoalesce(creatorLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
4273
+ const {
4274
+ vestingPercentage: creatorVestingPercentage,
4275
+ bpsPerPeriod: creatorBpsPerPeriod,
4276
+ numberOfPeriods: creatorNumberOfPeriods,
4277
+ cliffDurationFromMigrationTime: creatorCliffDurationFromMigrationTime,
4278
+ totalDuration: creatorTotalDuration
4279
+ } = creatorVestingParams;
4280
+ const creatorLiquidityVestingInfo = getLiquidityVestingInfoParams(
4281
+ creatorVestingPercentage,
4282
+ creatorBpsPerPeriod,
4283
+ creatorNumberOfPeriods,
4284
+ creatorCliffDurationFromMigrationTime,
4285
+ creatorTotalDuration
4286
+ );
4287
+ const poolCreationFeeInLamports = convertToLamports(
4288
+ poolCreationFee,
4289
+ 9 /* NINE */
4290
+ );
3860
4291
  const migratedPoolFeeParams = getMigratedPoolFeeParams(
3861
4292
  migrationOption,
3862
4293
  migrationFeeOption,
3863
4294
  migratedPoolFee
3864
4295
  );
3865
- let pMin = getSqrtPriceFromMarketCap(
4296
+ const pMin = getSqrtPriceFromMarketCap(
3866
4297
  initialMarketCap,
3867
4298
  totalTokenSupply,
3868
4299
  tokenBaseDecimal,
3869
4300
  tokenQuoteDecimal
3870
4301
  );
3871
- let pMax = getSqrtPriceFromMarketCap(
4302
+ const pMax = getSqrtPriceFromMarketCap(
3872
4303
  migrationMarketCap,
3873
4304
  totalTokenSupply,
3874
4305
  tokenBaseDecimal,
3875
4306
  tokenQuoteDecimal
3876
4307
  );
3877
- let priceRatio = new (0, _decimaljs2.default)(pMax.toString()).div(
4308
+ const priceRatio = new (0, _decimaljs2.default)(pMax.toString()).div(
3878
4309
  new (0, _decimaljs2.default)(pMin.toString())
3879
4310
  );
3880
- let qDecimal = priceRatio.pow(new (0, _decimaljs2.default)(1).div(new (0, _decimaljs2.default)(16)));
3881
- let sqrtPrices = [];
4311
+ const qDecimal = priceRatio.pow(new (0, _decimaljs2.default)(1).div(new (0, _decimaljs2.default)(16)));
4312
+ const sqrtPrices = [];
3882
4313
  let currentPrice = pMin;
3883
4314
  for (let i = 0; i < 17; i++) {
3884
4315
  sqrtPrices.push(currentPrice);
@@ -3886,49 +4317,51 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3886
4317
  qDecimal.mul(new (0, _decimaljs2.default)(currentPrice.toString()))
3887
4318
  );
3888
4319
  }
3889
- let totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
3890
- let totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
3891
- let totalVestingAmount = getTotalVestingAmount(lockedVesting);
3892
- let totalSwapAndMigrationAmount = totalSupply.sub(totalVestingAmount).sub(totalLeftover);
3893
- let sumFactor = new (0, _decimaljs2.default)(0);
3894
- let pmaxWeight = new (0, _decimaljs2.default)(pMax.toString());
3895
- let migrationFeeFactor = new (0, _decimaljs2.default)(100).sub(new (0, _decimaljs2.default)(migrationFee.feePercentage)).div(new (0, _decimaljs2.default)(100));
3896
- for (let i = 1; i < 17; i++) {
3897
- let pi = new (0, _decimaljs2.default)(sqrtPrices[i].toString());
3898
- let piMinus = new (0, _decimaljs2.default)(sqrtPrices[i - 1].toString());
3899
- let k = new (0, _decimaljs2.default)(liquidityWeights[i - 1]);
3900
- let w1 = pi.sub(piMinus).div(pi.mul(piMinus));
3901
- let w2 = pi.sub(piMinus).mul(migrationFeeFactor).div(pmaxWeight.mul(pmaxWeight));
3902
- let weight = k.mul(w1.add(w2));
4320
+ const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
4321
+ const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
4322
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
4323
+ const totalSwapAndMigrationAmount = totalSupply.sub(totalVestingAmount).sub(totalLeftover);
4324
+ let sumFactor = new (0, _decimaljs2.default)(0);
4325
+ const pmaxWeight = new (0, _decimaljs2.default)(pMax.toString());
4326
+ const migrationFeeFactor = new (0, _decimaljs2.default)(100).sub(new (0, _decimaljs2.default)(migrationFee.feePercentage)).div(new (0, _decimaljs2.default)(100));
4327
+ for (let i = 1; i < 17; i++) {
4328
+ const pi = new (0, _decimaljs2.default)(sqrtPrices[i].toString());
4329
+ const piMinus = new (0, _decimaljs2.default)(sqrtPrices[i - 1].toString());
4330
+ const k = new (0, _decimaljs2.default)(liquidityWeights[i - 1]);
4331
+ const w1 = pi.sub(piMinus).div(pi.mul(piMinus));
4332
+ const w2 = pi.sub(piMinus).mul(migrationFeeFactor).div(pmaxWeight.mul(pmaxWeight));
4333
+ const weight = k.mul(w1.add(w2));
3903
4334
  sumFactor = sumFactor.add(weight);
3904
4335
  }
3905
- let l1 = new (0, _decimaljs2.default)(totalSwapAndMigrationAmount.toString()).div(sumFactor);
3906
- let curve = [];
4336
+ const l1 = new (0, _decimaljs2.default)(totalSwapAndMigrationAmount.toString()).div(
4337
+ sumFactor
4338
+ );
4339
+ const curve = [];
3907
4340
  for (let i = 0; i < 16; i++) {
3908
- let k = new (0, _decimaljs2.default)(liquidityWeights[i]);
3909
- let liquidity = convertDecimalToBN(l1.mul(k));
3910
- let sqrtPrice = i < 15 ? sqrtPrices[i + 1] : pMax;
4341
+ const k = new (0, _decimaljs2.default)(liquidityWeights[i]);
4342
+ const liquidity = convertDecimalToBN(l1.mul(k));
4343
+ const sqrtPrice = i < 15 ? sqrtPrices[i + 1] : pMax;
3911
4344
  curve.push({
3912
4345
  sqrtPrice,
3913
4346
  liquidity
3914
4347
  });
3915
4348
  }
3916
- let swapBaseAmount = getBaseTokenForSwap(pMin, pMax, curve);
3917
- let swapBaseAmountBuffer = getSwapAmountWithBuffer(
4349
+ const swapBaseAmount = getBaseTokenForSwap(pMin, pMax, curve);
4350
+ const swapBaseAmountBuffer = getSwapAmountWithBuffer(
3918
4351
  swapBaseAmount,
3919
4352
  pMin,
3920
4353
  curve
3921
4354
  );
3922
- let migrationAmount = totalSwapAndMigrationAmount.sub(swapBaseAmountBuffer);
3923
- let migrationQuoteAmount = migrationAmount.mul(pMax).mul(pMax).shrn(128);
3924
- let migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
4355
+ const migrationAmount = totalSwapAndMigrationAmount.sub(swapBaseAmountBuffer);
4356
+ const migrationQuoteAmount = migrationAmount.mul(pMax).mul(pMax).shrn(128);
4357
+ const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
3925
4358
  new (0, _decimaljs2.default)(migrationQuoteAmount.toString()),
3926
4359
  new (0, _decimaljs2.default)(migrationFee.feePercentage)
3927
4360
  );
3928
- let migrationQuoteThresholdInLamport = fromDecimalToBN(
4361
+ const migrationQuoteThresholdInLamport = fromDecimalToBN(
3929
4362
  migrationQuoteThreshold
3930
4363
  );
3931
- let totalDynamicSupply = getTotalSupplyFromCurve(
4364
+ const totalDynamicSupply = getTotalSupplyFromCurve(
3932
4365
  migrationQuoteThresholdInLamport,
3933
4366
  pMin,
3934
4367
  curve,
@@ -3938,7 +4371,7 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3938
4371
  migrationFee.feePercentage
3939
4372
  );
3940
4373
  if (totalDynamicSupply.gt(totalSupply)) {
3941
- let leftOverDelta = totalDynamicSupply.sub(totalSupply);
4374
+ const leftOverDelta = totalDynamicSupply.sub(totalSupply);
3942
4375
  if (!leftOverDelta.lt(totalLeftover)) {
3943
4376
  throw new Error("leftOverDelta must be less than totalLeftover");
3944
4377
  }
@@ -3958,10 +4391,10 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3958
4391
  tokenType,
3959
4392
  tokenDecimal: tokenBaseDecimal,
3960
4393
  migrationQuoteThreshold: migrationQuoteThresholdInLamport,
3961
- partnerLpPercentage,
3962
- creatorLpPercentage,
3963
- partnerLockedLpPercentage,
3964
- creatorLockedLpPercentage,
4394
+ partnerLiquidityPercentage,
4395
+ partnerPermanentLockedLiquidityPercentage,
4396
+ creatorLiquidityPercentage,
4397
+ creatorPermanentLockedLiquidityPercentage,
3965
4398
  sqrtStartPrice: pMin,
3966
4399
  lockedVesting,
3967
4400
  migrationFeeOption,
@@ -3975,6 +4408,216 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
3975
4408
  dynamicFee: migratedPoolFeeParams.dynamicFee,
3976
4409
  poolFeeBps: migratedPoolFeeParams.poolFeeBps
3977
4410
  },
4411
+ poolCreationFee: poolCreationFeeInLamports,
4412
+ partnerLiquidityVestingInfo,
4413
+ creatorLiquidityVestingInfo,
4414
+ padding: [],
4415
+ curve,
4416
+ migrationFee,
4417
+ tokenUpdateAuthority
4418
+ };
4419
+ return instructionParams;
4420
+ }
4421
+ function buildCurveWithCustomSqrtPrices(buildCurveWithCustomSqrtPricesParam) {
4422
+ const {
4423
+ totalTokenSupply,
4424
+ tokenType,
4425
+ tokenBaseDecimal,
4426
+ tokenQuoteDecimal,
4427
+ tokenUpdateAuthority,
4428
+ lockedVestingParams,
4429
+ leftover,
4430
+ baseFeeParams,
4431
+ dynamicFeeEnabled,
4432
+ activationType,
4433
+ collectFeeMode,
4434
+ creatorTradingFeePercentage,
4435
+ poolCreationFee,
4436
+ migrationOption,
4437
+ migrationFeeOption,
4438
+ migrationFee,
4439
+ partnerPermanentLockedLiquidityPercentage,
4440
+ partnerLiquidityPercentage,
4441
+ creatorPermanentLockedLiquidityPercentage,
4442
+ creatorLiquidityPercentage,
4443
+ partnerLiquidityVestingInfoParams,
4444
+ creatorLiquidityVestingInfoParams,
4445
+ migratedPoolFee,
4446
+ sqrtPrices
4447
+ } = buildCurveWithCustomSqrtPricesParam;
4448
+ let { liquidityWeights } = buildCurveWithCustomSqrtPricesParam;
4449
+ if (sqrtPrices.length < 2) {
4450
+ throw new Error("sqrtPrices array must have at least 2 elements");
4451
+ }
4452
+ for (let i = 1; i < sqrtPrices.length; i++) {
4453
+ if (sqrtPrices[i].lte(sqrtPrices[i - 1])) {
4454
+ throw new Error("sqrtPrices must be in ascending order");
4455
+ }
4456
+ }
4457
+ if (!liquidityWeights) {
4458
+ const numSegments2 = sqrtPrices.length - 1;
4459
+ liquidityWeights = Array(numSegments2).fill(1);
4460
+ } else if (liquidityWeights.length !== sqrtPrices.length - 1) {
4461
+ throw new Error(
4462
+ "liquidityWeights length must equal sqrtPrices.length - 1"
4463
+ );
4464
+ }
4465
+ const baseFee = getBaseFeeParams(
4466
+ baseFeeParams,
4467
+ tokenQuoteDecimal,
4468
+ activationType
4469
+ );
4470
+ const {
4471
+ totalLockedVestingAmount,
4472
+ numberOfVestingPeriod,
4473
+ cliffUnlockAmount,
4474
+ totalVestingDuration,
4475
+ cliffDurationFromMigrationTime
4476
+ } = lockedVestingParams;
4477
+ const lockedVesting = getLockedVestingParams(
4478
+ totalLockedVestingAmount,
4479
+ numberOfVestingPeriod,
4480
+ cliffUnlockAmount,
4481
+ totalVestingDuration,
4482
+ cliffDurationFromMigrationTime,
4483
+ tokenBaseDecimal
4484
+ );
4485
+ const partnerVestingParams = _nullishCoalesce(partnerLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
4486
+ const {
4487
+ vestingPercentage: partnerVestingPercentage,
4488
+ bpsPerPeriod: partnerBpsPerPeriod,
4489
+ numberOfPeriods: partnerNumberOfPeriods,
4490
+ cliffDurationFromMigrationTime: partnerCliffDurationFromMigrationTime,
4491
+ totalDuration: partnerTotalDuration
4492
+ } = partnerVestingParams;
4493
+ const partnerLiquidityVestingInfo = getLiquidityVestingInfoParams(
4494
+ partnerVestingPercentage,
4495
+ partnerBpsPerPeriod,
4496
+ partnerNumberOfPeriods,
4497
+ partnerCliffDurationFromMigrationTime,
4498
+ partnerTotalDuration
4499
+ );
4500
+ const creatorVestingParams = _nullishCoalesce(creatorLiquidityVestingInfoParams, () => ( DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS));
4501
+ const {
4502
+ vestingPercentage: creatorVestingPercentage,
4503
+ bpsPerPeriod: creatorBpsPerPeriod,
4504
+ numberOfPeriods: creatorNumberOfPeriods,
4505
+ cliffDurationFromMigrationTime: creatorCliffDurationFromMigrationTime,
4506
+ totalDuration: creatorTotalDuration
4507
+ } = creatorVestingParams;
4508
+ const creatorLiquidityVestingInfo = getLiquidityVestingInfoParams(
4509
+ creatorVestingPercentage,
4510
+ creatorBpsPerPeriod,
4511
+ creatorNumberOfPeriods,
4512
+ creatorCliffDurationFromMigrationTime,
4513
+ creatorTotalDuration
4514
+ );
4515
+ const poolCreationFeeInLamports = convertToLamports(
4516
+ poolCreationFee,
4517
+ 9 /* NINE */
4518
+ );
4519
+ const migratedPoolFeeParams = getMigratedPoolFeeParams(
4520
+ migrationOption,
4521
+ migrationFeeOption,
4522
+ migratedPoolFee
4523
+ );
4524
+ const pMin = sqrtPrices[0];
4525
+ const pMax = sqrtPrices[sqrtPrices.length - 1];
4526
+ const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
4527
+ const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
4528
+ const totalVestingAmount = getTotalVestingAmount(lockedVesting);
4529
+ const totalSwapAndMigrationAmount = totalSupply.sub(totalVestingAmount).sub(totalLeftover);
4530
+ let sumFactor = new (0, _decimaljs2.default)(0);
4531
+ const pmaxWeight = new (0, _decimaljs2.default)(pMax.toString());
4532
+ const migrationFeeFactor = new (0, _decimaljs2.default)(100).sub(new (0, _decimaljs2.default)(migrationFee.feePercentage)).div(new (0, _decimaljs2.default)(100));
4533
+ const numSegments = sqrtPrices.length - 1;
4534
+ for (let i = 0; i < numSegments; i++) {
4535
+ const pi = new (0, _decimaljs2.default)(sqrtPrices[i + 1].toString());
4536
+ const piMinus = new (0, _decimaljs2.default)(sqrtPrices[i].toString());
4537
+ const k = new (0, _decimaljs2.default)(liquidityWeights[i]);
4538
+ const w1 = pi.sub(piMinus).div(pi.mul(piMinus));
4539
+ const w2 = pi.sub(piMinus).mul(migrationFeeFactor).div(pmaxWeight.mul(pmaxWeight));
4540
+ const weight = k.mul(w1.add(w2));
4541
+ sumFactor = sumFactor.add(weight);
4542
+ }
4543
+ const l1 = new (0, _decimaljs2.default)(totalSwapAndMigrationAmount.toString()).div(
4544
+ sumFactor
4545
+ );
4546
+ const curve = [];
4547
+ for (let i = 0; i < numSegments; i++) {
4548
+ const k = new (0, _decimaljs2.default)(liquidityWeights[i]);
4549
+ const liquidity = convertDecimalToBN(l1.mul(k));
4550
+ const sqrtPrice = sqrtPrices[i + 1];
4551
+ curve.push({
4552
+ sqrtPrice,
4553
+ liquidity
4554
+ });
4555
+ }
4556
+ const swapBaseAmount = getBaseTokenForSwap(pMin, pMax, curve);
4557
+ const swapBaseAmountBuffer = getSwapAmountWithBuffer(
4558
+ swapBaseAmount,
4559
+ pMin,
4560
+ curve
4561
+ );
4562
+ const migrationAmount = totalSwapAndMigrationAmount.sub(swapBaseAmountBuffer);
4563
+ const migrationQuoteAmount = migrationAmount.mul(pMax).mul(pMax).shrn(128);
4564
+ const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
4565
+ new (0, _decimaljs2.default)(migrationQuoteAmount.toString()),
4566
+ new (0, _decimaljs2.default)(migrationFee.feePercentage)
4567
+ );
4568
+ const migrationQuoteThresholdInLamport = fromDecimalToBN(
4569
+ migrationQuoteThreshold
4570
+ );
4571
+ const totalDynamicSupply = getTotalSupplyFromCurve(
4572
+ migrationQuoteThresholdInLamport,
4573
+ pMin,
4574
+ curve,
4575
+ lockedVesting,
4576
+ migrationOption,
4577
+ totalLeftover,
4578
+ migrationFee.feePercentage
4579
+ );
4580
+ if (totalDynamicSupply.gt(totalSupply)) {
4581
+ const leftOverDelta = totalDynamicSupply.sub(totalSupply);
4582
+ if (!leftOverDelta.lt(totalLeftover)) {
4583
+ throw new Error("leftOverDelta must be less than totalLeftover");
4584
+ }
4585
+ }
4586
+ const instructionParams = {
4587
+ poolFees: {
4588
+ baseFee: {
4589
+ ...baseFee
4590
+ },
4591
+ dynamicFee: dynamicFeeEnabled ? getDynamicFeeParams(
4592
+ baseFeeParams.baseFeeMode === 2 /* RateLimiter */ ? baseFeeParams.rateLimiterParam.baseFeeBps : baseFeeParams.feeSchedulerParam.endingFeeBps
4593
+ ) : null
4594
+ },
4595
+ activationType,
4596
+ collectFeeMode,
4597
+ migrationOption,
4598
+ tokenType,
4599
+ tokenDecimal: tokenBaseDecimal,
4600
+ migrationQuoteThreshold: migrationQuoteThresholdInLamport,
4601
+ partnerLiquidityPercentage,
4602
+ partnerPermanentLockedLiquidityPercentage,
4603
+ creatorLiquidityPercentage,
4604
+ creatorPermanentLockedLiquidityPercentage,
4605
+ sqrtStartPrice: pMin,
4606
+ lockedVesting,
4607
+ migrationFeeOption,
4608
+ tokenSupply: {
4609
+ preMigrationTokenSupply: totalSupply,
4610
+ postMigrationTokenSupply: totalSupply
4611
+ },
4612
+ creatorTradingFeePercentage,
4613
+ migratedPoolFee: {
4614
+ collectFeeMode: migratedPoolFeeParams.collectFeeMode,
4615
+ dynamicFee: migratedPoolFeeParams.dynamicFee,
4616
+ poolFeeBps: migratedPoolFeeParams.poolFeeBps
4617
+ },
4618
+ poolCreationFee: poolCreationFeeInLamports,
4619
+ partnerLiquidityVestingInfo,
4620
+ creatorLiquidityVestingInfo,
3978
4621
  padding: [],
3979
4622
  curve,
3980
4623
  migrationFee,
@@ -3991,7 +4634,7 @@ var idl_default = {
3991
4634
  address: "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN",
3992
4635
  metadata: {
3993
4636
  name: "dynamic_bonding_curve",
3994
- version: "0.1.7",
4637
+ version: "0.1.8",
3995
4638
  spec: "0.1.0",
3996
4639
  description: "Created with Anchor"
3997
4640
  },
@@ -4068,10 +4711,7 @@ var idl_default = {
4068
4711
  },
4069
4712
  {
4070
4713
  name: "creator",
4071
- signer: true,
4072
- relations: [
4073
- "pool"
4074
- ]
4714
+ signer: true
4075
4715
  },
4076
4716
  {
4077
4717
  name: "token_base_program",
@@ -4130,16 +4770,16 @@ var idl_default = {
4130
4770
  ]
4131
4771
  },
4132
4772
  {
4133
- name: "claim_pool_creation_fee",
4773
+ name: "claim_legacy_pool_creation_fee",
4134
4774
  discriminator: [
4135
- 246,
4136
- 51,
4137
- 18,
4138
- 222,
4139
- 80,
4140
- 42,
4141
- 236,
4142
- 205
4775
+ 96,
4776
+ 11,
4777
+ 187,
4778
+ 225,
4779
+ 54,
4780
+ 117,
4781
+ 161,
4782
+ 134
4143
4783
  ],
4144
4784
  accounts: [
4145
4785
  {
@@ -4153,14 +4793,11 @@ var idl_default = {
4153
4793
  ]
4154
4794
  },
4155
4795
  {
4156
- name: "operator",
4796
+ name: "signer",
4157
4797
  docs: [
4158
4798
  "Operator"
4159
4799
  ],
4160
- signer: true,
4161
- relations: [
4162
- "claim_fee_operator"
4163
- ]
4800
+ signer: true
4164
4801
  },
4165
4802
  {
4166
4803
  name: "treasury",
@@ -4206,6 +4843,72 @@ var idl_default = {
4206
4843
  ],
4207
4844
  args: []
4208
4845
  },
4846
+ {
4847
+ name: "claim_partner_pool_creation_fee",
4848
+ discriminator: [
4849
+ 250,
4850
+ 238,
4851
+ 26,
4852
+ 4,
4853
+ 139,
4854
+ 10,
4855
+ 101,
4856
+ 248
4857
+ ],
4858
+ accounts: [
4859
+ {
4860
+ name: "config",
4861
+ relations: [
4862
+ "pool"
4863
+ ]
4864
+ },
4865
+ {
4866
+ name: "pool",
4867
+ writable: true
4868
+ },
4869
+ {
4870
+ name: "fee_claimer",
4871
+ signer: true
4872
+ },
4873
+ {
4874
+ name: "fee_receiver",
4875
+ writable: true
4876
+ },
4877
+ {
4878
+ name: "event_authority",
4879
+ pda: {
4880
+ seeds: [
4881
+ {
4882
+ kind: "const",
4883
+ value: [
4884
+ 95,
4885
+ 95,
4886
+ 101,
4887
+ 118,
4888
+ 101,
4889
+ 110,
4890
+ 116,
4891
+ 95,
4892
+ 97,
4893
+ 117,
4894
+ 116,
4895
+ 104,
4896
+ 111,
4897
+ 114,
4898
+ 105,
4899
+ 116,
4900
+ 121
4901
+ ]
4902
+ }
4903
+ ]
4904
+ }
4905
+ },
4906
+ {
4907
+ name: "program"
4908
+ }
4909
+ ],
4910
+ args: []
4911
+ },
4209
4912
  {
4210
4913
  name: "claim_protocol_fee",
4211
4914
  discriminator: [
@@ -4464,14 +5167,11 @@ var idl_default = {
4464
5167
  ]
4465
5168
  },
4466
5169
  {
4467
- name: "operator",
5170
+ name: "signer",
4468
5171
  docs: [
4469
- "Operator"
5172
+ "Signer"
4470
5173
  ],
4471
- signer: true,
4472
- relations: [
4473
- "claim_fee_operator"
4474
- ]
5174
+ signer: true
4475
5175
  },
4476
5176
  {
4477
5177
  name: "token_base_program",
@@ -4520,6 +5220,82 @@ var idl_default = {
4520
5220
  ],
4521
5221
  args: []
4522
5222
  },
5223
+ {
5224
+ name: "claim_protocol_pool_creation_fee",
5225
+ discriminator: [
5226
+ 114,
5227
+ 205,
5228
+ 83,
5229
+ 188,
5230
+ 240,
5231
+ 153,
5232
+ 25,
5233
+ 54
5234
+ ],
5235
+ accounts: [
5236
+ {
5237
+ name: "config",
5238
+ relations: [
5239
+ "pool"
5240
+ ]
5241
+ },
5242
+ {
5243
+ name: "pool",
5244
+ writable: true
5245
+ },
5246
+ {
5247
+ name: "claim_fee_operator",
5248
+ docs: [
5249
+ "Claim fee operator"
5250
+ ]
5251
+ },
5252
+ {
5253
+ name: "signer",
5254
+ docs: [
5255
+ "Operator"
5256
+ ],
5257
+ signer: true
5258
+ },
5259
+ {
5260
+ name: "treasury",
5261
+ writable: true,
5262
+ address: "4EWqcx3aNZmMetCnxwLYwyNjan6XLGp3Ca2W316vrSjv"
5263
+ },
5264
+ {
5265
+ name: "event_authority",
5266
+ pda: {
5267
+ seeds: [
5268
+ {
5269
+ kind: "const",
5270
+ value: [
5271
+ 95,
5272
+ 95,
5273
+ 101,
5274
+ 118,
5275
+ 101,
5276
+ 110,
5277
+ 116,
5278
+ 95,
5279
+ 97,
5280
+ 117,
5281
+ 116,
5282
+ 104,
5283
+ 111,
5284
+ 114,
5285
+ 105,
5286
+ 116,
5287
+ 121
5288
+ ]
5289
+ }
5290
+ ]
5291
+ }
5292
+ },
5293
+ {
5294
+ name: "program"
5295
+ }
5296
+ ],
5297
+ args: []
5298
+ },
4523
5299
  {
4524
5300
  name: "claim_trading_fee",
4525
5301
  discriminator: [
@@ -4601,10 +5377,7 @@ var idl_default = {
4601
5377
  },
4602
5378
  {
4603
5379
  name: "fee_claimer",
4604
- signer: true,
4605
- relations: [
4606
- "config"
4607
- ]
5380
+ signer: true
4608
5381
  },
4609
5382
  {
4610
5383
  name: "token_base_program",
@@ -4663,16 +5436,16 @@ var idl_default = {
4663
5436
  ]
4664
5437
  },
4665
5438
  {
4666
- name: "close_claim_fee_operator",
5439
+ name: "close_claim_protocol_fee_operator",
4667
5440
  discriminator: [
4668
- 38,
4669
- 134,
4670
- 82,
4671
- 216,
4672
- 95,
4673
- 124,
4674
- 17,
4675
- 99
5441
+ 8,
5442
+ 41,
5443
+ 87,
5444
+ 35,
5445
+ 80,
5446
+ 48,
5447
+ 121,
5448
+ 26
4676
5449
  ],
4677
5450
  accounts: [
4678
5451
  {
@@ -4684,7 +5457,7 @@ var idl_default = {
4684
5457
  writable: true
4685
5458
  },
4686
5459
  {
4687
- name: "admin",
5460
+ name: "signer",
4688
5461
  signer: true
4689
5462
  },
4690
5463
  {
@@ -4723,19 +5496,16 @@ var idl_default = {
4723
5496
  args: []
4724
5497
  },
4725
5498
  {
4726
- name: "create_claim_fee_operator",
4727
- docs: [
4728
- "ADMIN FUNCTIONS_ ///"
4729
- ],
5499
+ name: "create_claim_protocol_fee_operator",
4730
5500
  discriminator: [
4731
- 169,
4732
- 62,
4733
- 207,
4734
- 107,
4735
- 58,
4736
- 187,
4737
- 162,
4738
- 109
5501
+ 51,
5502
+ 19,
5503
+ 150,
5504
+ 252,
5505
+ 105,
5506
+ 157,
5507
+ 48,
5508
+ 91
4739
5509
  ],
4740
5510
  accounts: [
4741
5511
  {
@@ -4770,7 +5540,11 @@ var idl_default = {
4770
5540
  name: "operator"
4771
5541
  },
4772
5542
  {
4773
- name: "admin",
5543
+ name: "signer",
5544
+ signer: true
5545
+ },
5546
+ {
5547
+ name: "payer",
4774
5548
  writable: true,
4775
5549
  signer: true
4776
5550
  },
@@ -5193,10 +5967,7 @@ var idl_default = {
5193
5967
  },
5194
5968
  {
5195
5969
  name: "creator",
5196
- signer: true,
5197
- relations: [
5198
- "virtual_pool"
5199
- ]
5970
+ signer: true
5200
5971
  },
5201
5972
  {
5202
5973
  name: "payer",
@@ -5312,10 +6083,7 @@ var idl_default = {
5312
6083
  },
5313
6084
  {
5314
6085
  name: "creator",
5315
- signer: true,
5316
- relations: [
5317
- "virtual_pool"
5318
- ]
6086
+ signer: true
5319
6087
  },
5320
6088
  {
5321
6089
  name: "token_quote_program",
@@ -6350,7 +7118,8 @@ var idl_default = {
6350
7118
  },
6351
7119
  {
6352
7120
  name: "first_position_nft_mint",
6353
- writable: true
7121
+ writable: true,
7122
+ signer: true
6354
7123
  },
6355
7124
  {
6356
7125
  name: "first_position_nft_account",
@@ -6363,6 +7132,7 @@ var idl_default = {
6363
7132
  {
6364
7133
  name: "second_position_nft_mint",
6365
7134
  writable: true,
7135
+ signer: true,
6366
7136
  optional: true
6367
7137
  },
6368
7138
  {
@@ -6650,10 +7420,7 @@ var idl_default = {
6650
7420
  },
6651
7421
  {
6652
7422
  name: "fee_claimer",
6653
- signer: true,
6654
- relations: [
6655
- "config"
6656
- ]
7423
+ signer: true
6657
7424
  },
6658
7425
  {
6659
7426
  name: "token_quote_program",
@@ -6835,6 +7602,19 @@ var idl_default = {
6835
7602
  "config"
6836
7603
  ]
6837
7604
  },
7605
+ {
7606
+ name: "claim_fee_operator",
7607
+ docs: [
7608
+ "Claim fee operator"
7609
+ ]
7610
+ },
7611
+ {
7612
+ name: "signer",
7613
+ docs: [
7614
+ "Signer"
7615
+ ],
7616
+ signer: true
7617
+ },
6838
7618
  {
6839
7619
  name: "token_quote_program",
6840
7620
  docs: [
@@ -7204,10 +7984,7 @@ var idl_default = {
7204
7984
  },
7205
7985
  {
7206
7986
  name: "creator",
7207
- signer: true,
7208
- relations: [
7209
- "virtual_pool"
7210
- ]
7987
+ signer: true
7211
7988
  },
7212
7989
  {
7213
7990
  name: "new_creator"
@@ -7247,36 +8024,6 @@ var idl_default = {
7247
8024
  ],
7248
8025
  args: []
7249
8026
  },
7250
- {
7251
- name: "withdraw_lamports_from_pool_authority",
7252
- discriminator: [
7253
- 20,
7254
- 185,
7255
- 242,
7256
- 240,
7257
- 129,
7258
- 24,
7259
- 212,
7260
- 194
7261
- ],
7262
- accounts: [
7263
- {
7264
- name: "pool_authority",
7265
- writable: true,
7266
- address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"
7267
- },
7268
- {
7269
- name: "receiver",
7270
- writable: true,
7271
- address: "4EWqcx3aNZmMetCnxwLYwyNjan6XLGp3Ca2W316vrSjv"
7272
- },
7273
- {
7274
- name: "system_program",
7275
- address: "11111111111111111111111111111111"
7276
- }
7277
- ],
7278
- args: []
7279
- },
7280
8027
  {
7281
8028
  name: "withdraw_leftover",
7282
8029
  discriminator: [
@@ -7800,6 +8547,19 @@ var idl_default = {
7800
8547
  37
7801
8548
  ]
7802
8549
  },
8550
+ {
8551
+ name: "EvtPartnerClaimPoolCreationFee",
8552
+ discriminator: [
8553
+ 174,
8554
+ 223,
8555
+ 44,
8556
+ 150,
8557
+ 145,
8558
+ 98,
8559
+ 89,
8560
+ 195
8561
+ ]
8562
+ },
7803
8563
  {
7804
8564
  name: "EvtPartnerMetadata",
7805
8565
  discriminator: [
@@ -8186,6 +8946,31 @@ var idl_default = {
8186
8946
  code: 6050,
8187
8947
  name: "AccountInvariantViolation",
8188
8948
  msg: "Account invariant violation"
8949
+ },
8950
+ {
8951
+ code: 6051,
8952
+ name: "InvalidPoolCreationFee",
8953
+ msg: "Invalid pool creation fee"
8954
+ },
8955
+ {
8956
+ code: 6052,
8957
+ name: "PoolCreationFeeHasBeenClaimed",
8958
+ msg: "Pool creation fee has been claimed"
8959
+ },
8960
+ {
8961
+ code: 6053,
8962
+ name: "Unauthorized",
8963
+ msg: "Not permit to do this action"
8964
+ },
8965
+ {
8966
+ code: 6054,
8967
+ name: "ZeroPoolCreationFee",
8968
+ msg: "Pool creation fee is zero"
8969
+ },
8970
+ {
8971
+ code: 6055,
8972
+ name: "InvalidMigrationLockedLiquidity",
8973
+ msg: "Invalid migration locked liquidity"
8189
8974
  }
8190
8975
  ],
8191
8976
  types: [
@@ -8371,19 +9156,19 @@ var idl_default = {
8371
9156
  type: "u8"
8372
9157
  },
8373
9158
  {
8374
- name: "partner_lp_percentage",
9159
+ name: "partner_liquidity_percentage",
8375
9160
  type: "u8"
8376
9161
  },
8377
9162
  {
8378
- name: "partner_locked_lp_percentage",
9163
+ name: "partner_permanent_locked_liquidity_percentage",
8379
9164
  type: "u8"
8380
9165
  },
8381
9166
  {
8382
- name: "creator_lp_percentage",
9167
+ name: "creator_liquidity_percentage",
8383
9168
  type: "u8"
8384
9169
  },
8385
9170
  {
8386
- name: "creator_locked_lp_percentage",
9171
+ name: "creator_permanent_locked_liquidity_percentage",
8387
9172
  type: "u8"
8388
9173
  },
8389
9174
  {
@@ -8440,6 +9225,29 @@ var idl_default = {
8440
9225
  }
8441
9226
  }
8442
9227
  },
9228
+ {
9229
+ name: "pool_creation_fee",
9230
+ docs: [
9231
+ "pool creation fee in SOL lamports value"
9232
+ ],
9233
+ type: "u64"
9234
+ },
9235
+ {
9236
+ name: "partner_liquidity_vesting_info",
9237
+ type: {
9238
+ defined: {
9239
+ name: "LiquidityVestingInfoParams"
9240
+ }
9241
+ }
9242
+ },
9243
+ {
9244
+ name: "creator_liquidity_vesting_info",
9245
+ type: {
9246
+ defined: {
9247
+ name: "LiquidityVestingInfoParams"
9248
+ }
9249
+ }
9250
+ },
8443
9251
  {
8444
9252
  name: "padding",
8445
9253
  docs: [
@@ -8447,8 +9255,8 @@ var idl_default = {
8447
9255
  ],
8448
9256
  type: {
8449
9257
  array: [
8450
- "u64",
8451
- 7
9258
+ "u8",
9259
+ 22
8452
9260
  ]
8453
9261
  }
8454
9262
  },
@@ -8651,7 +9459,7 @@ var idl_default = {
8651
9459
  type: "pubkey"
8652
9460
  },
8653
9461
  {
8654
- name: "treasury",
9462
+ name: "receiver",
8655
9463
  type: "pubkey"
8656
9464
  },
8657
9465
  {
@@ -8788,19 +9596,19 @@ var idl_default = {
8788
9596
  type: "u8"
8789
9597
  },
8790
9598
  {
8791
- name: "partner_locked_lp_percentage",
9599
+ name: "partner_permanent_locked_liquidity_percentage",
8792
9600
  type: "u8"
8793
9601
  },
8794
9602
  {
8795
- name: "partner_lp_percentage",
9603
+ name: "partner_liquidity_percentage",
8796
9604
  type: "u8"
8797
9605
  },
8798
9606
  {
8799
- name: "creator_locked_lp_percentage",
9607
+ name: "creator_permanent_locked_liquidity_percentage",
8800
9608
  type: "u8"
8801
9609
  },
8802
9610
  {
8803
- name: "creator_lp_percentage",
9611
+ name: "creator_liquidity_percentage",
8804
9612
  type: "u8"
8805
9613
  },
8806
9614
  {
@@ -8972,6 +9780,26 @@ var idl_default = {
8972
9780
  ]
8973
9781
  }
8974
9782
  },
9783
+ {
9784
+ name: "EvtPartnerClaimPoolCreationFee",
9785
+ type: {
9786
+ kind: "struct",
9787
+ fields: [
9788
+ {
9789
+ name: "pool",
9790
+ type: "pubkey"
9791
+ },
9792
+ {
9793
+ name: "partner",
9794
+ type: "pubkey"
9795
+ },
9796
+ {
9797
+ name: "creation_fee",
9798
+ type: "u64"
9799
+ }
9800
+ ]
9801
+ }
9802
+ },
8975
9803
  {
8976
9804
  name: "EvtPartnerMetadata",
8977
9805
  docs: [
@@ -9274,6 +10102,79 @@ var idl_default = {
9274
10102
  ]
9275
10103
  }
9276
10104
  },
10105
+ {
10106
+ name: "LiquidityVestingInfo",
10107
+ serialization: "bytemuck",
10108
+ repr: {
10109
+ kind: "c"
10110
+ },
10111
+ type: {
10112
+ kind: "struct",
10113
+ fields: [
10114
+ {
10115
+ name: "is_initialized",
10116
+ type: "u8"
10117
+ },
10118
+ {
10119
+ name: "vesting_percentage",
10120
+ type: "u8"
10121
+ },
10122
+ {
10123
+ name: "_padding",
10124
+ type: {
10125
+ array: [
10126
+ "u8",
10127
+ 2
10128
+ ]
10129
+ }
10130
+ },
10131
+ {
10132
+ name: "bps_per_period",
10133
+ type: "u16"
10134
+ },
10135
+ {
10136
+ name: "number_of_periods",
10137
+ type: "u16"
10138
+ },
10139
+ {
10140
+ name: "frequency",
10141
+ type: "u32"
10142
+ },
10143
+ {
10144
+ name: "cliff_duration_from_migration_time",
10145
+ type: "u32"
10146
+ }
10147
+ ]
10148
+ }
10149
+ },
10150
+ {
10151
+ name: "LiquidityVestingInfoParams",
10152
+ type: {
10153
+ kind: "struct",
10154
+ fields: [
10155
+ {
10156
+ name: "vesting_percentage",
10157
+ type: "u8"
10158
+ },
10159
+ {
10160
+ name: "bps_per_period",
10161
+ type: "u16"
10162
+ },
10163
+ {
10164
+ name: "number_of_periods",
10165
+ type: "u16"
10166
+ },
10167
+ {
10168
+ name: "cliff_duration_from_migration_time",
10169
+ type: "u32"
10170
+ },
10171
+ {
10172
+ name: "frequency",
10173
+ type: "u32"
10174
+ }
10175
+ ]
10176
+ }
10177
+ },
9277
10178
  {
9278
10179
  name: "LockEscrow",
9279
10180
  docs: [
@@ -9404,7 +10305,7 @@ var idl_default = {
9404
10305
  {
9405
10306
  name: "padding_0",
9406
10307
  docs: [
9407
- "!!! BE CAREFUL to use tomestone field, previous is pool creator"
10308
+ "!!! BE CAREFUL to use tombstone field, previous is pool creator"
9408
10309
  ],
9409
10310
  type: {
9410
10311
  array: [
@@ -9428,30 +10329,30 @@ var idl_default = {
9428
10329
  type: "pubkey"
9429
10330
  },
9430
10331
  {
9431
- name: "partner_locked_lp",
10332
+ name: "partner_locked_liquidity",
9432
10333
  docs: [
9433
- "partner locked lp"
10334
+ "partner locked liquidity"
9434
10335
  ],
9435
10336
  type: "u64"
9436
10337
  },
9437
10338
  {
9438
- name: "partner_lp",
10339
+ name: "partner_liquidity",
9439
10340
  docs: [
9440
- "partner lp"
10341
+ "partner liquidity"
9441
10342
  ],
9442
10343
  type: "u64"
9443
10344
  },
9444
10345
  {
9445
- name: "creator_locked_lp",
10346
+ name: "creator_locked_liquidity",
9446
10347
  docs: [
9447
- "creator locked lp"
10348
+ "creator locked liquidity"
9448
10349
  ],
9449
10350
  type: "u64"
9450
10351
  },
9451
10352
  {
9452
- name: "creator_lp",
10353
+ name: "creator_liquidity",
9453
10354
  docs: [
9454
- "creator lp"
10355
+ "creator liquidity"
9455
10356
  ],
9456
10357
  type: "u64"
9457
10358
  },
@@ -9465,28 +10366,28 @@ var idl_default = {
9465
10366
  {
9466
10367
  name: "creator_locked_status",
9467
10368
  docs: [
9468
- "flag to check whether lp is locked for creator"
10369
+ "flag to check whether liquidity token is locked for creator"
9469
10370
  ],
9470
10371
  type: "u8"
9471
10372
  },
9472
10373
  {
9473
10374
  name: "partner_locked_status",
9474
10375
  docs: [
9475
- "flag to check whether lp is locked for partner"
10376
+ "flag to check whether liquidity token is locked for partner"
9476
10377
  ],
9477
10378
  type: "u8"
9478
10379
  },
9479
10380
  {
9480
10381
  name: "creator_claim_status",
9481
10382
  docs: [
9482
- "flag to check whether creator has claimed lp token"
10383
+ "flag to check whether creator has claimed liquidity token"
9483
10384
  ],
9484
10385
  type: "u8"
9485
10386
  },
9486
10387
  {
9487
10388
  name: "partner_claim_status",
9488
10389
  docs: [
9489
- "flag to check whether partner has claimed lp token"
10390
+ "flag to check whether partner has claimed liquidity token"
9490
10391
  ],
9491
10392
  type: "u8"
9492
10393
  },
@@ -9633,6 +10534,41 @@ var idl_default = {
9633
10534
  }
9634
10535
  }
9635
10536
  },
10537
+ {
10538
+ name: "partner_liquidity_vesting_info",
10539
+ type: {
10540
+ defined: {
10541
+ name: "LiquidityVestingInfo"
10542
+ }
10543
+ }
10544
+ },
10545
+ {
10546
+ name: "creator_liquidity_vesting_info",
10547
+ type: {
10548
+ defined: {
10549
+ name: "LiquidityVestingInfo"
10550
+ }
10551
+ }
10552
+ },
10553
+ {
10554
+ name: "padding_0",
10555
+ docs: [
10556
+ "Padding for future use"
10557
+ ],
10558
+ type: {
10559
+ array: [
10560
+ "u8",
10561
+ 14
10562
+ ]
10563
+ }
10564
+ },
10565
+ {
10566
+ name: "padding_1",
10567
+ docs: [
10568
+ "Previously was protocol and referral fee percent. Beware of tombstone."
10569
+ ],
10570
+ type: "u16"
10571
+ },
9636
10572
  {
9637
10573
  name: "collect_fee_mode",
9638
10574
  docs: [
@@ -9683,30 +10619,30 @@ var idl_default = {
9683
10619
  type: "u8"
9684
10620
  },
9685
10621
  {
9686
- name: "partner_locked_lp_percentage",
10622
+ name: "partner_permanent_locked_liquidity_percentage",
9687
10623
  docs: [
9688
- "partner locked lp percentage"
10624
+ "partner locked liquidity percentage"
9689
10625
  ],
9690
10626
  type: "u8"
9691
10627
  },
9692
10628
  {
9693
- name: "partner_lp_percentage",
10629
+ name: "partner_liquidity_percentage",
9694
10630
  docs: [
9695
- "partner lp percentage"
10631
+ "partner liquidity percentage"
9696
10632
  ],
9697
10633
  type: "u8"
9698
10634
  },
9699
10635
  {
9700
- name: "creator_locked_lp_percentage",
10636
+ name: "creator_permanent_locked_liquidity_percentage",
9701
10637
  docs: [
9702
10638
  "creator post migration fee percentage"
9703
10639
  ],
9704
10640
  type: "u8"
9705
10641
  },
9706
10642
  {
9707
- name: "creator_lp_percentage",
10643
+ name: "creator_liquidity_percentage",
9708
10644
  docs: [
9709
- "creator lp percentage"
10645
+ "creator liquidity percentage"
9710
10646
  ],
9711
10647
  type: "u8"
9712
10648
  },
@@ -9753,10 +10689,7 @@ var idl_default = {
9753
10689
  type: "u8"
9754
10690
  },
9755
10691
  {
9756
- name: "_padding_0",
9757
- docs: [
9758
- "padding 0"
9759
- ],
10692
+ name: "padding_2",
9760
10693
  type: {
9761
10694
  array: [
9762
10695
  "u8",
@@ -9846,10 +10779,17 @@ var idl_default = {
9846
10779
  type: {
9847
10780
  array: [
9848
10781
  "u8",
9849
- 12
10782
+ 4
9850
10783
  ]
9851
10784
  }
9852
10785
  },
10786
+ {
10787
+ name: "pool_creation_fee",
10788
+ docs: [
10789
+ "pool creation fee in lamports value"
10790
+ ],
10791
+ type: "u64"
10792
+ },
9853
10793
  {
9854
10794
  name: "_padding_2",
9855
10795
  docs: [
@@ -9969,32 +10909,6 @@ var idl_default = {
9969
10909
  name: "DynamicFeeConfig"
9970
10910
  }
9971
10911
  }
9972
- },
9973
- {
9974
- name: "padding_0",
9975
- type: {
9976
- array: [
9977
- "u64",
9978
- 5
9979
- ]
9980
- }
9981
- },
9982
- {
9983
- name: "padding_1",
9984
- type: {
9985
- array: [
9986
- "u8",
9987
- 6
9988
- ]
9989
- }
9990
- },
9991
- {
9992
- name: "protocol_fee_percent",
9993
- type: "u8"
9994
- },
9995
- {
9996
- name: "referral_fee_percent",
9997
- type: "u8"
9998
10912
  }
9999
10913
  ]
10000
10914
  }
@@ -10370,16 +11284,29 @@ var idl_default = {
10370
11284
  ],
10371
11285
  type: "u64"
10372
11286
  },
11287
+ {
11288
+ name: "legacy_creation_fee_bits",
11289
+ docs: [
11290
+ "legacy creation fee bits, we dont use this now"
11291
+ ],
11292
+ type: "u8"
11293
+ },
10373
11294
  {
10374
11295
  name: "creation_fee_bits",
11296
+ docs: [
11297
+ "pool creation fee claim status"
11298
+ ],
10375
11299
  type: "u8"
10376
11300
  },
10377
11301
  {
10378
11302
  name: "_padding_0",
11303
+ docs: [
11304
+ "Padding for further use"
11305
+ ],
10379
11306
  type: {
10380
11307
  array: [
10381
11308
  "u8",
10382
- 7
11309
+ 6
10383
11310
  ]
10384
11311
  }
10385
11312
  },
@@ -24665,6 +25592,25 @@ var MigrationService = class extends DynamicBondingCurveProgram {
24665
25592
  );
24666
25593
  const tokenBaseProgram = poolConfigState.tokenType == 0 ? _spltoken.TOKEN_PROGRAM_ID : _spltoken.TOKEN_2022_PROGRAM_ID;
24667
25594
  const tokenQuoteProgram = poolConfigState.quoteTokenFlag == 0 ? _spltoken.TOKEN_PROGRAM_ID : _spltoken.TOKEN_2022_PROGRAM_ID;
25595
+ const firstPositionVestingAddress = deriveDammV2PositionVestingAccount(firstPosition);
25596
+ const secondPositionVestingAddress = deriveDammV2PositionVestingAccount(secondPosition);
25597
+ const remainingAccounts = [
25598
+ {
25599
+ isSigner: false,
25600
+ isWritable: false,
25601
+ pubkey: dammConfig
25602
+ },
25603
+ {
25604
+ isSigner: false,
25605
+ isWritable: true,
25606
+ pubkey: firstPositionVestingAddress
25607
+ },
25608
+ {
25609
+ isSigner: false,
25610
+ isWritable: true,
25611
+ pubkey: secondPositionVestingAddress
25612
+ }
25613
+ ];
24668
25614
  const tx = await this.program.methods.migrationDammV2().accountsStrict({
24669
25615
  virtualPool,
24670
25616
  migrationMetadata,
@@ -24691,15 +25637,9 @@ var MigrationService = class extends DynamicBondingCurveProgram {
24691
25637
  token2022Program: _spltoken.TOKEN_2022_PROGRAM_ID,
24692
25638
  systemProgram: _web3js.SystemProgram.programId,
24693
25639
  dammEventAuthority
24694
- }).remainingAccounts([
24695
- {
24696
- isSigner: false,
24697
- isWritable: false,
24698
- pubkey: dammConfig
24699
- }
24700
- ]).transaction();
25640
+ }).remainingAccounts(remainingAccounts).transaction();
24701
25641
  const modifyComputeUnits = _web3js.ComputeBudgetProgram.setComputeUnitLimit({
24702
- units: 5e5
25642
+ units: 6e5
24703
25643
  });
24704
25644
  tx.add(modifyComputeUnits);
24705
25645
  return {
@@ -25150,6 +26090,33 @@ var PartnerService = class extends DynamicBondingCurveProgram {
25150
26090
  }).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
25151
26091
  return transaction;
25152
26092
  }
26093
+ /**
26094
+ * Claim partner pool creation fee
26095
+ * @param params - The claim partner pool creation fee parameters
26096
+ * @returns A claim partner pool creation fee transaction
26097
+ */
26098
+ async claimPartnerPoolCreationFee(params) {
26099
+ const { virtualPool, feeReceiver } = params;
26100
+ const virtualPoolState = await this.state.getPool(virtualPool);
26101
+ if (!virtualPoolState) {
26102
+ throw new Error(`Pool not found: ${virtualPool.toString()}`);
26103
+ }
26104
+ const config = virtualPoolState.config;
26105
+ const configState = await this.state.getPoolConfig(
26106
+ virtualPoolState.config
26107
+ );
26108
+ if (!configState) {
26109
+ throw new Error(`Pool config not found for virtual pool`);
26110
+ }
26111
+ const feeClaimer = configState.feeClaimer;
26112
+ const transaction = await this.program.methods.claimPartnerPoolCreationFee().accountsPartial({
26113
+ config,
26114
+ pool: virtualPool,
26115
+ feeClaimer,
26116
+ feeReceiver
26117
+ }).transaction();
26118
+ return transaction;
26119
+ }
25153
26120
  };
25154
26121
 
25155
26122
  // src/services/pool.ts
@@ -26723,5 +27690,20 @@ var DynamicBondingCurveClient = class _DynamicBondingCurveClient {
26723
27690
 
26724
27691
 
26725
27692
 
26726
- 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.BaseFeeMode = BaseFeeMode; 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.DYNAMIC_FEE_ROUNDING_OFFSET = DYNAMIC_FEE_ROUNDING_OFFSET; exports.DYNAMIC_FEE_SCALING_FACTOR = DYNAMIC_FEE_SCALING_FACTOR; exports.DammV2DynamicFeeMode = DammV2DynamicFeeMode; exports.DynamicBondingCurveClient = DynamicBondingCurveClient; exports.DynamicBondingCurveIdl = idl_default; exports.DynamicBondingCurveProgram = DynamicBondingCurveProgram; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeRateLimiter = FeeRateLimiter; exports.FeeScheduler = FeeScheduler; exports.LOCKER_PROGRAM_ID = LOCKER_PROGRAM_ID; exports.MAX_CREATOR_MIGRATION_FEE_PERCENTAGE = MAX_CREATOR_MIGRATION_FEE_PERCENTAGE; exports.MAX_CURVE_POINT = MAX_CURVE_POINT; exports.MAX_DYNAMIC_FEE_PERCENTAGE = MAX_DYNAMIC_FEE_PERCENTAGE; exports.MAX_FEE_BPS = MAX_FEE_BPS; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_MIGRATED_POOL_FEE_BPS = MAX_MIGRATED_POOL_FEE_BPS; exports.MAX_MIGRATION_FEE_PERCENTAGE = MAX_MIGRATION_FEE_PERCENTAGE; exports.MAX_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_DEFAULT; exports.MAX_RATE_LIMITER_DURATION_IN_SECONDS = MAX_RATE_LIMITER_DURATION_IN_SECONDS; exports.MAX_RATE_LIMITER_DURATION_IN_SLOTS = MAX_RATE_LIMITER_DURATION_IN_SLOTS; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.METAPLEX_PROGRAM_ID = METAPLEX_PROGRAM_ID; exports.MIN_FEE_BPS = MIN_FEE_BPS; exports.MIN_FEE_NUMERATOR = MIN_FEE_NUMERATOR; exports.MIN_MIGRATED_POOL_FEE_BPS = MIN_MIGRATED_POOL_FEE_BPS; 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.SafeMath = SafeMath; exports.StateService = StateService; exports.SwapMode = SwapMode; exports.TIMESTAMP_DURATION = TIMESTAMP_DURATION; exports.TokenDecimal = TokenDecimal; exports.TokenType = TokenType; exports.TokenUpdateAuthorityOption = TokenUpdateAuthorityOption; exports.TradeDirection = TradeDirection; exports.U128_MAX = U128_MAX; exports.U16_MAX = U16_MAX; exports.U64_MAX = U64_MAX; exports.VAULT_PROGRAM_ID = VAULT_PROGRAM_ID; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.buildCurve = buildCurve; exports.buildCurveWithLiquidityWeights = buildCurveWithLiquidityWeights; exports.buildCurveWithMarketCap = buildCurveWithMarketCap; exports.buildCurveWithMidPrice = buildCurveWithMidPrice; exports.buildCurveWithTwoSegments = buildCurveWithTwoSegments; exports.calculateBaseToQuoteFromAmountIn = calculateBaseToQuoteFromAmountIn; exports.calculateBaseToQuoteFromAmountOut = calculateBaseToQuoteFromAmountOut; exports.calculateFeeSchedulerEndingBaseFeeBps = calculateFeeSchedulerEndingBaseFeeBps; exports.calculateQuoteToBaseFromAmountIn = calculateQuoteToBaseFromAmountIn; exports.calculateQuoteToBaseFromAmountOut = calculateQuoteToBaseFromAmountOut; exports.checkRateLimiterApplied = checkRateLimiterApplied; exports.cleanUpTokenAccountTx = cleanUpTokenAccountTx; exports.convertDecimalToBN = convertDecimalToBN; exports.convertToLamports = convertToLamports; 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.fromDecimalToBN = fromDecimalToBN; exports.getAccountCreationTimestamp = getAccountCreationTimestamp; exports.getAccountCreationTimestamps = getAccountCreationTimestamps; exports.getAccountData = getAccountData; exports.getBaseFeeHandler = getBaseFeeHandler; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getBaseFeeNumeratorByPeriod = getBaseFeeNumeratorByPeriod; exports.getBaseFeeParams = getBaseFeeParams; exports.getBaseTokenForSwap = getBaseTokenForSwap; exports.getCheckedAmounts = getCheckedAmounts; exports.getCurrentPoint = getCurrentPoint; exports.getCurveBreakdown = getCurveBreakdown; exports.getDeltaAmountBaseUnsigned = getDeltaAmountBaseUnsigned; exports.getDeltaAmountBaseUnsigned256 = getDeltaAmountBaseUnsigned256; exports.getDeltaAmountBaseUnsignedUnchecked = getDeltaAmountBaseUnsignedUnchecked; exports.getDeltaAmountQuoteUnsigned = getDeltaAmountQuoteUnsigned; exports.getDeltaAmountQuoteUnsigned256 = getDeltaAmountQuoteUnsigned256; exports.getDeltaAmountQuoteUnsignedUnchecked = getDeltaAmountQuoteUnsignedUnchecked; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getExcludedFeeAmount = getExcludedFeeAmount; exports.getFeeMode = getFeeMode; exports.getFeeNumeratorFromExcludedAmount = getFeeNumeratorFromExcludedAmount; exports.getFeeNumeratorFromIncludedAmount = getFeeNumeratorFromIncludedAmount; exports.getFeeNumeratorOnExponentialFeeScheduler = getFeeNumeratorOnExponentialFeeScheduler; exports.getFeeNumeratorOnLinearFeeScheduler = getFeeNumeratorOnLinearFeeScheduler; exports.getFeeOnAmount = getFeeOnAmount; exports.getFeeSchedulerParams = getFeeSchedulerParams; exports.getFirstCurve = getFirstCurve; exports.getFirstKey = getFirstKey; exports.getIncludedFeeAmount = getIncludedFeeAmount; exports.getInitialLiquidityFromDeltaBase = getInitialLiquidityFromDeltaBase; exports.getInitialLiquidityFromDeltaQuote = getInitialLiquidityFromDeltaQuote; exports.getLiquidity = getLiquidity; exports.getLockedVestingParams = getLockedVestingParams; exports.getMaxBaseFeeNumerator = getMaxBaseFeeNumerator; exports.getMaxIndex = getMaxIndex; exports.getMaxOutAmountWithMinBaseFee = getMaxOutAmountWithMinBaseFee; exports.getMigratedPoolFeeParams = getMigratedPoolFeeParams; exports.getMigrationBaseToken = getMigrationBaseToken; exports.getMigrationQuoteAmount = getMigrationQuoteAmount; exports.getMigrationQuoteAmountFromMigrationQuoteThreshold = getMigrationQuoteAmountFromMigrationQuoteThreshold; exports.getMigrationQuoteThresholdFromMigrationQuoteAmount = getMigrationQuoteThresholdFromMigrationQuoteAmount; exports.getMigrationThresholdPrice = getMigrationThresholdPrice; exports.getMinBaseFeeNumerator = getMinBaseFeeNumerator; exports.getNextSqrtPriceFromBaseAmountInRoundingUp = getNextSqrtPriceFromBaseAmountInRoundingUp; exports.getNextSqrtPriceFromBaseAmountOutRoundingUp = getNextSqrtPriceFromBaseAmountOutRoundingUp; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getNextSqrtPriceFromOutput = getNextSqrtPriceFromOutput; exports.getNextSqrtPriceFromQuoteAmountInRoundingDown = getNextSqrtPriceFromQuoteAmountInRoundingDown; exports.getNextSqrtPriceFromQuoteAmountOutRoundingDown = getNextSqrtPriceFromQuoteAmountOutRoundingDown; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPercentageSupplyOnMigration = getPercentageSupplyOnMigration; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getQuoteReserveFromNextSqrtPrice = getQuoteReserveFromNextSqrtPrice; exports.getRateLimiterExcludedFeeAmount = getRateLimiterExcludedFeeAmount; exports.getRateLimiterParams = getRateLimiterParams; exports.getSecondKey = getSecondKey; exports.getSqrtPriceFromMarketCap = getSqrtPriceFromMarketCap; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapAmountWithBuffer = getSwapAmountWithBuffer; exports.getSwapResult = getSwapResult; exports.getSwapResultFromExactInput = getSwapResultFromExactInput; exports.getSwapResultFromExactOutput = getSwapResultFromExactOutput; exports.getSwapResultFromPartialInput = getSwapResultFromPartialInput; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTokenType = getTokenType; exports.getTokenomics = getTokenomics; exports.getTotalFeeNumerator = getTotalFeeNumerator; exports.getTotalFeeNumeratorFromExcludedFeeAmount = getTotalFeeNumeratorFromExcludedFeeAmount; exports.getTotalFeeNumeratorFromIncludedFeeAmount = getTotalFeeNumeratorFromIncludedFeeAmount; exports.getTotalSupplyFromCurve = getTotalSupplyFromCurve; exports.getTotalTokenSupply = getTotalTokenSupply; exports.getTotalVestingAmount = getTotalVestingAmount; exports.getTwoCurve = getTwoCurve; exports.getVariableFeeNumerator = getVariableFeeNumerator; exports.isDefaultLockedVesting = isDefaultLockedVesting; exports.isDynamicFeeEnabled = isDynamicFeeEnabled; exports.isNativeSol = isNativeSol; exports.isNonZeroRateLimiter = isNonZeroRateLimiter; exports.isRateLimiterApplied = isRateLimiterApplied; exports.isZeroRateLimiter = isZeroRateLimiter; exports.mulDiv = mulDiv; exports.mulShr = mulShr; exports.pow = pow; exports.prepareSwapAmountParam = prepareSwapAmountParam; exports.prepareTokenAccountTx = prepareTokenAccountTx; exports.splitFees = splitFees; exports.sqrt = sqrt; exports.swapQuote = swapQuote; exports.swapQuoteExactIn = swapQuoteExactIn; exports.swapQuoteExactOut = swapQuoteExactOut; exports.swapQuotePartialFill = swapQuotePartialFill; exports.toNumerator = toNumerator; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateActivationType = validateActivationType; exports.validateBalance = validateBalance; exports.validateBaseTokenType = validateBaseTokenType; exports.validateCollectFeeMode = validateCollectFeeMode; exports.validateConfigParameters = validateConfigParameters; exports.validateCurve = validateCurve; exports.validateFeeRateLimiter = validateFeeRateLimiter; exports.validateFeeScheduler = validateFeeScheduler; exports.validateLPPercentages = validateLPPercentages; exports.validateMigratedPoolFee = validateMigratedPoolFee; exports.validateMigrationAndTokenType = validateMigrationAndTokenType; exports.validateMigrationFee = validateMigrationFee; exports.validateMigrationFeeOption = validateMigrationFeeOption; exports.validatePoolFees = validatePoolFees; exports.validateSwapAmount = validateSwapAmount; exports.validateTokenDecimals = validateTokenDecimals; exports.validateTokenSupply = validateTokenSupply; exports.validateTokenUpdateAuthorityOptions = validateTokenUpdateAuthorityOptions; exports.wrapSOLInstruction = wrapSOLInstruction;
27693
+
27694
+
27695
+
27696
+
27697
+
27698
+
27699
+
27700
+
27701
+
27702
+
27703
+
27704
+
27705
+
27706
+
27707
+
27708
+ exports.ActivationType = ActivationType; exports.BASE_ADDRESS = BASE_ADDRESS; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.BaseFeeMode = BaseFeeMode; 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.DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS = DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS; 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.DYNAMIC_FEE_ROUNDING_OFFSET = DYNAMIC_FEE_ROUNDING_OFFSET; exports.DYNAMIC_FEE_SCALING_FACTOR = DYNAMIC_FEE_SCALING_FACTOR; exports.DammV2DynamicFeeMode = DammV2DynamicFeeMode; exports.DynamicBondingCurveClient = DynamicBondingCurveClient; exports.DynamicBondingCurveIdl = idl_default; exports.DynamicBondingCurveProgram = DynamicBondingCurveProgram; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeRateLimiter = FeeRateLimiter; exports.FeeScheduler = FeeScheduler; exports.HOST_FEE_PERCENT = HOST_FEE_PERCENT; exports.LOCKER_PROGRAM_ID = LOCKER_PROGRAM_ID; exports.MAX_BASIS_POINT = MAX_BASIS_POINT; exports.MAX_CREATOR_MIGRATION_FEE_PERCENTAGE = MAX_CREATOR_MIGRATION_FEE_PERCENTAGE; exports.MAX_CURVE_POINT = MAX_CURVE_POINT; exports.MAX_FEE_BPS = MAX_FEE_BPS; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_LOCK_DURATION_IN_SECONDS = MAX_LOCK_DURATION_IN_SECONDS; exports.MAX_MIGRATED_POOL_FEE_BPS = MAX_MIGRATED_POOL_FEE_BPS; exports.MAX_MIGRATION_FEE_PERCENTAGE = MAX_MIGRATION_FEE_PERCENTAGE; exports.MAX_POOL_CREATION_FEE = MAX_POOL_CREATION_FEE; exports.MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT = MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT; exports.MAX_RATE_LIMITER_DURATION_IN_SECONDS = MAX_RATE_LIMITER_DURATION_IN_SECONDS; exports.MAX_RATE_LIMITER_DURATION_IN_SLOTS = MAX_RATE_LIMITER_DURATION_IN_SLOTS; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.METAPLEX_PROGRAM_ID = METAPLEX_PROGRAM_ID; exports.MIN_FEE_BPS = MIN_FEE_BPS; exports.MIN_FEE_NUMERATOR = MIN_FEE_NUMERATOR; exports.MIN_LOCKED_LIQUIDITY_BPS = MIN_LOCKED_LIQUIDITY_BPS; exports.MIN_MIGRATED_POOL_FEE_BPS = MIN_MIGRATED_POOL_FEE_BPS; exports.MIN_POOL_CREATION_FEE = MIN_POOL_CREATION_FEE; 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.PROTOCOL_FEE_PERCENT = PROTOCOL_FEE_PERCENT; exports.PROTOCOL_POOL_CREATION_FEE_PERCENT = PROTOCOL_POOL_CREATION_FEE_PERCENT; exports.PartnerService = PartnerService; exports.PoolService = PoolService; exports.RESOLUTION = RESOLUTION; exports.Rounding = Rounding; exports.SECONDS_PER_DAY = SECONDS_PER_DAY; exports.SWAP_BUFFER_PERCENTAGE = SWAP_BUFFER_PERCENTAGE; exports.SafeMath = SafeMath; exports.StateService = StateService; exports.SwapMode = SwapMode; exports.TokenDecimal = TokenDecimal; exports.TokenType = TokenType; exports.TokenUpdateAuthorityOption = TokenUpdateAuthorityOption; exports.TradeDirection = TradeDirection; exports.U128_MAX = U128_MAX; exports.U16_MAX = U16_MAX; exports.U64_MAX = U64_MAX; exports.VAULT_PROGRAM_ID = VAULT_PROGRAM_ID; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.buildCurve = buildCurve; exports.buildCurveWithCustomSqrtPrices = buildCurveWithCustomSqrtPrices; exports.buildCurveWithLiquidityWeights = buildCurveWithLiquidityWeights; exports.buildCurveWithMarketCap = buildCurveWithMarketCap; exports.buildCurveWithMidPrice = buildCurveWithMidPrice; exports.buildCurveWithTwoSegments = buildCurveWithTwoSegments; exports.calculateAdjustedPercentageSupplyOnMigration = calculateAdjustedPercentageSupplyOnMigration; exports.calculateBaseToQuoteFromAmountIn = calculateBaseToQuoteFromAmountIn; exports.calculateBaseToQuoteFromAmountOut = calculateBaseToQuoteFromAmountOut; exports.calculateFeeSchedulerEndingBaseFeeBps = calculateFeeSchedulerEndingBaseFeeBps; exports.calculateLockedLiquidityBpsAtTime = calculateLockedLiquidityBpsAtTime; exports.calculateQuoteToBaseFromAmountIn = calculateQuoteToBaseFromAmountIn; exports.calculateQuoteToBaseFromAmountOut = calculateQuoteToBaseFromAmountOut; exports.checkRateLimiterApplied = checkRateLimiterApplied; exports.cleanUpTokenAccountTx = cleanUpTokenAccountTx; exports.convertDecimalToBN = convertDecimalToBN; exports.convertToLamports = convertToLamports; exports.createDammV1Program = createDammV1Program; exports.createDammV2Program = createDammV2Program; exports.createDbcProgram = createDbcProgram; exports.createInitializePermissionlessDynamicVaultIx = createInitializePermissionlessDynamicVaultIx; exports.createLockEscrowIx = createLockEscrowIx; exports.createProgramAccountFilter = createProgramAccountFilter; exports.createSqrtPrices = createSqrtPrices; 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.deriveDammV2PositionVestingAccount = deriveDammV2PositionVestingAccount; 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.fromDecimalToBN = fromDecimalToBN; exports.getAccountCreationTimestamp = getAccountCreationTimestamp; exports.getAccountCreationTimestamps = getAccountCreationTimestamps; exports.getAccountData = getAccountData; exports.getBaseFeeHandler = getBaseFeeHandler; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getBaseFeeNumeratorByPeriod = getBaseFeeNumeratorByPeriod; exports.getBaseFeeParams = getBaseFeeParams; exports.getBaseTokenForSwap = getBaseTokenForSwap; exports.getCheckedAmounts = getCheckedAmounts; exports.getCurrentPoint = getCurrentPoint; exports.getCurveBreakdown = getCurveBreakdown; exports.getDeltaAmountBaseUnsigned = getDeltaAmountBaseUnsigned; exports.getDeltaAmountBaseUnsigned256 = getDeltaAmountBaseUnsigned256; exports.getDeltaAmountBaseUnsignedUnchecked = getDeltaAmountBaseUnsignedUnchecked; exports.getDeltaAmountQuoteUnsigned = getDeltaAmountQuoteUnsigned; exports.getDeltaAmountQuoteUnsigned256 = getDeltaAmountQuoteUnsigned256; exports.getDeltaAmountQuoteUnsignedUnchecked = getDeltaAmountQuoteUnsignedUnchecked; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getExcludedFeeAmount = getExcludedFeeAmount; exports.getFeeMode = getFeeMode; exports.getFeeNumeratorFromExcludedAmount = getFeeNumeratorFromExcludedAmount; exports.getFeeNumeratorFromIncludedAmount = getFeeNumeratorFromIncludedAmount; exports.getFeeNumeratorOnExponentialFeeScheduler = getFeeNumeratorOnExponentialFeeScheduler; exports.getFeeNumeratorOnLinearFeeScheduler = getFeeNumeratorOnLinearFeeScheduler; exports.getFeeOnAmount = getFeeOnAmount; exports.getFeeSchedulerParams = getFeeSchedulerParams; exports.getFirstCurve = getFirstCurve; exports.getFirstKey = getFirstKey; exports.getIncludedFeeAmount = getIncludedFeeAmount; exports.getInitialLiquidityFromDeltaBase = getInitialLiquidityFromDeltaBase; exports.getInitialLiquidityFromDeltaQuote = getInitialLiquidityFromDeltaQuote; exports.getLiquidity = getLiquidity; exports.getLiquidityVestingInfoParams = getLiquidityVestingInfoParams; exports.getLockedVestingParams = getLockedVestingParams; exports.getMaxBaseFeeNumerator = getMaxBaseFeeNumerator; exports.getMaxIndex = getMaxIndex; exports.getMaxOutAmountWithMinBaseFee = getMaxOutAmountWithMinBaseFee; exports.getMigratedPoolFeeParams = getMigratedPoolFeeParams; exports.getMigrationBaseToken = getMigrationBaseToken; exports.getMigrationQuoteAmount = getMigrationQuoteAmount; exports.getMigrationQuoteAmountFromMigrationQuoteThreshold = getMigrationQuoteAmountFromMigrationQuoteThreshold; exports.getMigrationQuoteThresholdFromMigrationQuoteAmount = getMigrationQuoteThresholdFromMigrationQuoteAmount; exports.getMigrationThresholdPrice = getMigrationThresholdPrice; exports.getMinBaseFeeNumerator = getMinBaseFeeNumerator; exports.getNextSqrtPriceFromBaseAmountInRoundingUp = getNextSqrtPriceFromBaseAmountInRoundingUp; exports.getNextSqrtPriceFromBaseAmountOutRoundingUp = getNextSqrtPriceFromBaseAmountOutRoundingUp; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getNextSqrtPriceFromOutput = getNextSqrtPriceFromOutput; exports.getNextSqrtPriceFromQuoteAmountInRoundingDown = getNextSqrtPriceFromQuoteAmountInRoundingDown; exports.getNextSqrtPriceFromQuoteAmountOutRoundingDown = getNextSqrtPriceFromQuoteAmountOutRoundingDown; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPercentageSupplyOnMigration = getPercentageSupplyOnMigration; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getQuoteReserveFromNextSqrtPrice = getQuoteReserveFromNextSqrtPrice; exports.getRateLimiterExcludedFeeAmount = getRateLimiterExcludedFeeAmount; exports.getRateLimiterParams = getRateLimiterParams; exports.getSecondKey = getSecondKey; exports.getSqrtPriceFromMarketCap = getSqrtPriceFromMarketCap; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapAmountWithBuffer = getSwapAmountWithBuffer; exports.getSwapResult = getSwapResult; exports.getSwapResultFromExactInput = getSwapResultFromExactInput; exports.getSwapResultFromExactOutput = getSwapResultFromExactOutput; exports.getSwapResultFromPartialInput = getSwapResultFromPartialInput; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTokenType = getTokenType; exports.getTokenomics = getTokenomics; exports.getTotalFeeNumerator = getTotalFeeNumerator; exports.getTotalFeeNumeratorFromExcludedFeeAmount = getTotalFeeNumeratorFromExcludedFeeAmount; exports.getTotalFeeNumeratorFromIncludedFeeAmount = getTotalFeeNumeratorFromIncludedFeeAmount; exports.getTotalSupplyFromCurve = getTotalSupplyFromCurve; exports.getTotalTokenSupply = getTotalTokenSupply; exports.getTotalVestingAmount = getTotalVestingAmount; exports.getTwoCurve = getTwoCurve; exports.getVariableFeeNumerator = getVariableFeeNumerator; exports.getVestingLockedLiquidityBpsAtNSeconds = getVestingLockedLiquidityBpsAtNSeconds; exports.isDefaultLockedVesting = isDefaultLockedVesting; exports.isDynamicFeeEnabled = isDynamicFeeEnabled; exports.isNativeSol = isNativeSol; exports.isNonZeroRateLimiter = isNonZeroRateLimiter; exports.isRateLimiterApplied = isRateLimiterApplied; exports.isZeroRateLimiter = isZeroRateLimiter; exports.mulDiv = mulDiv; exports.mulShr = mulShr; exports.pow = pow; exports.prepareSwapAmountParam = prepareSwapAmountParam; exports.prepareTokenAccountTx = prepareTokenAccountTx; exports.splitFees = splitFees; exports.sqrt = sqrt; exports.swapQuote = swapQuote; exports.swapQuoteExactIn = swapQuoteExactIn; exports.swapQuoteExactOut = swapQuoteExactOut; exports.swapQuotePartialFill = swapQuotePartialFill; exports.toNumerator = toNumerator; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateActivationType = validateActivationType; exports.validateBalance = validateBalance; exports.validateBaseTokenType = validateBaseTokenType; exports.validateCollectFeeMode = validateCollectFeeMode; exports.validateConfigParameters = validateConfigParameters; exports.validateCurve = validateCurve; exports.validateFeeRateLimiter = validateFeeRateLimiter; exports.validateFeeScheduler = validateFeeScheduler; exports.validateLPPercentages = validateLPPercentages; exports.validateLiquidityVestingInfo = validateLiquidityVestingInfo; exports.validateMigratedPoolFee = validateMigratedPoolFee; exports.validateMigrationAndTokenType = validateMigrationAndTokenType; exports.validateMigrationFee = validateMigrationFee; exports.validateMigrationFeeOption = validateMigrationFeeOption; exports.validateMinimumLockedLiquidity = validateMinimumLockedLiquidity; exports.validatePoolCreationFee = validatePoolCreationFee; exports.validatePoolFees = validatePoolFees; exports.validateSwapAmount = validateSwapAmount; exports.validateTokenDecimals = validateTokenDecimals; exports.validateTokenSupply = validateTokenSupply; exports.validateTokenUpdateAuthorityOptions = validateTokenUpdateAuthorityOptions; exports.wrapSOLInstruction = wrapSOLInstruction;
26727
27709
  //# sourceMappingURL=index.cjs.map