### Get Block Starting Tick and Liquidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/libraries/OracleLibrary.md Given a pool, returns the tick value and liquidity as of the start of the current block. Useful for block-based calculations. ```Solidity function getBlockStartingTickAndLiquidity(address pool) internal view returns (int24, uint128) ``` -------------------------------- ### latestPeriodStartTime Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/IMasterChefV3.md Retrieves the start time of the current reward period. ```APIDOC ## latestPeriodStartTime ### Description Retrieves the start time of the current reward period. ### Method VIEW ### Endpoint N/A (Solidity function) ### Parameters None ### Response #### Success Response - **uint256**: The timestamp representing the start of the current reward period. ``` -------------------------------- ### Get Block Starting Tick and Liquidity Function Signature Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/OracleTest.md Signature for the getBlockStartingTickAndLiquidity function, used to retrieve the tick and liquidity at the start of a block. ```solidity function getBlockStartingTickAndLiquidity(address pool) public view returns (int24, uint128) ``` -------------------------------- ### Get Gas Cost of Get Next Sqrt Price From Input Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/SqrtPriceMathTest.md Estimates the gas cost for the getNextSqrtPriceFromInput function. This is useful for gas optimizations and estimations. ```Solidity function getGasCostOfGetNextSqrtPriceFromInput(uint160 sqrtP, uint128 liquidity, uint256 amountIn, bool zeroForOne) external view returns (uint256) ``` -------------------------------- ### Get Gas Cost of Get Next Sqrt Price From Output Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/SqrtPriceMathTest.md Estimates the gas cost for the getNextSqrtPriceFromOutput function. Useful for gas planning and analysis. ```Solidity function getGasCostOfGetNextSqrtPriceFromOutput(uint160 sqrtP, uint128 liquidity, uint256 amountOut, bool zeroForOne) external view returns (uint256) ``` -------------------------------- ### PancakeV3LmPool Constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-lm-pool/docs/index.md Initializes the PancakeV3LmPool contract with the associated V3 pool, MasterChef contract, and the reward start timestamp. ```solidity constructor(address _pool, address _masterChef, uint32 rewardStartTimestamp) public ``` -------------------------------- ### OracleEchidnaTest Constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/OracleEchidnaTest.md Initializes the OracleEchidnaTest contract. No specific setup is required beyond deployment. ```Solidity constructor() public ``` -------------------------------- ### Get Gas Cost for getAmount0ForLiquidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/LiquidityAmountsTest.md Estimates the gas cost for executing the getAmount0ForLiquidity function. This is a view function. ```solidity function getGasCostOfGetAmount0ForLiquidity(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity) external view returns (uint256) ``` -------------------------------- ### constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/TestERC20.md Initializes the TestERC20 contract with a specified amount of tokens to mint. ```APIDOC ## constructor ### Description Initializes the TestERC20 contract, minting a specified initial amount of tokens. ### Method Constructor (Solidity) ### Parameters - **amountToMint** (uint256) - The initial amount of tokens to mint upon contract deployment. ``` -------------------------------- ### Get Gas Cost of Construct Token URI Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/NFTDescriptorTest.md Calculates the gas cost associated with constructing a token URI. ```solidity function getGasCostOfConstructTokenURI(struct NFTDescriptor.ConstructTokenURIParams params) public view returns (uint256) ``` -------------------------------- ### initialize Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/OracleEchidnaTest.md Initializes the contract with specific time, tick, and liquidity values. ```APIDOC ## initialize ### Description Initializes the contract with specific time, tick, and liquidity values. ### Method `initialize` ### Parameters #### Path Parameters - **time** (uint32) - Required - The time value for initialization. - **tick** (int24) - Required - The tick value for initialization. - **liquidity** (uint128) - Required - The liquidity value for initialization. ``` -------------------------------- ### createAndInitializePoolIfNecessary Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/base/PoolInitializer.md Creates a new pool if it does not exist, then initializes it. This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool. ```APIDOC ## createAndInitializePoolIfNecessary ### Description Creates a new pool if it does not exist, then initializes it. This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool. ### Method `external payable` ### Parameters #### Path Parameters - **token0** (address) - Required - The contract address of token0 of the pool - **token1** (address) - Required - The contract address of token1 of the pool - **fee** (uint24) - Required - The fee amount of the v3 pool for the specified token pair - **sqrtPriceX96** (uint160) - Required - The initial square root price of the pool as a Q64.96 value ### Return Values #### Success Response - **pool** (address) - Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary ``` -------------------------------- ### Get Latest Period Start Time Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/IMasterChefV3.md Retrieves the timestamp of the latest completed reward period's start. This function is viewable and does not modify the contract state. ```solidity function latestPeriodStartTime() external view returns (uint256) ``` -------------------------------- ### Get Next Sqrt Price from Output Amount Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/libraries/SqrtPriceMath.md Calculates the next square root price given an output amount of token0 or token1. Throws errors if price or liquidity are zero, or if the resulting price is out of bounds. ```Solidity function getNextSqrtPriceFromOutput(uint160 sqrtPX96, uint128 liquidity, uint256 amountOut, bool zeroForOne) internal pure returns (uint160 sqrtQX96) ``` -------------------------------- ### Get Gas Cost of Get Amount0 Delta Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/SqrtPriceMathTest.md Estimates the gas cost for the getAmount0Delta function. Use this for gas profiling and optimization. ```Solidity function getGasCostOfGetAmount0Delta(uint160 sqrtLower, uint160 sqrtUpper, uint128 liquidity, bool roundUp) external view returns (uint256) ``` -------------------------------- ### initialize Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/pool/IPancakeV3PoolActions.md Sets the initial price for the pool. The price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value. ```APIDOC ## initialize ### Description Sets the initial price for the pool. The price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value. ### Method external ### Endpoint initialize ### Parameters #### Path Parameters - **sqrtPriceX96** (uint160) - Required - the initial sqrt price of the pool as a Q64.96 ``` -------------------------------- ### IV3Migrator.migrate Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/interfaces/IV3Migrator.md Migrates liquidity to v3 by burning v2 liquidity and minting a new position for v3. Slippage protection is enforced via `amount{0,1}Min`, which should be a discount of the expected values of the maximum amount of v3 liquidity that the v2 liquidity can get. For the special case of migrating to an out-of-range position, `amount{0,1}Min` may be set to 0, enforcing that the position remains out of range. ```APIDOC ## migrate ### Description Migrates liquidity to v3 by burning v2 liquidity and minting a new position for v3. Slippage protection is enforced via `amount{0,1}Min`, which should be a discount of the expected values of the maximum amount of v3 liquidity that the v2 liquidity can get. For the special case of migrating to an out-of-range position, `amount{0,1}Min` may be set to 0, enforcing that the position remains out of range. ### Method EXTERNAL CALL ### Parameters #### Calldata Parameters - **params** (struct IV3Migrator.MigrateParams) - The params necessary to migrate v2 liquidity, encoded as `MigrateParams` in calldata ``` -------------------------------- ### Get Gas Cost of Get Quote At Tick Function Signature Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/OracleTest.md Signature for the getGasCostOfGetQuoteAtTick function, used to estimate the gas cost of the getQuoteAtTick function. ```solidity function getGasCostOfGetQuoteAtTick(int24 tick, uint128 baseAmount, address baseToken, address quoteToken) public view returns (uint256) ``` -------------------------------- ### constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/MasterChefV3.md Initializes the MasterChefV3 contract with the CAKE token, NFT position manager, and WETH addresses. ```APIDOC ## constructor MasterChefV3 ### Description Initializes the MasterChefV3 contract with the CAKE token, NFT position manager, and WETH addresses. ### Parameters #### Parameters - **_CAKE** (contract IERC20) - The CAKE token contract address. - **_nonfungiblePositionManager** (contract INonfungiblePositionManager) - the NFT position manager contract address. - **_WETH** (address) - ``` -------------------------------- ### Get Gas Cost of Get Amount1 Delta Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/SqrtPriceMathTest.md Estimates the gas cost for the getAmount1Delta function. This helps in understanding the computational expense of amount calculations. ```Solidity function getGasCostOfGetAmount1Delta(uint160 sqrtLower, uint160 sqrtUpper, uint128 liquidity, bool roundUp) external view returns (uint256) ``` -------------------------------- ### Importing SwapRouter Bytecode in TypeScript Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/README.md Demonstrates how to import the ABI and bytecode for the SwapRouter from the npm package for local testing. Ensure you are testing against the same bytecode deployed to mainnet. ```typescript import { abi as SWAP_ROUTER_ABI, bytecode as SWAP_ROUTER_BYTECODE, } from '@pancakeswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json' // deploy the bytecode ``` -------------------------------- ### Init Event Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/MasterChefV3.md Emitted when the MasterChefV3 contract is initialized. ```solidity event Init() ``` -------------------------------- ### Deposit Ether to get WETH Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/IWETH.md Use this function to deposit ether and receive wrapped ether in return. It is a payable function. ```Solidity function deposit() external payable ``` -------------------------------- ### Get Init Code Hash Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/OutputCodeHash.md Returns the immutable init code hash for contract creation. This is a pure function and does not require any state. ```Solidity function getInitCodeHash() public pure returns (bytes32) ``` -------------------------------- ### Retrieve Swap Price Limit and Execute Swaps (E2E_swap) Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/_audits/tob/README.md Uncomment console logging in E2E_swap.sol to view the price limit. Execute test swaps using JavaScript to trigger logging and observe the price limit used. ```javascript // to get pool params + created positions console.log(await E2E_swap.viewRandomInit('')) // execute the swap, which will create the above and log the used priceLimit to the console await E2E_swap.test_swap_exactOut_oneForZero('') // execute the swap, logs the used priceLimit to the console await E2E_swap.test_swap_exactIn_oneForZero('') ``` -------------------------------- ### Get Pool Creation Parameters Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/IPancakeV3PoolDeployer.md Retrieves the parameters used for constructing a pool. These are set transiently during pool creation and are called by the pool constructor. ```solidity function parameters() external view returns (address factory, address token0, address token1, uint24 fee, int24 tickSpacing) ``` -------------------------------- ### Get Signed Amount1 Delta Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/libraries/SqrtPriceMath.md Helper function to get the signed token1 delta corresponding to a change in liquidity between two square root prices. This function is pure. ```solidity function getAmount1Delta(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity) internal pure returns (int256 amount1) ``` -------------------------------- ### constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/receiver/MasterChefV3Receiver.md Initializes the MasterChefV3Receiver contract with addresses for MasterChef V2, MasterChef V3, the Cake token, and a V2 pool ID. ```APIDOC ## constructor MasterChefV3Receiver ### Description Initializes the MasterChefV3Receiver contract with addresses for MasterChef V2, MasterChef V3, the Cake token, and a V2 pool ID. ### Parameters #### Parameters - **_v2** (contract IMasterChefV2) - MasterChef V2 address. - **_v3** (contract IMasterChefV3) - MasterChef V3 address. - **_cake** (contract IERC20) - Cake token address. - **_v2Pid** (uint256) - The pool id of the dummy pool on the MCV2. ``` -------------------------------- ### Debugging Mint/Burn Operations in E2E Tests Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/_audits/tob/README.md Use these JavaScript snippets to view pool initialization and position parameters before executing mint and burn operations. Uncomment the provided Solidity import and console.log statements in your contract for detailed debugging output. ```javascript // show pool init params const poolInitParams = await E2E_mint_burn.viewInitRandomPoolParams('') console.log(positionParams) // show pool mint position params const positionParams = await E2E_mint_burn.viewMintRandomNewPosition( '', poolInitParams.tickSpacing, poolInitParams.tickCount, poolInitParams.maxTick ) console.log(positionParams) // execute the first mint await E2E_mint_burn.test_mint('') // execute the burn await E2E_mint_burn.test_burn_partial('') // this should log the index of the position that was burned to the console // as well as the amount that was burned. // together with the above output this should make it clear which exact position // was burned and how much ``` -------------------------------- ### Get Signed Amount0 Delta Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/libraries/SqrtPriceMath.md Helper function to get the signed token0 delta corresponding to a change in liquidity between two square root prices. This function is pure. ```solidity function getAmount0Delta(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, int128 liquidity) internal pure returns (int256 amount0) ``` -------------------------------- ### Get Next Sqrt Price From Output Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/SqrtPriceMathTest.md Calculates the next square root price given an output amount. Use this function when you know the desired amount of output tokens from a swap. ```Solidity function getNextSqrtPriceFromOutput(uint160 sqrtP, uint128 liquidity, uint256 amountOut, bool zeroForOne) external pure returns (uint160 sqrtQ) ``` -------------------------------- ### Get Amounts for Liquidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/libraries/LiquidityAmounts.md Computes the amounts of token0 and token1 for a given liquidity, considering current pool prices and prices at tick boundaries. ```Solidity function getAmountsForLiquidity(uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity) internal pure returns (uint256 amount0, uint256 amount1) ``` -------------------------------- ### Get Pool Observations Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/pool/IPancakeV3PoolState.md Retrieves data about a specific observation index. It is recommended to use #observe() for fetching observations as of a certain time. ```solidity function observations(uint256 index) external view returns (uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized) ``` -------------------------------- ### Solidity TestERC20 Constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/TestERC20.md Initializes the TestERC20 contract with a specified initial amount of tokens to mint. ```solidity constructor(uint256 amountToMint) public ``` -------------------------------- ### initialize Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/NonfungibleTokenPositionDescriptorOffChain.md Initializes the NonfungibleTokenPositionDescriptorOffChain contract with a base token URI. ```APIDOC ## initialize ### Description Initializes the contract with a base token URI. ### Method `initialize` ### Parameters #### Path Parameters - **baseTokenURI** (string) - Description: The base URI for token metadata. ``` -------------------------------- ### Get Native Currency Label Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/NonfungibleTokenPositionDescriptor.md Retrieves the native currency label as a string. ```solidity function nativeCurrencyLabel() public view returns (string) ``` -------------------------------- ### PancakeV3FactoryOwner.constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3FactoryOwner.md Initializes the PancakeV3FactoryOwner contract with a reference to the factory contract. ```Solidity constructor(contract IPancakeV3Factory _factory) public ``` -------------------------------- ### Get Token Balance Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/IERC20Minimal.md Returns the balance of a specified token for a given account. ```Solidity function balanceOf(address account) external view returns (uint256) ``` -------------------------------- ### Get Next Sqrt Price From Input Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/SqrtPriceMathTest.md Calculates the next square root price given an input amount. Use this function when you know the amount of input tokens to be swapped. ```Solidity function getNextSqrtPriceFromInput(uint160 sqrtP, uint128 liquidity, uint256 amountIn, bool zeroForOne) external pure returns (uint160 sqrtQ) ``` -------------------------------- ### Get Pool Fee Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/IPancakeV3Pool.md Retrieves the fee tier of the pool, represented as a uint24. ```Solidity function fee() external view returns (uint24) ``` -------------------------------- ### Retrieve Pool Initialization and Created Positions (E2E_swap) Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/_audits/tob/README.md Use a JavaScript unit test to view the deterministic pool initialization parameters and created positions for a given swap amount (seed). ```javascript console.log(await E2E_swap.viewRandomInit('')) ``` -------------------------------- ### Get Pool Factory Address Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/IPancakeV3Pool.md Retrieves the address of the factory that created this pool. ```Solidity function factory() external view returns (address) ``` -------------------------------- ### deploy Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3PoolDeployer.md Deploys a new V3 pool with specified parameters. It transiently sets the pool's parameters and then clears them after deployment. ```APIDOC ## deploy ### Description Deploys a pool with the given parameters by transiently setting the parameters storage slot and then clearing it after deploying the pool. ### Method external ### Signature function deploy(address factory, address token0, address token1, uint24 fee, int24 tickSpacing) external returns (address pool) ### Parameters #### Parameters - **factory** (address) - Required - The contract address of the PancakeSwap V3 factory - **token0** (address) - Required - The first token of the pool by address sort order - **token1** (address) - Required - The second token of the pool by address sort order - **fee** (uint24) - Required - The fee collected upon every swap in the pool, denominated in hundredths of a bip - **tickSpacing** (int24) - Required - The spacing between usable ticks ### Returns - **pool** (address) - The address of the newly deployed pool. ``` -------------------------------- ### initialize Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3Pool.md Sets the initial price for the liquidity pool. This function can only be called once as it initializes the pool's unlocked state. ```APIDOC ## initialize ### Description Sets the initial price for the pool. not locked because it initializes unlocked ### Method POST ### Endpoint /initialize ### Parameters #### Request Body - **sqrtPriceX96** (uint160) - Required - the initial sqrt price of the pool as a Q64.96 ``` -------------------------------- ### Get Token 1 Address Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/IPancakeV3Pool.md Retrieves the address of the second token (token1) in the pool. ```Solidity function token1() external view returns (address) ``` -------------------------------- ### Get Token 0 Address Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/IPancakeV3Pool.md Retrieves the address of the first token (token0) in the pool. ```Solidity function token0() external view returns (address) ``` -------------------------------- ### createAndInitializePoolIfNecessary Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/interfaces/IPoolInitializer.md Creates a new liquidity pool if it doesn't exist and initializes it with the provided parameters. This method is useful for bundling with other operations that require an existing pool. ```APIDOC ## createAndInitializePoolIfNecessary ### Description Creates a new pool if it does not exist, then initializes if not initialized. This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool. ### Method `external payable` ### Parameters #### Path Parameters - **token0** (address) - Required - The contract address of token0 of the pool - **token1** (address) - Required - The contract address of token1 of the pool - **fee** (uint24) - Required - The fee amount of the v3 pool for the specified token pair - **sqrtPriceX96** (uint160) - Required - The initial square root price of the pool as a Q64.96 value ### Return Values #### Success Response - **pool** (address) - Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary ``` -------------------------------- ### Initialize Event Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/pool/IPancakeV3PoolEvents.md Emitted once when the pool is first initialized. No other events can be emitted before this. ```solidity event Initialize(uint160 sqrtPriceX96, int24 tick) ``` -------------------------------- ### Get Token Ratio Priority Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/NonfungibleTokenPositionDescriptor.md Retrieves the priority of a token's ratio on a specific chain. ```solidity function tokenRatioPriority(address token, uint256 chainId) public view returns (int256) ``` -------------------------------- ### exactOutputSingle Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/SwapRouter.md Performs a swap to obtain a specific output amount by spending the minimum possible input amount of another token in a single hop. ```APIDOC ## exactOutputSingle ### Description Swaps as little as possible of one token for `amountOut` of another token. ### Function Signature ```solidity function exactOutputSingle(struct ISwapRouter.ExactOutputSingleParams params) external payable returns (uint256 amountIn) ``` ### Parameters #### Path Parameters - **params** (struct ISwapRouter.ExactOutputSingleParams) - Required - The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata ### Return Values #### Success Response (200) - **amountIn** (uint256) - The amount of the input token ``` -------------------------------- ### Get Gas Cost of GetTickAtSqrtRatio Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/TickMathTest.md Estimates the gas cost for the getTickAtSqrtRatio function. This is a view function. ```Solidity function getGasCostOfGetTickAtSqrtRatio(uint160 sqrtPriceX96) external view returns (uint256) ``` -------------------------------- ### initialize Function Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3Pool.md Sets the initial price for the pool. This function can only be called once as it initializes an unlocked state. ```solidity function initialize(uint160 sqrtPriceX96) external ``` -------------------------------- ### Get Next Sqrt Price from Input Amount Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/libraries/SqrtPriceMath.md Determines the next square root price based on an input amount of either token0 or token1. Throws errors if price or liquidity are zero, or if the resulting price is out of bounds. ```Solidity function getNextSqrtPriceFromInput(uint160 sqrtPX96, uint128 liquidity, uint256 amountIn, bool zeroForOne) internal pure returns (uint160 sqrtQX96) ``` -------------------------------- ### TestERC20Metadata Constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/TestERC20Metadata.md Initializes the TestERC20Metadata contract. Requires the amount to mint, and the name and symbol for the ERC20 token. ```solidity constructor(uint256 amountToMint, string name, string symbol) public ``` -------------------------------- ### Get Gas Cost of GetSqrtRatioAtTick Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/TickMathTest.md Estimates the gas cost for the getSqrtRatioAtTick function. This is a view function. ```Solidity function getGasCostOfGetSqrtRatioAtTick(int24 tick) external view returns (uint256) ``` -------------------------------- ### Retrieve Pool Initialization Parameters (E2E_mint_burn) Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/_audits/tob/README.md Use a JavaScript unit test to view the deterministic pool initialization parameters for a given mint amount (seed). ```javascript console.log(await E2E_mint_burn.viewInitRandomPoolParams('')) ``` -------------------------------- ### Get Pool Deployer Address Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3Factory.md Returns the address responsible for deploying new liquidity pools. ```Solidity address poolDeployer ``` -------------------------------- ### Initialize Pool Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/pool/IPancakeV3PoolActions.md Sets the initial price for the pool. The price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value. ```solidity function initialize(uint160 sqrtPriceX96) external ``` -------------------------------- ### Get Liquidity Management Pool Address Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/IPancakeV3Pool.md Retrieves the address of the associated liquidity management pool. ```Solidity function lmPool() external view returns (address) ``` -------------------------------- ### initialize Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/OracleTest.md Initializes the OracleTest contract with provided parameters. This function sets the initial state of the oracle. ```APIDOC ## initialize ### Description Initializes the OracleTest contract with provided parameters. This function sets the initial state of the oracle. ### Method external ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **params** (struct OracleTest.InitializeParams) - Required - Initialization parameters including time, tick, and liquidity. - **time** (uint32) - Required - The timestamp for initialization. - **tick** (int24) - Required - The initial tick value. - **liquidity** (uint128) - Required - The initial liquidity value. ### Request Example ```json { "params": { "time": 1678886400, "tick": 0, "liquidity": 1000000000000000000 } } ``` ### Response #### Success Response (200) No explicit return values documented. ``` -------------------------------- ### Get User Multiplier Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/IFarmBooster.md Retrieves the current booster multiplier for a given NFT token ID. ```Solidity function getUserMultiplier(uint256 _tokenId) external view returns (uint256) ``` -------------------------------- ### Get Gas Cost for getAmountsForLiquidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/LiquidityAmountsTest.md Estimates the gas cost for executing the getAmountsForLiquidity function. This is a view function. ```solidity function getGasCostOfGetAmountsForLiquidity(uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity) external view returns (uint256) ``` -------------------------------- ### initFlash Function Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/examples/PairFlash.md Initiates a flash loan by calling the pool's flash function with specified parameters. ```Solidity function initFlash(struct PairFlash.FlashParams params) external ``` -------------------------------- ### Get Gas Cost for getAmount1ForLiquidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/LiquidityAmountsTest.md Estimates the gas cost for executing the getAmount1ForLiquidity function. This is a view function. ```solidity function getGasCostOfGetAmount1ForLiquidity(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity) external view returns (uint256) ``` -------------------------------- ### constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/OracleEchidnaTest.md Initializes the OracleEchidnaTest contract. ```APIDOC ## constructor ### Description Initializes the OracleEchidnaTest contract. ### Method `constructor` ### Parameters None ``` -------------------------------- ### pancakeV3MintCallback Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/TestPancakeV3Callee.md Callback function for mint operations, called by the pool after liquidity is minted. ```APIDOC ## pancakeV3MintCallback ### Description Callback function invoked by a Pancake V3 Pool after minting liquidity. Implementations must pay the pool the tokens owed for the minted liquidity. The caller must be verified as a Pancake V3 Pool. ### Method external ### Signature `pancakeV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes data)` ### Parameters - **amount0Owed** (uint256) - The amount of token0 owed to the pool for the minted liquidity. - **amount1Owed** (uint256) - The amount of token1 owed to the pool for the minted liquidity. - **data** (bytes) - Arbitrary data passed through from the initial mint call. ``` -------------------------------- ### Get Gas Cost for getLiquidityForAmounts Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/LiquidityAmountsTest.md Estimates the gas cost for executing the getLiquidityForAmounts function. This is a view function. ```solidity function getGasCostOfGetLiquidityForAmounts(uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1) external view returns (uint256) ``` -------------------------------- ### SwapRouter Constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/SwapRouter.md Initializes the SwapRouter contract with addresses for the deployer, factory, and WETH9. ```solidity constructor(address _deployer, address _factory, address _WETH9) public ``` -------------------------------- ### Get Range Location Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/NFTDescriptorTest.md Determines the string representations for the lower and upper bounds of a given tick range. ```solidity function rangeLocation(int24 tickLower, int24 tickUpper) public pure returns (string, string) ``` -------------------------------- ### createAndInitializePoolIfNecessary Function Signature Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/base/PoolInitializer.md This is the function signature for creating and initializing a new pool if it doesn't exist. It can be bundled with other actions using IMulticall. ```solidity function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) external payable returns (address pool) ``` -------------------------------- ### Get Next Sqrt Price from Amount0 (Rounding Up) Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/libraries/SqrtPriceMath.md Calculates the next square root price when a specific amount of token0 is added or removed. It always rounds up to ensure sufficient price movement. ```Solidity function getNextSqrtPriceFromAmount0RoundingUp(uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add) internal pure returns (uint160) ``` -------------------------------- ### Get Pool Initialization Code Hash Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/PoolAddressTest.md Returns the immutable hash used for initializing pool contracts. ```solidity function POOL_INIT_CODE_HASH() external pure returns (bytes32) ``` -------------------------------- ### pancakeV3MintCallback Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/callback/IPancakeV3MintCallback.md This function is called by the IPancakeV3Pool#mint function after liquidity has been minted to a position. The implementing contract must pay the pool the tokens owed for the minted liquidity. It's crucial to verify that the caller is a PancakeV3Pool deployed by the canonical PancakeV3Factory. ```APIDOC ## pancakeV3MintCallback ### Description Called to `msg.sender` after minting liquidity to a position from IPancakeV3Pool#mint. In the implementation you must pay the pool tokens owed for the minted liquidity. The caller of this method must be checked to be a PancakeV3Pool deployed by the canonical PancakeV3Factory. ### Method External Call ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **amount0Owed** (uint256) - The amount of token0 due to the pool for the minted liquidity - **amount1Owed** (uint256) - The amount of token1 due to the pool for the minted liquidity - **data** (bytes) - Any data passed through by the caller via the IPancakeV3PoolActions#mint call ### Request Example ```solidity // Example implementation structure contract MyContract is IPancakeV3MintCallback { function pancakeV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes data) external { // Implementation details here } } ``` ### Response #### Success Response This function does not return a value directly, but its execution results in the payment of owed tokens to the pool. ``` -------------------------------- ### Get WETH9 Address Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/interfaces/IPeripheryImmutableState.md Returns the address of WETH9. Use this function to retrieve the WETH9 contract address. ```solidity function WETH9() external view returns (address) ``` -------------------------------- ### PancakeV3LmPoolDeployer Constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-lm-pool/docs/index.md Initializes the PancakeV3LmPoolDeployer with the MasterChef contract address and the Factory Owner contract address. ```solidity constructor(address _masterChef, contract IPancakeV3FactoryOwner _factoryOwner) public ``` -------------------------------- ### Get Domain Separator Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/base/ERC721Permit.md Retrieves the domain separator used in the permit signature encoding. This is a view function. ```Solidity function DOMAIN_SEPARATOR() public view returns (bytes32) ``` -------------------------------- ### Initialize Event Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/pool/IPancakeV3PoolEvents.md Emitted exactly once when the pool is first initialized. It records the initial price and tick. ```APIDOC ## Initialize Event ### Description Emitted exactly once by a pool when #initialize is first called on the pool. Mint/Burn/Swap cannot be emitted by the pool before Initialize. ### Parameters #### Parameters - **sqrtPriceX96** (uint160) - The initial sqrt price of the pool, as a Q64.96 - **tick** (int24) - The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool ``` -------------------------------- ### Get Token Color Hex Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/NFTDescriptorTest.md Retrieves the color hex code for a given token address with an optional offset. ```solidity function tokenToColorHex(address token, uint256 offset) public pure returns (string) ``` -------------------------------- ### setFeeAmountExtraInfo Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3Factory.md Configures extra information for a fee amount, including whether it requires whitelist approval for creation and if it is enabled. ```APIDOC ## setFeeAmountExtraInfo ### Description Set a fee amount extra info. ### Method `public` ### Parameters - **fee** (uint24) - The fee amount to configure. - **whitelistRequested** (bool) - The flag whether should be created by owner only. - **enabled** (bool) - The flag is the fee is enabled or not. ``` -------------------------------- ### Get Gas Cost of Compute Address Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/PoolAddressTest.md Estimates the gas cost required to compute a pool's address. ```solidity function getGasCostOfComputeAddress(address deployer, address token0, address token1, uint24 fee) external view returns (uint256) ``` -------------------------------- ### Get Tick at Square Root Ratio Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/TickMathTest.md Calculates the tick for a given square root ratio. This is a pure function. ```Solidity function getTickAtSqrtRatio(uint160 sqrtPriceX96) external pure returns (int24) ``` -------------------------------- ### PancakeV3FactoryOwner.enableFeeAmount Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3FactoryOwner.md Enables a new fee amount and tick spacing for the factory. This function can only be called by the owner. ```Solidity function enableFeeAmount(uint24 fee, int24 tickSpacing) external ``` -------------------------------- ### Get Square Root Ratio at Tick Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/TickMathTest.md Calculates the square root ratio for a given tick. This is a pure function. ```Solidity function getSqrtRatioAtTick(int24 tick) external pure returns (uint160) ``` -------------------------------- ### Importing ISwapRouter Interface in Solidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/README.md Shows how to import the ISwapRouter interface from the npm artifact into your Solidity smart contracts. This allows your contract to interact with the SwapRouter. ```solidity import '@pancakeswap/v3-periphery/contracts/interfaces/ISwapRouter.sol'; contract MyContract { ISwapRouter router; function doSomethingWithSwapRouter() { // router.exactInput(...); } } ``` -------------------------------- ### Get Owner Address Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3Factory.md Retrieves the current owner of the factory contract. The owner can be changed using the setOwner function. ```Solidity address owner ``` -------------------------------- ### Constructor for ERC721Permit Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/base/ERC721Permit.md Initializes the ERC721Permit contract by computing the nameHash and versionHash. Requires name, symbol, and version strings. ```Solidity constructor(string name_, string symbol_, string version_) internal ``` -------------------------------- ### Slice Bytes Array Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/libraries/BytesLib.md Extracts a portion of a byte array. Specify the starting position and the desired length of the slice. ```Solidity function slice(bytes _bytes, uint256 _start, uint256 _length) internal pure returns (bytes) ``` -------------------------------- ### Get Amount1 for Liquidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/libraries/LiquidityAmounts.md Computes the amount of token1 corresponding to a given amount of liquidity within a specified price range. ```Solidity function getAmount1ForLiquidity(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity) internal pure returns (uint256 amount1) ``` -------------------------------- ### initFlash Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/examples/PairFlash.md Initiates a flash loan operation. This function calls the pool's flash function with the necessary data for the `PancakeV3FlashCallback`. ```APIDOC ## initFlash ### Description Initiates a flash loan operation. This function calls the pool's flash function with the necessary data for the `PancakeV3FlashCallback`. ### Function Signature `function initFlash(struct PairFlash.FlashParams params) external` ### Parameters #### Parameters - **params** (struct PairFlash.FlashParams) - The parameters necessary for flash and the callback, passed in as FlashParams ``` -------------------------------- ### MasterChefV3 Constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/MasterChefV3.md Initializes the MasterChefV3 contract with CAKE token, NFT position manager, and WETH addresses. ```solidity constructor(contract IERC20 _CAKE, contract INonfungiblePositionManager _nonfungiblePositionManager, address _WETH) public ``` -------------------------------- ### Get Amount0 for Liquidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/libraries/LiquidityAmounts.md Computes the amount of token0 corresponding to a given amount of liquidity within a specified price range. ```Solidity function getAmount0ForLiquidity(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity) internal pure returns (uint256 amount0) ``` -------------------------------- ### tokenURI Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/NonfungiblePositionManager.md Retrieves the token URI for a given token ID, which can be used to get metadata for the NFT representing the V3 position. ```APIDOC ## tokenURI ### Description Returns the token URI for a given token ID. ### Method `public view` ### Endpoint `tokenURI(uint256 tokenId)` ### Parameters #### Path Parameters - **tokenId** (uint256) - Required - The ID of the token ``` -------------------------------- ### Import and Deploy Factory Bytecode Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/README.md Import the factory ABI and bytecode from the npm package for local deployment. This ensures interoperability with mainnet deployments. ```typescript import { abi as FACTORY_ABI, bytecode as FACTORY_BYTECODE, } from '@pancakeswap/v3-core/artifacts/contracts/PancakeV3Factory.sol/PancakeV3Factory.json' // deploy the bytecode ``` -------------------------------- ### deploy Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/IPancakeV3PoolDeployer.md Deploys a new Pancake V3 pool with the specified parameters. This method returns the address of the newly created pool. ```APIDOC ## deploy ### Description Deploys a new Pancake V3 pool with the specified parameters. ### Method `deploy` ### Parameters - **factory** (address) - The factory address - **token0** (address) - The first token of the pool by address sort order - **token1** (address) - The second token of the pool by address sort order - **fee** (uint24) - The fee collected upon every swap in the pool, denominated in hundredths of a bip - **tickSpacing** (int24) - The minimum number of ticks between initialized ticks ### Returns - **pool** (address) - The address of the newly created pool ``` -------------------------------- ### Get Deployer Address Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/interfaces/IPeripheryImmutableState.md Returns the address of the PancakeSwap V3 deployer. Use this function to retrieve the deployer's address. ```solidity function deployer() external view returns (address) ``` -------------------------------- ### PairFlash Constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/examples/PairFlash.md Initializes the PairFlash contract with essential router and factory addresses. ```Solidity constructor(contract ISwapRouter _swapRouter, address _deployer, address _factory, address _WETH9) public ``` -------------------------------- ### Get Token Balance of Owner Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/Enumerable.md Returns the total number of tokens owned by a specific address. This is a standard ERC721 function. ```solidity function balanceOf(address owner) public view returns (uint256) ``` -------------------------------- ### Initialize Function Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/OracleTest.md Initializes the OracleTest contract using the provided InitializeParams. This function is external. ```solidity function initialize(struct OracleTest.InitializeParams params) external ``` -------------------------------- ### Retrieve Minted Random Position Parameters (E2E_mint_burn) Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/_audits/tob/README.md Use JavaScript to first retrieve pool initialization parameters, then use those to retrieve the parameters of a randomly created position for a given mint amount (seed). ```javascript const poolInitParams = await E2E_mint_burn.viewInitRandomPoolParams('') const positionParams = await E2E_mint_burn.viewMintRandomNewPosition( '', poolInitParams.tickSpacing, poolInitParams.tickCount, poolInitParams.maxTick ) console.log(positionParams) ``` -------------------------------- ### getBlockStartingTickAndLiquidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/libraries/OracleLibrary.md Given a pool, it returns the tick value as of the start of the current block. This is useful for block-specific calculations or state tracking. ```APIDOC ## getBlockStartingTickAndLiquidity ### Description Given a pool, it returns the tick value as of the start of the current block. ### Method `internal view` ### Parameters #### Path Parameters - **pool** (address) - Required - Address of PancakeSwap V3 pool #### Return Values - **[0]** (int24) - The tick that the pool was in at the start of the current block - **[1]** (uint128) - ``` -------------------------------- ### Get Latest Period Info Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-lm-pool/docs/index.md Retrieves the current reward rate and the end time of the current reward period for a V3 pool. ```solidity function getLatestPeriodInfo(address _v3Pool) external view returns (uint256 cakePerSecond, uint256 endTime) ``` -------------------------------- ### deploy Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/interfaces/ILMPoolDeployer.md Deploys a new LM pool associated with a given Pancake V3 pool. ```APIDOC ## deploy ### Description Deploys a new LM pool and returns a reference to it. This function is intended to be called by users to create new liquidity mining pools. ### Method external ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **pool** (IPancakeV3Pool) - The Pancake V3 pool to associate the new LM pool with. ### Request Example None ### Response #### Success Response (200) * **lmPool** (ILMPool) - A reference to the newly deployed LM pool. ``` -------------------------------- ### Get Gas Cost of Consult Function Signature Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/OracleTest.md Signature for the getGasCostOfConsult function, used to estimate the gas cost of the consult function. ```solidity function getGasCostOfConsult(address pool, uint32 period) public view returns (uint256) ``` -------------------------------- ### exactOutput Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/SwapRouter.md Executes a swap to obtain a specific output amount by spending the minimum possible input amount along a defined path of token pairs (reversed). ```APIDOC ## exactOutput ### Description Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed). ### Function Signature ```solidity function exactOutput(struct ISwapRouter.ExactOutputParams params) external payable returns (uint256 amountIn) ``` ### Parameters #### Path Parameters - **params** (struct ISwapRouter.ExactOutputParams) - Required - The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata ### Return Values #### Success Response (200) - **amountIn** (uint256) - The amount of the input token ``` -------------------------------- ### Get Gas Cost of Base64 Encoding Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/test/Base64Test.md Calculates the gas cost for encoding a given bytes input to Base64. This is a view function. ```Solidity function getGasCostOfEncode(bytes data) external view returns (uint256) ``` -------------------------------- ### ExactOutputSingle Swap Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/SwapRouter.md Executes a swap to obtain a specific output amount of a token, minimizing the input amount required in a single hop. ```solidity function exactOutputSingle(struct ISwapRouter.ExactOutputSingleParams params) external payable returns (uint256 amountIn) ``` -------------------------------- ### PancakeV3Pool Fee Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3Pool.md Gets the pool's fee, expressed in hundredths of a bip (1e-6). This value determines the trading fee percentage. ```solidity uint24 fee ``` -------------------------------- ### PancakeV3Pool Methods Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3Pool.md Provides documentation for key methods of the PancakeV3Pool contract, including slot0, ticks, positions, observations, and lmPool. ```APIDOC ## PancakeV3Pool Methods ### slot0 #### Description Returns the 0th storage slot in the pool, which stores many values and is exposed as a single method to save gas when accessed externally. #### Return Values - **Slot0** (struct) - The Slot0 struct containing pool state information. ### ticks #### Description Look up information about a specific tick in the pool. #### Parameters - **tick** (int24) - The tick to query. #### Return Values - **Info** (struct) - Information about the specified tick. ### tickBitmap #### Description Returns 256 packed tick initialized boolean values. See TickBitmap for more information. #### Parameters - **word** (int16) - The word index to query. #### Return Values - **tickWord** (uint256) - A 256-bit integer representing the initialized ticks in the specified word. ### positions #### Description Returns the information about a position by the position's key. #### Parameters - **key** (bytes32) - The key of the position. #### Return Values - **Info** (struct) - Information about the specified position. ### observations #### Description Returns data about a specific observation index. You most likely want to use #observe() instead of this method to get an observation as of some amount of time ago, rather than at a specific index in the array. #### Parameters - **index** (uint16) - The index of the observation to retrieve. #### Return Values - **Observation** (struct) - The observation data at the specified index. ### lmPool #### Description Returns the address of the liquidity mining pool associated with this pool. ``` -------------------------------- ### V3Migrator Constructor Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-periphery/docs/V3Migrator.md Initializes the V3Migrator contract with necessary addresses. ```solidity constructor(address _deployer, address _factory, address _WETH9, address _nonfungiblePositionManager) public ``` -------------------------------- ### Get Current Liquidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/interfaces/pool/IPancakeV3PoolState.md Returns the currently available in-range liquidity for the pool. This value is not related to the total liquidity across all ticks. ```solidity function liquidity() external view returns (uint128) ``` -------------------------------- ### InitializeParams Structure Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/test/OracleTest.md Defines the parameters required for initializing the OracleTest contract. Includes time, tick, and liquidity. ```solidity struct InitializeParams { uint32 time; int24 tick; uint128 liquidity; } ``` -------------------------------- ### Run Echidna Tests Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/_audits/tob/README.md Execute end-to-end tests using Echidna for different contract configurations. Ensure Echidna 1.7.0 is installed. ```bash echidna-test contracts/crytic/echidna/E2E_swap.sol --config contracts/crytic/echidna/E2E_swap.config.yaml --contract E2E_swap echidna-test contracts/crytic/echidna/E2E_mint_burn.sol --config contracts/crytic/echidna/E2E_mint_burn.config.yaml --contract E2E_mint_burn echidna-test contracts/crytic/echidna/Other.sol --config contracts/crytic/echidna/Other.config.yaml --contract Other ``` -------------------------------- ### Import PancakeSwap V3 Pool Interface in Solidity Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/README.md Import the IPancakeV3Pool interface from the npm artifact into your Solidity smart contracts. This allows interaction with V3 pools. ```solidity import '@pancakeswap/v3-core/contracts/interfaces/IPancakeV3Pool.sol'; contract MyContract { IPancakeV3Pool pool; function doSomethingWithPool() { // pool.swap(...); } } ``` -------------------------------- ### Receive ETH Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/masterchef-v3/docs/MasterChefV3.md Fallback function to receive ETH. ```solidity receive() external payable ``` -------------------------------- ### PancakeV3PoolDeployer deploy Function Source: https://github.com/pancakeswap/pancake-v3-contracts/blob/main/projects/v3-core/docs/PancakeV3PoolDeployer.md Deploys a new V3 pool with the specified factory, token, fee, and tick spacing. It transiently sets parameters before deployment and clears them afterward. ```solidity function deploy(address factory, address token0, address token1, uint24 fee, int24 tickSpacing) external returns (address pool) ```