@meteora-ag/dynamic-bonding-curve-sdk 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +46 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21264,6 +21264,39 @@ async function swapQuote(virtualPool, config, swapBaseForQuote, amountIn, slippa
|
|
|
21264
21264
|
}
|
|
21265
21265
|
return result;
|
|
21266
21266
|
}
|
|
21267
|
+
function calculateQuoteExactInAmount(config, virtualPool, currentPoint) {
|
|
21268
|
+
if (virtualPool.quoteReserve.gte(config.migrationQuoteThreshold)) {
|
|
21269
|
+
return new (0, _bnjs2.default)(0);
|
|
21270
|
+
}
|
|
21271
|
+
const amountInAfterFee = config.migrationQuoteThreshold.sub(
|
|
21272
|
+
virtualPool.quoteReserve
|
|
21273
|
+
);
|
|
21274
|
+
if (config.collectFeeMode === 0 /* OnlyQuote */) {
|
|
21275
|
+
const baseFeeNumerator = getCurrentBaseFeeNumerator(
|
|
21276
|
+
config.poolFees.baseFee,
|
|
21277
|
+
currentPoint,
|
|
21278
|
+
virtualPool.activationPoint
|
|
21279
|
+
);
|
|
21280
|
+
let totalFeeNumerator = baseFeeNumerator;
|
|
21281
|
+
if (config.poolFees.dynamicFee.initialized !== 0) {
|
|
21282
|
+
const variableFee = getVariableFee(
|
|
21283
|
+
config.poolFees.dynamicFee,
|
|
21284
|
+
virtualPool.volatilityTracker
|
|
21285
|
+
);
|
|
21286
|
+
totalFeeNumerator = SafeMath.add(totalFeeNumerator, variableFee);
|
|
21287
|
+
}
|
|
21288
|
+
totalFeeNumerator = _bnjs2.default.min(totalFeeNumerator, new (0, _bnjs2.default)(MAX_FEE_NUMERATOR));
|
|
21289
|
+
const denominator = new (0, _bnjs2.default)(FEE_DENOMINATOR).sub(totalFeeNumerator);
|
|
21290
|
+
return mulDiv(
|
|
21291
|
+
amountInAfterFee,
|
|
21292
|
+
new (0, _bnjs2.default)(FEE_DENOMINATOR),
|
|
21293
|
+
denominator,
|
|
21294
|
+
0 /* Up */
|
|
21295
|
+
);
|
|
21296
|
+
} else {
|
|
21297
|
+
return amountInAfterFee;
|
|
21298
|
+
}
|
|
21299
|
+
}
|
|
21267
21300
|
|
|
21268
21301
|
// src/services/state.ts
|
|
21269
21302
|
|
|
@@ -22062,6 +22095,17 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
22062
22095
|
currentPoint
|
|
22063
22096
|
);
|
|
22064
22097
|
}
|
|
22098
|
+
swapQuoteExactIn(swapQuoteExactInParam) {
|
|
22099
|
+
const { virtualPool, config, currentPoint } = swapQuoteExactInParam;
|
|
22100
|
+
const requiredQuoteAmount = calculateQuoteExactInAmount(
|
|
22101
|
+
config,
|
|
22102
|
+
virtualPool,
|
|
22103
|
+
currentPoint
|
|
22104
|
+
);
|
|
22105
|
+
return {
|
|
22106
|
+
exactAmountIn: requiredQuoteAmount
|
|
22107
|
+
};
|
|
22108
|
+
}
|
|
22065
22109
|
};
|
|
22066
22110
|
|
|
22067
22111
|
// src/services/migration.ts
|
|
@@ -23635,5 +23679,6 @@ var DynamicBondingCurveClient = class _DynamicBondingCurveClient {
|
|
|
23635
23679
|
|
|
23636
23680
|
|
|
23637
23681
|
|
|
23638
|
-
|
|
23682
|
+
|
|
23683
|
+
exports.ActivationType = ActivationType; exports.BASE_ADDRESS = BASE_ADDRESS; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.CollectFeeMode = CollectFeeMode; exports.CreatorService = CreatorService; exports.DAMM_V1_MIGRATION_FEE_ADDRESS = DAMM_V1_MIGRATION_FEE_ADDRESS; exports.DAMM_V1_PROGRAM_ID = DAMM_V1_PROGRAM_ID; exports.DAMM_V2_MIGRATION_FEE_ADDRESS = DAMM_V2_MIGRATION_FEE_ADDRESS; exports.DAMM_V2_PROGRAM_ID = DAMM_V2_PROGRAM_ID; exports.DYNAMIC_BONDING_CURVE_PROGRAM_ID = DYNAMIC_BONDING_CURVE_PROGRAM_ID; exports.DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = DYNAMIC_FEE_DECAY_PERIOD_DEFAULT; exports.DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = DYNAMIC_FEE_FILTER_PERIOD_DEFAULT; exports.DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT; exports.DynamicBondingCurveClient = DynamicBondingCurveClient; exports.DynamicBondingCurveProgram = DynamicBondingCurveProgram; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeSchedulerMode = FeeSchedulerMode; exports.GetFeeMode = GetFeeMode; exports.LOCKER_PROGRAM_ID = LOCKER_PROGRAM_ID; exports.MAX_CURVE_POINT = MAX_CURVE_POINT; exports.MAX_FEE_NUMERATOR = MAX_FEE_NUMERATOR; exports.MAX_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_DEFAULT; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MAX_SWALLOW_PERCENTAGE = MAX_SWALLOW_PERCENTAGE; exports.METAPLEX_PROGRAM_ID = METAPLEX_PROGRAM_ID; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.MigrationFeeOption = MigrationFeeOption; exports.MigrationOption = MigrationOption; exports.MigrationService = MigrationService; exports.OFFSET = OFFSET; exports.ONE_Q64 = ONE_Q64; exports.PARTNER_SURPLUS_SHARE = PARTNER_SURPLUS_SHARE; exports.PartnerService = PartnerService; exports.PoolService = PoolService; exports.RESOLUTION = RESOLUTION; exports.Rounding = Rounding; exports.SLOT_DURATION = SLOT_DURATION; exports.SWAP_BUFFER_PERCENTAGE = SWAP_BUFFER_PERCENTAGE; exports.TIMESTAMP_DURATION = TIMESTAMP_DURATION; exports.TokenDecimal = TokenDecimal; exports.TokenType = TokenType; exports.TokenUpdateAuthorityOption = TokenUpdateAuthorityOption; exports.TradeDirection = TradeDirection; exports.U64_MAX = U64_MAX; exports.VAULT_PROGRAM_ID = VAULT_PROGRAM_ID; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.buildCurve = buildCurve; exports.buildCurveWithLiquidityWeights = buildCurveWithLiquidityWeights; exports.buildCurveWithMarketCap = buildCurveWithMarketCap; exports.buildCurveWithTwoSegments = buildCurveWithTwoSegments; exports.calculateQuoteExactInAmount = calculateQuoteExactInAmount; exports.cleanUpTokenAccountTx = cleanUpTokenAccountTx; exports.convertDecimalToBN = convertDecimalToBN; exports.convertToLamports = convertToLamports; exports.createDammV1Program = createDammV1Program; exports.createDammV2Program = createDammV2Program; exports.createDbcProgram = createDbcProgram; exports.createInitializePermissionlessDynamicVaultIx = createInitializePermissionlessDynamicVaultIx; exports.createLockEscrowIx = createLockEscrowIx; exports.createProgramAccountFilter = createProgramAccountFilter; exports.createVaultProgram = createVaultProgram; exports.deriveBaseKeyForLocker = deriveBaseKeyForLocker; exports.deriveDammV1EventAuthority = deriveDammV1EventAuthority; exports.deriveDammV1LockEscrowAddress = deriveDammV1LockEscrowAddress; exports.deriveDammV1LpMintAddress = deriveDammV1LpMintAddress; exports.deriveDammV1MigrationMetadataAddress = deriveDammV1MigrationMetadataAddress; exports.deriveDammV1PoolAddress = deriveDammV1PoolAddress; exports.deriveDammV1PoolAuthority = deriveDammV1PoolAuthority; exports.deriveDammV1ProtocolFeeAddress = deriveDammV1ProtocolFeeAddress; exports.deriveDammV1VaultLPAddress = deriveDammV1VaultLPAddress; exports.deriveDammV2EventAuthority = deriveDammV2EventAuthority; exports.deriveDammV2LockEscrowAddress = deriveDammV2LockEscrowAddress; exports.deriveDammV2MigrationMetadataAddress = deriveDammV2MigrationMetadataAddress; exports.deriveDammV2PoolAddress = deriveDammV2PoolAddress; exports.deriveDammV2PoolAuthority = deriveDammV2PoolAuthority; exports.deriveDammV2TokenVaultAddress = deriveDammV2TokenVaultAddress; exports.deriveDbcEventAuthority = deriveDbcEventAuthority; exports.deriveDbcPoolAddress = deriveDbcPoolAddress; exports.deriveDbcPoolAuthority = deriveDbcPoolAuthority; exports.deriveDbcPoolMetadata = deriveDbcPoolMetadata; exports.deriveDbcTokenVaultAddress = deriveDbcTokenVaultAddress; exports.deriveEscrow = deriveEscrow; exports.deriveLockerEventAuthority = deriveLockerEventAuthority; exports.deriveMintMetadata = deriveMintMetadata; exports.derivePartnerMetadata = derivePartnerMetadata; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveTokenVaultKey = deriveTokenVaultKey; exports.deriveVaultAddress = deriveVaultAddress; exports.deriveVaultLpMintAddress = deriveVaultLpMintAddress; exports.deriveVaultPdas = deriveVaultPdas; exports.feeNumeratorToBps = feeNumeratorToBps; exports.findAssociatedTokenAddress = findAssociatedTokenAddress; exports.fromDecimalToBN = fromDecimalToBN; exports.getAccountCreationTimestamp = getAccountCreationTimestamp; exports.getAccountCreationTimestamps = getAccountCreationTimestamps; exports.getAccountData = getAccountData; exports.getBaseFeeParams = getBaseFeeParams; exports.getBaseTokenForSwap = getBaseTokenForSwap; exports.getCurrentBaseFeeNumerator = getCurrentBaseFeeNumerator; exports.getDeltaAmountBase = getDeltaAmountBase; exports.getDeltaAmountBaseUnsigned = getDeltaAmountBaseUnsigned; exports.getDeltaAmountQuoteUnsigned = getDeltaAmountQuoteUnsigned; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getFeeInPeriod = getFeeInPeriod; exports.getFeeMode = getFeeMode; exports.getFeeOnAmount = getFeeOnAmount; exports.getFirstCurve = getFirstCurve; exports.getFirstKey = getFirstKey; exports.getInitialLiquidityFromDeltaBase = getInitialLiquidityFromDeltaBase; exports.getInitialLiquidityFromDeltaQuote = getInitialLiquidityFromDeltaQuote; exports.getInitializeAmounts = getInitializeAmounts; exports.getLiquidity = getLiquidity; exports.getLockedVestingParams = getLockedVestingParams; exports.getMigrationBaseToken = getMigrationBaseToken; exports.getMigrationQuoteAmount = getMigrationQuoteAmount; exports.getMigrationQuoteAmountFromMigrationQuoteThreshold = getMigrationQuoteAmountFromMigrationQuoteThreshold; exports.getMigrationQuoteThresholdFromMigrationQuoteAmount = getMigrationQuoteThresholdFromMigrationQuoteAmount; exports.getMigrationThresholdPrice = getMigrationThresholdPrice; exports.getMinBaseFeeBps = getMinBaseFeeBps; exports.getNextSqrtPriceFromAmountBaseRoundingUp = getNextSqrtPriceFromAmountBaseRoundingUp; exports.getNextSqrtPriceFromAmountQuoteRoundingDown = getNextSqrtPriceFromAmountQuoteRoundingDown; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPercentageSupplyOnMigration = getPercentageSupplyOnMigration; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getSecondKey = getSecondKey; exports.getSqrtPriceFromMarketCap = getSqrtPriceFromMarketCap; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapAmountFromBaseToQuote = getSwapAmountFromBaseToQuote; exports.getSwapAmountFromQuoteToBase = getSwapAmountFromQuoteToBase; exports.getSwapAmountWithBuffer = getSwapAmountWithBuffer; exports.getSwapResult = getSwapResult; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTokenType = getTokenType; exports.getTotalSupplyFromCurve = getTotalSupplyFromCurve; exports.getTotalTokenSupply = getTotalTokenSupply; exports.getTotalVestingAmount = getTotalVestingAmount; exports.getTwoCurve = getTwoCurve; exports.getVariableFee = getVariableFee; exports.isDefaultLockedVesting = isDefaultLockedVesting; exports.isNativeSol = isNativeSol; exports.prepareTokenAccountTx = prepareTokenAccountTx; exports.swapQuote = swapQuote; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateActivationType = validateActivationType; exports.validateBalance = validateBalance; exports.validateBaseTokenType = validateBaseTokenType; exports.validateCollectFeeMode = validateCollectFeeMode; exports.validateConfigParameters = validateConfigParameters; exports.validateCurve = validateCurve; exports.validateLPPercentages = validateLPPercentages; exports.validateMigrationAndTokenType = validateMigrationAndTokenType; exports.validateMigrationFeeOption = validateMigrationFeeOption; exports.validatePoolFees = validatePoolFees; exports.validateSwapAmount = validateSwapAmount; exports.validateTokenDecimals = validateTokenDecimals; exports.validateTokenSupply = validateTokenSupply; exports.validateTokenUpdateAuthorityOptions = validateTokenUpdateAuthorityOptions; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
23639
23684
|
//# sourceMappingURL=index.cjs.map
|