Skip to content

veilco/veil-contracts

Repository files navigation

Veil Smart Contracts

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.

Current addresses of relevant contracts

Contract Commit Ethereum Address
Veil Ether 5f5d6cf324 0x53b04999c1ff2d77fcdde98935bb936a67209e4c
VirtualAugurShareFactory 97be1e2334 0x94888179c352fdf7fbfbdf436651e516c83cfe37
OracleBridge 14086eba65 0x83aa83e02929c0783a463a0105ce25e52f6092c1

Usage

Install:

yarn add veil-contracts

Development

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

Testing

yarn run ganache
yarn run test

Deployment

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

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:

  1. 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.

  2. 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.

OracleBridge

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.

Questions and support

If you have questions, comments, or ideas, we recommend pursuing one of these channels:

veil-contracts is maintained by @mertcelebi, @gkaemmer, and @pfletcherhill.

License

The Veil smart contracts are released under the MIT License. See License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published