diff --git a/contracts/arbitrum/connectors/arb-claim/events.sol b/contracts/arbitrum/connectors/arb-claim/events.sol index 8ecdd7b0..ba1a1835 100644 --- a/contracts/arbitrum/connectors/arb-claim/events.sol +++ b/contracts/arbitrum/connectors/arb-claim/events.sol @@ -10,21 +10,12 @@ contract Events { event LogArbTokensDelegated( address indexed account, - address indexed delegatee, - uint256 indexed delegatedAmount + address indexed delegatee ); event LogArbTokensDelegatedBySig( address indexed account, address indexed delegatee, - uint256 indexed delegatedAmount, uint256 nonce ); - - event LogArbAirdropClaimedAndDelegated( - address indexed account, - address indexed delegatee, - uint256 indexed claimable, - uint256 setId - ); } diff --git a/contracts/arbitrum/connectors/arb-claim/helpers.sol b/contracts/arbitrum/connectors/arb-claim/helpers.sol new file mode 100644 index 00000000..0e91e30e --- /dev/null +++ b/contracts/arbitrum/connectors/arb-claim/helpers.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.7.0; + +import "./variables.sol"; +import { Basic } from "../../common/basic.sol"; + +contract Helpers is Variables, Basic { + function claimableArbTokens(address user) internal view returns (uint256) { + return ARBITRUM_TOKEN_DISTRIBUTOR.claimableTokens(user); + } +} \ No newline at end of file diff --git a/contracts/arbitrum/connectors/arb-claim/main.sol b/contracts/arbitrum/connectors/arb-claim/main.sol index 9ec1b5e4..e1068821 100644 --- a/contracts/arbitrum/connectors/arb-claim/main.sol +++ b/contracts/arbitrum/connectors/arb-claim/main.sol @@ -2,16 +2,13 @@ pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; -import "./variables.sol"; +import "./helpers.sol"; import { Events } from "./events.sol"; import { IArbitrumTokenDistributor } from "./interface.sol"; -abstract contract ArbitrumAirdrop is Events, Variables { - function claimableArbTokens(address user) public view returns (uint256) { - return ARBITRUM_TOKEN_DISTRIBUTOR.claimableTokens(user); - } +abstract contract ArbitrumAirdrop is Events, Helpers { - function claimArbAirdrop(uint256 setId) + function claimAirdrop(uint256 setId) public returns (string memory eventName_, bytes memory eventParam_) { @@ -24,31 +21,21 @@ abstract contract ArbitrumAirdrop is Events, Variables { eventParam_ = abi.encode(address(this), claimable, setId); } - function delegateArbTokens(address delegatee) + function delegate(address delegatee) public returns (string memory eventName_, bytes memory eventParam_) { - uint256 balance = TokenInterface(address(ARB_TOKEN_CONTRACT)).balanceOf( - address(this) - ); - require(balance > 0, "no-balance-to-delegate"); - ARB_TOKEN_CONTRACT.delegate(delegatee); - eventName_ = "LogArbTokensDelegated(address,address,uint256)"; - eventParam_ = abi.encode(address(this), delegatee, balance); + eventName_ = "LogArbTokensDelegated(address,address)"; + eventParam_ = abi.encode(address(this), delegatee); } - function delegateArbTokensBySig( + function delegateBySig( address delegatee, uint256 nonce, SignedPermits calldata permits ) public returns (string memory eventName_, bytes memory eventParam_) { - uint256 balance = TokenInterface(address(ARB_TOKEN_CONTRACT)).balanceOf( - address(this) - ); - require(balance > 0, "no-balance-to-delegate"); - ARB_TOKEN_CONTRACT.delegateBySig( delegatee, nonce, @@ -58,31 +45,11 @@ abstract contract ArbitrumAirdrop is Events, Variables { permits.s ); - eventName_ = "LogArbTokensDelegatedBySig(address,address,uint256,uint256)"; - eventParam_ = abi.encode(address(this), delegatee, balance, nonce); - } - - function claimAndDelegateArbAirdrop( - address delegatee, - SignedPermits memory permits, - uint256 setId - ) public returns (string memory eventName_, bytes memory eventParam_) { - uint256 claimable = claimableArbTokens(address(this)); - require(claimable > 0, "0-tokens-claimable"); - ARBITRUM_TOKEN_DISTRIBUTOR.claimAndDelegate( - delegatee, - permits.expiry, - permits.v, - permits.r, - permits.s - ); - setUint(setId, claimable); - - eventName_ = "LogArbAirdropClaimedAndDelegated(address,address,uint256,uint256)"; - eventParam_ = abi.encode(address(this), delegatee, claimable, setId); + eventName_ = "LogArbTokensDelegatedBySig(address,address,uint256)"; + eventParam_ = abi.encode(address(this), delegatee, nonce); } } contract ConnectV2ArbitrumAirdrop is ArbitrumAirdrop { - string public name = "ArbitrumAirdrop-v1"; + string public constant name = "ArbitrumAirdrop-v1"; } diff --git a/contracts/arbitrum/connectors/arb-claim/variables.sol b/contracts/arbitrum/connectors/arb-claim/variables.sol index b03a6f75..4f08a35c 100644 --- a/contracts/arbitrum/connectors/arb-claim/variables.sol +++ b/contracts/arbitrum/connectors/arb-claim/variables.sol @@ -2,9 +2,8 @@ pragma solidity ^0.7.0; import "./interface.sol"; -import { Basic } from "../../common/basic.sol"; -contract Variables is Basic { +contract Variables { IArbitrumTokenDistributor public constant ARBITRUM_TOKEN_DISTRIBUTOR = IArbitrumTokenDistributor(0x67a24CE4321aB3aF51c2D0a4801c3E111D88C9d9);