// SPDX-License-Identifier: MIT pragma solidity =0.8.18; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol"; /** * @title SOMA Swap Pair contract. * @author SOMA.finance * @notice Interface for the {SomaSwapPair} contract. */ interface ISomaSwapPair is IERC20Upgradeable, IERC20PermitUpgradeable { /** * @notice Emitted when `sender` adds liquidity of `amount0` token0 and `amount1` token1. * @param sender The address of the message sender. * @param amount0 The amount of amount0 added as liquidity. * @param amount1 The amount of amount1 added as liquidity. */ event Mint(address indexed sender, uint256 amount0, uint256 amount1); /** * @notice Emitted when `sender` removes liquidity of `amount0` token0 and `amount1` token1. * @param sender The address of the message sender. * @param amount0 The address of amount0 removed as liquidity. * @param amount1 The address of amount1 removed as liquidity. * @param to The address where the underlying liquidity gets sent to. */ event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); /** * @notice Emitted when `sender` swaps `amount0Out` token0 and `amount1Out` token1. * @param sender The address of the message sender. * @param amount0In The amount of token0 sent into the contract from message sender. * @param amount1In The amount of token1 sent into the contract from message sender. * @param amount0Out The amount of token0 received by the message sender. * @param amount1Out The amount of token1 received by the message sender. * @param to The address receiving the swapped tokens. */ event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); /** * @notice Emitted when the reserves are set to match the balances of the contract. * @param reserve0 The updated amount of reserve0. * @param reserve1 The updated amount of reserve1. */ event Sync(uint112 reserve0, uint112 reserve1); /** * @notice Returns the minimum liquidity for the pair. * @dev Returns `10**3`. */ function MINIMUM_LIQUIDITY() external pure returns (uint256); /** * @notice Returns the address of the SOMA Swap Factory. */ function factory() external view returns (address); /** * @notice Returns the address of token0 of the pair. */ function token0() external view returns (address); /** * @notice Returns the address of token1 of the pair. */ function token1() external view returns (address); /** * @notice Returns the reserves of token0 and token1, and the block timestamp from the latest pair interaction. * @return _reserve0 The reserve of token0. * @return _reserve1 The reserve of token1. * @return _blockTimestampLast The latest block timestamp of a pair interaction. */ function getReserves() external view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast); /** * @notice Returns the price of token0 denominated in token1. */ function price0CumulativeLast() external view returns (uint256); /** * @notice Returns the price of token1 denominated in token0. */ function price1CumulativeLast() external view returns (uint256); /** * @notice Returns product of the reserves as of the latest liquidity event. */ function kLast() external view returns (uint256); /** * @notice Creates pool tokens. * @param to The address to receive the minted tokens. * @custom:emits Mint * @custom:requirement The liquidity of `token0` and `token1` must both be greater than zero. * @custom:requirement SomaSwap must not be locked. * @return liquidity The liquidity of the pair. */ function mint(address to) external returns (uint256 liquidity); /** * @notice Burns pool tokens. * @param to The address to receive the underlying liquidity. * @custom:emits Burn * @custom:requirement The liquidity of `token0` and `token1` must both be greater than zero. * @custom:requirement SomaSwap must not be locked. * @return amount0 The amount of liquidity in token0 redeemed. * @return amount1 The amount of liquidity in token1 redeemed. */ function burn(address to) external returns (uint256 amount0, uint256 amount1); /** * @notice Tries to perform a swap. * @param amount0Out The amount of token0 to be swapped. * @param amount1Out The amount of token1 to be swapped. * @param to The address to receive the swapped tokens. * @param data Miscalaneous data associated with the swap. * @custom:requirement `amount0Out` and `amount1In` must be greater than zero. * @custom:requirement `amount0Out` must be less than `reserve0`. * @custom:requirement `amount1In` must be less than `reserve1`. * @custom:requirement `to` must not be equal to `token0` or `token1`. * @custom:requirement SomaSwap must not be locked. * @custom:requirement The function caller must have the required privileges to swap. */ function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external; /** * @notice Transfers the difference between the reserves and the balance of the contract to `to`. * @param to The address to receive the skimmed tokens. * @custom:emits Skim * @custom:requirement SomaSwap must not be locked. */ function skim(address to) external; /** * @notice Syncing the reserves to the current balances of token0 and token1. * @custom:emits Sync * @custom:requirement SomaSwap must not be locked. */ function sync() external; /** * @notice Initializer for the contract. * @param _token0 The address of token0. * @param _token1 The address of token1. */ function initialize(address _token0, address _token1) external; }