dsa-connectors/contracts/arbitrum/connectors/arb-claim/main.sol

89 lines
2.5 KiB
Solidity
Raw Normal View History

2023-04-19 16:06:43 +00:00
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import "./variables.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);
}
2023-04-19 16:06:43 +00:00
function claimArbAirdrop(uint256 setId)
public
returns (string memory eventName_, bytes memory eventParam_)
{
uint256 claimable = claimableArbTokens(address(this));
require(claimable > 0, "0-tokens-claimable");
ARBITRUM_TOKEN_DISTRIBUTOR.claim();
setUint(setId, claimable);
eventName_ = "LogArbAirdropClaimed(address,uint256,uint256)";
eventParam_ = abi.encode(address(this), claimable, setId);
}
function delegateArbTokens(address delegatee)
2023-04-19 16:06:43 +00:00
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");
2023-04-19 16:06:43 +00:00
ARB_TOKEN_CONTRACT.delegate(delegatee);
eventName_ = "LogArbTokensDelegated(address,address,uint256)";
eventParam_ = abi.encode(address(this), delegatee, balance);
}
function delegateArbTokensBySig(
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");
2023-04-19 16:06:43 +00:00
ARB_TOKEN_CONTRACT.delegateBySig(
delegatee,
nonce,
permits.expiry,
permits.v,
permits.r,
permits.s
);
2023-04-19 16:06:43 +00:00
eventName_ = "LogArbTokensDelegatedBySig(address,address,uint256,uint256)";
eventParam_ = abi.encode(address(this), delegatee, balance, nonce);
}
2023-04-19 16:06:43 +00:00
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);
2023-04-19 16:06:43 +00:00
}
}
contract ConnectV2ArbitrumAirdrop is ArbitrumAirdrop {
string public name = "ArbitrumAirdrop-v1";
}