This repository is a home for the XFI Token contract as well as the Ethereum XFI Exchange which allows Ethereum accounts to convert their WINGS or ETH to XFI.
- XFI Token | Ethereum XFI Exchange
- Contents
- XFI Token
- XFI Token Methods
- isTransferringStopped
- isMigratingAllowed
- VESTING_DURATION
- VESTING_DURATION_DAYS
- RESERVE_FREEZE_DURATION
- RESERVE_FREEZE_DURATION_DAYS
- MAX_VESTING_TOTAL_SUPPLY
- vestingStart
- vestingEnd
- vestingDaysSinceStart
- vestingDaysLeft
- reserveFrozenUntil
- reserveAmount
- convertAmountUsingRatio
- convertAmountUsingReverseRatio
- totalVestedBalanceOf
- unspentVestedBalanceOf
- spentVestedBalanceOf
- XFI Token Methods
- Exchange
- Requirements
- Compiling
- Deploying
- Testing
- License
XFIToken
is an extended version of ERC20 standard. This extended version adds minting, vesting and token transfer management to the functionality described in the original EIP.
Returns whether transfering is stopped.
Output:
bool
- whether transferring is stopped.
Example:
isTransferringStopped()
Returns whether migrating is allowed.
Output:
bool
- whether migrating is allowed.
Example:
isMigratingAllowed()
Returns vesting duration in seconds.
Output:
uint256
- vesting duration in seconds.
Example:
VESTING_DURATION()
Returns vesting duration in days.
Output:
uint256
- vesting duration in days.
Example:
VESTING_DURATION_DAYS()
Returns reserve freeze duration in seconds.
Output:
uint256
- reserve freeze duration in seconds.
Example:
RESERVE_FREEZE_DURATION()
Returns reserve freeze duration in days.
Output:
uint256
- reserve freeze duration in days.
Example:
RESERVE_FREEZE_DURATION_DAYS()
Returns maximum vesting total supply.
Output:
uint256
- maximum total supply.
Example:
MAX_VESTING_TOTAL_SUPPLY()
Returns the vesting start.
Output:
uint256
- vesting start timestamp.
Example:
vestingStart()
Returns the vesting end.
Output:
uint256
- vesting end timestamp.
Example:
vestingEnd()
Returns days since the vesting start.
Output:
uint256
- integer number of days since the vesting start.
Example:
vestingDaysSinceStart()
Returns vesting days left.
Output:
uint256
- integer number of vesting days left.
Example:
vestingDaysLeft()
Returns the date when freeze of the reserve XFI amount.
Output:
uint256
- reserve frozen until timestamp.
Example:
reserveFrozenUntil()
Output:
uint256
- reserve amount.
Example:
reserveAmount()
Convert input amount to the output amount using the vesting ratio (days since vesting start / vesting duration).
Input:
uint256 amount
- amount to convert.
Output:
uint256
- converted amount.
Example:
convertAmountUsingRatio(amount)
Convert input amount to the output amount using the vesting reverse ratio (days until vesting end / vesting duration).
Input:
uint256 amount
- amount to convert.
Output:
uint256
- converted amount.
Example:
convertAmountUsingReverseRatio(amount)
Returns total vested balance of the account
.
Input:
address account
- owner address.
Output:
uint256
- amount of vested tokens owned byaccount
.
Example:
totalVestedBalanceOf(account)
Returns unspent vested balance of the account
.
Input:
address account
- owner address.
Output:
uint256
- amount of vested tokens unspent byaccount
.
Example:
unspentVestedBalanceOf(account)
Returns spent vested balance of the account
.
Input:
address account
- owner address.
Output:
uint256
- amount of vested tokens spent byaccount
.
Example:
spentVestedBalanceOf(account)
Exchange
is the Ethereum XFI Exchange which allows Ethereum accounts to convert their WINGS or ETH to XFI.
Returns estimation for swap of WINGS-XFI pair.
Input:
uint256 amountIn
- amount of WINGS to swap.
Output:
uint256[] amounts
- estimation for swap of WINGS-XFI pair.
Example:
estimateSwapWINGSForXFI(amountIn)
Returns daily vesting estimation for swap of WINGS-XFI pair.
Input:
uint256 amountIn
- amount of WINGS to swap.
Output:
uint256 amounts
- estimated amount of XFI that will be vested each day of the vesting period.
Example:
estimateSwapWINGSForXFIPerDay(amountIn)
Returns whether swapping is stopped.
Example:
isSwappingStopped()
NOTE: To receive real-time updates on the status of the swaps, consider listening to SwapsStarted
and SwapsStopped
events.
Returns maximum gas price for swap. If set, any swap transaction that has a gas price exceeding this limit will be reverted.
Example:
maxGasPrice()
Executes swap of WINGS-XFI pair.
Emits a SwapWINGSForXFI
event.
Input:
uint256 amountIn
- amount of WINGS to swap.
Output:
uint256[] amounts
- result of a swap of WINGS-XFI pair.
Example:
swapWINGSForXFI(amountIn)
- Nodejs ~10.16.2
- Truffle ~5.1.33
- Ganache-cli ~6.9.1 (for testing)
Configure truffle-config.js
(see configuration manual).
Compile contracts:
npm run compile
Copy and configure .env
:
cp .env.example .env
Required environment variables:
CREATOR_ADDRESS
- address of the creator account.WINGS_TOKEN_ADDRESS
- address of the WINGS Token.START_DATE
- vesting start date (only XFI Token deploy).XFI_TOKEN_ADDRESS
- XFI token address (only Exchange deploy).
Migrate contracts:
truffle migrate
To run migration for a specific network, make sure that the network is configured in your truffle-config.js
and specify the --network
option, like below:
truffle migrate --network live
Compile contracts:
npm run compile
Run tests:
npm test