This is the repo of the wicked.financial dapp for creating, redeeming and settling synthetich tokens based on UMA LSP (Long Short Position) contracts.
The LSP contracts are a financial primitive that allow the user to build a variety of different derivatives by choosing the corresponding configuration parameters. We are currently focusing on a configuration that allows the user to achieve a leveraged exposure to exchange rate changes between fiat currencies (i.e. EUR/USD) while providing a (potentially interest yielding) Stable-Coin token as collateral.
The ultimate goal is to enable people around the world to easily hedge their foreign currency risk in a distributed and permission-less way.
Using the LSP contract for this purpose allows users to:
Assuming you have Node(v14.x)
and Yarn (v1.22)
installed you should be able to install
all other dependencies using:
$ yarn install
Some of the tasks / tests described below will require hardhat to access a kovan RPC-node and / or a wallet using the first account in the wallet for various test / deployment tasks.
For these purposes you will have to save the url of a Kovan RPC-Node as well as a wallet mnemonic in url.txt
and mnemonic.txt
files at the root level of the repository.
Note that these files are added to the .gitignore
file but you should be extra careful to NEVER commit / push these files to the repository.
The project contains a number of tests regarding the dapp itself as well as the UMA contract interfaces that we use which you can run with:
$ yarn test
Run a development Nuxt
server with hot reload to serve the Dapp at localhost:300:
$ yarn dev
# generate static project
$ yarn generate
# build for production and launch server
$ yarn build
$ yarn start
Currently the relevant contract instances for the Dapp are only deployed on the Kovan-testnet. Therefore you have to options when using the dapp:
In both cases we suggest using the Metamask browser wallet. All steps below should work identicially wether you use a locally hosted version of the dapp or the one hosted at wicked.financial.
For this option all you have to do is switch your metamask wallet to the Kovan network and start using the dapp.
If you want to have unlimited test ETH and extended control over the state of the network (i.e. setting timestamps) you might want to fork the Kovan network and run a local copy.
You can achieve this by running the following hardhat command replacing KOVAN_RPC_URL
with the URL of a Kovan RPC provider such as Infura or Alchemy.
$ yarn hardhat node --fork KOVAN_RPC_URL --show-accounts`
We recommend to provide an RPC that allows archive access to avoid unnecessary transaction errors. The above command should show a number of accounts each of which should contain 10000 ETH on the local network. To setup your Metamask for this local network you should first conn
http://localhost:8545
and Chain-ID:42
While using the local network you might get errors in Metamask saying something like Transaction Nonce too high
, in this case you will need to reset the respective
account using the button in the settings.
To speed up testing and allow the user to interactively step through the different phases of the contract lifecycle we
have implemented a number of custom hardhat tasks.
Note that the parameter --network localhost
runs all of these commands on the local kovan fork but you can also run them directly on
kovan by adjusting this parameter accordingly.
However this might result in spending significant amount of ETH from the wallet whose mnemonic you have provided.
Creating / Minting synthetic tokens for a given contract will require you to provide the configured collateral. To generate collateral of the respective Token (in this case LUSD) you can visit a liquity front-end on kovan:
### Some liquity front-ends to get some LUSD
### Remember that we are currently only on Kovan
https://eth.liquity.fi/
https://liquityapp.com/
https://app.liquity.gg/#/
To forward the block timestamp to the expiry date of a contract identified by its synthetic-name
run:
$ yarn hardhat time:expiry --synthetic-name EURUSD-210701 --network localhost
To propose a settlement price for the price feed of a given contract to the Optimistic Oracle run:
$ yarn hardhat propose --synthetic-name EURUSD-210701 --proposed-price 1.25 --network localhost
To fast forward the block timestamp by the default dispute liveness period of the Optimistic Oracle run:
$ yarn hardhat time:dispute --network localhost
If a price has been proposed (and not disputed) and the liveness period has past you can settle synthetic tokens that you have created before
$ yarn hardhat settle:lsp --synthetic-name EURUSD-210701 --long-tokens 0 --short-tokens 0 --network localhost