FairAirdrop.sol

Quick Links

VIEW CONTRACT ON GITHUB

The FairAirdrop.sol contract manages the distribution of 71,111,111 AEC (8% of the total supply) to early contributors. It works in conjunction with ContributorPoints.sol, allowing users to deposit their non-transferable CP tokens to claim a proportional share of the airdrop allocation. The contract features a unique choice system, allowing users to claim either 100% of their allocation for a small USDC fee or 80% for free.

Inherits from: ReentrancyGuard


Key State Variables

Variable
Type
Description

cpToken

IContributorPoints

The address of the ContributorPoints contract.

aecToken

IERC20

The address of the AEC token to be distributed.

usdcToken

IERC20

The address of the USDC token used for the claimFullAllocation fee.

perpetualEngine

address

The address of the PerpetualEngine which receives all fees and unclaimed AEC.

startTime

uint256

The timestamp when the 7-day deposit window begins.

endTime

uint256

The timestamp when the 7-day deposit window ends.

claimDeadline

uint256

The timestamp when the 30-day claim window ends. Set upon finalization.

isFinalized

bool

A flag that becomes true after the deposit window ends and finalizeAirdrop() is called.

aecPerCP

uint256

The calculated exchange rate of AEC per CP, determined upon finalization.

userDeposits

mapping(address => uint256)

A mapping from a user's address to the amount of CP they have deposited.

hasClaimed

mapping(address => bool)

A mapping that returns true if a user has already claimed their airdrop.

Write Functions

User-Facing Functions

  • depositCP(uint256 amount): Allows users to deposit their CP tokens during the 7-day deposit window. This action registers them for the airdrop.

  • withdrawCP(uint256 amount): Allows users to withdraw their deposited CP tokens at any time before the deposit window ends and the airdrop is finalized.

  • claimFullAllocation(): Allows a finalized user to claim 100% of their pro-rata AEC allocation by paying a 1 USDC fee. The USDC is sent to the perpetualEngine. Can only be called during the 30-day claim window.

  • claimPartialAllocation(): Allows a finalized user to claim 80% of their pro-rata AEC allocation for free. The remaining 20% is sent to the perpetualEngine. Can only be called during the 30-day claim window.

  • emergencyRecoverCP(): A failsafe function allowing users who missed the claim window to recover their deposited CP tokens. This function does not grant any AEC rewards.

Public Functions

  • finalizeAirdrop(): A permissionless function that can be called by anyone after the deposit window (endTime) has passed. It calculates the final aecPerCP rate and starts the 30-day claim period.

  • transferUnclaimedTokens(): A function to transfer any remaining (unclaimed) AEC tokens to the perpetualEngine. Can only be called after a long delay (claim deadline + 365 days) to prevent tokens from being permanently locked.


View Functions

  • getAirdropStatus(): Returns a summary of the airdrop's current state, including whether the deposit and claim windows are open, if it's finalized, the time remaining, total CP deposited, and the number of participants.

  • getUserAllocation(address user): Returns detailed allocation information for a specific user, including their CP deposited, their full (100%) and partial (80%) AEC allocations, and whether they have already claimed.

  • getClaimOptions(address user): A convenience function for dApp frontends. It checks a user's USDC balance and returns whether they are eligible to use claimFullAllocation or claimPartialAllocation, along with the respective amounts.


Events

  • AirdropCreated(...): Emitted at contract deployment, logging the start and end times of the deposit window.

  • CPDeposited(address indexed user, uint256 amount): Emitted when a user successfully deposits CP.

  • AirdropFinalized(uint256 totalCP, uint256 participants): Emitted when finalizeAirdrop() is successfully called.

  • ClaimedFull(address indexed user, uint256 cpAmount, uint256 aecReceived): Emitted when a user claims 100% of their allocation.

  • ClaimedPartial(address indexed user, uint256 cpAmount, uint256 aecReceived, uint256 toEngine): Emitted when a user claims 80% of their allocation.

  • EmergencyRecovered(address indexed user, uint256 cpAmount): Emitted when a user recovers their CP after the claim deadline.

Last updated