Veil Smart Contracts
VeilEther as of commit 5f5d6cf3241f915495ed971d47f18d95cfa43672 is deployed at 0x53b04999c1ff2d77fcdde98935bb936a67209e4c. VirtualAugurShareFactory as of commit 0e2356bbf156d73a8efab3157322f7034a47f7be is deployed at 0xcb662b5b0890c6d2de97dcd19117fa9e30a8e211.
yarn add veil-contracts
This repo assumes you have truffle installed globally. If you don't have it make sure you have the most recent version installed.
yarn global add truffle truffle version Truffle v4.1.13 (core: 4.1.13) Solidity v0.4.24 (solc-js)
Install packages using yarn
Rename development.env to .env and set some environment variables:
MNEMONIC=... INFURA_API_KEY=... JSON_RPC_PORT=8545
yarn run ganache
Compile and migrate your local smart contracts.
truffle migrate --reset
yarn run ganache yarn run test
Deploying to Kovan, Mainnet
To deploy to Kovan or Mainnet, make sure your account (the first address derived from your MNEMONIC) has at least
0.3 ETH, then run:
yarn run migrate:kovan # or yarn run migrate:mainnet
Notes about VeilEther and VirtualAugurShares
Veil uses 0x to let people trade shares in Augur markets, meaning users can immediately create orders without sending Ethereum transactions. Unfortunately it requires two awkward steps before users can trade:
They need to wrap their ETH and approve it for trading with 0x. For every token they trade, they need to approve a 0x smart contract to control their balance of that token.
The UX of wrapping ETH and setting an unlimited allowance for the 0x contract is bad. From the user's perspective, it is tough to understand (wrapping ETH) and scary (setting unlimited allowance). And the user needs to make two Ethereum transactions, which is slow and expensive. The goal is to create a version of WETH that is either pre-approved for trading on 0x. For this, we've considered 3 approaches.
From the user’s perspective, both steps are tough to understand (e.g. “why do I need to wrap my ETH?”) and scary (e.g. “am I putting 1.158e+59 shares at risk?”). And both steps require at least one Ethereum transaction, which is slow and expensive.
The Veil smart contracts are designed to streamline Veil’s UX by removing the extra unlocking transaction. Veil Ether is a fork of WETH with a custom
depositAndApprove function that lets users deposit ETH and set an allowance in a single transaction. This means that once you’ve wrapped your ETH into Veil Ether, there’s no need to approve it for trading on 0x.
The second step, unlocking tokens, poses a bigger challenge for Augur shares. Each market on Veil (and Augur more generally) introduces at least two new ERC-20 tokens — one for each outcome. For a user to trade or redeem their shares in those new markets, they’ll need to unlock both tokens. If a user trades on 10–20 markets, then they’re faced with an additional 20–40 Ethereum transactions. Obviously, at some point this becomes untenable, and it’s a bad user experience.
To let users skip all of these transactions, we’ve built Virtual Augur Shares, a template for ERC-20 tokens that wrap Augur shares and approve them for trading on 0x. Each Virtual Augur Share is redeemable for a share in a specific Augur token, just like WETH is redeemable for ETH. And by default Virtual Augur Shares are pre-approved for trading on 0x, so users do not have to submit a second approve transaction.