Skip to content
Verified contractExactMIT

ConnectV2FluidMerkleClaim

Address0x2d014be8a418ce1ee1c4b4b5606cf4e4e182f9ee
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.27

 

Same code

1 more contract

 

Details

Compiler
solc 0.8.27+commit.40a35a09
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
21,436,162
Creation transaction
0xf5bcd160ad…ee1d22c290
Main copy (most transactions)
0x0cb7de57…fc781abf

contracts/mainnet/connectors/fluid-merkle-claim/main.sol

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "./events.sol";
import {Basic} from "../../common/basic.sol";
import {IFluidMerkleDistributor, IFluidMerkleDistributorV2} from "./interfaces.sol";
import {TokenInterface} from "../../common/interfaces.sol";

abstract contract FluidMerkleClaim is Basic, Events {
    function claim(
        address merkleDistributorContract,
        address rewardToken,
        uint256 cumulativeAmount_,
        bytes32 positionId_,
        uint256 cycle_,
        bytes32[] calldata merkleProof_,
        uint256 setId_
    )
        external
        payable
        returns (string memory _eventName, bytes memory _eventParam)
    {
        TokenInterface REWARD_TOKEN = TokenInterface(rewardToken);
        IFluidMerkleDistributor MERKLE_DISTRIBUTOR = IFluidMerkleDistributor(
            merkleDistributorContract
        );

        uint256 rewardsBeforeBal_ = REWARD_TOKEN.balanceOf(address(this));
        MERKLE_DISTRIBUTOR.claim(
            address(this),
            cumulativeAmount_,
            positionId_,
            cycle_,
            merkleProof_
        );

        uint256 rewardsClaimed_ = REWARD_TOKEN.balanceOf(address(this)) -
            rewardsBeforeBal_;
        setUint(setId_, rewardsClaimed_);

        _eventName = "LogClaim(address,address,uint256,bytes32,uint256,bytes32[],uint256,uint256)";
        _eventParam = abi.encode(
            merkleDistributorContract,
            rewardToken,
            cumulativeAmount_,
            positionId_,
            cycle_,
            merkleProof_,
            rewardsClaimed_,
            setId_
        );
    }

    function claimOnBehalf(
        address merkleDistributorContract,
        address rewardToken,
        address recipient_,
        uint256 cumulativeAmount_,
        bytes32 positionId_,
        uint256 cycle_,
        bytes32[] calldata merkleProof_,
        uint256 setId_
    )
        external
        payable
        returns (string memory _eventName, bytes memory _eventParam)
    {
        TokenInterface REWARD_TOKEN = TokenInterface(rewardToken);
        IFluidMerkleDistributor MERKLE_DISTRIBUTOR = IFluidMerkleDistributor(
            merkleDistributorContract
        );

        uint256 rewardsBeforeBal_ = REWARD_TOKEN.balanceOf(address(this));
        MERKLE_DISTRIBUTOR.claim(
            recipient_,
            cumulativeAmount_,
            positionId_,
            cycle_,
            merkleProof_
        );

        uint256 rewardsClaimed_ = REWARD_TOKEN.balanceOf(address(this)) -
            rewardsBeforeBal_;
        setUint(setId_, rewardsClaimed_);

        _eventName = "LogClaimOnBehalf(address,address,uint256,bytes32,uint256,bytes32[],uint256,uint256)";
        _eventParam = abi.encode(
            merkleDistributorContract,
            rewardToken,
            recipient_,
            cumulativeAmount_,
            positionId_,
            cycle_,
            merkleProof_,
            rewardsClaimed_,
            setId_
        );
    }

    function claimV2(
        address merkleDistributorContract,
        address rewardToken,
        uint256 cumulativeAmount_,
        uint8 positonType_,
        bytes32 positionId_,
        uint256 cycle_,
        bytes32[] calldata merkleProof_,
        bytes memory metadata_,
        uint256 setId_
    )
        external
        payable
        returns (string memory _eventName, bytes memory _eventParam)
    {
        TokenInterface REWARD_TOKEN = TokenInterface(rewardToken);
        IFluidMerkleDistributorV2 MERKLE_DISTRIBUTOR = IFluidMerkleDistributorV2(
                merkleDistributorContract
            );

        uint256 rewardsBeforeBal_ = REWARD_TOKEN.balanceOf(address(this));
        MERKLE_DISTRIBUTOR.claim(
            address(this),
            cumulativeAmount_,
            positonType_,
            positionId_,
            cycle_,
            merkleProof_,
            metadata_
        );

        uint256 rewardsClaimed_ = REWARD_TOKEN.balanceOf(address(this)) -
            rewardsBeforeBal_;
        setUint(setId_, rewardsClaimed_);

        _eventName = "LogClaimV2(address,address,uint256,bytes32,uint256,bytes32[],uint256,uint256)";
        _eventParam = abi.encode(
            merkleDistributorContract,
            rewardToken,
            cumulativeAmount_,
            positionId_,
            cycle_,
            merkleProof_,
            rewardsClaimed_,
            setId_
        );
    }

    struct ClaimOnBehalfHelper{
        uint256 rewardsBeforeBal_;
        uint256 rewardsClaimed_;
    }

    function claimOnBehalfV2(
        address merkleDistributorContract,
        address rewardToken,
        address recipient_,
        uint256 cumulativeAmount_,
        uint8 positonType_,
        bytes32 positionId_,
        uint256 cycle_,
        bytes32[] calldata merkleProof_,
        bytes memory metadata_,
        uint256 setId_
    )
        external
        payable
        returns (string memory _eventName, bytes memory _eventParam)
    {
        TokenInterface REWARD_TOKEN = TokenInterface(rewardToken);
        IFluidMerkleDistributorV2 MERKLE_DISTRIBUTOR = IFluidMerkleDistributorV2(
                merkleDistributorContract
            );

        ClaimOnBehalfHelper memory helper_;

        helper_.rewardsBeforeBal_ = REWARD_TOKEN.balanceOf(address(this));
        MERKLE_DISTRIBUTOR.claim(
            recipient_,
            cumulativeAmount_,
            positonType_,
            positionId_,
            cycle_,
            merkleProof_,
            metadata_
        );

        helper_.rewardsClaimed_ = REWARD_TOKEN.balanceOf(address(this)) -
            helper_.rewardsBeforeBal_;
        setUint(setId_, helper_.rewardsClaimed_);

        _eventName = "LogClaimOnBehalfV2(address,address,uint256,bytes32,uint256,bytes32[],uint256,uint256)";
        _eventParam = abi.encode(
            merkleDistributorContract,
            rewardToken,
            recipient_,
            cumulativeAmount_,
            positionId_,
            cycle_,
            merkleProof_,
            helper_.rewardsClaimed_,
            setId_
        );
    }
}

