- getSwapResult(bucket: BondingCurveBucketV2, amountIn: bigint, swapDirection: SwapDirection, isFirstBuy?: boolean): {
amountIn: bigint;
amountOut: bigint;
creatorFee: bigint;
fee: bigint;
}
-
Parameters
-
-
amountIn: bigint
-
-
isFirstBuy: boolean = false
Returns {
amountIn: bigint;
amountOut: bigint;
creatorFee: bigint;
fee: bigint;
}
-
amountIn: bigint
-
amountOut: bigint
-
creatorFee: bigint
-
fee: bigint
Calculates the complete swap result including fees for a bonding curve swap.
Both the protocol fee and creator fee are calculated independently on the gross amount (not stacked). The first buy is fee-free for both fee types.
Returns
An object containing the actual input amount, fees, and output amount
Throws
Error if the bucket has insufficient reserves or calculation errors occur