This repository contains contracts for the ARTIS 2.0 launch. Tested with nodejs v12.x.
Prepare for deployment:
npm ci
npm run build
Test:
npm run test
Deploy:
npx truffle exec scripts/deploy.js [: <OLD_TOKEN_ADDRESS>] --network <network>
does the following:
- if no OLD_TOKEN_ADDRESS is given: deploys a mock ERC20+ERC677 contract representing xATS_tmp
- deploys an instance of XATSToken (new xATS) with an initial supply of 300 000 000
- deploys an instance of Artis2Launch with the 2 token contract addresses as constructor arguments. old token is the token to be sent to the contract, new token is the token which will be sent back from the contract in return
- funds the Artis2Launch contract with 50 000 000 (new) xATS tokens
XATSToken
is an ERC777 token based on the OpenZeppelin implementation.
It additionally implements the ERC677 interface in order to be compatible with TokenBridge. This is important because the xATS token will later be bridged to the new ARTIS 2.0 chain.
Notes
In order to make sure that old tokens are accepted by the Launcher contract only if the swap is successful (swapping period not over, enough new tokens to hand out), the oldToken contract needs to enforce successful execution of the ERC677 hook not just for transferAndCall()
, but also for transfer()
.
To facilitate this, the Launcher contract implements ERC165 with the IERC677Receiver
interface published.
The same mechanism can be used to later attach the new xATS token to a tokenbridge mediator. For all transfer methods (except the ERC777 specific ones which have their own callback mechanism) it checks if the receiver advertised an implementation of IERC677Receiver
via ERC165 and if so enforces successful execution.
The tokenbridge mediator contracts don't implement ERC165 yet, but that can be added easily.