XFI Token | Ethereum XFI Exchange
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.
Contents
- 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
XFI Token
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.
XFI Token Methods
isTransferringStopped
Returns whether transfering is stopped.
Output:
bool
- whether transferring is stopped.
Example:
isTransferringStopped()
isMigratingAllowed
Returns whether migrating is allowed.
Output:
bool
- whether migrating is allowed.
Example:
isMigratingAllowed()
VESTING_DURATION
Returns vesting duration in seconds.
Output:
uint256
- vesting duration in seconds.
Example:
VESTING_DURATION()
VESTING_DURATION_DAYS
Returns vesting duration in days.
Output:
uint256
- vesting duration in days.
Example:
VESTING_DURATION_DAYS()
RESERVE_FREEZE_DURATION
Returns reserve freeze duration in seconds.
Output:
uint256
- reserve freeze duration in seconds.
Example:
RESERVE_FREEZE_DURATION()
RESERVE_FREEZE_DURATION_DAYS
Returns reserve freeze duration in days.
Output:
uint256
- reserve freeze duration in days.
Example:
RESERVE_FREEZE_DURATION_DAYS()
MAX_VESTING_TOTAL_SUPPLY
Returns maximum vesting total supply.
Output:
uint256
- maximum total supply.
Example:
MAX_VESTING_TOTAL_SUPPLY()
vestingStart
Returns the vesting start.
Output:
uint256
- vesting start timestamp.
Example:
vestingStart()
vestingEnd
Returns the vesting end.
Output:
uint256
- vesting end timestamp.
Example:
vestingEnd()
vestingDaysSinceStart
Returns days since the vesting start.
Output:
uint256
- integer number of days since the vesting start.
Example:
vestingDaysSinceStart()
vestingDaysLeft
Returns vesting days left.
Output:
uint256
- integer number of vesting days left.
Example:
vestingDaysLeft()
reserveFrozenUntil
Returns the date when freeze of the reserve XFI amount.
Output:
uint256
- reserve frozen until timestamp.
Example:
reserveFrozenUntil()
reserveAmount
Output:
uint256
- reserve amount.
Example:
reserveAmount()
convertAmountUsingRatio
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)
convertAmountUsingReverseRatio
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)
totalVestedBalanceOf
Returns total vested balance of the account
.
Input:
address account
- owner address.
Output:
uint256
- amount of vested tokens owned byaccount
.
Example:
totalVestedBalanceOf(account)
unspentVestedBalanceOf
Returns unspent vested balance of the account
.
Input:
address account
- owner address.
Output:
uint256
- amount of vested tokens unspent byaccount
.
Example:
unspentVestedBalanceOf(account)
spentVestedBalanceOf
Returns spent vested balance of the account
.
Input:
address account
- owner address.
Output:
uint256
- amount of vested tokens spent byaccount
.
Example:
spentVestedBalanceOf(account)
Exchange
Exchange
is the Ethereum XFI Exchange which allows Ethereum accounts to convert their WINGS or ETH to XFI.
Exchange Methods
estimateSwapWINGSForXFI
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)
estimateSwapWINGSForXFIPerDay
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)
isSwappingStopped
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.
maxGasPrice
Returns maximum gas price for swap. If set, any swap transaction that has a gas price exceeding this limit will be reverted.
Example:
maxGasPrice()
swapWINGSForXFI
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)
Requirements
- Nodejs ~10.16.2
- Truffle ~5.1.33
- Ganache-cli ~6.9.1 (for testing)
Compiling
Configure truffle-config.js
(see configuration manual).
Compile contracts:
npm run compile
Deploying
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
Testing
Compile contracts:
npm run compile
Run tests:
npm test