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 indexed delegatedAmount,
|
||||||
uint256 nonce
|
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 delegate(address delegatee) external;
|
||||||
|
|
||||||
function delegateBySig(
|
function delegateBySig(
|
||||||
address delegatee,
|
address delegatee,
|
||||||
uint256 nonce,
|
uint256 nonce,
|
||||||
uint256 expiry,
|
uint256 expiry,
|
||||||
uint8 v,
|
uint8 v,
|
||||||
bytes32 r,
|
bytes32 r,
|
||||||
bytes32 s
|
bytes32 s
|
||||||
) external;
|
) external;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TokenInterface {
|
interface TokenInterface {
|
||||||
function approve(address, uint256) external;
|
function approve(address, uint256) external;
|
||||||
function transfer(address, uint) external;
|
|
||||||
function transferFrom(address, address, uint) external;
|
function transfer(address, uint256) external;
|
||||||
function deposit() external payable;
|
|
||||||
function withdraw(uint) external;
|
function transferFrom(
|
||||||
function balanceOf(address) external view returns (uint);
|
address,
|
||||||
function decimals() external view returns (uint);
|
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";
|
import { IArbitrumTokenDistributor } from "./interface.sol";
|
||||||
|
|
||||||
abstract contract ArbitrumAirdrop is Events, Variables {
|
abstract contract ArbitrumAirdrop is Events, Variables {
|
||||||
|
function claimableArbTokens(address user) public view returns (uint256) {
|
||||||
|
return ARBITRUM_TOKEN_DISTRIBUTOR.claimableTokens(user);
|
||||||
|
}
|
||||||
|
|
||||||
function claimArbAirdrop(uint256 setId)
|
function claimArbAirdrop(uint256 setId)
|
||||||
public
|
public
|
||||||
returns (string memory eventName_, bytes memory eventParam_)
|
returns (string memory eventName_, bytes memory eventParam_)
|
||||||
|
@ -20,12 +24,14 @@ abstract contract ArbitrumAirdrop is Events, Variables {
|
||||||
eventParam_ = abi.encode(address(this), claimable, setId);
|
eventParam_ = abi.encode(address(this), claimable, setId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delegateArbTokens(address delegatee)
|
function delegateArbTokens(address delegatee)
|
||||||
public
|
public
|
||||||
returns (string memory eventName_, bytes memory eventParam_)
|
returns (string memory eventName_, bytes memory eventParam_)
|
||||||
{
|
{
|
||||||
uint256 balance = TokenInterface(address(ARB_TOKEN_CONTRACT)).balanceOf(address(this));
|
uint256 balance = TokenInterface(address(ARB_TOKEN_CONTRACT)).balanceOf(
|
||||||
require(balance > 0, "no-balance-to-delegate");
|
address(this)
|
||||||
|
);
|
||||||
|
require(balance > 0, "no-balance-to-delegate");
|
||||||
|
|
||||||
ARB_TOKEN_CONTRACT.delegate(delegatee);
|
ARB_TOKEN_CONTRACT.delegate(delegatee);
|
||||||
|
|
||||||
|
@ -33,25 +39,47 @@ abstract contract ArbitrumAirdrop is Events, Variables {
|
||||||
eventParam_ = abi.encode(address(this), delegatee, balance);
|
eventParam_ = abi.encode(address(this), delegatee, balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delegateArbTokensBySig(
|
function delegateArbTokensBySig(
|
||||||
address delegatee,
|
address delegatee,
|
||||||
uint256 nonce,
|
uint256 nonce,
|
||||||
SignedPermits calldata permits
|
SignedPermits calldata permits
|
||||||
)
|
) public returns (string memory eventName_, bytes memory eventParam_) {
|
||||||
public
|
uint256 balance = TokenInterface(address(ARB_TOKEN_CONTRACT)).balanceOf(
|
||||||
returns (string memory eventName_, bytes memory eventParam_)
|
address(this)
|
||||||
{
|
);
|
||||||
uint256 balance = TokenInterface(address(ARB_TOKEN_CONTRACT)).balanceOf(address(this));
|
require(balance > 0, "no-balance-to-delegate");
|
||||||
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)";
|
eventName_ = "LogArbTokensDelegatedBySig(address,address,uint256,uint256)";
|
||||||
eventParam_ = abi.encode(address(this), delegatee, balance, nonce);
|
eventParam_ = abi.encode(address(this), delegatee, balance, nonce);
|
||||||
}
|
}
|
||||||
|
|
||||||
function claimableArbTokens(address user) public view returns (uint256) {
|
function claimAndDelegateArbAirdrop(
|
||||||
return ARBITRUM_TOKEN_DISTRIBUTOR.claimableTokens(user);
|
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