GithubHelp home page GithubHelp logo

oasisdex / oasis-borrow Goto Github PK

View Code? Open in Web Editor NEW
85.0 17.0 66.0 187.64 MB

summer.fi

Home Page: https://summer.fi

License: Apache License 2.0

Dockerfile 0.01% TypeScript 99.62% JavaScript 0.29% Shell 0.06% Nix 0.01% Procfile 0.01% PLpgSQL 0.02%

oasis-borrow's Introduction

License codecov



Environment URL Branch Build Status
Production summer.fi main
Staging staging.summer.fi dev

Summer.fi

Summer.fi 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.


Getting Started

Clone the repository

git clone https://github.com/OasisDEX/oasis-borrow.git

Navigate to the project folder and install all dependencies

NOTE: to install private packages from NPM you need to have an env variable called NPM_TOKEN containing your personal NPM access token. We recommend to set NPM_TOKEN in your .env file using our .env.template, this way you can just source .env before install.

source .env
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

  • NOTE: If you get a localnode Error when running ./scripts/dev.sh, comment out the whole localnode section in ./scripts/docker/compose.yml file and run the command again.

In a second terminal we can then begin the web server instance over http or https (https is required for testing hardware wallets):

  • Note: For running the app locally you'll need to create a .env.local file. Make sure you have everything setup correctly according to the configuration explained here.
yarn start

# Optionally
HTTPS=true yarn start

The application will be viewable on http://localhost:3000 or https://localhost:3443 respectively

At this point, no products will be loaded in the products hub of the homepage. To see products, open a third terminal and run:

curl -X PATCH -H "Authorization: <your PRODUCT_HUB_KEY entered in .env.local file>" -H "Content-Type: application/json" -d '{"protocols": ["aavev2", "aavev3", "maker", "ajna", "sparkv3"]}' http://localhost:3000/api/product-hub

Run staging site locally

