### Swap Function Example Usage Source: https://docs.syncswap.xyz/syncswap-technical-docs/aqua-pool/pool-contract An example demonstrating how to initiate a swap by encoding the necessary data and calling the `swap` function. Ensure the `_data` parameter is correctly encoded with token addresses and withdrawal mode. ```solidity // Example of initiating a swap bytes memory data = abi.encode(tokenA, recipient, 0); TokenAmount memory output = cryptoPool.swap(data, msg.sender, address(0), ""); ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.syncswap.xyz/syncswap/resources Perform an HTTP GET request on a documentation URL with the 'ask' query parameter to dynamically query for additional information. The question should be specific and self-contained. ```HTTP GET https://docs.syncswap.xyz/syncswap/resources.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/resources/miscellaneous To get information not directly on the page, perform an HTTP GET request with the `ask` query parameter. The question should be specific and self-contained. Use this for clarification or to retrieve related documentation. ```HTTP GET https://docs.syncswap.xyz/syncswap/resources/miscellaneous.md?ask= ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/protocol-overview/paymaster To get additional information not directly present on the page, perform an HTTP GET request with the 'ask' query parameter. The question should be specific and self-contained. ```http GET https://docs.syncswap.xyz/syncswap/protocol-overview/paymaster.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-factory To get information not explicitly present on a page, perform an HTTP GET request to the page URL with the 'ask' query parameter. The question should be specific and self-contained. The response will include a direct answer and relevant excerpts. ```bash GET https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-factory.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/resources/brand-kit Perform an HTTP GET request to query the documentation dynamically. Use the 'ask' query parameter with a specific, self-contained question in natural language to get direct answers and relevant excerpts. ```http GET https://docs.syncswap.xyz/syncswap/resources/brand-kit.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/integration/swapbox To get additional information not present on the current page, perform an HTTP GET request to the page URL with the `ask` query parameter. The question should be specific and self-contained. ```http GET https://docs.syncswap.xyz/syncswap/integration/swapbox.md?ask= ``` -------------------------------- ### Get Epoch Start Time - Fee Recipient Source: https://docs.syncswap.xyz/syncswap-technical-docs/fee-manager/contract-details Calculates and returns the start timestamp of the current epoch based on a given timestamp and the contract's epoch duration. ```solidity epochStart = feeRecipient.getEpochStart(block.timestamp); // Returns the start time of the epoch for the given timestamp. >>> 1625097600 ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract To get additional information not directly present on the page, perform an HTTP GET request to the page URL with the `ask` query parameter. The question should be specific and self-contained. This mechanism is useful for clarifications, additional context, or retrieving related documentation sections. ```http GET https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract.md?ask= ``` -------------------------------- ### Example Usage: Creating a New Classic Pool Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-factory Demonstrates the typical steps to create a new Classic Pool: initializing the factory, encoding token pair data, and calling the `createPool` function. ```Solidity address poolMaster = 0x0000000000000000000000000000000000000000; SyncSwapClassicPoolFactory factory = new SyncSwapClassicPoolFactory(poolMaster); address tokenA = 0x0000000000000000000000000000000000000000; address tokenB = 0x0000000000000000000000000000000000000000; bytes memory data = abi.encode(tokenA, tokenB); address newPool = factory.createPool(data); // The new pool is now created and registered with the Pool Master. ``` -------------------------------- ### Get Deployment Data for Pool Creation Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-factory Returns the deployment data for the pool that is currently being created. ```Solidity function getDeployData() external view override returns (bytes memory deployData) { deployData = cachedDeployData; } ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.syncswap.xyz/syncswap-technical-docs/stable-pool/pool-factory Demonstrates how to query the documentation dynamically by appending an 'ask' query parameter to the page URL. This is useful for retrieving specific information not explicitly present on the page. ```http GET https://docs.syncswap.xyz/syncswap-technical-docs/stable-pool/pool-factory.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/resources/community Use this GET request to query documentation dynamically when information is not explicitly present. Include your question as the value for the 'ask' query parameter. ```http GET https://docs.syncswap.xyz/syncswap/resources/community.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/overview Use this HTTP GET request to query the documentation dynamically with a specific question. The response includes direct answers and relevant excerpts. ```http GET https://docs.syncswap.xyz/syncswap/overview.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/features Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific and self-contained. Use this mechanism when the answer is not explicitly present or you need clarification. ```http GET https://docs.syncswap.xyz/syncswap/features.md?ask= ``` -------------------------------- ### Get Pool Assets Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Retrieves an array containing the addresses of both assets in the pool. Use to get a list of the pool's supported tokens. ```Solidity address[] memory assets = pool.getAssets(); // Returns an array containing the addresses of the pool's assets. >>> [0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000] ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.syncswap.xyz/syncswap/resources/partnership Use this mechanism to query documentation dynamically when information is not explicitly present. The question should be specific and self-contained. ```http GET https://docs.syncswap.xyz/syncswap/resources/partnership.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/protocol-overview/portfolio Perform an HTTP GET request to query documentation dynamically. Use the `ask` query parameter with a specific, self-contained question in natural language. ```http GET https://docs.syncswap.xyz/syncswap/protocol-overview/portfolio.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/protocol-overview/token-conversion Perform an HTTP GET request to query documentation dynamically. Use this when the answer is not explicitly present, for clarification, or to retrieve related sections. ```HTTP GET https://docs.syncswap.xyz/syncswap/protocol-overview/token-conversion.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.syncswap.xyz/syncswap/resources/legal-disclaimer Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific, self-contained, and written in natural language. ```HTTP GET https://docs.syncswap.xyz/syncswap/resources/legal-disclaimer.md?ask= ``` -------------------------------- ### Get XCP Profit Source: https://docs.syncswap.xyz/syncswap-technical-docs/aqua-pool/pool-contract Fetches the current profit of the pool. This is used in calculations for adjusting liquidity and understanding gains. ```solidity uint xcpProfit = pool.xcpProfit(); ``` -------------------------------- ### Get Protocol Fee - Fee Manager Source: https://docs.syncswap.xyz/syncswap-technical-docs/fee-manager/contract-details Retrieves the protocol fee percentage for a specified pool. ```solidity rotocolFee = feeManager.getProtocolFee(poolAddress); // Returns the protocol fee for the given pool. >>> 30000 ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.syncswap.xyz/syncswap/integration Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. The question should be specific, self-contained, and written in natural language. ```http GET https://docs.syncswap.xyz/syncswap/integration.md?ask= ``` -------------------------------- ### Burn LP tokens and swap for a single token Source: https://docs.syncswap.xyz/syncswap-technical-docs/stable-pool/pool-contract Use this function to burn LP tokens and swap one of the output tokens for another, resulting in a single token received by the user. Ensure `data` is encoded correctly with `token0`, `userAddress`, and `0`. No callback is used in this example. ```solidity bytes memory data = abi.encode(token0, userAddress, 0); // Encode the burn single data address sender = userAddress; // The address of the user initiating the burn address callback = address(0); // No callback in this example bytes memory callbackData = ""; // No callback data TokenAmount memory tokenAmount = pool.burnSingle(data, sender, callback, callbackData); // Returns the amount of tokens received after the swap and burn as a TokenAmount struct. >>> TokenAmount { token: 0x1234567890abcdef1234567890abcdef12345678, amount: 1500 } ``` -------------------------------- ### Get Swap Fee for a Pool Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-factory Returns the swap fee for a given pool and token pair by querying the Pool Master. ```Solidity function getSwapFee( address pool, address sender, address tokenIn, address tokenOut, bytes calldata data ) external view override returns (uint24 swapFee) { swapFee = IPoolMaster(master).getSwapFee(pool, sender, tokenIn, tokenOut, data); } ``` -------------------------------- ### Get Amplification Coefficient Source: https://docs.syncswap.xyz/syncswap-technical-docs/stable-pool/pool-contract Retrieves the current amplification coefficient (A) of the pool. This value influences the pool's pricing mechanism. ```Solidity uint64 amplificationCoefficient = pool.getA(); // Returns the current amplification coefficient of the pool. >>> 2000 ``` -------------------------------- ### Get Pool Parameters Source: https://docs.syncswap.xyz/syncswap-technical-docs/aqua-pool/pool-contract Retrieves the `PoolParams` struct, which contains all current pool parameters related to amplification and gamma ramping. This helps in understanding the pool's dynamic pricing configuration. ```solidity PoolParams memory params = pool.poolParams(); ``` -------------------------------- ### Get Fees for Epoch and Token - Fee Recipient Source: https://docs.syncswap.xyz/syncswap-technical-docs/fee-manager/contract-details Retrieves the total fees recorded for a specific token within a given epoch. ```solidity feeRecipient.fees(epoch, tokenAddress); // Returns the total fees recorded for the given token in the specified epoch. >>> 5000 ``` -------------------------------- ### Get Price Scale Source: https://docs.syncswap.xyz/syncswap-technical-docs/aqua-pool/pool-contract Retrieves the current price scale of the pool. This value influences the price band around which liquidity is concentrated. ```solidity uint priceScale = pool.priceScale(); ``` -------------------------------- ### Get Fees By Pool - Fee Registry V2 Source: https://docs.syncswap.xyz/syncswap-technical-docs/fee-manager/contract-details Retrieves an array of all fee amounts associated with a specific pool address. ```solidity uint256[] memory fees = feeRegistryV2.getFeesByPool(poolAddress); // Returns all fees associated with the given pool. >>> [1000, 2000] ``` -------------------------------- ### Get Swap Fee - Fee Manager Source: https://docs.syncswap.xyz/syncswap-technical-docs/fee-manager/contract-details Returns the calculated swap fee for a given pool, sender, and token pair. Requires pool, sender, and token addresses, along with additional data. ```solidity feeManager.getSwapFee(poolAddress, senderAddress, tokenInAddress, tokenOutAddress, data); // Returns the swap fee for the given parameters. >>> 290 ``` -------------------------------- ### Get Pool Reserves Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Retrieves the current reserve amounts for both tokens in the pool. Use to get a snapshot of the pool's liquidity. ```Solidity (uint reserve0, uint reserve1) = pool.getReserves(); // Returns the reserve amount of the first token and the second token in the pool. >>> (0x0, 0x0) ``` -------------------------------- ### Get wETH Contract Address Source: https://docs.syncswap.xyz/syncswap-technical-docs/vault/overview Use this function to retrieve the address of the wETH contract. ```solidity // Returns address of the wETH contract. function wETH() external view returns (address); ``` -------------------------------- ### Get Token1 Address Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Retrieves the address of the second token in the pool. Use when you need to identify the second asset. ```Solidity address secondToken = pool.token1(); // Returns the address of the second token in the pool. >>> 0x0000000000000000000000000000000000000000 ``` -------------------------------- ### Get Token0 Address Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Retrieves the address of the first token in the pool. Use when you need to identify the first asset. ```Solidity address firstToken = pool.token0(); // Returns the address of the first token in the pool. >>> 0x0000000000000000000000000000000000000000 ``` -------------------------------- ### constructor Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-factory Initializes the Classic Pool Factory with the address of the Pool Master contract. ```APIDOC ## constructor ### Description Initializes the Classic Pool Factory with the address of the Pool Master contract. ### Parameters * `_master` (address) - The address of the Pool Master contract. ``` -------------------------------- ### Get Fee Amount - Fee Registry V2 Source: https://docs.syncswap.xyz/syncswap-technical-docs/fee-manager/contract-details Retrieves the fee amount associated with a given pool address. ```solidity feeAmount = feeRegistryV2.getFee(poolAddress); // Returns the fee amount for the given pool. >>> 1000 ``` -------------------------------- ### Get Fee Recipient Address - Fee Manager Source: https://docs.syncswap.xyz/syncswap-technical-docs/fee-manager/contract-details Fetches the current address designated to receive protocol fees. ```solidity address recipient = feeManager.getFeeRecipient(); // Returns the current fee recipient address. >>> 0x1234567890abcdef1234567890abcdef12345678 ``` -------------------------------- ### Get Reserve1 Amount Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Retrieves the reserve amount of the second token in the pool. Use to check the balance of the second asset. ```Solidity uint reserveSecondToken = pool.reserve1(); // Returns the reserve amount of the second token in the pool. >>> 0x0 ``` -------------------------------- ### Calculate Output Amount for Swap Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Calculates the expected output amount for a given input amount in a swap. Requires the input token address, input amount, and sender address. ```Solidity address tokenIn = token0; uint amountIn = 1000; address sender = userAddress; uint amountOut = pool.getAmountOut(tokenIn, amountIn, sender); // Returns the amount of output tokens for the given input amount. >>> 0 ``` -------------------------------- ### Balancer Style Flash Loan Interface (Solidity) Source: https://docs.syncswap.xyz/syncswap-technical-docs/vault/overview Enables multiple flash loans simultaneously. Requires sorted token addresses and forwards user data to the recipient. ```solidity interface IFlashLoan { // Balancer style multiple flashloan /** * @dev Performs a 'flash loan', sending tokens to `recipient`, executing the `receiveFlashLoan` hook on it, * and then reverting unless the tokens plus a proportional protocol fee have been returned. * * The `tokens` and `amounts` arrays must have the same length, and each entry in these indicates the loan amount * for each token contract. `tokens` must be sorted in ascending order. * * The 'userData' field is ignored by the Vault, and forwarded as-is to `recipient` as part of the * `receiveFlashLoan` call. * * Emits `FlashLoan` events. */ function flashLoanMultiple( IFlashLoanRecipient recipient, address[] memory tokens, uint[] memory amounts, bytes memory userData ) external; // EIP-3156 style flashloan /** * @dev The amount of currency available to be lent. * @param token The loan currency. * @return The amount of `token` that can be borrowed. */ // Returns ` IERC20(token).balanceOf(address(this))` function maxFlashLoan(address token) external view returns (uint256); /** * @dev The fee to be charged for a given loan. * @param amount The amount of tokens lent. * @return The amount of `token` to be charged for the loan, on top of the returned principal. */ // Returns `amount * flashLoanFeePercentage / 1e18` function flashFee(address token, uint256 amount) external view returns (uint256); /** * @dev Initiate a flash loan. * @param receiver The receiver of the tokens in the loan, and the receiver of the callback. * @param token The loan currency. * @param amount The amount of tokens lent. * @param userData Arbitrary data structure, intended to contain user-defined parameters. */ function flashLoan( IERC3156FlashBorrower receiver, address token, uint amount, bytes memory userData ) external returns (bool); // The fee percentage is in 18 decimals. // Fees will be applied to the surplus balance (postLoanBalance - preLoanBalance). function flashLoanFeePercentage() external view returns (uint); /** * @dev Emitted for each individual flash loan performed by `flashLoan`. */ event FlashLoan (IFlashLoanRecipient indexed recipient, address indexed token, uint amount, uint feeAmount); } ``` -------------------------------- ### Get Reserve0 Amount Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Retrieves the reserve amount of the first token in the pool. Use to check the balance of the first asset. ```Solidity uint reserveFirstToken = pool.reserve0(); // Returns the reserve amount of the first token in the pool. >>> 0x0 ``` -------------------------------- ### Swap Methods Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Methods for performing token swaps within the pool. ```APIDOC ## swap ### Description Swaps one token for another within the pool. Calculates the output amount based on input, reserves, and fees, then updates reserves. ### Method `swap(bytes data, address sender, address callback, bytes memory callbackData)` ### Parameters - **data** (bytes) - Encoded swap parameters. - **sender** (address) - The address initiating the swap. - **callback** (address) - The callback address. - **callbackData** (bytes memory) - Data for the callback. ### Response - **TokenAmount** - A struct containing the token address and amount received after the swap. ``` ```APIDOC ## getAmountOut ### Description Calculates the amount of output tokens received for a given input amount. ### Method `getAmountOut(address tokenIn, uint amountIn, address sender)` ### Parameters - **tokenIn** (address) - The address of the input token. - **amountIn** (uint) - The amount of input tokens. - **sender** (address) - The address initiating the calculation. ### Response - **uint** - The calculated amount of output tokens. ``` -------------------------------- ### Constructor for Classic Pool Factory Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-factory Initializes the Classic Pool Factory with the address of the Pool Master contract. ```Solidity constructor(address _master) BasePoolFactory(_master) { } ``` -------------------------------- ### Calculate Swap Output Amount Source: https://docs.syncswap.xyz/syncswap-technical-docs/stable-pool/pool-contract Calculates the expected amount of output tokens for a given input token and amount, considering the pool's current state. Requires the input token address, amount, and sender address. ```Solidity address tokenIn = token0; uint amountIn = 1000; address sender = userAddress; uint amountOut = pool.getAmountOut(tokenIn, amountIn, sender); // Returns the amount of output tokens for the given input amount. >>> 990 ``` -------------------------------- ### Get Swap Fee Hook Address - Fee Manager Source: https://docs.syncswap.xyz/syncswap-technical-docs/fee-manager/contract-details Retrieves the address of the current swap fee hook, which can modify fee calculations. ```solidity saddress hook = feeManager.getSwapFeeHook(); // Returns the current swap fee hook address. >>> 0xabcdef1234567890abcdef1234567890abcdef12 ``` -------------------------------- ### createPool Source: https://docs.syncswap.xyz/syncswap-technical-docs/stable-pool/pool-factory Creates a new pool with the provided data and registers it with the Pool Master. It handles token validation, sorting, and pool deployment. ```APIDOC ## createPool ### Description Creates a new pool with the provided data and registers it with the Pool Master. It handles token validation, sorting, and pool deployment. ### Method `createPool(bytes calldata data)` ### Parameters #### Request Body - **data** (bytes) - Required - Encoded data containing the addresses of the two tokens for the pool. ### Request Example ```json { "data": "0x..." } ``` ### Response #### Success Response (200) - **pool** (address) - The address of the newly created pool. #### Response Example ```json { "pool": "0x..." } ``` ``` -------------------------------- ### Create and Register a New Classic Pool Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-factory Creates a new pool with the provided data, performs safety checks, sorts tokens, and registers it with the Pool Master. Emits a PoolCreated event upon successful creation. ```Solidity function createPool(bytes calldata data) external override returns (address pool) { (address tokenA, address tokenB) = abi.decode(data, (address, address)); // Perform safety checks. if (tokenA == tokenB) { revert InvalidTokens(); } // Sort tokens. if (tokenB < tokenA) { (tokenA, tokenB) = (tokenB, tokenA); } if (tokenA == address(0)) { revert InvalidTokens(); } // Underlying implementation to deploy the pools and register them. pool = _createPool(tokenA, tokenB); // Populate mapping in both directions. getPool[tokenA][tokenB] = pool; getPool[tokenB][tokenA] = pool; emit PoolCreated(tokenA, tokenB, pool); } ``` -------------------------------- ### Info Methods Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Methods to retrieve information about the pool, such as token addresses and reserves. ```APIDOC ## token0 ### Description Returns the address of the first token in the pool. ### Method `token0()` ### Response - **address** - The address of the first token. ``` ```APIDOC ## token1 ### Description Returns the address of the second token in the pool. ### Method `token1()` ### Response - **address** - The address of the second token. ``` ```APIDOC ## reserve0 ### Description Returns the reserve of the first token in the pool. ### Method `reserve0()` ### Response - **uint** - The reserve amount of the first token. ``` ```APIDOC ## reserve1 ### Description Returns the reserve of the second token in the pool. ### Method `reserve1()` ### Response - **uint** - The reserve amount of the second token. ``` ```APIDOC ## getAssets ### Description Returns the addresses of the assets in the pool. ### Method `getAssets()` ### Response - **address[]** - An array containing the addresses of the pool's assets. ``` ```APIDOC ## getReserves ### Description Returns the current reserves of the tokens in the pool. ### Method `getReserves()` ### Response - **(uint reserve0, uint reserve1)** - A tuple containing the reserve amounts of the first and second tokens. ``` -------------------------------- ### Get Token Balance of an Account Source: https://docs.syncswap.xyz/syncswap-technical-docs/vault/overview Query the token balance of a specific account within the vault. Use `address(0)` or the wETH address for ETH balances. ```solidity // Returns token balance of the owner. // Use `address(0)` or wETH address for ETH balance. function balanceOf(address token, address owner) external view returns (uint balance); ``` -------------------------------- ### EIP-3156 Flash Loan Borrower Callback Interface (Solidity) Source: https://docs.syncswap.xyz/syncswap-technical-docs/vault/overview Defines the callback function for EIP-3156 style flash loans. It receives loan details and must return a specific hash upon successful execution. ```solidity // Callback for ERC3156 flashloan interface IERC3156FlashBorrower { /** * @dev Receive a flash loan. * @param initiator The initiator of the loan. * @param token The loan currency. * @param amount The amount of tokens lent. * @param fee The additional amount of tokens to repay. * @param data Arbitrary data structure, intended to contain user-defined parameters. * @return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan" */ function onFlashLoan( address initiator, address token, uint256 amount, uint256 fee, bytes calldata data ) external returns (bytes32); } ``` -------------------------------- ### Create New Stable Pool with SyncSwap Factory Source: https://docs.syncswap.xyz/syncswap-technical-docs/stable-pool/pool-factory Initializes the SyncSwap Stable Pool Factory and creates a new stable pool for a given token pair. Ensure the Pool Master address is correctly set and the token addresses are valid. ```solidity address poolMaster = 0x0000000000000000000000000000000000000000; SyncSwapStablePoolFactory factory = new SyncSwapStablePoolFactory(poolMaster); address tokenA = 0x0000000000000000000000000000000000000000; address tokenB = 0x0000000000000000000000000000000000000000; bytes memory data = abi.encode(tokenA, tokenB); address newPool = factory.createPool(data); // The new pool is now created and registered with the Pool Master. ``` -------------------------------- ### Fee Recipient Contract Functions Source: https://docs.syncswap.xyz/syncswap-technical-docs/fee-manager/contract-details Information on functions within the Fee Recipient contract for notifying fees, retrieving epoch start times, and querying recorded fees. ```APIDOC ## Fee Recipient ### `notifyFees` **Description**: Notifies the contract about a fee that needs to be recorded. **Usage**: `feeRecipient.notifyFees(senderAddress, tokenAddress, feeAmount, feeRate, data)` ### `getEpochStart` **Description**: Returns the start time of a given timestamp based on the epoch duration. **Usage**: `feeRecipient.getEpochStart(timestamp)` **Returns**: `number` (the epoch start time) ### `fees` **Description**: Returns the total fees recorded for a specific token within a specific epoch. **Usage**: `feeRecipient.fees(epoch, tokenAddress)` **Returns**: `number` (the total fees recorded) ``` -------------------------------- ### SyncSwap Vault Interface (Solidity) Source: https://docs.syncswap.xyz/syncswap-technical-docs/vault/overview Defines the core functionalities of the Vault, including asset management and flash loan capabilities. It inherits from IFlashLoan. ```solidity interface IVault is IFlashLoan { function wETH() external view returns (address); function reserves(address token) external view returns (uint reserve); function balanceOf(address token, address owner) external view returns (uint balance); function deposit(address token, address to) external payable returns (uint amount); function depositETH(address to) external payable returns (uint amount); function transferAndDeposit(address token, address to, uint amount) external payable; function transfer(address token, address to, uint amount) external; function withdraw(address token, address to, uint amount) external; function withdrawAlternative(address token, address to, uint amount, uint8 mode) external; function withdrawETH(address to, uint amount) external; } ``` -------------------------------- ### createPool Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-factory Creates a new pool with the provided data and registers it with the Pool Master. This is an external function. ```APIDOC ## createPool ### Description Creates a new pool with the provided data and registers it with the Pool Master. ### Method POST ### Endpoint /createPool ### Parameters #### Request Body * `data` (bytes calldata) - Encoded data containing the addresses of the two tokens (tokenA, tokenB). ### Returns * `pool` (address) - The address of the newly created pool. ### Events Emitted * `PoolCreated(address indexed token0, address indexed token1, address pool)` - Emitted when a new pool is created. ``` -------------------------------- ### Swap Event Definitions Source: https://docs.syncswap.xyz/syncswap-technical-docs/aqua-pool/pool-contract Defines the events emitted by the `swap` function to log swap-related activities. These events provide details about the transaction, including sender, tokens involved, amounts, and fees. ```solidity event Swapped( address indexed sender, address indexed user, address indexed tokenOut, uint amountIn, uint amountOut, uint24 swapFee, address to ); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); ``` -------------------------------- ### IFlashLoan Interface Source: https://docs.syncswap.xyz/syncswap-technical-docs/vault/overview The IFlashLoan interface defines methods for executing flash loans, including single-asset loans and multi-asset loans, along with functions to query maximum loan amounts and fees. ```APIDOC ## IFlashLoan Interface ### Description Defines methods for executing flash loans, including single-asset and multi-asset loans. ### Functions - `flashLoanMultiple(IFlashLoanRecipient recipient, address[] memory tokens, uint[] memory amounts, bytes memory userData)`: external - `maxFlashLoan(address token)`: external view returns (uint256) - `flashFee(address token, uint256 amount)`: external view returns (uint256) - `flashLoan(IERC3156FlashBorrower receiver, address token, uint amount, bytes memory userData)`: external returns (bool) - `flashLoanFeePercentage()`: external view returns (uint) ### Events - `FlashLoan(IFlashLoanRecipient indexed recipient, address indexed token, uint amount, uint feeAmount)` ``` -------------------------------- ### Burn LP Tokens and Swap Single Token Source: https://docs.syncswap.xyz/syncswap-technical-docs/classic-pool/pool-contract Use this function to burn LP tokens and simultaneously swap one of the output tokens for another, allowing you to receive a single token. Ensure the `data` is correctly encoded with `token0`, `userAddress`, and `0` for the burn single operation. Callbacks are optional and can be omitted by setting `callback` to `address(0)` and `callbackData` to an empty byte string. ```solidity bytes memory data = abi.encode(token0, userAddress, 0) // Encode the burn single data address sender = userAddress // The address of the user initiating the burn address callback = address(0) // No callback in this example bytes memory callbackData = "" // No callback data TokenAmount memory tokenAmount = pool.burnSingle(data, sender, callback, callbackData) // Returns the amount of tokens received after the swap and burn as a TokenAmount struct. >>> TokenAmount { token: 0x0000000000000000000000000000000000000000, amount: 0 } ``` -------------------------------- ### burnSingle Source: https://docs.syncswap.xyz/syncswap-technical-docs/stable-pool/pool-contract Burns LP tokens and swaps one of the output tokens for another, allowing the user to receive a single token. ```APIDOC ## burnSingle ### Description Burns LP tokens and swaps one of the output tokens for another, allowing the user to receive a single token. ### Method Signature `pool.burnSingle(bytes memory data, address sender, address callback, bytes memory callbackData)` ### Parameters - `data` (bytes memory) - Encoded data for the burn operation, typically including `token0`, `userAddress`, and a swap amount. - `sender` (address) - The address of the user initiating the burn. - `callback` (address) - The address of a callback contract (optional). - `callbackData` (bytes memory) - Data to be passed to the callback contract (optional). ### Returns - `TokenAmount` - A struct containing the `token` address and `amount` received after the swap and burn. ### Example Usage ```solidity bytes memory data = abi.encode(token0, userAddress, 0); // Encode the burn single data address sender = userAddress; // The address of the user initiating the burn address callback = address(0); // No callback in this example bytes memory callbackData = ""; // No callback data TokenAmount memory tokenAmount = pool.burnSingle(data, sender, callback, callbackData); // Returns the amount of tokens received after the swap and burn as a TokenAmount struct. // Example return: TokenAmount { token: 0x1234567890abcdef1234567890abcdef12345678, amount: 1500 } ``` ```