contract ConnectV2FluidMerkleClaim is FluidMerkleClaim {
    string public constant name = "Fluid-Merkle-Claim-v1.1";
}

@openzeppelin/contracts/utils/math/SafeMath.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

contracts/mainnet/common/basic.sol

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import { TokenInterface } from "./interfaces.sol";
import { Stores } from "./stores.sol";
import { DSMath } from "./math.sol";

abstract contract Basic is DSMath, Stores {

    function convert18ToDec(uint _dec, uint256 _amt) internal pure returns (uint256 amt) {
        amt = (_amt / 10 ** (18 - _dec));
    }

    function convertTo18(uint _dec, uint256 _amt) internal pure returns (uint256 amt) {
        amt = mul(_amt, 10 ** (18 - _dec));
    }

    function getTokenBal(TokenInterface token) internal view returns(uint _amt) {
        _amt = address(token) == ethAddr ? address(this).balance : token.balanceOf(address(this));
    }

    function getTokensDec(TokenInterface buyAddr, TokenInterface sellAddr) internal view returns(uint buyDec, uint sellDec) {
        buyDec = address(buyAddr) == ethAddr ?  18 : buyAddr.decimals();
        sellDec = address(sellAddr) == ethAddr ?  18 : sellAddr.decimals();
    }

    function encodeEvent(string memory eventName, bytes memory eventParam) internal pure returns (bytes memory) {
        return abi.encode(eventName, eventParam);
    }

    function approve(TokenInterface token, address spender, uint256 amount) internal {
        try token.approve(spender, amount) {

        } catch {
            token.approve(spender, 0);
            token.approve(spender, amount);
        }
    }

    function changeEthAddress(address buy, address sell) internal pure returns(TokenInterface _buy, TokenInterface _sell){
        _buy = buy == ethAddr ? TokenInterface(wethAddr) : TokenInterface(buy);
        _sell = sell == ethAddr ? TokenInterface(wethAddr) : TokenInterface(sell);
    }

    function changeEthAddrToWethAddr(address token) internal pure returns(address tokenAddr){
        tokenAddr = token == ethAddr ? wethAddr : token;
    }

    function convertEthToWeth(bool isEth, TokenInterface token, uint amount) internal {
        if(isEth) token.deposit{value: amount}();
    }

    function convertWethToEth(bool isEth, TokenInterface token, uint amount) internal {
       if(isEth) {
            approve(token, address(token), amount);
            token.withdraw(amount);
        }
    }
}

contracts/mainnet/common/interfaces.sol

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

interface TokenInterface {
    function approve(address, uint256) external;
    function transfer(address, uint) external;
    function transferFrom(address, address, uint) external;
    function deposit() external payable;
    function withdraw(uint) external;
    function balanceOf(address) external view returns (uint);
    function decimals() external view returns (uint);
    function totalSupply() external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint256);
}

interface MemoryInterface {
    function getUint(uint id) external returns (uint num);
    function setUint(uint id, uint val) external;
}

interface InstaMapping {
    function cTokenMapping(address) external view returns (address);
    function gemJoinMapping(bytes32) external view returns (address);
}

