KeeperFeePayer.sol
KeeperFeePayer
A contract that pays keeper fees using a Uniswap router.
factory
contract IChromaticMarketFactory factory
uniswapRouter
contract ISwapRouter uniswapRouter
WETH9
contract IWETH9 WETH9
OnlyAccessableByDao
error OnlyAccessableByDao()
Throws an error indicating that the caller is not the DAO.
OnlyAccessableByFactoryOrDao
error OnlyAccessableByFactoryOrDao()
Throws an error indicating that the caller is nether the chormatic factory contract nor the DAO.
KeeperFeeTransferFailure
error KeeperFeeTransferFailure()
Throws an error indicating that the transfer of keeper fee has failed.
InvalidSwapValue
error InvalidSwapValue()
Throws an error indicating that the swap value for the Uniswap trade is invalid.
onlyDao
modifier onlyDao()
Modifier to restrict access to only the DAO.
Throws an OnlyAccessableByDao
error if the caller is not the DAO.
onlyFactoryOrDao
modifier onlyFactoryOrDao()
Modifier to restrict access to only the factory or the DAO.
Throws an OnlyAccessableByFactoryOrDao
error if the caller is nether the chormatic factory contract nor the DAO.
constructor
constructor(contract IChromaticMarketFactory _factory, contract ISwapRouter _uniswapRouter, contract IWETH9 _weth) public
Constructor function.
Parameters:
Name Type Description _factory contract IChromaticMarketFactory The address of the ChromaticMarketFactory contract. _uniswapRouter contract ISwapRouter The address of the Uniswap router contract. _weth contract IWETH9 The address of the WETH9 contract.
setRouter
function setRouter(contract ISwapRouter _uniswapRouter) public
Only the DAO can call this function.
Sets the Uniswap router address.
Parameters:
Name Type Description _uniswapRouter contract ISwapRouter The address of the Uniswap router contract.
approveToRouter
function approveToRouter(address token, bool approve) external
Approves or revokes approval to the Uniswap router for a given token.
Only the factory or the DAO can call this function.
Parameters:
Name Type Description token address The address of the token. approve bool A boolean indicating whether to approve or revoke approval.
payKeeperFee
function payKeeperFee(address tokenIn, uint256 amountOut, address keeperAddress) external returns (uint256 amountIn)
Pays the keeper fee using Uniswap swaps.
Throws a KeeperFeeTransferFailure
error if the transfer of ETH to the keeper address fails.
Throws an InvalidSwapValue
error if the remaining balance of the input token after the swap is insufficient.
Parameters:
Name Type Description tokenIn address The address of the token being swapped. amountOut uint256 The desired amount of output tokens. keeperAddress address The address of the keeper to receive the fee. Return Values:
Name Type Description amountIn uint256 The actual amount of input tokens used for the swap.
swapExactOutput
function swapExactOutput(address tokenIn, address recipient, uint256 amountOut, uint256 amountInMaximum) internal returns (uint256 amountIn)
Executes a Uniswap swap with exact output amount.
Parameters:
Name Type Description tokenIn address The address of the input token. recipient address The address that will receive the output tokens. amountOut uint256 The desired amount of output tokens. amountInMaximum uint256 The maximum amount of input tokens allowed for the swap. Return Values:
Name Type Description amountIn uint256 The actual amount of input tokens used for the swap.
receive
receive() external payable
Fallback function to receive ETH payments.
fallback
fallback() external payable
Fallback function to receive ETH payments.