Environment | URL | Branch | Build Status |
---|---|---|---|
Production | oasis.app | main |
|
Staging | staging.oasis.app | dev |
Oasis Borrow is the most popular user-interface to interact with the Maker protocol. It enables users to generate Dai, the most used and decentralized stablecoin, using a variety of crypto assets as collateral.
Clone the repository
git clone https://github.com/OasisDEX/oasis-borrow.git
Navigate to the project folder and install all dependencies
yarn
To create a local development instance we must first spin up the database prior to starting the web server.
# Open one terminal and run:
./scripts/dev.sh
Monitor the logs and wait for the migrations to complete. This should be evident by a log message
Migrations DONE
In a second terminal we can then begin the web server instance over http or https (https is required for testing hardware wallets):
*Note: Make sure you have everything setup correctly according to the configuration explain here
yarn start
# Optionally
HTTPS=true yarn start
The application will be viewable on http://localhost:3000 or https://localhost:3443 respectively
We utilise storybook for visualising some of our UI components in isolation. This makes development easier for UI work as next.js is very compute heavy when re-rendering changes in development mode.
yarn storybook
Stories should be viewable at http://localhost:6006 A live version of storybook on parity with the staging environment can be found by navigating to https://storybook.oasis.app.
For specific deployments, users can navigate to
https://storybook.oasis.app/<COMMIT_HASH>/index.html
where the <COMMIT_HASH>
is the shortened commit hash of the branch/commit that has been pushed.
The application consists of two parts
-
next.js
-
custom
express
server
There is the next.config.js
which contains the configuration for next.js
. This configuration is
created during build time thus The env variables that are used in this file will be evaluated during
build time.
Some of the values that are used you can check in the .env
file.
-
COMMIT_SHA
- The value is used together withSHOW_BUILD_INFO
. Main usages is to display a commit in the footer. This targets build deployments to staging environments so that the team can see which version the UI reflects. The value could be a branch name or specific commit. -
API_HOST
- The value is used to construct links based on root domain. -
MIXPANEL_ENV
- The value could be eitherproduction
or anything else you'd like to use to denote that it's NOT production. The difference is where the events are sent. For "development" environments the events will be displayed in the dev console within the browser. If the env is set toproduction
then all the events will be actually sent to Mixpanel. -
MIXPANEL_KEY
- The value will be used forproduction
environments. This is the project key that is generated from Mixpanel. -
ADROLL_PIX_ID
- The value will be used forproduction
environments. This is the project key that is generated from AdRoll Pixel. -
ADROLL_ADV_ID
- The value will be used forproduction
environments. This is the project key that is generated from AdRoll Pixel. -
USE_TERMS_OF_SERVICE
- In order to use some functionalities the user should read and accept Terms of Service. For development purposes, this feature can be disabled. You can disable this feature if you'd like to remove that functionality at all. The values are either0
(disabled) or1
(enabled). -
SHOW_BUILD_INFO
- The value will determine whether an information about the build is diplayed in the footer. Currently we display only the build time and commit from which it is built. This targets deployments to staging environments so that the tam can see which version the UI reflects. The value is either0
(disabled) or1
(enabled) -
INFURA_PROJECT_ID
- This is used in cases where the user hasn't authorized the application to access their wallet ( hasn't connected their wallet -read-only
mode) or when the application is accessed with a specific provider injected. -
ETHERSCAN_API_KEY
- The value is used to create the corresponding etherscan endpoint. For each transaction, there is a url that leads to that TX details in etherscan.
As mentioned previously, there is also the custom express server part which uses the env variables at run time
-
INFURA_PROJECT_ID_BACKEND
- This is used mainly together with the<build_time>.USE_TERM_OF_SERVICE
. It is related with Argent internals. On the backend we need to connect to a node in order to verify the wallet that is signing the Terms of Service. -
CHALLENGE_JWT_SECRET
- Could be any value. This is used on the server to sign JWT message. -
USER_JWT_SECRET
- Could be any value different fromCHALLENGE_JWT_SECRET
. This is used when the user signs the Terms of Service.
Note: Make sure that you call the process that build the project with the build-time
vars and
make sure that you call the proces that runs the application with the run-time
vars.
In addition, we make use of hardhat in order to test the application in a controlled mainnet-like environment. More details can be found here
Current we have two containers:
-
postgres-oasis-borrow
- This container contains Postgre database -
multiply-proxy-actions
- This container contains all contracts related to multiply functionality deployed to a hardhat instance
Once you are in the project directory, please execute the following command:
docker-compose -f ./scripts/docker-compose.yml up
Alternative to that is to do the following steps:
cd ./scripts
docker-compose up
By executing one of the following commands you will run both containers at the same time. The process won't exit so you will be able to see the output in real time.
If you open docker-compose.yml
file under the ./scripts
folder, you will see that there are some environmental variables.
For the Postgres container, you won't have the need to change them that often. Also the names are pretty explanatory
The configuration params for multiply-proxy-actions
container are as follows:
ALCHEMY_NODE
- The node that is used to read/sync data from the blockchain.ETHERSCAN_API
- Etherscan API Key that is used to get information for a transactionPRIV_KEY_MAINNET
- The private key of the first wallet address from the signer that is usedTENDERLY_USERNAME
- This is the username in tenderly. It is advised to create your own registration and use your own username. Register here.TENDERLY_PROJECT
- Once you have an account there is a default project -project
. You can create other project names as well.USE_DUMMY
- By defailt this value is0
. If it is set to1
then instead of the real 1inch Exchange implementation being used, you will use the DummyExchange implementation.BLOCK_NUMBER
- There is a hardcoded number currently used -13008355
. If you want to fork from a different one, please use this parameter.
We have added multiply functionality, where generated DAI is immediately used to swap for more collateral. This utilizes the multiply proxy actions smart contract. The documentation for those contracts can be found here.
Contributions are welcome. Feel free to open issues or PR's to improve Oasis Borrow. We are always open to suggestions on how best to improve the application to give the optimal user experience.
Please ensure that the tests pass, typechecks and conforms to the linting rules. The most convenient way to do this is by calling:
yarn test:fix
Copyright (C) 2021 Oazo Apps Limited, Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.