Skip to main content

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:

    NameTypeDescription
    _factorycontract IChromaticMarketFactoryThe address of the ChromaticMarketFactory contract.
    _uniswapRoutercontract ISwapRouterThe address of the Uniswap router contract.
    _wethcontract IWETH9The 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:

    NameTypeDescription
    _uniswapRoutercontract ISwapRouterThe 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:

    NameTypeDescription
    tokenaddressThe address of the token.
    approveboolA 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:

    NameTypeDescription
    tokenInaddressThe address of the token being swapped.
    amountOutuint256The desired amount of output tokens.
    keeperAddressaddressThe address of the keeper to receive the fee.
  • Return Values:

    NameTypeDescription
    amountInuint256The 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:

    NameTypeDescription
    tokenInaddressThe address of the input token.
    recipientaddressThe address that will receive the output tokens.
    amountOutuint256The desired amount of output tokens.
    amountInMaximumuint256The maximum amount of input tokens allowed for the swap.
  • Return Values:

    NameTypeDescription
    amountInuint256The 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.