mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Added claimAndDelegateArbAirdrop + prettier
This commit is contained in:
parent
bade2b6642
commit
a51382d1da
|
@ -20,4 +20,11 @@ contract Events {
|
|||
uint256 indexed delegatedAmount,
|
||||
uint256 nonce
|
||||
);
|
||||
|
||||
event LogArbAirdropClaimedAndDelegated(
|
||||
address indexed account,
|
||||
address indexed delegatee,
|
||||
uint256 indexed claimable,
|
||||
uint256 setId
|
||||
);
|
||||
}
|
||||
|
|
|
@ -19,21 +19,31 @@ interface IArbTokenContract {
|
|||
function delegate(address delegatee) external;
|
||||
|
||||
function delegateBySig(
|
||||
address delegatee,
|
||||
uint256 nonce,
|
||||
uint256 expiry,
|
||||
uint8 v,
|
||||
bytes32 r,
|
||||
bytes32 s
|
||||
) external;
|
||||
address delegatee,
|
||||
uint256 nonce,
|
||||
uint256 expiry,
|
||||
uint8 v,
|
||||
bytes32 r,
|
||||
bytes32 s
|
||||
) external;
|
||||
}
|
||||
|
||||
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 approve(address, uint256) external;
|
||||
|
||||
function transfer(address, uint256) external;
|
||||
|
||||
function transferFrom(
|
||||
address,
|
||||
address,
|
||||
uint256
|
||||
) external;
|
||||
|
||||
function deposit() external payable;
|
||||
|
||||
function withdraw(uint256) external;
|
||||
|
||||
function balanceOf(address) external view returns (uint256);
|
||||
|
||||
function decimals() external view returns (uint256);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,10 @@ 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);
|
||||
}
|
||||
|
||||
function claimArbAirdrop(uint256 setId)
|
||||
public
|
||||
returns (string memory eventName_, bytes memory eventParam_)
|
||||
|
@ -20,12 +24,14 @@ abstract contract ArbitrumAirdrop is Events, Variables {
|
|||
eventParam_ = abi.encode(address(this), claimable, setId);
|
||||
}
|
||||
|
||||
function delegateArbTokens(address delegatee)
|
||||
function delegateArbTokens(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");
|
||||
uint256 balance = TokenInterface(address(ARB_TOKEN_CONTRACT)).balanceOf(
|
||||
address(this)
|
||||
);
|
||||
require(balance > 0, "no-balance-to-delegate");
|
||||
|
||||
ARB_TOKEN_CONTRACT.delegate(delegatee);
|
||||
|
||||
|
@ -33,25 +39,47 @@ abstract contract ArbitrumAirdrop is Events, Variables {
|
|||
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");
|
||||
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");
|
||||
|
||||
ARB_TOKEN_CONTRACT.delegateBySig(delegatee, nonce, permits.expiry, permits.v, permits.r, permits.s);
|
||||
ARB_TOKEN_CONTRACT.delegateBySig(
|
||||
delegatee,
|
||||
nonce,
|
||||
permits.expiry,
|
||||
permits.v,
|
||||
permits.r,
|
||||
permits.s
|
||||
);
|
||||
|
||||
eventName_ = "LogArbTokensDelegatedBySig(address,address,uint256,uint256)";
|
||||
eventParam_ = abi.encode(address(this), delegatee, balance, nonce);
|
||||
}
|
||||
eventName_ = "LogArbTokensDelegatedBySig(address,address,uint256,uint256)";
|
||||
eventParam_ = abi.encode(address(this), delegatee, balance, nonce);
|
||||
}
|
||||
|
||||
function claimableArbTokens(address user) public view returns (uint256) {
|
||||
return ARBITRUM_TOKEN_DISTRIBUTOR.claimableTokens(user);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user