@gala-chain/chaincode ∙ API
API > swap
Function: swap()
swap(
ctx
,dto
):Promise
\<SwapResDto
>
Parameters
▪ ctx: GalaChainContext
GalaChainContext – The execution context providing access to the GalaChain environment.
▪ dto: SwapDto
SwapDto – A data transfer object containing: - tokenIn – The input token being swapped. - amountIn – The amount of tokenIn provided for the swap. - amountInMaximum – The amount of tokenIn provided for the swap. - tokenOut – The token the user wants to receive. - amountOutMinimum- This amount token user want to receive Minimum; - zeroForOne - Boolean value for swap direction - Pool Identiers – Identifier for the liquidity pool facilitating the swap. - sqrtPriceLimit – The square root price limit to protect against excessive price impact.
Returns
Dev
The swap function executes a token swap in a Uniswap V3-like liquidity pool within the GalaChain ecosystem.