@meteora-ag/dynamic-bonding-curve-sdk 1.4.8 → 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/README.md +13 -5
- package/dist/index.cjs +1591 -398
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1005 -309
- package/dist/index.d.ts +1005 -309
- package/dist/index.js +1602 -409
- package/dist/index.js.map +1 -1
- package/package.json +13 -8
package/dist/index.js
CHANGED
|
@@ -83,29 +83,44 @@ var SwapMode = /* @__PURE__ */ ((SwapMode2) => {
|
|
|
83
83
|
// src/constants.ts
|
|
84
84
|
import BN from "bn.js";
|
|
85
85
|
import { PublicKey } from "@solana/web3.js";
|
|
86
|
+
var MAX_CURVE_POINT = 16;
|
|
86
87
|
var OFFSET = 64;
|
|
87
|
-
var U128_MAX = new BN("340282366920938463463374607431768211455");
|
|
88
|
-
var U64_MAX = new BN("18446744073709551615");
|
|
89
|
-
var U16_MAX = 65535;
|
|
90
|
-
var MIN_SQRT_PRICE = new BN("4295048016");
|
|
91
|
-
var MAX_SQRT_PRICE = new BN("79226673521066979257578248091");
|
|
92
88
|
var RESOLUTION = 64;
|
|
93
89
|
var ONE_Q64 = new BN(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 BN("18446744073709551615");
|
|
94
|
+
var U128_MAX = new BN("340282366920938463463374607431768211455");
|
|
95
|
+
var MIN_SQRT_PRICE = new BN("4295048016");
|
|
96
|
+
var MAX_SQRT_PRICE = new BN("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
|
|
100
|
-
var
|
|
101
|
-
var
|
|
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 BN(1e11);
|
|
107
|
+
var DYNAMIC_FEE_ROUNDING_OFFSET = new BN(99999999999);
|
|
108
|
+
var BIN_STEP_BPS_DEFAULT = 1;
|
|
109
|
+
var BIN_STEP_BPS_U128_DEFAULT = new BN("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
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
var
|
|
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 PublicKey(
|
|
110
125
|
"dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN"
|
|
111
126
|
);
|
|
@@ -127,17 +142,6 @@ var LOCKER_PROGRAM_ID = new PublicKey(
|
|
|
127
142
|
var BASE_ADDRESS = new 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 BN(1e11);
|
|
135
|
-
var DYNAMIC_FEE_ROUNDING_OFFSET = new BN(99999999999);
|
|
136
|
-
var BIN_STEP_BPS_DEFAULT = 1;
|
|
137
|
-
var BIN_STEP_BPS_U128_DEFAULT = new BN("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 PublicKey("8f848CEy8eY6PhJ3VcemtBDzPPSD4Vq7aJczLZ3o8MmX"),
|
|
143
147
|
// FixedBps25
|
|
@@ -168,6 +172,13 @@ var DAMM_V2_MIGRATION_FEE_ADDRESS = [
|
|
|
168
172
|
new 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
|
import BN6 from "bn.js";
|
|
@@ -512,10 +523,10 @@ function convertDecimalToBN(value) {
|
|
|
512
523
|
return new BN5(value.floor().toFixed());
|
|
513
524
|
}
|
|
514
525
|
function bpsToFeeNumerator(bps) {
|
|
515
|
-
return new BN5(bps * FEE_DENOMINATOR).divn(
|
|
526
|
+
return new BN5(bps * FEE_DENOMINATOR).divn(MAX_BASIS_POINT);
|
|
516
527
|
}
|
|
517
528
|
function feeNumeratorToBps(feeNumerator) {
|
|
518
|
-
return feeNumerator.muln(
|
|
529
|
+
return feeNumerator.muln(MAX_BASIS_POINT).div(new BN5(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(
|
|
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(Decimal2.pow(2, 64));
|
|
738
749
|
return new BN6(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
|
-
|
|
761
|
+
const price = new Decimal2(marketCap).div(new Decimal2(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
|
-
|
|
928
|
-
|
|
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
|
);
|
|
@@ -933,6 +953,56 @@ var getMigrationThresholdPrice = (migrationThreshold, sqrtStartPrice, curve) =>
|
|
|
933
953
|
}
|
|
934
954
|
return nextSqrtPrice;
|
|
935
955
|
};
|
|
956
|
+
var getCurveBreakdown = (migrationQuoteThreshold, sqrtStartPrice, curve) => {
|
|
957
|
+
if (curve.length === 0) {
|
|
958
|
+
throw Error("Curve is empty");
|
|
959
|
+
}
|
|
960
|
+
const segmentAmounts = [];
|
|
961
|
+
let totalAllocated = new BN6(0);
|
|
962
|
+
let currentSqrtPrice = sqrtStartPrice;
|
|
963
|
+
let finalSqrtPrice = sqrtStartPrice;
|
|
964
|
+
for (let i = 0; i < curve.length; i++) {
|
|
965
|
+
const lowerSqrtPrice = currentSqrtPrice;
|
|
966
|
+
const upperSqrtPrice = curve[i].sqrtPrice;
|
|
967
|
+
const liquidity = curve[i].liquidity;
|
|
968
|
+
const maxSegmentAmount = getDeltaAmountQuoteUnsigned(
|
|
969
|
+
lowerSqrtPrice,
|
|
970
|
+
upperSqrtPrice,
|
|
971
|
+
liquidity,
|
|
972
|
+
0 /* Up */
|
|
973
|
+
);
|
|
974
|
+
if (maxSegmentAmount.gte(migrationQuoteThreshold)) {
|
|
975
|
+
segmentAmounts.push(migrationQuoteThreshold);
|
|
976
|
+
totalAllocated = totalAllocated.add(migrationQuoteThreshold);
|
|
977
|
+
finalSqrtPrice = getNextSqrtPriceFromInput(
|
|
978
|
+
lowerSqrtPrice,
|
|
979
|
+
liquidity,
|
|
980
|
+
migrationQuoteThreshold,
|
|
981
|
+
false
|
|
982
|
+
);
|
|
983
|
+
for (let j = i + 1; j < curve.length; j++) {
|
|
984
|
+
segmentAmounts.push(new BN6(0));
|
|
985
|
+
}
|
|
986
|
+
break;
|
|
987
|
+
} else {
|
|
988
|
+
segmentAmounts.push(maxSegmentAmount);
|
|
989
|
+
totalAllocated = totalAllocated.add(maxSegmentAmount);
|
|
990
|
+
currentSqrtPrice = upperSqrtPrice;
|
|
991
|
+
finalSqrtPrice = upperSqrtPrice;
|
|
992
|
+
if (i === curve.length - 1 && totalAllocated.lt(migrationQuoteThreshold)) {
|
|
993
|
+
const shortfall = migrationQuoteThreshold.sub(totalAllocated);
|
|
994
|
+
throw Error(
|
|
995
|
+
`Not enough liquidity in curve. Total allocated: ${totalAllocated.toString()}, Required: ${migrationQuoteThreshold.toString()}, Shortfall: ${shortfall.toString()}`
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
return {
|
|
1001
|
+
segmentAmounts,
|
|
1002
|
+
finalSqrtPrice,
|
|
1003
|
+
totalAmount: totalAllocated
|
|
1004
|
+
};
|
|
1005
|
+
};
|
|
936
1006
|
var getSwapAmountWithBuffer = (swapBaseAmount, sqrtStartPrice, curve) => {
|
|
937
1007
|
const swapAmountBuffer = swapBaseAmount.add(
|
|
938
1008
|
swapBaseAmount.mul(new BN6(SWAP_BUFFER_PERCENTAGE)).div(new BN6(100))
|
|
@@ -954,6 +1024,21 @@ var getPercentageSupplyOnMigration = (initialMarketCap, migrationMarketCap, lock
|
|
|
954
1024
|
const denominator = new Decimal2(1).add(sqrtRatio);
|
|
955
1025
|
return numerator.div(denominator).toNumber();
|
|
956
1026
|
};
|
|
1027
|
+
function calculateAdjustedPercentageSupplyOnMigration(initialMarketCap, migrationMarketCap, migrationFee, lockedVesting, totalLeftover, totalTokenSupply) {
|
|
1028
|
+
const D = new Decimal2(initialMarketCap);
|
|
1029
|
+
const M = new Decimal2(migrationMarketCap);
|
|
1030
|
+
const f = new Decimal2(migrationFee.feePercentage).div(100);
|
|
1031
|
+
const totalVestingAmount = getTotalVestingAmount(lockedVesting);
|
|
1032
|
+
const V = new Decimal2(totalVestingAmount.toString()).mul(100).div(new Decimal2(totalTokenSupply.toString()));
|
|
1033
|
+
const L = new Decimal2(totalLeftover.toString()).mul(100).div(new Decimal2(totalTokenSupply.toString()));
|
|
1034
|
+
const requiredRatio = Decimal2.sqrt(D.div(M));
|
|
1035
|
+
const oneMinusF = new Decimal2(1).sub(f);
|
|
1036
|
+
const availablePercentage = new Decimal2(100).sub(V).sub(L);
|
|
1037
|
+
const numerator = requiredRatio.mul(oneMinusF).mul(availablePercentage);
|
|
1038
|
+
const denominator = new Decimal2(1).add(requiredRatio.mul(oneMinusF));
|
|
1039
|
+
const percentageSupplyOnMigration = numerator.div(denominator).toNumber();
|
|
1040
|
+
return percentageSupplyOnMigration;
|
|
1041
|
+
}
|
|
957
1042
|
var getMigrationQuoteAmount = (migrationMarketCap, percentageSupplyOnMigration) => {
|
|
958
1043
|
return migrationMarketCap.mul(percentageSupplyOnMigration).div(new Decimal2(100));
|
|
959
1044
|
};
|
|
@@ -980,6 +1065,11 @@ function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode
|
|
|
980
1065
|
`startingBaseFeeBps (${startingBaseFeeBps} bps) exceeds maximum allowed value of ${MAX_FEE_BPS} bps`
|
|
981
1066
|
);
|
|
982
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
|
+
}
|
|
983
1073
|
if (endingBaseFeeBps > startingBaseFeeBps) {
|
|
984
1074
|
throw new Error(
|
|
985
1075
|
"endingBaseFeeBps bps must be less than or equal to startingBaseFeeBps bps"
|
|
@@ -1000,7 +1090,7 @@ function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode
|
|
|
1000
1090
|
} else {
|
|
1001
1091
|
const ratio = minBaseFeeNumerator.toNumber() / maxBaseFeeNumerator.toNumber();
|
|
1002
1092
|
const decayBase = Math.pow(ratio, 1 / numberOfPeriod);
|
|
1003
|
-
reductionFactor = new BN6(
|
|
1093
|
+
reductionFactor = new BN6(MAX_BASIS_POINT * (1 - decayBase));
|
|
1004
1094
|
}
|
|
1005
1095
|
return {
|
|
1006
1096
|
cliffFeeNumerator: maxBaseFeeNumerator,
|
|
@@ -1012,16 +1102,16 @@ function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode
|
|
|
1012
1102
|
}
|
|
1013
1103
|
function calculateFeeSchedulerEndingBaseFeeBps(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, baseFeeMode) {
|
|
1014
1104
|
if (numberOfPeriod === 0 || periodFrequency === 0) {
|
|
1015
|
-
return cliffFeeNumerator / FEE_DENOMINATOR *
|
|
1105
|
+
return cliffFeeNumerator / FEE_DENOMINATOR * MAX_BASIS_POINT;
|
|
1016
1106
|
}
|
|
1017
1107
|
let baseFeeNumerator;
|
|
1018
1108
|
if (baseFeeMode == 0 /* FeeSchedulerLinear */) {
|
|
1019
1109
|
baseFeeNumerator = cliffFeeNumerator - numberOfPeriod * reductionFactor;
|
|
1020
1110
|
} else {
|
|
1021
|
-
const decayRate = 1 - reductionFactor /
|
|
1111
|
+
const decayRate = 1 - reductionFactor / MAX_BASIS_POINT;
|
|
1022
1112
|
baseFeeNumerator = cliffFeeNumerator * Math.pow(decayRate, numberOfPeriod);
|
|
1023
1113
|
}
|
|
1024
|
-
return Math.max(0, baseFeeNumerator / FEE_DENOMINATOR *
|
|
1114
|
+
return Math.max(0, baseFeeNumerator / FEE_DENOMINATOR * MAX_BASIS_POINT);
|
|
1025
1115
|
}
|
|
1026
1116
|
function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxLimiterDuration, tokenQuoteDecimal, activationType) {
|
|
1027
1117
|
const cliffFeeNumerator = bpsToFeeNumerator(baseFeeBps);
|
|
@@ -1034,6 +1124,11 @@ function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxL
|
|
|
1034
1124
|
`Base fee (${baseFeeBps} bps) exceeds maximum allowed value of ${MAX_FEE_BPS} bps`
|
|
1035
1125
|
);
|
|
1036
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
|
+
}
|
|
1037
1132
|
if (feeIncrementBps > MAX_FEE_BPS) {
|
|
1038
1133
|
throw new Error(
|
|
1039
1134
|
`Fee increment (${feeIncrementBps} bps) exceeds maximum allowed value of ${MAX_FEE_BPS} bps`
|
|
@@ -1070,21 +1165,21 @@ function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxL
|
|
|
1070
1165
|
baseFeeMode: 2 /* RateLimiter */
|
|
1071
1166
|
};
|
|
1072
1167
|
}
|
|
1073
|
-
function getDynamicFeeParams(baseFeeBps,
|
|
1074
|
-
if (
|
|
1168
|
+
function getDynamicFeeParams(baseFeeBps, maxPriceChangePercentage = MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT) {
|
|
1169
|
+
if (maxPriceChangePercentage > MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT) {
|
|
1075
1170
|
throw new Error(
|
|
1076
|
-
`
|
|
1171
|
+
`maxPriceChangePercentage (${maxPriceChangePercentage}%) must be less than or equal to ${MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT}`
|
|
1077
1172
|
);
|
|
1078
1173
|
}
|
|
1079
|
-
const priceRatio =
|
|
1174
|
+
const priceRatio = maxPriceChangePercentage / MAX_BASIS_POINT + 1;
|
|
1080
1175
|
const sqrtPriceRatioQ64 = new BN6(
|
|
1081
1176
|
Decimal2.sqrt(priceRatio.toString()).mul(Decimal2.pow(2, 64)).floor().toFixed()
|
|
1082
1177
|
);
|
|
1083
1178
|
const deltaBinId = sqrtPriceRatioQ64.sub(ONE_Q64).div(BIN_STEP_BPS_U128_DEFAULT).muln(2);
|
|
1084
|
-
const maxVolatilityAccumulator = new BN6(deltaBinId.muln(
|
|
1179
|
+
const maxVolatilityAccumulator = new BN6(deltaBinId.muln(MAX_BASIS_POINT));
|
|
1085
1180
|
const squareVfaBin = maxVolatilityAccumulator.mul(new BN6(BIN_STEP_BPS_DEFAULT)).pow(new BN6(2));
|
|
1086
1181
|
const baseFeeNumerator = new BN6(bpsToFeeNumerator(baseFeeBps));
|
|
1087
|
-
const maxDynamicFeeNumerator = baseFeeNumerator.muln(
|
|
1182
|
+
const maxDynamicFeeNumerator = baseFeeNumerator.muln(maxPriceChangePercentage).divn(100);
|
|
1088
1183
|
const vFee = maxDynamicFeeNumerator.mul(new BN6(1e11)).sub(new BN6(99999999999));
|
|
1089
1184
|
const variableFeeControl = vFee.div(squareVfaBin);
|
|
1090
1185
|
return {
|
|
@@ -1154,20 +1249,83 @@ function getLockedVestingParams(totalLockedVestingAmount, numberOfVestingPeriod,
|
|
|
1154
1249
|
)
|
|
1155
1250
|
};
|
|
1156
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
|
+
};
|
|
1157
1315
|
var getTwoCurve = (migrationSqrtPrice, midSqrtPrice, initialSqrtPrice, swapAmount, migrationQuoteThreshold) => {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1316
|
+
const p0 = new Decimal2(initialSqrtPrice.toString());
|
|
1317
|
+
const p1 = new Decimal2(midSqrtPrice.toString());
|
|
1318
|
+
const p2 = new Decimal2(migrationSqrtPrice.toString());
|
|
1319
|
+
const a1 = new Decimal2(1).div(p0).sub(new Decimal2(1).div(p1));
|
|
1320
|
+
const b1 = new Decimal2(1).div(p1).sub(new Decimal2(1).div(p2));
|
|
1321
|
+
const c1 = new Decimal2(swapAmount.toString());
|
|
1322
|
+
const a2 = p1.sub(p0);
|
|
1323
|
+
const b2 = p2.sub(p1);
|
|
1324
|
+
const c2 = new Decimal2(migrationQuoteThreshold.toString()).mul(
|
|
1167
1325
|
Decimal2.pow(2, 128)
|
|
1168
1326
|
);
|
|
1169
|
-
|
|
1170
|
-
|
|
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)));
|
|
1171
1329
|
if (l0.isNeg() || l1.isNeg()) {
|
|
1172
1330
|
return {
|
|
1173
1331
|
isOk: false,
|
|
@@ -1294,8 +1452,72 @@ async function prepareSwapAmountParam(amount, mintAddress, connection) {
|
|
|
1294
1452
|
const mintTokenDecimals = await getTokenDecimals(connection, mintAddress);
|
|
1295
1453
|
return convertToLamports(amount, mintTokenDecimals);
|
|
1296
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 BN6(vestingInfo.vestingPercentage)).div(new BN6(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 BN6(totalBpsAfterCliff)).div(new BN6(MAX_BASIS_POINT));
|
|
1467
|
+
let liquidityPerPeriod = new BN6(0);
|
|
1468
|
+
let adjustedFrequency = frequency;
|
|
1469
|
+
let adjustedNumberOfPeriods = numberOfPeriods;
|
|
1470
|
+
let adjustedCliffDuration = cliffDuration;
|
|
1471
|
+
if (numberOfPeriods > 0) {
|
|
1472
|
+
liquidityPerPeriod = totalVestingLiquidityAfterCliff.div(
|
|
1473
|
+
new BN6(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 BN6(adjustedNumberOfPeriods))
|
|
1483
|
+
);
|
|
1484
|
+
const cliffPoint = new BN6(adjustedCliffDuration);
|
|
1485
|
+
const currentPoint = new BN6(nSeconds);
|
|
1486
|
+
let unlockedLiquidity = new BN6(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 BN6(adjustedFrequency)).toNumber();
|
|
1492
|
+
const actualPeriodsElapsed = Math.min(
|
|
1493
|
+
periodsElapsed,
|
|
1494
|
+
adjustedNumberOfPeriods
|
|
1495
|
+
);
|
|
1496
|
+
unlockedLiquidity = unlockedLiquidity.add(
|
|
1497
|
+
liquidityPerPeriod.mul(new BN6(actualPeriodsElapsed))
|
|
1498
|
+
);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
const lockedLiquidity = totalVestedLiquidity.sub(unlockedLiquidity);
|
|
1502
|
+
const liquidityLockedBps = lockedLiquidity.mul(new BN6(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
|
+
}
|
|
1297
1519
|
|
|
1298
|
-
// src/helpers/
|
|
1520
|
+
// src/helpers/pda.ts
|
|
1299
1521
|
import { PublicKey as PublicKey5 } from "@solana/web3.js";
|
|
1300
1522
|
var SEED = Object.freeze({
|
|
1301
1523
|
POOL_AUTHORITY: "pool_authority",
|
|
@@ -1554,6 +1776,12 @@ function deriveBaseKeyForLocker(virtualPool) {
|
|
|
1554
1776
|
DYNAMIC_BONDING_CURVE_PROGRAM_ID
|
|
1555
1777
|
)[0];
|
|
1556
1778
|
}
|
|
1779
|
+
function deriveDammV2PositionVestingAccount(position) {
|
|
1780
|
+
return PublicKey5.findProgramAddressSync(
|
|
1781
|
+
[Buffer.from("position_vesting"), position.toBuffer()],
|
|
1782
|
+
DYNAMIC_BONDING_CURVE_PROGRAM_ID
|
|
1783
|
+
)[0];
|
|
1784
|
+
}
|
|
1557
1785
|
|
|
1558
1786
|
// src/helpers/validation.ts
|
|
1559
1787
|
import BN13 from "bn.js";
|
|
@@ -1819,7 +2047,7 @@ function getFeeNumeratorOnExponentialFeeScheduler(cliffFeeNumerator, reductionFa
|
|
|
1819
2047
|
if (period === 0) {
|
|
1820
2048
|
return cliffFeeNumerator;
|
|
1821
2049
|
}
|
|
1822
|
-
const basisPointMax = new BN8(
|
|
2050
|
+
const basisPointMax = new BN8(MAX_BASIS_POINT);
|
|
1823
2051
|
const ONE_Q642 = new BN8(1).shln(64);
|
|
1824
2052
|
const bps = SafeMath.div(SafeMath.shl(reductionFactor, 64), basisPointMax);
|
|
1825
2053
|
const base = SafeMath.sub(ONE_Q642, bps);
|
|
@@ -1905,7 +2133,7 @@ var FeeScheduler = class {
|
|
|
1905
2133
|
this.reductionFactor = reductionFactor;
|
|
1906
2134
|
this.feeSchedulerMode = feeSchedulerMode;
|
|
1907
2135
|
}
|
|
1908
|
-
validate(
|
|
2136
|
+
validate() {
|
|
1909
2137
|
return validateFeeScheduler(
|
|
1910
2138
|
this.numberOfPeriod,
|
|
1911
2139
|
this.periodFrequency,
|
|
@@ -1998,13 +2226,13 @@ function toNumerator(bps, feeDenominator) {
|
|
|
1998
2226
|
const numerator = mulDiv(
|
|
1999
2227
|
bps,
|
|
2000
2228
|
feeDenominator,
|
|
2001
|
-
new BN11(
|
|
2229
|
+
new BN11(MAX_BASIS_POINT),
|
|
2002
2230
|
1 /* Down */
|
|
2003
2231
|
);
|
|
2004
2232
|
return numerator;
|
|
2005
2233
|
} catch (error) {
|
|
2006
2234
|
throw new Error(
|
|
2007
|
-
|
|
2235
|
+
`Type cast failed or calculation overflow in toNumerator ${error}`
|
|
2008
2236
|
);
|
|
2009
2237
|
}
|
|
2010
2238
|
}
|
|
@@ -2094,14 +2322,14 @@ function getFeeOnAmount(tradeFeeNumerator, amount, poolFees, hasReferral) {
|
|
|
2094
2322
|
);
|
|
2095
2323
|
const protocolFee = mulDiv(
|
|
2096
2324
|
tradingFee,
|
|
2097
|
-
new BN11(
|
|
2325
|
+
new BN11(PROTOCOL_FEE_PERCENT),
|
|
2098
2326
|
new BN11(100),
|
|
2099
2327
|
1 /* Down */
|
|
2100
2328
|
);
|
|
2101
2329
|
const updatedTradingFee = SafeMath.sub(tradingFee, protocolFee);
|
|
2102
2330
|
const referralFee = hasReferral ? mulDiv(
|
|
2103
2331
|
protocolFee,
|
|
2104
|
-
new BN11(
|
|
2332
|
+
new BN11(HOST_FEE_PERCENT),
|
|
2105
2333
|
new BN11(100),
|
|
2106
2334
|
1 /* Down */
|
|
2107
2335
|
) : new BN11(0);
|
|
@@ -2136,14 +2364,14 @@ function getIncludedFeeAmount(tradeFeeNumerator, excludedFeeAmount) {
|
|
|
2136
2364
|
function splitFees(poolFees, feeAmount, hasReferral) {
|
|
2137
2365
|
const protocolFee = mulDiv(
|
|
2138
2366
|
feeAmount,
|
|
2139
|
-
new BN11(
|
|
2367
|
+
new BN11(PROTOCOL_FEE_PERCENT),
|
|
2140
2368
|
new BN11(100),
|
|
2141
2369
|
1 /* Down */
|
|
2142
2370
|
);
|
|
2143
2371
|
const tradingFee = SafeMath.sub(feeAmount, protocolFee);
|
|
2144
2372
|
const referralFee = hasReferral ? mulDiv(
|
|
2145
2373
|
protocolFee,
|
|
2146
|
-
new BN11(
|
|
2374
|
+
new BN11(HOST_FEE_PERCENT),
|
|
2147
2375
|
new BN11(100),
|
|
2148
2376
|
1 /* Down */
|
|
2149
2377
|
) : new BN11(0);
|
|
@@ -2977,8 +3205,8 @@ function validateMigrationFeeOption(migrationFeeOption, migrationOption) {
|
|
|
2977
3205
|
function validateTokenDecimals(tokenDecimal) {
|
|
2978
3206
|
return tokenDecimal >= 6 /* SIX */ && tokenDecimal <= 9 /* NINE */;
|
|
2979
3207
|
}
|
|
2980
|
-
function validateLPPercentages(
|
|
2981
|
-
const totalLPPercentage =
|
|
3208
|
+
function validateLPPercentages(partnerLiquidityPercentage, partnerPermanentLockedLiquidityPercentage, creatorLiquidityPercentage, creatorPermanentLockedLiquidityPercentage, partnerVestingPercentage, creatorVestingPercentage) {
|
|
3209
|
+
const totalLPPercentage = partnerLiquidityPercentage + partnerPermanentLockedLiquidityPercentage + creatorLiquidityPercentage + creatorPermanentLockedLiquidityPercentage + partnerVestingPercentage + creatorVestingPercentage;
|
|
2982
3210
|
return totalLPPercentage === 100;
|
|
2983
3211
|
}
|
|
2984
3212
|
function validateCurve(curve, sqrtStartPrice) {
|
|
@@ -3038,6 +3266,35 @@ function validateTokenUpdateAuthorityOptions(option) {
|
|
|
3038
3266
|
4 /* PartnerUpdateAndMintAuthority */
|
|
3039
3267
|
].includes(option);
|
|
3040
3268
|
}
|
|
3269
|
+
function validatePoolCreationFee(poolCreationFee) {
|
|
3270
|
+
if (poolCreationFee.eq(new BN13(0))) {
|
|
3271
|
+
return true;
|
|
3272
|
+
}
|
|
3273
|
+
return poolCreationFee.gte(new BN13(MIN_POOL_CREATION_FEE)) && poolCreationFee.lte(new BN13(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
|
+
}
|
|
3041
3298
|
function validateMigratedPoolFee(migratedPoolFee, migrationOption, migrationFeeOption) {
|
|
3042
3299
|
const isEmpty = () => {
|
|
3043
3300
|
return migratedPoolFee.collectFeeMode === 0 && migratedPoolFee.dynamicFee === 0 && migratedPoolFee.poolFeeBps === 0;
|
|
@@ -3101,17 +3358,72 @@ function validateConfigParameters(configParam) {
|
|
|
3101
3358
|
if (!validateMigrationFee(configParam.migrationFee)) {
|
|
3102
3359
|
throw new Error("Invalid migration fee");
|
|
3103
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
|
+
}
|
|
3104
3366
|
if (!validateTokenDecimals(configParam.tokenDecimal)) {
|
|
3105
3367
|
throw new Error("Token decimal must be between 6 and 9");
|
|
3106
3368
|
}
|
|
3369
|
+
const partnerVestingPercentage = configParam.partnerLiquidityVestingInfo?.vestingPercentage ?? 0;
|
|
3370
|
+
const creatorVestingPercentage = configParam.creatorLiquidityVestingInfo?.vestingPercentage ?? 0;
|
|
3107
3371
|
if (!validateLPPercentages(
|
|
3108
|
-
configParam.
|
|
3109
|
-
configParam.
|
|
3110
|
-
configParam.
|
|
3111
|
-
configParam.
|
|
3372
|
+
configParam.partnerLiquidityPercentage,
|
|
3373
|
+
configParam.partnerPermanentLockedLiquidityPercentage,
|
|
3374
|
+
configParam.creatorLiquidityPercentage,
|
|
3375
|
+
configParam.creatorPermanentLockedLiquidityPercentage,
|
|
3376
|
+
partnerVestingPercentage,
|
|
3377
|
+
creatorVestingPercentage
|
|
3112
3378
|
)) {
|
|
3113
3379
|
throw new Error("Sum of LP percentages must equal 100");
|
|
3114
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
|
+
}
|
|
3115
3427
|
if (configParam.migrationQuoteThreshold.lte(new BN13(0))) {
|
|
3116
3428
|
throw new Error("Migration quote threshold must be greater than 0");
|
|
3117
3429
|
}
|
|
@@ -3141,7 +3453,7 @@ function validateConfigParameters(configParam) {
|
|
|
3141
3453
|
throw new Error("Invalid vesting parameters");
|
|
3142
3454
|
}
|
|
3143
3455
|
} catch (error) {
|
|
3144
|
-
throw new Error(
|
|
3456
|
+
throw new Error(`Invalid vesting parameters ${error}`);
|
|
3145
3457
|
}
|
|
3146
3458
|
}
|
|
3147
3459
|
if (configParam.tokenSupply) {
|
|
@@ -3206,7 +3518,7 @@ async function validateBalance(connection, owner, inputMint, amountIn, inputToke
|
|
|
3206
3518
|
}
|
|
3207
3519
|
} catch (error) {
|
|
3208
3520
|
throw new Error(
|
|
3209
|
-
`Failed to fetch token balance or token account doesn't exist`
|
|
3521
|
+
`Failed to fetch token balance or token account doesn't exist ${error}`
|
|
3210
3522
|
);
|
|
3211
3523
|
}
|
|
3212
3524
|
}
|
|
@@ -3241,28 +3553,32 @@ function validateMigrationFee(migrationFee) {
|
|
|
3241
3553
|
import Decimal4 from "decimal.js";
|
|
3242
3554
|
import BN14 from "bn.js";
|
|
3243
3555
|
function buildCurve(buildCurveParam) {
|
|
3244
|
-
|
|
3556
|
+
const {
|
|
3245
3557
|
totalTokenSupply,
|
|
3246
|
-
|
|
3247
|
-
migrationQuoteThreshold,
|
|
3248
|
-
migrationOption,
|
|
3558
|
+
tokenType,
|
|
3249
3559
|
tokenBaseDecimal,
|
|
3250
3560
|
tokenQuoteDecimal,
|
|
3561
|
+
tokenUpdateAuthority,
|
|
3562
|
+
lockedVestingParams,
|
|
3563
|
+
leftover,
|
|
3564
|
+
baseFeeParams,
|
|
3251
3565
|
dynamicFeeEnabled,
|
|
3252
3566
|
activationType,
|
|
3253
3567
|
collectFeeMode,
|
|
3254
|
-
migrationFeeOption,
|
|
3255
|
-
tokenType,
|
|
3256
|
-
partnerLpPercentage,
|
|
3257
|
-
creatorLpPercentage,
|
|
3258
|
-
partnerLockedLpPercentage,
|
|
3259
|
-
creatorLockedLpPercentage,
|
|
3260
3568
|
creatorTradingFeePercentage,
|
|
3261
|
-
|
|
3262
|
-
|
|
3569
|
+
poolCreationFee,
|
|
3570
|
+
migrationOption,
|
|
3571
|
+
migrationFeeOption,
|
|
3263
3572
|
migrationFee,
|
|
3264
|
-
|
|
3265
|
-
|
|
3573
|
+
partnerPermanentLockedLiquidityPercentage,
|
|
3574
|
+
partnerLiquidityPercentage,
|
|
3575
|
+
creatorPermanentLockedLiquidityPercentage,
|
|
3576
|
+
creatorLiquidityPercentage,
|
|
3577
|
+
partnerLiquidityVestingInfoParams,
|
|
3578
|
+
creatorLiquidityVestingInfoParams,
|
|
3579
|
+
migratedPoolFee,
|
|
3580
|
+
percentageSupplyOnMigration,
|
|
3581
|
+
migrationQuoteThreshold
|
|
3266
3582
|
} = buildCurveParam;
|
|
3267
3583
|
const baseFee = getBaseFeeParams(
|
|
3268
3584
|
baseFeeParams,
|
|
@@ -3275,7 +3591,7 @@ function buildCurve(buildCurveParam) {
|
|
|
3275
3591
|
cliffUnlockAmount,
|
|
3276
3592
|
totalVestingDuration,
|
|
3277
3593
|
cliffDurationFromMigrationTime
|
|
3278
|
-
} =
|
|
3594
|
+
} = lockedVestingParams;
|
|
3279
3595
|
const lockedVesting = getLockedVestingParams(
|
|
3280
3596
|
totalLockedVestingAmount,
|
|
3281
3597
|
numberOfVestingPeriod,
|
|
@@ -3284,6 +3600,40 @@ function buildCurve(buildCurveParam) {
|
|
|
3284
3600
|
cliffDurationFromMigrationTime,
|
|
3285
3601
|
tokenBaseDecimal
|
|
3286
3602
|
);
|
|
3603
|
+
const partnerVestingParams = 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 = 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
|
+
);
|
|
3287
3637
|
const migratedPoolFeeParams = getMigratedPoolFeeParams(
|
|
3288
3638
|
migrationOption,
|
|
3289
3639
|
migrationFeeOption,
|
|
@@ -3298,7 +3648,7 @@ function buildCurve(buildCurveParam) {
|
|
|
3298
3648
|
const migrationPrice = new Decimal4(migrationQuoteAmount.toString()).div(
|
|
3299
3649
|
new Decimal4(migrationBaseSupply.toString())
|
|
3300
3650
|
);
|
|
3301
|
-
|
|
3651
|
+
const migrationQuoteThresholdInLamport = convertToLamports(
|
|
3302
3652
|
migrationQuoteThreshold,
|
|
3303
3653
|
tokenQuoteDecimal
|
|
3304
3654
|
);
|
|
@@ -3308,7 +3658,7 @@ function buildCurve(buildCurveParam) {
|
|
|
3308
3658
|
tokenBaseDecimal,
|
|
3309
3659
|
tokenQuoteDecimal
|
|
3310
3660
|
);
|
|
3311
|
-
|
|
3661
|
+
const migrationQuoteAmountInLamport = fromDecimalToBN(
|
|
3312
3662
|
migrationQuoteAmount.mul(new Decimal4(10 ** tokenQuoteDecimal))
|
|
3313
3663
|
);
|
|
3314
3664
|
const migrationBaseAmount = getMigrationBaseToken(
|
|
@@ -3355,16 +3705,16 @@ function buildCurve(buildCurveParam) {
|
|
|
3355
3705
|
baseFeeParams.baseFeeMode === 2 /* RateLimiter */ ? baseFeeParams.rateLimiterParam.baseFeeBps : baseFeeParams.feeSchedulerParam.endingFeeBps
|
|
3356
3706
|
) : null
|
|
3357
3707
|
},
|
|
3358
|
-
activationType,
|
|
3359
3708
|
collectFeeMode,
|
|
3360
3709
|
migrationOption,
|
|
3710
|
+
activationType,
|
|
3361
3711
|
tokenType,
|
|
3362
3712
|
tokenDecimal: tokenBaseDecimal,
|
|
3713
|
+
partnerLiquidityPercentage,
|
|
3714
|
+
partnerPermanentLockedLiquidityPercentage,
|
|
3715
|
+
creatorLiquidityPercentage,
|
|
3716
|
+
creatorPermanentLockedLiquidityPercentage,
|
|
3363
3717
|
migrationQuoteThreshold: migrationQuoteThresholdInLamport,
|
|
3364
|
-
partnerLpPercentage,
|
|
3365
|
-
creatorLpPercentage,
|
|
3366
|
-
partnerLockedLpPercentage,
|
|
3367
|
-
creatorLockedLpPercentage,
|
|
3368
3718
|
sqrtStartPrice,
|
|
3369
3719
|
lockedVesting,
|
|
3370
3720
|
migrationFeeOption,
|
|
@@ -3380,6 +3730,9 @@ function buildCurve(buildCurveParam) {
|
|
|
3380
3730
|
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
3381
3731
|
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
3382
3732
|
},
|
|
3733
|
+
poolCreationFee: poolCreationFeeInLamports,
|
|
3734
|
+
partnerLiquidityVestingInfo,
|
|
3735
|
+
creatorLiquidityVestingInfo,
|
|
3383
3736
|
padding: [],
|
|
3384
3737
|
curve
|
|
3385
3738
|
};
|
|
@@ -3387,12 +3740,13 @@ function buildCurve(buildCurveParam) {
|
|
|
3387
3740
|
}
|
|
3388
3741
|
function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
|
|
3389
3742
|
const {
|
|
3390
|
-
initialMarketCap,
|
|
3391
|
-
migrationMarketCap,
|
|
3392
3743
|
totalTokenSupply,
|
|
3393
3744
|
tokenBaseDecimal,
|
|
3745
|
+
lockedVestingParams,
|
|
3746
|
+
leftover,
|
|
3394
3747
|
migrationFee,
|
|
3395
|
-
|
|
3748
|
+
initialMarketCap,
|
|
3749
|
+
migrationMarketCap
|
|
3396
3750
|
} = buildCurveWithMarketCapParam;
|
|
3397
3751
|
const {
|
|
3398
3752
|
totalLockedVestingAmount,
|
|
@@ -3400,7 +3754,7 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
|
|
|
3400
3754
|
cliffUnlockAmount,
|
|
3401
3755
|
totalVestingDuration,
|
|
3402
3756
|
cliffDurationFromMigrationTime
|
|
3403
|
-
} =
|
|
3757
|
+
} = lockedVestingParams;
|
|
3404
3758
|
const lockedVesting = getLockedVestingParams(
|
|
3405
3759
|
totalLockedVestingAmount,
|
|
3406
3760
|
numberOfVestingPeriod,
|
|
@@ -3411,7 +3765,14 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
|
|
|
3411
3765
|
);
|
|
3412
3766
|
const totalLeftover = convertToLamports(leftover, tokenBaseDecimal);
|
|
3413
3767
|
const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
|
|
3414
|
-
const percentageSupplyOnMigration =
|
|
3768
|
+
const percentageSupplyOnMigration = migrationFee.feePercentage > 0 ? calculateAdjustedPercentageSupplyOnMigration(
|
|
3769
|
+
initialMarketCap,
|
|
3770
|
+
migrationMarketCap,
|
|
3771
|
+
migrationFee,
|
|
3772
|
+
lockedVesting,
|
|
3773
|
+
totalLeftover,
|
|
3774
|
+
totalSupply
|
|
3775
|
+
) : getPercentageSupplyOnMigration(
|
|
3415
3776
|
new Decimal4(initialMarketCap),
|
|
3416
3777
|
new Decimal4(migrationMarketCap),
|
|
3417
3778
|
lockedVesting,
|
|
@@ -3435,27 +3796,31 @@ function buildCurveWithMarketCap(buildCurveWithMarketCapParam) {
|
|
|
3435
3796
|
function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
3436
3797
|
const {
|
|
3437
3798
|
totalTokenSupply,
|
|
3438
|
-
|
|
3439
|
-
migrationMarketCap,
|
|
3440
|
-
percentageSupplyOnMigration,
|
|
3441
|
-
migrationOption,
|
|
3799
|
+
tokenType,
|
|
3442
3800
|
tokenBaseDecimal,
|
|
3443
3801
|
tokenQuoteDecimal,
|
|
3444
|
-
|
|
3445
|
-
collectFeeMode,
|
|
3802
|
+
tokenUpdateAuthority,
|
|
3446
3803
|
leftover,
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
creatorLpPercentage,
|
|
3450
|
-
partnerLockedLpPercentage,
|
|
3451
|
-
creatorLockedLpPercentage,
|
|
3452
|
-
activationType,
|
|
3804
|
+
lockedVestingParams,
|
|
3805
|
+
baseFeeParams,
|
|
3453
3806
|
dynamicFeeEnabled,
|
|
3807
|
+
activationType,
|
|
3808
|
+
collectFeeMode,
|
|
3809
|
+
creatorTradingFeePercentage,
|
|
3810
|
+
poolCreationFee,
|
|
3811
|
+
migrationOption,
|
|
3454
3812
|
migrationFeeOption,
|
|
3455
3813
|
migrationFee,
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3814
|
+
partnerPermanentLockedLiquidityPercentage,
|
|
3815
|
+
partnerLiquidityPercentage,
|
|
3816
|
+
creatorPermanentLockedLiquidityPercentage,
|
|
3817
|
+
creatorLiquidityPercentage,
|
|
3818
|
+
partnerLiquidityVestingInfoParams,
|
|
3819
|
+
creatorLiquidityVestingInfoParams,
|
|
3820
|
+
migratedPoolFee,
|
|
3821
|
+
initialMarketCap,
|
|
3822
|
+
migrationMarketCap,
|
|
3823
|
+
percentageSupplyOnMigration
|
|
3459
3824
|
} = buildCurveWithTwoSegmentsParam;
|
|
3460
3825
|
const baseFee = getBaseFeeParams(
|
|
3461
3826
|
baseFeeParams,
|
|
@@ -3468,7 +3833,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
3468
3833
|
cliffUnlockAmount,
|
|
3469
3834
|
totalVestingDuration,
|
|
3470
3835
|
cliffDurationFromMigrationTime
|
|
3471
|
-
} =
|
|
3836
|
+
} = lockedVestingParams;
|
|
3472
3837
|
const lockedVesting = getLockedVestingParams(
|
|
3473
3838
|
totalLockedVestingAmount,
|
|
3474
3839
|
numberOfVestingPeriod,
|
|
@@ -3477,62 +3842,96 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
3477
3842
|
cliffDurationFromMigrationTime,
|
|
3478
3843
|
tokenBaseDecimal
|
|
3479
3844
|
);
|
|
3845
|
+
const partnerVestingParams = 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 = 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
|
+
);
|
|
3480
3879
|
const migratedPoolFeeParams = getMigratedPoolFeeParams(
|
|
3481
3880
|
migrationOption,
|
|
3482
3881
|
migrationFeeOption,
|
|
3483
3882
|
migratedPoolFee
|
|
3484
3883
|
);
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3884
|
+
const migrationBaseSupply = new BN14(totalTokenSupply).mul(new BN14(percentageSupplyOnMigration)).div(new BN14(100));
|
|
3885
|
+
const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
|
|
3886
|
+
const migrationQuoteAmount = getMigrationQuoteAmount(
|
|
3488
3887
|
new Decimal4(migrationMarketCap),
|
|
3489
3888
|
new Decimal4(percentageSupplyOnMigration)
|
|
3490
3889
|
);
|
|
3491
|
-
|
|
3890
|
+
const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
|
|
3492
3891
|
migrationQuoteAmount,
|
|
3493
3892
|
new Decimal4(migrationFee.feePercentage)
|
|
3494
3893
|
);
|
|
3495
|
-
|
|
3894
|
+
const migrationPrice = migrationQuoteAmount.div(
|
|
3496
3895
|
new Decimal4(migrationBaseSupply.toString())
|
|
3497
3896
|
);
|
|
3498
|
-
|
|
3897
|
+
const migrationQuoteThresholdInLamport = fromDecimalToBN(
|
|
3499
3898
|
migrationQuoteThreshold.mul(new Decimal4(10 ** tokenQuoteDecimal))
|
|
3500
3899
|
);
|
|
3501
|
-
|
|
3900
|
+
const migrationQuoteAmountInLamport = fromDecimalToBN(
|
|
3502
3901
|
migrationQuoteAmount.mul(new Decimal4(10 ** tokenQuoteDecimal))
|
|
3503
3902
|
);
|
|
3504
|
-
|
|
3903
|
+
const migrateSqrtPrice = getSqrtPriceFromPrice(
|
|
3505
3904
|
migrationPrice.toString(),
|
|
3506
3905
|
tokenBaseDecimal,
|
|
3507
3906
|
tokenQuoteDecimal
|
|
3508
3907
|
);
|
|
3509
|
-
|
|
3908
|
+
const migrationBaseAmount = getMigrationBaseToken(
|
|
3510
3909
|
migrationQuoteAmountInLamport,
|
|
3511
3910
|
migrateSqrtPrice,
|
|
3512
3911
|
migrationOption
|
|
3513
3912
|
);
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
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(
|
|
3518
3917
|
initialMarketCap,
|
|
3519
3918
|
totalTokenSupply,
|
|
3520
3919
|
tokenBaseDecimal,
|
|
3521
3920
|
tokenQuoteDecimal
|
|
3522
3921
|
);
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3922
|
+
const midSqrtPriceDecimal1 = new Decimal4(migrateSqrtPrice.toString()).mul(new Decimal4(initialSqrtPrice.toString())).sqrt();
|
|
3923
|
+
const midSqrtPrice1 = new BN14(midSqrtPriceDecimal1.floor().toFixed());
|
|
3924
|
+
const numerator1 = new Decimal4(initialSqrtPrice.toString());
|
|
3925
|
+
const numerator2 = Decimal4.pow(migrateSqrtPrice.toString(), 3);
|
|
3926
|
+
const product1 = numerator1.mul(numerator2);
|
|
3927
|
+
const midSqrtPriceDecimal2 = Decimal4.pow(product1, 0.25);
|
|
3928
|
+
const midSqrtPrice2 = new BN14(midSqrtPriceDecimal2.floor().toFixed());
|
|
3929
|
+
const numerator3 = Decimal4.pow(initialSqrtPrice.toString(), 3);
|
|
3930
|
+
const numerator4 = new Decimal4(migrateSqrtPrice.toString());
|
|
3931
|
+
const product2 = numerator3.mul(numerator4);
|
|
3932
|
+
const midSqrtPriceDecimal3 = Decimal4.pow(product2, 0.25);
|
|
3933
|
+
const midSqrtPrice3 = new BN14(midSqrtPriceDecimal3.floor().toFixed());
|
|
3934
|
+
const midPrices = [midSqrtPrice3, midSqrtPrice2, midSqrtPrice1];
|
|
3536
3935
|
let sqrtStartPrice = new BN14(0);
|
|
3537
3936
|
let curve = [];
|
|
3538
3937
|
for (let i = 0; i < midPrices.length; i++) {
|
|
@@ -3549,7 +3948,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
3549
3948
|
break;
|
|
3550
3949
|
}
|
|
3551
3950
|
}
|
|
3552
|
-
|
|
3951
|
+
const totalDynamicSupply = getTotalSupplyFromCurve(
|
|
3553
3952
|
migrationQuoteThresholdInLamport,
|
|
3554
3953
|
sqrtStartPrice,
|
|
3555
3954
|
curve,
|
|
@@ -3559,7 +3958,7 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
3559
3958
|
migrationFee.feePercentage
|
|
3560
3959
|
);
|
|
3561
3960
|
if (totalDynamicSupply.gt(totalSupply)) {
|
|
3562
|
-
|
|
3961
|
+
const leftOverDelta = totalDynamicSupply.sub(totalSupply);
|
|
3563
3962
|
if (!leftOverDelta.lt(totalLeftover)) {
|
|
3564
3963
|
throw new Error("leftOverDelta must be less than totalLeftover");
|
|
3565
3964
|
}
|
|
@@ -3579,10 +3978,10 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
3579
3978
|
tokenType,
|
|
3580
3979
|
tokenDecimal: tokenBaseDecimal,
|
|
3581
3980
|
migrationQuoteThreshold: migrationQuoteThresholdInLamport,
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3981
|
+
partnerLiquidityPercentage,
|
|
3982
|
+
partnerPermanentLockedLiquidityPercentage,
|
|
3983
|
+
creatorLiquidityPercentage,
|
|
3984
|
+
creatorPermanentLockedLiquidityPercentage,
|
|
3586
3985
|
sqrtStartPrice,
|
|
3587
3986
|
lockedVesting,
|
|
3588
3987
|
migrationFeeOption,
|
|
@@ -3596,6 +3995,9 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
3596
3995
|
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
3597
3996
|
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
3598
3997
|
},
|
|
3998
|
+
poolCreationFee: poolCreationFeeInLamports,
|
|
3999
|
+
partnerLiquidityVestingInfo,
|
|
4000
|
+
creatorLiquidityVestingInfo,
|
|
3599
4001
|
padding: [],
|
|
3600
4002
|
curve,
|
|
3601
4003
|
tokenUpdateAuthority,
|
|
@@ -3603,31 +4005,36 @@ function buildCurveWithTwoSegments(buildCurveWithTwoSegmentsParam) {
|
|
|
3603
4005
|
};
|
|
3604
4006
|
return instructionParams;
|
|
3605
4007
|
}
|
|
3606
|
-
function
|
|
3607
|
-
|
|
4008
|
+
function buildCurveWithMidPrice(buildCurveWithMidPriceParam) {
|
|
4009
|
+
const {
|
|
3608
4010
|
totalTokenSupply,
|
|
3609
|
-
|
|
4011
|
+
tokenType,
|
|
3610
4012
|
tokenBaseDecimal,
|
|
3611
4013
|
tokenQuoteDecimal,
|
|
4014
|
+
tokenUpdateAuthority,
|
|
4015
|
+
lockedVestingParams,
|
|
4016
|
+
leftover,
|
|
4017
|
+
baseFeeParams,
|
|
3612
4018
|
dynamicFeeEnabled,
|
|
3613
4019
|
activationType,
|
|
3614
4020
|
collectFeeMode,
|
|
3615
|
-
migrationFeeOption,
|
|
3616
|
-
tokenType,
|
|
3617
|
-
partnerLpPercentage,
|
|
3618
|
-
creatorLpPercentage,
|
|
3619
|
-
partnerLockedLpPercentage,
|
|
3620
|
-
creatorLockedLpPercentage,
|
|
3621
4021
|
creatorTradingFeePercentage,
|
|
3622
|
-
|
|
4022
|
+
poolCreationFee,
|
|
4023
|
+
migrationOption,
|
|
4024
|
+
migrationFeeOption,
|
|
4025
|
+
migrationFee,
|
|
4026
|
+
partnerPermanentLockedLiquidityPercentage,
|
|
4027
|
+
partnerLiquidityPercentage,
|
|
4028
|
+
creatorPermanentLockedLiquidityPercentage,
|
|
4029
|
+
creatorLiquidityPercentage,
|
|
4030
|
+
partnerLiquidityVestingInfoParams,
|
|
4031
|
+
creatorLiquidityVestingInfoParams,
|
|
4032
|
+
migratedPoolFee,
|
|
3623
4033
|
initialMarketCap,
|
|
3624
4034
|
migrationMarketCap,
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
baseFeeParams,
|
|
3629
|
-
migratedPoolFee
|
|
3630
|
-
} = buildCurveWithLiquidityWeightsParam;
|
|
4035
|
+
midPrice,
|
|
4036
|
+
percentageSupplyOnMigration
|
|
4037
|
+
} = buildCurveWithMidPriceParam;
|
|
3631
4038
|
const baseFee = getBaseFeeParams(
|
|
3632
4039
|
baseFeeParams,
|
|
3633
4040
|
tokenQuoteDecimal,
|
|
@@ -3639,7 +4046,7 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
3639
4046
|
cliffUnlockAmount,
|
|
3640
4047
|
totalVestingDuration,
|
|
3641
4048
|
cliffDurationFromMigrationTime
|
|
3642
|
-
} =
|
|
4049
|
+
} = lockedVestingParams;
|
|
3643
4050
|
const lockedVesting = getLockedVestingParams(
|
|
3644
4051
|
totalLockedVestingAmount,
|
|
3645
4052
|
numberOfVestingPeriod,
|
|
@@ -3648,28 +4055,261 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
3648
4055
|
cliffDurationFromMigrationTime,
|
|
3649
4056
|
tokenBaseDecimal
|
|
3650
4057
|
);
|
|
4058
|
+
const partnerVestingParams = 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 = 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
|
+
);
|
|
3651
4092
|
const migratedPoolFeeParams = getMigratedPoolFeeParams(
|
|
3652
4093
|
migrationOption,
|
|
3653
4094
|
migrationFeeOption,
|
|
3654
4095
|
migratedPoolFee
|
|
3655
4096
|
);
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
4097
|
+
const migrationBaseSupply = new BN14(totalTokenSupply).mul(new BN14(percentageSupplyOnMigration)).div(new BN14(100));
|
|
4098
|
+
const totalSupply = convertToLamports(totalTokenSupply, tokenBaseDecimal);
|
|
4099
|
+
const migrationQuoteAmount = getMigrationQuoteAmount(
|
|
4100
|
+
new Decimal4(migrationMarketCap),
|
|
4101
|
+
new Decimal4(percentageSupplyOnMigration)
|
|
3661
4102
|
);
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
tokenBaseDecimal,
|
|
3666
|
-
tokenQuoteDecimal
|
|
4103
|
+
const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
|
|
4104
|
+
migrationQuoteAmount,
|
|
4105
|
+
new Decimal4(migrationFee.feePercentage)
|
|
3667
4106
|
);
|
|
3668
|
-
|
|
3669
|
-
new Decimal4(
|
|
4107
|
+
const migrationPrice = migrationQuoteAmount.div(
|
|
4108
|
+
new Decimal4(migrationBaseSupply.toString())
|
|
3670
4109
|
);
|
|
3671
|
-
|
|
3672
|
-
|
|
4110
|
+
const migrationQuoteThresholdInLamport = fromDecimalToBN(
|
|
4111
|
+
migrationQuoteThreshold.mul(new Decimal4(10 ** tokenQuoteDecimal))
|
|
4112
|
+
);
|
|
4113
|
+
const migrationQuoteAmountInLamport = fromDecimalToBN(
|
|
4114
|
+
migrationQuoteAmount.mul(new Decimal4(10 ** tokenQuoteDecimal))
|
|
4115
|
+
);
|
|
4116
|
+
const migrateSqrtPrice = getSqrtPriceFromPrice(
|
|
4117
|
+
migrationPrice.toString(),
|
|
4118
|
+
tokenBaseDecimal,
|
|
4119
|
+
tokenQuoteDecimal
|
|
4120
|
+
);
|
|
4121
|
+
const migrationBaseAmount = getMigrationBaseToken(
|
|
4122
|
+
migrationQuoteAmountInLamport,
|
|
4123
|
+
migrateSqrtPrice,
|
|
4124
|
+
migrationOption
|
|
4125
|
+
);
|
|
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(
|
|
4130
|
+
initialMarketCap,
|
|
4131
|
+
totalTokenSupply,
|
|
4132
|
+
tokenBaseDecimal,
|
|
4133
|
+
tokenQuoteDecimal
|
|
4134
|
+
);
|
|
4135
|
+
const midSqrtPrice = getSqrtPriceFromPrice(
|
|
4136
|
+
midPrice.toString(),
|
|
4137
|
+
tokenBaseDecimal,
|
|
4138
|
+
tokenQuoteDecimal
|
|
4139
|
+
);
|
|
4140
|
+
let sqrtStartPrice = new BN14(0);
|
|
4141
|
+
let curve = [];
|
|
4142
|
+
const result = getTwoCurve(
|
|
4143
|
+
migrateSqrtPrice,
|
|
4144
|
+
midSqrtPrice,
|
|
4145
|
+
initialSqrtPrice,
|
|
4146
|
+
swapAmount,
|
|
4147
|
+
migrationQuoteThresholdInLamport
|
|
4148
|
+
);
|
|
4149
|
+
curve = result.curve;
|
|
4150
|
+
sqrtStartPrice = result.sqrtStartPrice;
|
|
4151
|
+
const totalDynamicSupply = getTotalSupplyFromCurve(
|
|
4152
|
+
migrationQuoteThresholdInLamport,
|
|
4153
|
+
sqrtStartPrice,
|
|
4154
|
+
curve,
|
|
4155
|
+
lockedVesting,
|
|
4156
|
+
migrationOption,
|
|
4157
|
+
totalLeftover,
|
|
4158
|
+
migrationFee.feePercentage
|
|
4159
|
+
);
|
|
4160
|
+
if (totalDynamicSupply.gt(totalSupply)) {
|
|
4161
|
+
const leftOverDelta = totalDynamicSupply.sub(totalSupply);
|
|
4162
|
+
if (!leftOverDelta.lt(totalLeftover)) {
|
|
4163
|
+
throw new Error("leftOverDelta must be less than totalLeftover");
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4166
|
+
const instructionParams = {
|
|
4167
|
+
poolFees: {
|
|
4168
|
+
baseFee: {
|
|
4169
|
+
...baseFee
|
|
4170
|
+
},
|
|
4171
|
+
dynamicFee: dynamicFeeEnabled ? getDynamicFeeParams(
|
|
4172
|
+
baseFeeParams.baseFeeMode === 2 /* RateLimiter */ ? baseFeeParams.rateLimiterParam.baseFeeBps : baseFeeParams.feeSchedulerParam.endingFeeBps
|
|
4173
|
+
) : null
|
|
4174
|
+
},
|
|
4175
|
+
activationType,
|
|
4176
|
+
collectFeeMode,
|
|
4177
|
+
migrationOption,
|
|
4178
|
+
tokenType,
|
|
4179
|
+
tokenDecimal: tokenBaseDecimal,
|
|
4180
|
+
migrationQuoteThreshold: migrationQuoteThresholdInLamport,
|
|
4181
|
+
partnerLiquidityPercentage,
|
|
4182
|
+
partnerPermanentLockedLiquidityPercentage,
|
|
4183
|
+
creatorLiquidityPercentage,
|
|
4184
|
+
creatorPermanentLockedLiquidityPercentage,
|
|
4185
|
+
sqrtStartPrice,
|
|
4186
|
+
lockedVesting,
|
|
4187
|
+
migrationFeeOption,
|
|
4188
|
+
tokenSupply: {
|
|
4189
|
+
preMigrationTokenSupply: totalSupply,
|
|
4190
|
+
postMigrationTokenSupply: totalSupply
|
|
4191
|
+
},
|
|
4192
|
+
creatorTradingFeePercentage,
|
|
4193
|
+
migratedPoolFee: {
|
|
4194
|
+
collectFeeMode: migratedPoolFeeParams.collectFeeMode,
|
|
4195
|
+
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
4196
|
+
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
4197
|
+
},
|
|
4198
|
+
poolCreationFee: poolCreationFeeInLamports,
|
|
4199
|
+
partnerLiquidityVestingInfo,
|
|
4200
|
+
creatorLiquidityVestingInfo,
|
|
4201
|
+
padding: [],
|
|
4202
|
+
curve,
|
|
4203
|
+
tokenUpdateAuthority,
|
|
4204
|
+
migrationFee
|
|
4205
|
+
};
|
|
4206
|
+
return instructionParams;
|
|
4207
|
+
}
|
|
4208
|
+
function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
4209
|
+
const {
|
|
4210
|
+
totalTokenSupply,
|
|
4211
|
+
tokenType,
|
|
4212
|
+
tokenBaseDecimal,
|
|
4213
|
+
tokenQuoteDecimal,
|
|
4214
|
+
tokenUpdateAuthority,
|
|
4215
|
+
lockedVestingParams,
|
|
4216
|
+
leftover,
|
|
4217
|
+
baseFeeParams,
|
|
4218
|
+
dynamicFeeEnabled,
|
|
4219
|
+
activationType,
|
|
4220
|
+
collectFeeMode,
|
|
4221
|
+
creatorTradingFeePercentage,
|
|
4222
|
+
poolCreationFee,
|
|
4223
|
+
migrationOption,
|
|
4224
|
+
migrationFeeOption,
|
|
4225
|
+
migrationFee,
|
|
4226
|
+
partnerPermanentLockedLiquidityPercentage,
|
|
4227
|
+
partnerLiquidityPercentage,
|
|
4228
|
+
creatorPermanentLockedLiquidityPercentage,
|
|
4229
|
+
creatorLiquidityPercentage,
|
|
4230
|
+
partnerLiquidityVestingInfoParams,
|
|
4231
|
+
creatorLiquidityVestingInfoParams,
|
|
4232
|
+
migratedPoolFee,
|
|
4233
|
+
initialMarketCap,
|
|
4234
|
+
migrationMarketCap,
|
|
4235
|
+
liquidityWeights
|
|
4236
|
+
} = buildCurveWithLiquidityWeightsParam;
|
|
4237
|
+
const baseFee = getBaseFeeParams(
|
|
4238
|
+
baseFeeParams,
|
|
4239
|
+
tokenQuoteDecimal,
|
|
4240
|
+
activationType
|
|
4241
|
+
);
|
|
4242
|
+
const {
|
|
4243
|
+
totalLockedVestingAmount,
|
|
4244
|
+
numberOfVestingPeriod,
|
|
4245
|
+
cliffUnlockAmount,
|
|
4246
|
+
totalVestingDuration,
|
|
4247
|
+
cliffDurationFromMigrationTime
|
|
4248
|
+
} = lockedVestingParams;
|
|
4249
|
+
const lockedVesting = getLockedVestingParams(
|
|
4250
|
+
totalLockedVestingAmount,
|
|
4251
|
+
numberOfVestingPeriod,
|
|
4252
|
+
cliffUnlockAmount,
|
|
4253
|
+
totalVestingDuration,
|
|
4254
|
+
cliffDurationFromMigrationTime,
|
|
4255
|
+
tokenBaseDecimal
|
|
4256
|
+
);
|
|
4257
|
+
const partnerVestingParams = 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 = 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
|
+
);
|
|
4291
|
+
const migratedPoolFeeParams = getMigratedPoolFeeParams(
|
|
4292
|
+
migrationOption,
|
|
4293
|
+
migrationFeeOption,
|
|
4294
|
+
migratedPoolFee
|
|
4295
|
+
);
|
|
4296
|
+
const pMin = getSqrtPriceFromMarketCap(
|
|
4297
|
+
initialMarketCap,
|
|
4298
|
+
totalTokenSupply,
|
|
4299
|
+
tokenBaseDecimal,
|
|
4300
|
+
tokenQuoteDecimal
|
|
4301
|
+
);
|
|
4302
|
+
const pMax = getSqrtPriceFromMarketCap(
|
|
4303
|
+
migrationMarketCap,
|
|
4304
|
+
totalTokenSupply,
|
|
4305
|
+
tokenBaseDecimal,
|
|
4306
|
+
tokenQuoteDecimal
|
|
4307
|
+
);
|
|
4308
|
+
const priceRatio = new Decimal4(pMax.toString()).div(
|
|
4309
|
+
new Decimal4(pMin.toString())
|
|
4310
|
+
);
|
|
4311
|
+
const qDecimal = priceRatio.pow(new Decimal4(1).div(new Decimal4(16)));
|
|
4312
|
+
const sqrtPrices = [];
|
|
3673
4313
|
let currentPrice = pMin;
|
|
3674
4314
|
for (let i = 0; i < 17; i++) {
|
|
3675
4315
|
sqrtPrices.push(currentPrice);
|
|
@@ -3677,49 +4317,258 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
3677
4317
|
qDecimal.mul(new Decimal4(currentPrice.toString()))
|
|
3678
4318
|
);
|
|
3679
4319
|
}
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
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);
|
|
3684
4324
|
let sumFactor = new Decimal4(0);
|
|
3685
|
-
|
|
3686
|
-
|
|
4325
|
+
const pmaxWeight = new Decimal4(pMax.toString());
|
|
4326
|
+
const migrationFeeFactor = new Decimal4(100).sub(new Decimal4(migrationFee.feePercentage)).div(new Decimal4(100));
|
|
3687
4327
|
for (let i = 1; i < 17; i++) {
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
4328
|
+
const pi = new Decimal4(sqrtPrices[i].toString());
|
|
4329
|
+
const piMinus = new Decimal4(sqrtPrices[i - 1].toString());
|
|
4330
|
+
const k = new Decimal4(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));
|
|
3694
4334
|
sumFactor = sumFactor.add(weight);
|
|
3695
4335
|
}
|
|
3696
|
-
|
|
3697
|
-
|
|
4336
|
+
const l1 = new Decimal4(totalSwapAndMigrationAmount.toString()).div(
|
|
4337
|
+
sumFactor
|
|
4338
|
+
);
|
|
4339
|
+
const curve = [];
|
|
3698
4340
|
for (let i = 0; i < 16; i++) {
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
4341
|
+
const k = new Decimal4(liquidityWeights[i]);
|
|
4342
|
+
const liquidity = convertDecimalToBN(l1.mul(k));
|
|
4343
|
+
const sqrtPrice = i < 15 ? sqrtPrices[i + 1] : pMax;
|
|
4344
|
+
curve.push({
|
|
4345
|
+
sqrtPrice,
|
|
4346
|
+
liquidity
|
|
4347
|
+
});
|
|
4348
|
+
}
|
|
4349
|
+
const swapBaseAmount = getBaseTokenForSwap(pMin, pMax, curve);
|
|
4350
|
+
const swapBaseAmountBuffer = getSwapAmountWithBuffer(
|
|
4351
|
+
swapBaseAmount,
|
|
4352
|
+
pMin,
|
|
4353
|
+
curve
|
|
4354
|
+
);
|
|
4355
|
+
const migrationAmount = totalSwapAndMigrationAmount.sub(swapBaseAmountBuffer);
|
|
4356
|
+
const migrationQuoteAmount = migrationAmount.mul(pMax).mul(pMax).shrn(128);
|
|
4357
|
+
const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
|
|
4358
|
+
new Decimal4(migrationQuoteAmount.toString()),
|
|
4359
|
+
new Decimal4(migrationFee.feePercentage)
|
|
4360
|
+
);
|
|
4361
|
+
const migrationQuoteThresholdInLamport = fromDecimalToBN(
|
|
4362
|
+
migrationQuoteThreshold
|
|
4363
|
+
);
|
|
4364
|
+
const totalDynamicSupply = getTotalSupplyFromCurve(
|
|
4365
|
+
migrationQuoteThresholdInLamport,
|
|
4366
|
+
pMin,
|
|
4367
|
+
curve,
|
|
4368
|
+
lockedVesting,
|
|
4369
|
+
migrationOption,
|
|
4370
|
+
totalLeftover,
|
|
4371
|
+
migrationFee.feePercentage
|
|
4372
|
+
);
|
|
4373
|
+
if (totalDynamicSupply.gt(totalSupply)) {
|
|
4374
|
+
const leftOverDelta = totalDynamicSupply.sub(totalSupply);
|
|
4375
|
+
if (!leftOverDelta.lt(totalLeftover)) {
|
|
4376
|
+
throw new Error("leftOverDelta must be less than totalLeftover");
|
|
4377
|
+
}
|
|
4378
|
+
}
|
|
4379
|
+
const instructionParams = {
|
|
4380
|
+
poolFees: {
|
|
4381
|
+
baseFee: {
|
|
4382
|
+
...baseFee
|
|
4383
|
+
},
|
|
4384
|
+
dynamicFee: dynamicFeeEnabled ? getDynamicFeeParams(
|
|
4385
|
+
baseFeeParams.baseFeeMode === 2 /* RateLimiter */ ? baseFeeParams.rateLimiterParam.baseFeeBps : baseFeeParams.feeSchedulerParam.endingFeeBps
|
|
4386
|
+
) : null
|
|
4387
|
+
},
|
|
4388
|
+
activationType,
|
|
4389
|
+
collectFeeMode,
|
|
4390
|
+
migrationOption,
|
|
4391
|
+
tokenType,
|
|
4392
|
+
tokenDecimal: tokenBaseDecimal,
|
|
4393
|
+
migrationQuoteThreshold: migrationQuoteThresholdInLamport,
|
|
4394
|
+
partnerLiquidityPercentage,
|
|
4395
|
+
partnerPermanentLockedLiquidityPercentage,
|
|
4396
|
+
creatorLiquidityPercentage,
|
|
4397
|
+
creatorPermanentLockedLiquidityPercentage,
|
|
4398
|
+
sqrtStartPrice: pMin,
|
|
4399
|
+
lockedVesting,
|
|
4400
|
+
migrationFeeOption,
|
|
4401
|
+
tokenSupply: {
|
|
4402
|
+
preMigrationTokenSupply: totalSupply,
|
|
4403
|
+
postMigrationTokenSupply: totalSupply
|
|
4404
|
+
},
|
|
4405
|
+
creatorTradingFeePercentage,
|
|
4406
|
+
migratedPoolFee: {
|
|
4407
|
+
collectFeeMode: migratedPoolFeeParams.collectFeeMode,
|
|
4408
|
+
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
4409
|
+
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
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 = 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 = 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 Decimal4(0);
|
|
4531
|
+
const pmaxWeight = new Decimal4(pMax.toString());
|
|
4532
|
+
const migrationFeeFactor = new Decimal4(100).sub(new Decimal4(migrationFee.feePercentage)).div(new Decimal4(100));
|
|
4533
|
+
const numSegments = sqrtPrices.length - 1;
|
|
4534
|
+
for (let i = 0; i < numSegments; i++) {
|
|
4535
|
+
const pi = new Decimal4(sqrtPrices[i + 1].toString());
|
|
4536
|
+
const piMinus = new Decimal4(sqrtPrices[i].toString());
|
|
4537
|
+
const k = new Decimal4(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 Decimal4(totalSwapAndMigrationAmount.toString()).div(
|
|
4544
|
+
sumFactor
|
|
4545
|
+
);
|
|
4546
|
+
const curve = [];
|
|
4547
|
+
for (let i = 0; i < numSegments; i++) {
|
|
4548
|
+
const k = new Decimal4(liquidityWeights[i]);
|
|
4549
|
+
const liquidity = convertDecimalToBN(l1.mul(k));
|
|
4550
|
+
const sqrtPrice = sqrtPrices[i + 1];
|
|
3702
4551
|
curve.push({
|
|
3703
4552
|
sqrtPrice,
|
|
3704
4553
|
liquidity
|
|
3705
4554
|
});
|
|
3706
4555
|
}
|
|
3707
|
-
|
|
3708
|
-
|
|
4556
|
+
const swapBaseAmount = getBaseTokenForSwap(pMin, pMax, curve);
|
|
4557
|
+
const swapBaseAmountBuffer = getSwapAmountWithBuffer(
|
|
3709
4558
|
swapBaseAmount,
|
|
3710
4559
|
pMin,
|
|
3711
4560
|
curve
|
|
3712
4561
|
);
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
4562
|
+
const migrationAmount = totalSwapAndMigrationAmount.sub(swapBaseAmountBuffer);
|
|
4563
|
+
const migrationQuoteAmount = migrationAmount.mul(pMax).mul(pMax).shrn(128);
|
|
4564
|
+
const migrationQuoteThreshold = getMigrationQuoteThresholdFromMigrationQuoteAmount(
|
|
3716
4565
|
new Decimal4(migrationQuoteAmount.toString()),
|
|
3717
4566
|
new Decimal4(migrationFee.feePercentage)
|
|
3718
4567
|
);
|
|
3719
|
-
|
|
4568
|
+
const migrationQuoteThresholdInLamport = fromDecimalToBN(
|
|
3720
4569
|
migrationQuoteThreshold
|
|
3721
4570
|
);
|
|
3722
|
-
|
|
4571
|
+
const totalDynamicSupply = getTotalSupplyFromCurve(
|
|
3723
4572
|
migrationQuoteThresholdInLamport,
|
|
3724
4573
|
pMin,
|
|
3725
4574
|
curve,
|
|
@@ -3729,7 +4578,7 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
3729
4578
|
migrationFee.feePercentage
|
|
3730
4579
|
);
|
|
3731
4580
|
if (totalDynamicSupply.gt(totalSupply)) {
|
|
3732
|
-
|
|
4581
|
+
const leftOverDelta = totalDynamicSupply.sub(totalSupply);
|
|
3733
4582
|
if (!leftOverDelta.lt(totalLeftover)) {
|
|
3734
4583
|
throw new Error("leftOverDelta must be less than totalLeftover");
|
|
3735
4584
|
}
|
|
@@ -3749,10 +4598,10 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
3749
4598
|
tokenType,
|
|
3750
4599
|
tokenDecimal: tokenBaseDecimal,
|
|
3751
4600
|
migrationQuoteThreshold: migrationQuoteThresholdInLamport,
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
4601
|
+
partnerLiquidityPercentage,
|
|
4602
|
+
partnerPermanentLockedLiquidityPercentage,
|
|
4603
|
+
creatorLiquidityPercentage,
|
|
4604
|
+
creatorPermanentLockedLiquidityPercentage,
|
|
3756
4605
|
sqrtStartPrice: pMin,
|
|
3757
4606
|
lockedVesting,
|
|
3758
4607
|
migrationFeeOption,
|
|
@@ -3766,6 +4615,9 @@ function buildCurveWithLiquidityWeights(buildCurveWithLiquidityWeightsParam) {
|
|
|
3766
4615
|
dynamicFee: migratedPoolFeeParams.dynamicFee,
|
|
3767
4616
|
poolFeeBps: migratedPoolFeeParams.poolFeeBps
|
|
3768
4617
|
},
|
|
4618
|
+
poolCreationFee: poolCreationFeeInLamports,
|
|
4619
|
+
partnerLiquidityVestingInfo,
|
|
4620
|
+
creatorLiquidityVestingInfo,
|
|
3769
4621
|
padding: [],
|
|
3770
4622
|
curve,
|
|
3771
4623
|
migrationFee,
|
|
@@ -3782,7 +4634,7 @@ var idl_default = {
|
|
|
3782
4634
|
address: "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN",
|
|
3783
4635
|
metadata: {
|
|
3784
4636
|
name: "dynamic_bonding_curve",
|
|
3785
|
-
version: "0.1.
|
|
4637
|
+
version: "0.1.8",
|
|
3786
4638
|
spec: "0.1.0",
|
|
3787
4639
|
description: "Created with Anchor"
|
|
3788
4640
|
},
|
|
@@ -3859,10 +4711,7 @@ var idl_default = {
|
|
|
3859
4711
|
},
|
|
3860
4712
|
{
|
|
3861
4713
|
name: "creator",
|
|
3862
|
-
signer: true
|
|
3863
|
-
relations: [
|
|
3864
|
-
"pool"
|
|
3865
|
-
]
|
|
4714
|
+
signer: true
|
|
3866
4715
|
},
|
|
3867
4716
|
{
|
|
3868
4717
|
name: "token_base_program",
|
|
@@ -3915,52 +4764,115 @@ var idl_default = {
|
|
|
3915
4764
|
type: "u64"
|
|
3916
4765
|
},
|
|
3917
4766
|
{
|
|
3918
|
-
name: "max_quote_amount",
|
|
3919
|
-
type: "u64"
|
|
4767
|
+
name: "max_quote_amount",
|
|
4768
|
+
type: "u64"
|
|
4769
|
+
}
|
|
4770
|
+
]
|
|
4771
|
+
},
|
|
4772
|
+
{
|
|
4773
|
+
name: "claim_legacy_pool_creation_fee",
|
|
4774
|
+
discriminator: [
|
|
4775
|
+
96,
|
|
4776
|
+
11,
|
|
4777
|
+
187,
|
|
4778
|
+
225,
|
|
4779
|
+
54,
|
|
4780
|
+
117,
|
|
4781
|
+
161,
|
|
4782
|
+
134
|
|
4783
|
+
],
|
|
4784
|
+
accounts: [
|
|
4785
|
+
{
|
|
4786
|
+
name: "pool",
|
|
4787
|
+
writable: true
|
|
4788
|
+
},
|
|
4789
|
+
{
|
|
4790
|
+
name: "claim_fee_operator",
|
|
4791
|
+
docs: [
|
|
4792
|
+
"Claim fee operator"
|
|
4793
|
+
]
|
|
4794
|
+
},
|
|
4795
|
+
{
|
|
4796
|
+
name: "signer",
|
|
4797
|
+
docs: [
|
|
4798
|
+
"Operator"
|
|
4799
|
+
],
|
|
4800
|
+
signer: true
|
|
4801
|
+
},
|
|
4802
|
+
{
|
|
4803
|
+
name: "treasury",
|
|
4804
|
+
writable: true,
|
|
4805
|
+
address: "4EWqcx3aNZmMetCnxwLYwyNjan6XLGp3Ca2W316vrSjv"
|
|
4806
|
+
},
|
|
4807
|
+
{
|
|
4808
|
+
name: "system_program",
|
|
4809
|
+
address: "11111111111111111111111111111111"
|
|
4810
|
+
},
|
|
4811
|
+
{
|
|
4812
|
+
name: "event_authority",
|
|
4813
|
+
pda: {
|
|
4814
|
+
seeds: [
|
|
4815
|
+
{
|
|
4816
|
+
kind: "const",
|
|
4817
|
+
value: [
|
|
4818
|
+
95,
|
|
4819
|
+
95,
|
|
4820
|
+
101,
|
|
4821
|
+
118,
|
|
4822
|
+
101,
|
|
4823
|
+
110,
|
|
4824
|
+
116,
|
|
4825
|
+
95,
|
|
4826
|
+
97,
|
|
4827
|
+
117,
|
|
4828
|
+
116,
|
|
4829
|
+
104,
|
|
4830
|
+
111,
|
|
4831
|
+
114,
|
|
4832
|
+
105,
|
|
4833
|
+
116,
|
|
4834
|
+
121
|
|
4835
|
+
]
|
|
4836
|
+
}
|
|
4837
|
+
]
|
|
4838
|
+
}
|
|
4839
|
+
},
|
|
4840
|
+
{
|
|
4841
|
+
name: "program"
|
|
3920
4842
|
}
|
|
3921
|
-
]
|
|
4843
|
+
],
|
|
4844
|
+
args: []
|
|
3922
4845
|
},
|
|
3923
4846
|
{
|
|
3924
|
-
name: "
|
|
4847
|
+
name: "claim_partner_pool_creation_fee",
|
|
3925
4848
|
discriminator: [
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
4849
|
+
250,
|
|
4850
|
+
238,
|
|
4851
|
+
26,
|
|
4852
|
+
4,
|
|
4853
|
+
139,
|
|
4854
|
+
10,
|
|
4855
|
+
101,
|
|
4856
|
+
248
|
|
3934
4857
|
],
|
|
3935
4858
|
accounts: [
|
|
3936
4859
|
{
|
|
3937
|
-
name: "
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
{
|
|
3941
|
-
name: "claim_fee_operator",
|
|
3942
|
-
docs: [
|
|
3943
|
-
"Claim fee operator"
|
|
4860
|
+
name: "config",
|
|
4861
|
+
relations: [
|
|
4862
|
+
"pool"
|
|
3944
4863
|
]
|
|
3945
4864
|
},
|
|
3946
4865
|
{
|
|
3947
|
-
name: "
|
|
3948
|
-
|
|
3949
|
-
"Operator"
|
|
3950
|
-
],
|
|
3951
|
-
signer: true,
|
|
3952
|
-
relations: [
|
|
3953
|
-
"claim_fee_operator"
|
|
3954
|
-
]
|
|
4866
|
+
name: "pool",
|
|
4867
|
+
writable: true
|
|
3955
4868
|
},
|
|
3956
4869
|
{
|
|
3957
|
-
name: "
|
|
3958
|
-
|
|
3959
|
-
address: "4EWqcx3aNZmMetCnxwLYwyNjan6XLGp3Ca2W316vrSjv"
|
|
4870
|
+
name: "fee_claimer",
|
|
4871
|
+
signer: true
|
|
3960
4872
|
},
|
|
3961
4873
|
{
|
|
3962
|
-
name: "
|
|
3963
|
-
|
|
4874
|
+
name: "fee_receiver",
|
|
4875
|
+
writable: true
|
|
3964
4876
|
},
|
|
3965
4877
|
{
|
|
3966
4878
|
name: "event_authority",
|
|
@@ -4255,14 +5167,11 @@ var idl_default = {
|
|
|
4255
5167
|
]
|
|
4256
5168
|
},
|
|
4257
5169
|
{
|
|
4258
|
-
name: "
|
|
5170
|
+
name: "signer",
|
|
4259
5171
|
docs: [
|
|
4260
|
-
"
|
|
5172
|
+
"Signer"
|
|
4261
5173
|
],
|
|
4262
|
-
signer: true
|
|
4263
|
-
relations: [
|
|
4264
|
-
"claim_fee_operator"
|
|
4265
|
-
]
|
|
5174
|
+
signer: true
|
|
4266
5175
|
},
|
|
4267
5176
|
{
|
|
4268
5177
|
name: "token_base_program",
|
|
@@ -4311,6 +5220,82 @@ var idl_default = {
|
|
|
4311
5220
|
],
|
|
4312
5221
|
args: []
|
|
4313
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
|
+
},
|
|
4314
5299
|
{
|
|
4315
5300
|
name: "claim_trading_fee",
|
|
4316
5301
|
discriminator: [
|
|
@@ -4392,10 +5377,7 @@ var idl_default = {
|
|
|
4392
5377
|
},
|
|
4393
5378
|
{
|
|
4394
5379
|
name: "fee_claimer",
|
|
4395
|
-
signer: true
|
|
4396
|
-
relations: [
|
|
4397
|
-
"config"
|
|
4398
|
-
]
|
|
5380
|
+
signer: true
|
|
4399
5381
|
},
|
|
4400
5382
|
{
|
|
4401
5383
|
name: "token_base_program",
|
|
@@ -4454,16 +5436,16 @@ var idl_default = {
|
|
|
4454
5436
|
]
|
|
4455
5437
|
},
|
|
4456
5438
|
{
|
|
4457
|
-
name: "
|
|
5439
|
+
name: "close_claim_protocol_fee_operator",
|
|
4458
5440
|
discriminator: [
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
5441
|
+
8,
|
|
5442
|
+
41,
|
|
5443
|
+
87,
|
|
5444
|
+
35,
|
|
5445
|
+
80,
|
|
5446
|
+
48,
|
|
5447
|
+
121,
|
|
5448
|
+
26
|
|
4467
5449
|
],
|
|
4468
5450
|
accounts: [
|
|
4469
5451
|
{
|
|
@@ -4475,7 +5457,7 @@ var idl_default = {
|
|
|
4475
5457
|
writable: true
|
|
4476
5458
|
},
|
|
4477
5459
|
{
|
|
4478
|
-
name: "
|
|
5460
|
+
name: "signer",
|
|
4479
5461
|
signer: true
|
|
4480
5462
|
},
|
|
4481
5463
|
{
|
|
@@ -4514,19 +5496,16 @@ var idl_default = {
|
|
|
4514
5496
|
args: []
|
|
4515
5497
|
},
|
|
4516
5498
|
{
|
|
4517
|
-
name: "
|
|
4518
|
-
docs: [
|
|
4519
|
-
"ADMIN FUNCTIONS_ ///"
|
|
4520
|
-
],
|
|
5499
|
+
name: "create_claim_protocol_fee_operator",
|
|
4521
5500
|
discriminator: [
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
5501
|
+
51,
|
|
5502
|
+
19,
|
|
5503
|
+
150,
|
|
5504
|
+
252,
|
|
5505
|
+
105,
|
|
5506
|
+
157,
|
|
5507
|
+
48,
|
|
5508
|
+
91
|
|
4530
5509
|
],
|
|
4531
5510
|
accounts: [
|
|
4532
5511
|
{
|
|
@@ -4561,7 +5540,11 @@ var idl_default = {
|
|
|
4561
5540
|
name: "operator"
|
|
4562
5541
|
},
|
|
4563
5542
|
{
|
|
4564
|
-
name: "
|
|
5543
|
+
name: "signer",
|
|
5544
|
+
signer: true
|
|
5545
|
+
},
|
|
5546
|
+
{
|
|
5547
|
+
name: "payer",
|
|
4565
5548
|
writable: true,
|
|
4566
5549
|
signer: true
|
|
4567
5550
|
},
|
|
@@ -4984,10 +5967,7 @@ var idl_default = {
|
|
|
4984
5967
|
},
|
|
4985
5968
|
{
|
|
4986
5969
|
name: "creator",
|
|
4987
|
-
signer: true
|
|
4988
|
-
relations: [
|
|
4989
|
-
"virtual_pool"
|
|
4990
|
-
]
|
|
5970
|
+
signer: true
|
|
4991
5971
|
},
|
|
4992
5972
|
{
|
|
4993
5973
|
name: "payer",
|
|
@@ -5103,10 +6083,7 @@ var idl_default = {
|
|
|
5103
6083
|
},
|
|
5104
6084
|
{
|
|
5105
6085
|
name: "creator",
|
|
5106
|
-
signer: true
|
|
5107
|
-
relations: [
|
|
5108
|
-
"virtual_pool"
|
|
5109
|
-
]
|
|
6086
|
+
signer: true
|
|
5110
6087
|
},
|
|
5111
6088
|
{
|
|
5112
6089
|
name: "token_quote_program",
|
|
@@ -6141,7 +7118,8 @@ var idl_default = {
|
|
|
6141
7118
|
},
|
|
6142
7119
|
{
|
|
6143
7120
|
name: "first_position_nft_mint",
|
|
6144
|
-
writable: true
|
|
7121
|
+
writable: true,
|
|
7122
|
+
signer: true
|
|
6145
7123
|
},
|
|
6146
7124
|
{
|
|
6147
7125
|
name: "first_position_nft_account",
|
|
@@ -6154,6 +7132,7 @@ var idl_default = {
|
|
|
6154
7132
|
{
|
|
6155
7133
|
name: "second_position_nft_mint",
|
|
6156
7134
|
writable: true,
|
|
7135
|
+
signer: true,
|
|
6157
7136
|
optional: true
|
|
6158
7137
|
},
|
|
6159
7138
|
{
|
|
@@ -6441,10 +7420,7 @@ var idl_default = {
|
|
|
6441
7420
|
},
|
|
6442
7421
|
{
|
|
6443
7422
|
name: "fee_claimer",
|
|
6444
|
-
signer: true
|
|
6445
|
-
relations: [
|
|
6446
|
-
"config"
|
|
6447
|
-
]
|
|
7423
|
+
signer: true
|
|
6448
7424
|
},
|
|
6449
7425
|
{
|
|
6450
7426
|
name: "token_quote_program",
|
|
@@ -6626,6 +7602,19 @@ var idl_default = {
|
|
|
6626
7602
|
"config"
|
|
6627
7603
|
]
|
|
6628
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
|
+
},
|
|
6629
7618
|
{
|
|
6630
7619
|
name: "token_quote_program",
|
|
6631
7620
|
docs: [
|
|
@@ -6995,10 +7984,7 @@ var idl_default = {
|
|
|
6995
7984
|
},
|
|
6996
7985
|
{
|
|
6997
7986
|
name: "creator",
|
|
6998
|
-
signer: true
|
|
6999
|
-
relations: [
|
|
7000
|
-
"virtual_pool"
|
|
7001
|
-
]
|
|
7987
|
+
signer: true
|
|
7002
7988
|
},
|
|
7003
7989
|
{
|
|
7004
7990
|
name: "new_creator"
|
|
@@ -7019,51 +8005,21 @@ var idl_default = {
|
|
|
7019
8005
|
116,
|
|
7020
8006
|
95,
|
|
7021
8007
|
97,
|
|
7022
|
-
117,
|
|
7023
|
-
116,
|
|
7024
|
-
104,
|
|
7025
|
-
111,
|
|
7026
|
-
114,
|
|
7027
|
-
105,
|
|
7028
|
-
116,
|
|
7029
|
-
121
|
|
7030
|
-
]
|
|
7031
|
-
}
|
|
7032
|
-
]
|
|
7033
|
-
}
|
|
7034
|
-
},
|
|
7035
|
-
{
|
|
7036
|
-
name: "program"
|
|
7037
|
-
}
|
|
7038
|
-
],
|
|
7039
|
-
args: []
|
|
7040
|
-
},
|
|
7041
|
-
{
|
|
7042
|
-
name: "withdraw_lamports_from_pool_authority",
|
|
7043
|
-
discriminator: [
|
|
7044
|
-
20,
|
|
7045
|
-
185,
|
|
7046
|
-
242,
|
|
7047
|
-
240,
|
|
7048
|
-
129,
|
|
7049
|
-
24,
|
|
7050
|
-
212,
|
|
7051
|
-
194
|
|
7052
|
-
],
|
|
7053
|
-
accounts: [
|
|
7054
|
-
{
|
|
7055
|
-
name: "pool_authority",
|
|
7056
|
-
writable: true,
|
|
7057
|
-
address: "FhVo3mqL8PW5pH5U2CN4XE33DokiyZnUwuGpH2hmHLuM"
|
|
7058
|
-
},
|
|
7059
|
-
{
|
|
7060
|
-
name: "receiver",
|
|
7061
|
-
writable: true,
|
|
7062
|
-
address: "4EWqcx3aNZmMetCnxwLYwyNjan6XLGp3Ca2W316vrSjv"
|
|
8008
|
+
117,
|
|
8009
|
+
116,
|
|
8010
|
+
104,
|
|
8011
|
+
111,
|
|
8012
|
+
114,
|
|
8013
|
+
105,
|
|
8014
|
+
116,
|
|
8015
|
+
121
|
|
8016
|
+
]
|
|
8017
|
+
}
|
|
8018
|
+
]
|
|
8019
|
+
}
|
|
7063
8020
|
},
|
|
7064
8021
|
{
|
|
7065
|
-
name: "
|
|
7066
|
-
address: "11111111111111111111111111111111"
|
|
8022
|
+
name: "program"
|
|
7067
8023
|
}
|
|
7068
8024
|
],
|
|
7069
8025
|
args: []
|
|
@@ -7591,6 +8547,19 @@ var idl_default = {
|
|
|
7591
8547
|
37
|
|
7592
8548
|
]
|
|
7593
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
|
+
},
|
|
7594
8563
|
{
|
|
7595
8564
|
name: "EvtPartnerMetadata",
|
|
7596
8565
|
discriminator: [
|
|
@@ -7977,6 +8946,31 @@ var idl_default = {
|
|
|
7977
8946
|
code: 6050,
|
|
7978
8947
|
name: "AccountInvariantViolation",
|
|
7979
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"
|
|
7980
8974
|
}
|
|
7981
8975
|
],
|
|
7982
8976
|
types: [
|
|
@@ -8162,19 +9156,19 @@ var idl_default = {
|
|
|
8162
9156
|
type: "u8"
|
|
8163
9157
|
},
|
|
8164
9158
|
{
|
|
8165
|
-
name: "
|
|
9159
|
+
name: "partner_liquidity_percentage",
|
|
8166
9160
|
type: "u8"
|
|
8167
9161
|
},
|
|
8168
9162
|
{
|
|
8169
|
-
name: "
|
|
9163
|
+
name: "partner_permanent_locked_liquidity_percentage",
|
|
8170
9164
|
type: "u8"
|
|
8171
9165
|
},
|
|
8172
9166
|
{
|
|
8173
|
-
name: "
|
|
9167
|
+
name: "creator_liquidity_percentage",
|
|
8174
9168
|
type: "u8"
|
|
8175
9169
|
},
|
|
8176
9170
|
{
|
|
8177
|
-
name: "
|
|
9171
|
+
name: "creator_permanent_locked_liquidity_percentage",
|
|
8178
9172
|
type: "u8"
|
|
8179
9173
|
},
|
|
8180
9174
|
{
|
|
@@ -8231,6 +9225,29 @@ var idl_default = {
|
|
|
8231
9225
|
}
|
|
8232
9226
|
}
|
|
8233
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
|
+
},
|
|
8234
9251
|
{
|
|
8235
9252
|
name: "padding",
|
|
8236
9253
|
docs: [
|
|
@@ -8238,8 +9255,8 @@ var idl_default = {
|
|
|
8238
9255
|
],
|
|
8239
9256
|
type: {
|
|
8240
9257
|
array: [
|
|
8241
|
-
"
|
|
8242
|
-
|
|
9258
|
+
"u8",
|
|
9259
|
+
22
|
|
8243
9260
|
]
|
|
8244
9261
|
}
|
|
8245
9262
|
},
|
|
@@ -8442,7 +9459,7 @@ var idl_default = {
|
|
|
8442
9459
|
type: "pubkey"
|
|
8443
9460
|
},
|
|
8444
9461
|
{
|
|
8445
|
-
name: "
|
|
9462
|
+
name: "receiver",
|
|
8446
9463
|
type: "pubkey"
|
|
8447
9464
|
},
|
|
8448
9465
|
{
|
|
@@ -8579,19 +9596,19 @@ var idl_default = {
|
|
|
8579
9596
|
type: "u8"
|
|
8580
9597
|
},
|
|
8581
9598
|
{
|
|
8582
|
-
name: "
|
|
9599
|
+
name: "partner_permanent_locked_liquidity_percentage",
|
|
8583
9600
|
type: "u8"
|
|
8584
9601
|
},
|
|
8585
9602
|
{
|
|
8586
|
-
name: "
|
|
9603
|
+
name: "partner_liquidity_percentage",
|
|
8587
9604
|
type: "u8"
|
|
8588
9605
|
},
|
|
8589
9606
|
{
|
|
8590
|
-
name: "
|
|
9607
|
+
name: "creator_permanent_locked_liquidity_percentage",
|
|
8591
9608
|
type: "u8"
|
|
8592
9609
|
},
|
|
8593
9610
|
{
|
|
8594
|
-
name: "
|
|
9611
|
+
name: "creator_liquidity_percentage",
|
|
8595
9612
|
type: "u8"
|
|
8596
9613
|
},
|
|
8597
9614
|
{
|
|
@@ -8763,6 +9780,26 @@ var idl_default = {
|
|
|
8763
9780
|
]
|
|
8764
9781
|
}
|
|
8765
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
|
+
},
|
|
8766
9803
|
{
|
|
8767
9804
|
name: "EvtPartnerMetadata",
|
|
8768
9805
|
docs: [
|
|
@@ -9065,6 +10102,79 @@ var idl_default = {
|
|
|
9065
10102
|
]
|
|
9066
10103
|
}
|
|
9067
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
|
+
},
|
|
9068
10178
|
{
|
|
9069
10179
|
name: "LockEscrow",
|
|
9070
10180
|
docs: [
|
|
@@ -9195,7 +10305,7 @@ var idl_default = {
|
|
|
9195
10305
|
{
|
|
9196
10306
|
name: "padding_0",
|
|
9197
10307
|
docs: [
|
|
9198
|
-
"!!! BE CAREFUL to use
|
|
10308
|
+
"!!! BE CAREFUL to use tombstone field, previous is pool creator"
|
|
9199
10309
|
],
|
|
9200
10310
|
type: {
|
|
9201
10311
|
array: [
|
|
@@ -9219,30 +10329,30 @@ var idl_default = {
|
|
|
9219
10329
|
type: "pubkey"
|
|
9220
10330
|
},
|
|
9221
10331
|
{
|
|
9222
|
-
name: "
|
|
10332
|
+
name: "partner_locked_liquidity",
|
|
9223
10333
|
docs: [
|
|
9224
|
-
"partner locked
|
|
10334
|
+
"partner locked liquidity"
|
|
9225
10335
|
],
|
|
9226
10336
|
type: "u64"
|
|
9227
10337
|
},
|
|
9228
10338
|
{
|
|
9229
|
-
name: "
|
|
10339
|
+
name: "partner_liquidity",
|
|
9230
10340
|
docs: [
|
|
9231
|
-
"partner
|
|
10341
|
+
"partner liquidity"
|
|
9232
10342
|
],
|
|
9233
10343
|
type: "u64"
|
|
9234
10344
|
},
|
|
9235
10345
|
{
|
|
9236
|
-
name: "
|
|
10346
|
+
name: "creator_locked_liquidity",
|
|
9237
10347
|
docs: [
|
|
9238
|
-
"creator locked
|
|
10348
|
+
"creator locked liquidity"
|
|
9239
10349
|
],
|
|
9240
10350
|
type: "u64"
|
|
9241
10351
|
},
|
|
9242
10352
|
{
|
|
9243
|
-
name: "
|
|
10353
|
+
name: "creator_liquidity",
|
|
9244
10354
|
docs: [
|
|
9245
|
-
"creator
|
|
10355
|
+
"creator liquidity"
|
|
9246
10356
|
],
|
|
9247
10357
|
type: "u64"
|
|
9248
10358
|
},
|
|
@@ -9256,28 +10366,28 @@ var idl_default = {
|
|
|
9256
10366
|
{
|
|
9257
10367
|
name: "creator_locked_status",
|
|
9258
10368
|
docs: [
|
|
9259
|
-
"flag to check whether
|
|
10369
|
+
"flag to check whether liquidity token is locked for creator"
|
|
9260
10370
|
],
|
|
9261
10371
|
type: "u8"
|
|
9262
10372
|
},
|
|
9263
10373
|
{
|
|
9264
10374
|
name: "partner_locked_status",
|
|
9265
10375
|
docs: [
|
|
9266
|
-
"flag to check whether
|
|
10376
|
+
"flag to check whether liquidity token is locked for partner"
|
|
9267
10377
|
],
|
|
9268
10378
|
type: "u8"
|
|
9269
10379
|
},
|
|
9270
10380
|
{
|
|
9271
10381
|
name: "creator_claim_status",
|
|
9272
10382
|
docs: [
|
|
9273
|
-
"flag to check whether creator has claimed
|
|
10383
|
+
"flag to check whether creator has claimed liquidity token"
|
|
9274
10384
|
],
|
|
9275
10385
|
type: "u8"
|
|
9276
10386
|
},
|
|
9277
10387
|
{
|
|
9278
10388
|
name: "partner_claim_status",
|
|
9279
10389
|
docs: [
|
|
9280
|
-
"flag to check whether partner has claimed
|
|
10390
|
+
"flag to check whether partner has claimed liquidity token"
|
|
9281
10391
|
],
|
|
9282
10392
|
type: "u8"
|
|
9283
10393
|
},
|
|
@@ -9424,6 +10534,41 @@ var idl_default = {
|
|
|
9424
10534
|
}
|
|
9425
10535
|
}
|
|
9426
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
|
+
},
|
|
9427
10572
|
{
|
|
9428
10573
|
name: "collect_fee_mode",
|
|
9429
10574
|
docs: [
|
|
@@ -9474,30 +10619,30 @@ var idl_default = {
|
|
|
9474
10619
|
type: "u8"
|
|
9475
10620
|
},
|
|
9476
10621
|
{
|
|
9477
|
-
name: "
|
|
10622
|
+
name: "partner_permanent_locked_liquidity_percentage",
|
|
9478
10623
|
docs: [
|
|
9479
|
-
"partner locked
|
|
10624
|
+
"partner locked liquidity percentage"
|
|
9480
10625
|
],
|
|
9481
10626
|
type: "u8"
|
|
9482
10627
|
},
|
|
9483
10628
|
{
|
|
9484
|
-
name: "
|
|
10629
|
+
name: "partner_liquidity_percentage",
|
|
9485
10630
|
docs: [
|
|
9486
|
-
"partner
|
|
10631
|
+
"partner liquidity percentage"
|
|
9487
10632
|
],
|
|
9488
10633
|
type: "u8"
|
|
9489
10634
|
},
|
|
9490
10635
|
{
|
|
9491
|
-
name: "
|
|
10636
|
+
name: "creator_permanent_locked_liquidity_percentage",
|
|
9492
10637
|
docs: [
|
|
9493
10638
|
"creator post migration fee percentage"
|
|
9494
10639
|
],
|
|
9495
10640
|
type: "u8"
|
|
9496
10641
|
},
|
|
9497
10642
|
{
|
|
9498
|
-
name: "
|
|
10643
|
+
name: "creator_liquidity_percentage",
|
|
9499
10644
|
docs: [
|
|
9500
|
-
"creator
|
|
10645
|
+
"creator liquidity percentage"
|
|
9501
10646
|
],
|
|
9502
10647
|
type: "u8"
|
|
9503
10648
|
},
|
|
@@ -9544,10 +10689,7 @@ var idl_default = {
|
|
|
9544
10689
|
type: "u8"
|
|
9545
10690
|
},
|
|
9546
10691
|
{
|
|
9547
|
-
name: "
|
|
9548
|
-
docs: [
|
|
9549
|
-
"padding 0"
|
|
9550
|
-
],
|
|
10692
|
+
name: "padding_2",
|
|
9551
10693
|
type: {
|
|
9552
10694
|
array: [
|
|
9553
10695
|
"u8",
|
|
@@ -9637,10 +10779,17 @@ var idl_default = {
|
|
|
9637
10779
|
type: {
|
|
9638
10780
|
array: [
|
|
9639
10781
|
"u8",
|
|
9640
|
-
|
|
10782
|
+
4
|
|
9641
10783
|
]
|
|
9642
10784
|
}
|
|
9643
10785
|
},
|
|
10786
|
+
{
|
|
10787
|
+
name: "pool_creation_fee",
|
|
10788
|
+
docs: [
|
|
10789
|
+
"pool creation fee in lamports value"
|
|
10790
|
+
],
|
|
10791
|
+
type: "u64"
|
|
10792
|
+
},
|
|
9644
10793
|
{
|
|
9645
10794
|
name: "_padding_2",
|
|
9646
10795
|
docs: [
|
|
@@ -9760,32 +10909,6 @@ var idl_default = {
|
|
|
9760
10909
|
name: "DynamicFeeConfig"
|
|
9761
10910
|
}
|
|
9762
10911
|
}
|
|
9763
|
-
},
|
|
9764
|
-
{
|
|
9765
|
-
name: "padding_0",
|
|
9766
|
-
type: {
|
|
9767
|
-
array: [
|
|
9768
|
-
"u64",
|
|
9769
|
-
5
|
|
9770
|
-
]
|
|
9771
|
-
}
|
|
9772
|
-
},
|
|
9773
|
-
{
|
|
9774
|
-
name: "padding_1",
|
|
9775
|
-
type: {
|
|
9776
|
-
array: [
|
|
9777
|
-
"u8",
|
|
9778
|
-
6
|
|
9779
|
-
]
|
|
9780
|
-
}
|
|
9781
|
-
},
|
|
9782
|
-
{
|
|
9783
|
-
name: "protocol_fee_percent",
|
|
9784
|
-
type: "u8"
|
|
9785
|
-
},
|
|
9786
|
-
{
|
|
9787
|
-
name: "referral_fee_percent",
|
|
9788
|
-
type: "u8"
|
|
9789
10912
|
}
|
|
9790
10913
|
]
|
|
9791
10914
|
}
|
|
@@ -10161,16 +11284,29 @@ var idl_default = {
|
|
|
10161
11284
|
],
|
|
10162
11285
|
type: "u64"
|
|
10163
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
|
+
},
|
|
10164
11294
|
{
|
|
10165
11295
|
name: "creation_fee_bits",
|
|
11296
|
+
docs: [
|
|
11297
|
+
"pool creation fee claim status"
|
|
11298
|
+
],
|
|
10166
11299
|
type: "u8"
|
|
10167
11300
|
},
|
|
10168
11301
|
{
|
|
10169
11302
|
name: "_padding_0",
|
|
11303
|
+
docs: [
|
|
11304
|
+
"Padding for further use"
|
|
11305
|
+
],
|
|
10170
11306
|
type: {
|
|
10171
11307
|
array: [
|
|
10172
11308
|
"u8",
|
|
10173
|
-
|
|
11309
|
+
6
|
|
10174
11310
|
]
|
|
10175
11311
|
}
|
|
10176
11312
|
},
|
|
@@ -24456,6 +25592,25 @@ var MigrationService = class extends DynamicBondingCurveProgram {
|
|
|
24456
25592
|
);
|
|
24457
25593
|
const tokenBaseProgram = poolConfigState.tokenType == 0 ? TOKEN_PROGRAM_ID3 : TOKEN_2022_PROGRAM_ID2;
|
|
24458
25594
|
const tokenQuoteProgram = poolConfigState.quoteTokenFlag == 0 ? TOKEN_PROGRAM_ID3 : TOKEN_2022_PROGRAM_ID2;
|
|
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
|
+
];
|
|
24459
25614
|
const tx = await this.program.methods.migrationDammV2().accountsStrict({
|
|
24460
25615
|
virtualPool,
|
|
24461
25616
|
migrationMetadata,
|
|
@@ -24482,15 +25637,9 @@ var MigrationService = class extends DynamicBondingCurveProgram {
|
|
|
24482
25637
|
token2022Program: TOKEN_2022_PROGRAM_ID2,
|
|
24483
25638
|
systemProgram: SystemProgram3.programId,
|
|
24484
25639
|
dammEventAuthority
|
|
24485
|
-
}).remainingAccounts(
|
|
24486
|
-
{
|
|
24487
|
-
isSigner: false,
|
|
24488
|
-
isWritable: false,
|
|
24489
|
-
pubkey: dammConfig
|
|
24490
|
-
}
|
|
24491
|
-
]).transaction();
|
|
25640
|
+
}).remainingAccounts(remainingAccounts).transaction();
|
|
24492
25641
|
const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
|
|
24493
|
-
units:
|
|
25642
|
+
units: 6e5
|
|
24494
25643
|
});
|
|
24495
25644
|
tx.add(modifyComputeUnits);
|
|
24496
25645
|
return {
|
|
@@ -24941,6 +26090,33 @@ var PartnerService = class extends DynamicBondingCurveProgram {
|
|
|
24941
26090
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
24942
26091
|
return transaction;
|
|
24943
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
|
+
}
|
|
24944
26120
|
};
|
|
24945
26121
|
|
|
24946
26122
|
// src/services/pool.ts
|
|
@@ -26282,7 +27458,6 @@ var DynamicBondingCurveClient = class _DynamicBondingCurveClient {
|
|
|
26282
27458
|
export {
|
|
26283
27459
|
ActivationType,
|
|
26284
27460
|
BASE_ADDRESS,
|
|
26285
|
-
BASIS_POINT_MAX,
|
|
26286
27461
|
BIN_STEP_BPS_DEFAULT,
|
|
26287
27462
|
BIN_STEP_BPS_U128_DEFAULT,
|
|
26288
27463
|
BaseFeeMode,
|
|
@@ -26292,6 +27467,7 @@ export {
|
|
|
26292
27467
|
DAMM_V1_PROGRAM_ID,
|
|
26293
27468
|
DAMM_V2_MIGRATION_FEE_ADDRESS,
|
|
26294
27469
|
DAMM_V2_PROGRAM_ID,
|
|
27470
|
+
DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS,
|
|
26295
27471
|
DYNAMIC_BONDING_CURVE_PROGRAM_ID,
|
|
26296
27472
|
DYNAMIC_FEE_DECAY_PERIOD_DEFAULT,
|
|
26297
27473
|
DYNAMIC_FEE_FILTER_PERIOD_DEFAULT,
|
|
@@ -26305,39 +27481,44 @@ export {
|
|
|
26305
27481
|
FEE_DENOMINATOR,
|
|
26306
27482
|
FeeRateLimiter,
|
|
26307
27483
|
FeeScheduler,
|
|
27484
|
+
HOST_FEE_PERCENT,
|
|
26308
27485
|
LOCKER_PROGRAM_ID,
|
|
27486
|
+
MAX_BASIS_POINT,
|
|
26309
27487
|
MAX_CREATOR_MIGRATION_FEE_PERCENTAGE,
|
|
26310
27488
|
MAX_CURVE_POINT,
|
|
26311
|
-
MAX_DYNAMIC_FEE_PERCENTAGE,
|
|
26312
27489
|
MAX_FEE_BPS,
|
|
26313
27490
|
MAX_FEE_NUMERATOR,
|
|
27491
|
+
MAX_LOCK_DURATION_IN_SECONDS,
|
|
26314
27492
|
MAX_MIGRATED_POOL_FEE_BPS,
|
|
26315
27493
|
MAX_MIGRATION_FEE_PERCENTAGE,
|
|
26316
|
-
|
|
27494
|
+
MAX_POOL_CREATION_FEE,
|
|
27495
|
+
MAX_PRICE_CHANGE_PERCENTAGE_DEFAULT,
|
|
26317
27496
|
MAX_RATE_LIMITER_DURATION_IN_SECONDS,
|
|
26318
27497
|
MAX_RATE_LIMITER_DURATION_IN_SLOTS,
|
|
26319
27498
|
MAX_SQRT_PRICE,
|
|
26320
27499
|
METAPLEX_PROGRAM_ID,
|
|
26321
27500
|
MIN_FEE_BPS,
|
|
26322
27501
|
MIN_FEE_NUMERATOR,
|
|
27502
|
+
MIN_LOCKED_LIQUIDITY_BPS,
|
|
26323
27503
|
MIN_MIGRATED_POOL_FEE_BPS,
|
|
27504
|
+
MIN_POOL_CREATION_FEE,
|
|
26324
27505
|
MIN_SQRT_PRICE,
|
|
26325
27506
|
MigrationFeeOption,
|
|
26326
27507
|
MigrationOption,
|
|
26327
27508
|
MigrationService,
|
|
26328
27509
|
OFFSET,
|
|
26329
27510
|
ONE_Q64,
|
|
26330
|
-
|
|
27511
|
+
PROTOCOL_FEE_PERCENT,
|
|
27512
|
+
PROTOCOL_POOL_CREATION_FEE_PERCENT,
|
|
26331
27513
|
PartnerService,
|
|
26332
27514
|
PoolService,
|
|
26333
27515
|
RESOLUTION,
|
|
26334
27516
|
Rounding,
|
|
26335
|
-
|
|
27517
|
+
SECONDS_PER_DAY,
|
|
26336
27518
|
SWAP_BUFFER_PERCENTAGE,
|
|
26337
27519
|
SafeMath,
|
|
26338
27520
|
StateService,
|
|
26339
27521
|
SwapMode,
|
|
26340
|
-
TIMESTAMP_DURATION,
|
|
26341
27522
|
TokenDecimal,
|
|
26342
27523
|
TokenType,
|
|
26343
27524
|
TokenUpdateAuthorityOption,
|
|
@@ -26348,12 +27529,16 @@ export {
|
|
|
26348
27529
|
VAULT_PROGRAM_ID,
|
|
26349
27530
|
bpsToFeeNumerator,
|
|
26350
27531
|
buildCurve,
|
|
27532
|
+
buildCurveWithCustomSqrtPrices,
|
|
26351
27533
|
buildCurveWithLiquidityWeights,
|
|
26352
27534
|
buildCurveWithMarketCap,
|
|
27535
|
+
buildCurveWithMidPrice,
|
|
26353
27536
|
buildCurveWithTwoSegments,
|
|
27537
|
+
calculateAdjustedPercentageSupplyOnMigration,
|
|
26354
27538
|
calculateBaseToQuoteFromAmountIn,
|
|
26355
27539
|
calculateBaseToQuoteFromAmountOut,
|
|
26356
27540
|
calculateFeeSchedulerEndingBaseFeeBps,
|
|
27541
|
+
calculateLockedLiquidityBpsAtTime,
|
|
26357
27542
|
calculateQuoteToBaseFromAmountIn,
|
|
26358
27543
|
calculateQuoteToBaseFromAmountOut,
|
|
26359
27544
|
checkRateLimiterApplied,
|
|
@@ -26366,6 +27551,7 @@ export {
|
|
|
26366
27551
|
createInitializePermissionlessDynamicVaultIx,
|
|
26367
27552
|
createLockEscrowIx,
|
|
26368
27553
|
createProgramAccountFilter,
|
|
27554
|
+
createSqrtPrices,
|
|
26369
27555
|
createVaultProgram,
|
|
26370
27556
|
deriveBaseKeyForLocker,
|
|
26371
27557
|
deriveDammV1EventAuthority,
|
|
@@ -26381,6 +27567,7 @@ export {
|
|
|
26381
27567
|
deriveDammV2MigrationMetadataAddress,
|
|
26382
27568
|
deriveDammV2PoolAddress,
|
|
26383
27569
|
deriveDammV2PoolAuthority,
|
|
27570
|
+
deriveDammV2PositionVestingAccount,
|
|
26384
27571
|
deriveDammV2TokenVaultAddress,
|
|
26385
27572
|
deriveDbcEventAuthority,
|
|
26386
27573
|
deriveDbcPoolAddress,
|
|
@@ -26410,6 +27597,7 @@ export {
|
|
|
26410
27597
|
getBaseTokenForSwap,
|
|
26411
27598
|
getCheckedAmounts,
|
|
26412
27599
|
getCurrentPoint,
|
|
27600
|
+
getCurveBreakdown,
|
|
26413
27601
|
getDeltaAmountBaseUnsigned,
|
|
26414
27602
|
getDeltaAmountBaseUnsigned256,
|
|
26415
27603
|
getDeltaAmountBaseUnsignedUnchecked,
|
|
@@ -26431,6 +27619,7 @@ export {
|
|
|
26431
27619
|
getInitialLiquidityFromDeltaBase,
|
|
26432
27620
|
getInitialLiquidityFromDeltaQuote,
|
|
26433
27621
|
getLiquidity,
|
|
27622
|
+
getLiquidityVestingInfoParams,
|
|
26434
27623
|
getLockedVestingParams,
|
|
26435
27624
|
getMaxBaseFeeNumerator,
|
|
26436
27625
|
getMaxIndex,
|
|
@@ -26474,6 +27663,7 @@ export {
|
|
|
26474
27663
|
getTotalVestingAmount,
|
|
26475
27664
|
getTwoCurve,
|
|
26476
27665
|
getVariableFeeNumerator,
|
|
27666
|
+
getVestingLockedLiquidityBpsAtNSeconds,
|
|
26477
27667
|
isDefaultLockedVesting,
|
|
26478
27668
|
isDynamicFeeEnabled,
|
|
26479
27669
|
isNativeSol,
|
|
@@ -26502,10 +27692,13 @@ export {
|
|
|
26502
27692
|
validateFeeRateLimiter,
|
|
26503
27693
|
validateFeeScheduler,
|
|
26504
27694
|
validateLPPercentages,
|
|
27695
|
+
validateLiquidityVestingInfo,
|
|
26505
27696
|
validateMigratedPoolFee,
|
|
26506
27697
|
validateMigrationAndTokenType,
|
|
26507
27698
|
validateMigrationFee,
|
|
26508
27699
|
validateMigrationFeeOption,
|
|
27700
|
+
validateMinimumLockedLiquidity,
|
|
27701
|
+
validatePoolCreationFee,
|
|
26509
27702
|
validatePoolFees,
|
|
26510
27703
|
validateSwapAmount,
|
|
26511
27704
|
validateTokenDecimals,
|