@meteora-ag/dynamic-bonding-curve-sdk 1.2.2 → 1.2.3-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +68 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -24
- package/dist/index.d.ts +36 -24
- package/dist/index.js +67 -37
- 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
|
|
|
@@ -21327,6 +21360,15 @@ var StateService = class extends DynamicBondingCurveProgram {
|
|
|
21327
21360
|
const filters = createProgramAccountFilter(configAddress, 72);
|
|
21328
21361
|
return this.program.account.virtualPool.all(filters);
|
|
21329
21362
|
}
|
|
21363
|
+
/**
|
|
21364
|
+
* Get all dynamic bonding curve pools by creator address
|
|
21365
|
+
* @param creatorAddress - The address of the creator
|
|
21366
|
+
* @returns Array of pool accounts with their addresses
|
|
21367
|
+
*/
|
|
21368
|
+
async getPoolsByCreator(creatorAddress) {
|
|
21369
|
+
const filters = createProgramAccountFilter(creatorAddress, 104);
|
|
21370
|
+
return this.program.account.virtualPool.all(filters);
|
|
21371
|
+
}
|
|
21330
21372
|
/**
|
|
21331
21373
|
* Get pool by base mint
|
|
21332
21374
|
* @param baseMint - The base mint address
|
|
@@ -21448,61 +21490,37 @@ var StateService = class extends DynamicBondingCurveProgram {
|
|
|
21448
21490
|
};
|
|
21449
21491
|
}
|
|
21450
21492
|
/**
|
|
21451
|
-
* Get
|
|
21452
|
-
* @param poolAddress - The address of the pool
|
|
21453
|
-
* @returns Object containing current and total fee metrics
|
|
21454
|
-
*/
|
|
21455
|
-
async getPoolCreatorFeeMetrics(poolAddress) {
|
|
21456
|
-
const pool = await this.getPool(poolAddress);
|
|
21457
|
-
if (!pool) {
|
|
21458
|
-
throw new Error(`Pool not found: ${poolAddress.toString()}`);
|
|
21459
|
-
}
|
|
21460
|
-
return {
|
|
21461
|
-
creatorBaseFee: pool.creatorBaseFee,
|
|
21462
|
-
creatorQuoteFee: pool.creatorQuoteFee
|
|
21463
|
-
};
|
|
21464
|
-
}
|
|
21465
|
-
/**
|
|
21466
|
-
* Get fee metrics for a specific pool
|
|
21467
|
-
* @param poolAddress - The address of the pool
|
|
21468
|
-
* @returns Object containing current and total fee metrics
|
|
21469
|
-
*/
|
|
21470
|
-
async getPoolPartnerFeeMetrics(poolAddress) {
|
|
21471
|
-
const pool = await this.getPool(poolAddress);
|
|
21472
|
-
if (!pool) {
|
|
21473
|
-
throw new Error(`Pool not found: ${poolAddress.toString()}`);
|
|
21474
|
-
}
|
|
21475
|
-
return {
|
|
21476
|
-
partnerBaseFee: pool.partnerBaseFee,
|
|
21477
|
-
partnerQuoteFee: pool.partnerQuoteFee
|
|
21478
|
-
};
|
|
21479
|
-
}
|
|
21480
|
-
/**
|
|
21481
|
-
* Get all quote fees for pools linked to a specific config key
|
|
21493
|
+
* Get all fees for pools linked to a specific config key
|
|
21482
21494
|
* @param configAddress - The address of the pool config
|
|
21483
21495
|
* @returns Array of pools with their quote fees
|
|
21484
21496
|
*/
|
|
21485
|
-
async
|
|
21497
|
+
async getPoolsFeesByConfig(configAddress) {
|
|
21486
21498
|
const filteredPools = await this.getPoolsByConfig(configAddress);
|
|
21487
21499
|
return filteredPools.map((pool) => ({
|
|
21488
21500
|
poolAddress: pool.publicKey,
|
|
21501
|
+
partnerBaseFee: pool.account.partnerBaseFee,
|
|
21489
21502
|
partnerQuoteFee: pool.account.partnerQuoteFee,
|
|
21503
|
+
creatorBaseFee: pool.account.creatorBaseFee,
|
|
21490
21504
|
creatorQuoteFee: pool.account.creatorQuoteFee,
|
|
21505
|
+
totalTradingBaseFee: pool.account.metrics.totalTradingBaseFee,
|
|
21491
21506
|
totalTradingQuoteFee: pool.account.metrics.totalTradingQuoteFee
|
|
21492
21507
|
}));
|
|
21493
21508
|
}
|
|
21494
21509
|
/**
|
|
21495
|
-
* Get all
|
|
21496
|
-
* @param
|
|
21510
|
+
* Get all fees for pools linked to a specific creator
|
|
21511
|
+
* @param creatorAddress - The address of the creator
|
|
21497
21512
|
* @returns Array of pools with their base fees
|
|
21498
21513
|
*/
|
|
21499
|
-
async
|
|
21500
|
-
const filteredPools = await this.
|
|
21514
|
+
async getPoolsFeesByCreator(creatorAddress) {
|
|
21515
|
+
const filteredPools = await this.getPoolsByCreator(creatorAddress);
|
|
21501
21516
|
return filteredPools.map((pool) => ({
|
|
21502
21517
|
poolAddress: pool.publicKey,
|
|
21503
21518
|
partnerBaseFee: pool.account.partnerBaseFee,
|
|
21519
|
+
partnerQuoteFee: pool.account.partnerQuoteFee,
|
|
21504
21520
|
creatorBaseFee: pool.account.creatorBaseFee,
|
|
21505
|
-
|
|
21521
|
+
creatorQuoteFee: pool.account.creatorQuoteFee,
|
|
21522
|
+
totalTradingBaseFee: pool.account.metrics.totalTradingBaseFee,
|
|
21523
|
+
totalTradingQuoteFee: pool.account.metrics.totalTradingQuoteFee
|
|
21506
21524
|
}));
|
|
21507
21525
|
}
|
|
21508
21526
|
};
|
|
@@ -22062,6 +22080,17 @@ var PoolService = class extends DynamicBondingCurveProgram {
|
|
|
22062
22080
|
currentPoint
|
|
22063
22081
|
);
|
|
22064
22082
|
}
|
|
22083
|
+
swapQuoteExactIn(swapQuoteExactInParam) {
|
|
22084
|
+
const { virtualPool, config, currentPoint } = swapQuoteExactInParam;
|
|
22085
|
+
const requiredQuoteAmount = calculateQuoteExactInAmount(
|
|
22086
|
+
config,
|
|
22087
|
+
virtualPool,
|
|
22088
|
+
currentPoint
|
|
22089
|
+
);
|
|
22090
|
+
return {
|
|
22091
|
+
exactAmountIn: requiredQuoteAmount
|
|
22092
|
+
};
|
|
22093
|
+
}
|
|
22065
22094
|
};
|
|
22066
22095
|
|
|
22067
22096
|
// src/services/migration.ts
|
|
@@ -23635,5 +23664,6 @@ var DynamicBondingCurveClient = class _DynamicBondingCurveClient {
|
|
|
23635
23664
|
|
|
23636
23665
|
|
|
23637
23666
|
|
|
23638
|
-
|
|
23667
|
+
|
|
23668
|
+
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
23669
|
//# sourceMappingURL=index.cjs.map
|