interface AccountInterface {
    function enable(address) external;
    function disable(address) external;
    function isAuth(address) external view returns (bool);
    function cast(
        string[] calldata _targetNames,
        bytes[] calldata _datas,
        address _origin
    ) external payable returns (bytes32[] memory responses);
}

interface ListInterface {
    function accountID(address) external returns (uint64);
}

interface InstaConnectors {
    function isConnectors(string[] calldata) external returns (bool, address[] memory);
}

contracts/mainnet/common/math.sol

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import { SafeMath } from "@openzeppelin/contracts/utils/math/SafeMath.sol";

contract DSMath {
  uint constant WAD = 10 ** 18;
  uint constant RAY = 10 ** 27;

  function add(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(x, y);
  }

  function sub(uint x, uint y) internal virtual pure returns (uint z) {
    z = SafeMath.sub(x, y);
  }

  function mul(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.mul(x, y);
  }

  function div(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.div(x, y);
  }

  function wmul(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, y), WAD / 2) / WAD;
  }

  function wdiv(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, WAD), y / 2) / y;
  }

  function rdiv(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, RAY), y / 2) / y;
  }

  function rmul(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, y), RAY / 2) / RAY;
  }

  function toInt(uint x) internal pure returns (int y) {
    y = int(x);
    require(y >= 0, "int-overflow");
  }

  function toUint(int256 x) internal pure returns (uint256) {
      require(x >= 0, "int-overflow");
      return uint256(x);
  }

  function toRad(uint wad) internal pure returns (uint rad) {
    rad = mul(wad, 10 ** 27);
  }

}

contracts/mainnet/common/stores.sol

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import { MemoryInterface, InstaMapping, ListInterface, InstaConnectors } from "./interfaces.sol";


abstract contract Stores {

  /**
   * @dev Return ethereum address
   */
  address constant internal ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

  /**
   * @dev Return Wrapped ETH address
   */
  address constant internal wethAddr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

  /**
   * @dev Return memory variable address
   */
  MemoryInterface constant internal instaMemory = MemoryInterface(0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F);

  /**
   * @dev Return InstaDApp Mapping Addresses
   */
  InstaMapping constant internal instaMapping = InstaMapping(0xe81F70Cc7C0D46e12d70efc60607F16bbD617E88);

  /**
   * @dev Return InstaList Address
   */
  ListInterface internal constant instaList = ListInterface(0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb);

  /**
	 * @dev Return connectors registry address
	 */
	InstaConnectors internal constant instaConnectors = InstaConnectors(0x97b0B3A8bDeFE8cB9563a3c610019Ad10DB8aD11);

  /**
   * @dev Get Uint value from InstaMemory Contract.
   */
  function getUint(uint getId, uint val) internal returns (uint returnVal) {
    returnVal = getId == 0 ? val : instaMemory.getUint(getId);
  }

  /**
  * @dev Set Uint value in InstaMemory Contract.
  */
  function setUint(uint setId, uint val) virtual internal {
    if (setId != 0) instaMemory.setUint(setId, val);
  }

}

contracts/mainnet/connectors/fluid-merkle-claim/events.sol

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

contract Events {
    event LogClaim(
        address merkleDistributorContract,
        address rewardToken,
        uint256 cumulativeAmount,
        bytes32 positionId,
        uint256 cycle,
        bytes32[] merkleProof,
        uint256 rewardsClaimed,
        uint256 setId
    );

    event LogClaimOnBehalf(
        address merkleDistributorContract,
        address rewardToken,
        address recipient_,
        uint256 cumulativeAmount,
        bytes32 positionId,
        uint256 cycle,
        bytes32[] merkleProof,
        uint256 rewardsClaimed,
        uint256 setId
    );

    event LogClaimV2(
        address merkleDistributorContract,
        address rewardToken,
        uint256 cumulativeAmount,
        uint8 positonType,
        bytes32 positionId,
        uint256 cycle,
        bytes32[] merkleProof,
        bytes metadata,
        uint256 rewardsClaimed,
        uint256 setId
    );

    event LogClaimOnBehalfV2(
        address merkleDistributorContract,
        address rewardToken,
        address recipient_,
        uint256 cumulativeAmount,
        uint8 positonType,
        bytes32 positionId,
        uint256 cycle,
        bytes32[] merkleProof,
        bytes metadata,
        uint256 rewardsClaimed,
        uint256 setId
    );
}

contracts/mainnet/connectors/fluid-merkle-claim/interfaces.sol

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

interface IFluidMerkleDistributor {
    function claim(
        address recipient_,
        uint256 cumulativeAmount_,
        bytes32 positionId_,
        uint256 cycle_,
        bytes32[] calldata merkleProof_
    ) external;
}

interface IFluidMerkleDistributorV2 {
    function claim(
        address recipient_,
        uint256 cumulativeAmount_,
        uint8 positionType_,
        bytes32 positionId_,
        uint256 cycle_,
        bytes32[] calldata merkleProof_,
        bytes memory metadata_
    ) external;
}
Compiler settingsShow
{
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.