The veil-contracts
repo includes various smart contracts developed by the Veil team and deployed to Ethereum. These include Veil Ether, Veil’s Virtual Augur Shares template, OracleBridge, and two smart contracts that we’ve built to improve the experience of onboarding and trading on Veil.
Install:
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
yarn
Rename development.env to .env and set some environment variables:
MNEMONIC=<INSERT MNEMONIC OF ADDRESS DEPLOYING CONTRACTS>
ALCHEMY_API_KEY=<INSERT ALCHMEY API KEY>
You can generate a MNEMONIC using Metamask and get an API key from Alchemy
Start a local blockchain like Ganache. You can use Ganache CLI or the desktop client.
yarn run ganache
Compile and migrate your local smart contracts.
truffle migrate --reset
yarn run ganache
yarn run test
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
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.
To support AugurLite, we developed a smart contract to resolve AugurLite markets. This contract, OracleBridge stores a mapping of markets to their resolvers, addresses that can finalize AugurLite markets by calling the resolve
method in OracleBridge. Effectively OracleBridge is the resolver for many markets, but it can delegate resolving responsibility to another address or smart contract.
This design enables the deployment of additional smart contracts that sit between OracleBridge and oracles, like Augur, that pass along state from the oracle to OracleBridge—and ultimately AugurLite. So once the Augur oracles finalize a market, the bridge contract can observe the market's outcome and pass it to the resolve
method to resolve AugurLite markets. The same system could be used to pull state from other oracles, and OracleBridge is responsible only for determining which address can call the resolve
method for a given market.
If you have questions, comments, or ideas, we recommend pursuing one of these channels:
- Open an issue or pull request in this repository
- Reach out to @veil on Twitter
- Send an email to hello@veil.co
- Join Veil's discord and reach out to a Veil team member
veil-contracts
is maintained by @mertcelebi, @gkaemmer, and @pfletcherhill.
The Veil smart contracts are released under the MIT License. See License.