You can run the current staging site, (found at https://staging.summer.fi) alongside the database, by running:

./scripts/dev-with-staging.sh

It will pull an additional docker container with the current staging site and will make it available at http://0.0.0.0:3000


Configuration

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.

List of env vars needed in .env.local file to run the app locally

INFURA_PROJECT_ID="<API key from Infura>"
OPTIMISM_MAINNET_RPC_URL="<Optimism URL from Alchemy>"
ARBITRUM_MAINNET_RPC_URL="<Arbitrum URL from Alchemy>"
SENTRY_RELEASE="local"
PRODUCT_HUB_KEY="<any value of your choice>"
  • Note: You'll need to create an account in Infura and another one in Alchemy (Free accounts are ok), and create apps in Alchemy for Arbitrum & Optimism.

List of the build-time env vars

  • COMMIT_SHA - The value is used together with SHOW_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.

  • MIXPANEL_ENV - The value could be either production 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 to production then all the events will be actually sent to Mixpanel.

  • MIXPANEL_KEY - The value will be used for production environments. This is the project key that is generated from Mixpanel.

  • ADROLL_PIX_ID - The value will be used for production environments. This is the project key that is generated from AdRoll Pixel.

  • ADROLL_ADV_ID - The value will be used for production 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 either 0 (disabled) or 1 (enabled).

  • USE_TRM_API - 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 either 0 (disabled) or 1 (enabled).

  • SHOW_BUILD_INFO - The value will determine whether an information about the build is displayed 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 either 0 (disabled) or 1 (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.

  • SENTRY_RELEASE - The release in sentry.io. Used by sentry.io to generate and upload source maps for a given release at build time, and tie those source maps to errors sent to sentry at run time.

  • SENTRY_AUTH_TOKEN - auth token used by sentry.io to upload source maps.

As mentioned previously, there is also the custom express server part which uses the env variables at run time

List of the run-time env vars

  • 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 from CHALLENGE_JWT_SECRET. This is used when the user signs the Terms of Service.

  • SENTRY_RELEASE - The release in sentry.io. Used by sentry.io to generate and upload source maps for a given release at build time, and tie those source maps to errors sent to sentry at run time.

  • NEXT_PUBLIC_SENTRY_ENV - The environment that sentry events are tagged as. production | staging | pullrequest | development

Note: Make sure that you call the process that build the project with the build-time vars and make sure that you call the process that runs the application with the run-time vars.


Hardhat

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


Docker Containers

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

Docker Containers Usage

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.

Docker Containers Configuration

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 transaction
  • PRIV_KEY_MAINNET - The private key of the first wallet address from the signer that is used
  • TENDERLY_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 default this value is 0. If it is set to 1 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.

Multiply feature

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.

Contributing

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

Unit tests 👷

We are currently in the process of moving our tests from Mocha (with Chai, Enzyme, and Sinon) to Jest (with React Testing Library). We are also in the process of adding more tests to increase our coverage. We have some tests skipped for now, but we are working on fixing them. We needed to disable caching in the build action. Testing with collecting coverage was failing with caching enabled. Skipped tests (Marked with TODO: [Mocha -> Jest] Rewrite in Jest compatible format.):

License

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

http://www.apache.org/licenses/LICENSE-2.0

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.

oasis-borrow's People

Contributors

adamskrodzki avatar chrisbradbury88 avatar cristidas avatar dependabot[bot] avatar dizzy avatar eskp avatar fbrinkkemper avatar fenris85 avatar ferni avatar george-field avatar halaprix avatar jakubswierczek avatar jeannettemcd avatar johnnieskywalker avatar juan-langa avatar logvinovleon avatar lucianken avatar maciejka avatar marcinciarka avatar pacxiu avatar padraic-o-mhuiris avatar paszkowskidamian avatar peculiarity avatar piekczyk avatar piotrkonowrocki avatar piotrwitek avatar rkrasiuk avatar sasicodes avatar sennett avatar zerotucks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oasis-borrow's Issues

[Bug] - <bug issue>

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop/Smartphone (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Connection method [e.g. Metamask, Ledger, Trezor]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

I cant see DAI generated after opening a n ETH-C vault from my safe.

Describe the bug
I submitted a transaction to create a vault on ETH-C using 161 ETH as collateral with the minimum liquidation price possible, when teh transaction was confirmed I didnt recieved any DAI on the safe account, I was expecting to receive 66000 DAI.

To Reproduce
Steps to reproduce the behavior:

Go to ETH-A and create a vault from a gnosis safe.

Expected behavior
I was expecting to recieve 66000 DAI on my safe account but it didnt happened.

Screenshots
Screenshot from 2023-08-18 20-14-40
Screenshot from 2023-08-18 20-15-09

Desktop/Smartphone (please complete the following information):
Linux, Ubuntu.

Additional context
I did this plenty of times and I always received dai every time I created a vault, what happened? im freaking out.

Here is the TX of the vault creation: https://etherscan.io/tx/0xd9ca74fc244de849c1a13b46b8d44733f37bf0106b75b20cb628bca5190e8357

[Bug] - <bug issue>

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop/Smartphone (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Connection method [e.g. Metamask, Ledger, Trezor]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Unable to Payback DAI for very first vault - Payback Vault

Describe the bug
When the user creates a vault for the very first time through proxy contract. Then if the user try to payback DAI, then it shows wrong Collateral Ratio. And user is unable to payback DAI. Dai debt is not displayed correctly, because of that we cant Payback DAI.
Let say 0.001 dai is left but our collateral ratio becomes soo high and it appears wrong.

To Reproduce
Steps to Reproduce:

Enter the URL "https://oasis.app/?network=goerli#multiply"
Click on Connect Wallet Button on Navbar.
Click on Metamask & Change the Network to Goerli Testnet.
Sign in with the very new account of Metamask.
Accept the terms & condition.
Click on Borrow APP & select any ETH-C, ETH-A or ETH-B.
Create Proxy Contract.
Confirm & Create Vault.
Click on my position and select the first ever vault you created.
Select the option "Payback DAI"
Enter the Payback DAI & collateral (ETH) value.
You will see the WRONG Collateral RATION appearing under Collateral Ratio heading in Overview.

Expected behavior
The user should be able to Payback DAI & gets it collateral back for the very first created vault.

Screenshots
Oasis APP

Desktop/Smartphone (please complete the following information):

  • OS: [ MAC, windows & Linux]
  • Browser [chrome]
  • Connection method [Metamask]
  • Version [mac os monterey 12.2, windows 10, Ubuntu 22.04.2]

Additional context
Issue appears on TestNet goerli so you have to change network to testnet then follow the steps.

[Bug] - <bug issue>und und die Wolte

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop/Smartphone (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Connection method [e.g. Metamask, Ledger, Trezor]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Show ENS name and avatar in UI if user owned one

Is your feature request related to a problem? Please describe.
It would be great if we show the ENS name and avatar if the user has it

Describe the solution you'd like
We just gonna replace the address with ens name

Describe alternatives you've considered
Using ethers, we can able to resolve the ENS domain and avatar of the address.

Additional context
image
image

"Switch to Multiply" functionality broken in ETH-B Vaults after 7.9.0 Release

Description:

The "Switch to Multiply" functionality broken in ETH-B Vaults after the 7.9.0 Release.

Steps to reproduce the behavior:

  1. Go to ETH-B vault overview.
  2. Select "Manage Your Vault" > "Switch to Multiply"
  3. Click on "Switch to Multiply" on the dropdown menu.
  4. The vault overview reloads and stays in "Borrow" mode.

Expected behavior:

Switch to Multiply mode.

Desktop/Smartphone:

  • OS: macOS Ventura 13.0.1 and macOS Big Sur 11.7.6
  • Browsers: Chrome and Firefox.
  • Connection method: Metamask 10.28.3

Additional context:

Check the other vault types, "Switch to Multiply" and "Switch to Borrow" are critical functionalities for the end user.

Bounty - Add front-end support for borrowing with Curve stETH/ETH LP tokens through CropJoin

Overview

Please note - this bounty requires advanced TypeScript knowledge. Knowledge of the Maker protocol is highly recommended.

The Maker protocol is adding support for generating DAI with the Curve stETH/ETH LP token as collateral. As this collateral also provides the user liquidity mining rewards in LDO tokens, this is a non-standard collateral to be added. Therefore the Maker protocol has created a new module: cropjoin. The collateral will be added through the cropjoin module.

This bounty is for adding cropjoin support in Oasis.app, and thereby supporting the Curve stETH/ETH LP token as collateral.

Resources

  • The goal of this bounty is to add the Curve stETH/ETH LP token as a 'borrow' product on Oasis.app. So the product must be under a new 'Curve LP' category on https://oasis.app/borrow
  • The card must use the following visual assets
  • The new proxyActions for interacting with the Cropjoin must be used for the interaction with the new collateral (link: https://github.com/makerdao/dss-crop-join/blob/master/src/DssProxyActionsCropper.sol)
  • The vaults that are created with CropJoin have a CDP ID registered slightly different than regular vaults. It is important that Oasis.app/{vaultid} continues working for these vault types.

Acceptance criteria

  • If the user opens the https://oasis.app/borrow page there is a new category for Curve LP
  • If the user clicks on this category, there is shown 1 borrow product, the Curve stETH/ETH LP token
  • If the user clicks 'borrow' on this new product, the user is redirected to oasis.app/vaults/open/{TBD- ILK name}
  • The 'Open vault' flow uses the same proxy & allowance validations as existing vaults
  • If the user is on the open {TBD-ILK name} page, the user is able to enter an amount of Curve stETH/ETH LP tokens to deposit.
  • The existing calculations in the open page are updated to account for this new token type.
  • If the user enters a deposit amount, and optionally an amount of dai to generate, then the user can open the vault by signing the generated transaction. This transaction makes use of the proxyActions
  • If the transaction succeeds, a vault is opened, and the user can manage their vault there.
  • if the user goes to manage their newly created vault on oasis.app/{vaultid}, then the user should be able to manage their vault by: depositing/withdrawing collateral & generating/paying back DAI on the Collateral & DAI tabs. The Multiply tab should notify users that multiply is not available, as is done for Uniswap v2 lp token collateral types.
  • The existing proxy, token & dai allowance validations are used for the relevant manage options.

Coinbase - Auto-Connect / 1-Click Connect

Is your feature request related to a problem? Please describe.
We are finalizing the dapps marketplace on the browser on the Coinbase app and what dapps to list on the homepage and I am reaching out to share the requirements needed to qualify:

  1. Responsive Web Design
  2. CBW SDK - Integration
  3. Auto Connect / 1-click connect (To simplify the wallet connection experience, consider implementing autoconnect/1-click connect on mobile)

The last requirement is the only requirement Oasis needs to complete to qualify to be listed on the homepage of our dapps marketplace.

Describe the solution you'd like
The steps to enable auto-connect are on this site: https://docs.cloud.coinbase.com/wallet-sdk/docs/ux-tips#mobile-ux-guidance

Testing Instructions
To test auto-connect, on the Coinbase Wallet app, click the middle icon and search for your dapp in the browser on top. If the wallet auto-connects or connects after clicking “connect”, then you have enabled the feature and there are no further steps. If you are given an option of wallets to choose from, then auto-connect did not work.

You can also contact me on discord - Ryan (Coinbase)#6131 or my email [email protected]. I would love to discuss this more and provide any assistance if needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.