Code Monkey home page Code Monkey logo

dsa-resolvers's People

Contributors

0xdaksh avatar babkendev01 avatar bhavik-m avatar carlos53093 avatar cryptodev222 avatar ishanjain28 avatar kaymasjain avatar letteldream avatar pradyuman-verma avatar prodesert22 avatar richa-iitr avatar shriyatyagii avatar tbouder avatar thrilok209 avatar universefinance avatar vaibhav20201 avatar yaronvel avatar zapaz avatar

Stargazers

 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

dsa-resolvers's Issues

New standardized resolvers

Old resolvers are very untidy and can't communicate main things easily. We've to refactor it into different files as needed.

Take example from connectors repo.

Divide the resolver into 4 parts just like connectors:

  • events.sol (If needed)
  • Interface
  • Helpers
  • Main

We'll also write the test cases using Typechain for it which will be comparatively very simple as they will rarely be dependant on any contract which are not live on-chain.

Standardize old resolvers from here

Initial resolvers to start with:

Mainnet:-

  • aave_v2
  • compound
  • erc20
  • makerdao

Polygon:-

  • aave_v2

These are good to start with. We'll work on more going forward.

Uniswap v3 on Polygon

Deploy:

  • Uniswap v3 resolver
  • Uniswap v3 staking resolver

The resolvers will be exactly the same as mainnet or arbitrum as the contract addresses for Uniswap v3 stay the same on all chains. For reference look at the addresses here

Add CRV USD Resolver

Add curveUSD Resolver.

CurveUSD is a borrow and lending protocol, similar to MakerDao. It offers various token markets against which you can borrow crvUSD (similar to Makerdao vaults in which you can borrow Dai).

It should contain these functions ->

  • getPosition with user address and market address (token) input and it will return all the user data for that market including the market details.
  • getPositionAll with user address input and it will return all the user data for all the markets including the market details.
  • getMarketDetails should return all the market details for a particular market
  • getMarketDetailsAll should return all the market details

You can go through the docs and try to include as many fields and data as possible.

App - https://crvusd.curve.fi/#/ethereum/markets
Github- https://github.com/curvefi/curve-contract
Docs - https://curve.readthedocs.io/

Resolve error

Hey! Running the updated way of test cases here in this PR is causing error. We all tried to look into it but were not able to figure out what it is. Seems to work on windows of Pradhyuman (who did the code) but not on Mac for me & Thrilok and Linux for Pradhyuman. Can you have a look into it?

Here's a loom video for the error.

Previously, we used to run test cases of single-chain at once but with this we were trying to automate to run test cases of all chains at once.

Onchain Oracle

Use 1nch's oracle to get prices of multiple tokens in usdc.
Here is 1inch's oracle repo:- https://github.com/1inch/offchain-oracle
Can get the contract addresses from the readme of the above repo.
Make a contract that will take multiple token addresses, will call the getRate() function of the 1nch's oracle for every token, store the price of each token in an array, return it.

Uniswap resolver update

  • getPositionByTokenId and getPositionByTokenIds returns only the details about the tokenIds, need to include this params as well:
    • owner address of respective tokenId

Update uniswap v3 resolver

  • Update uniswap v3 resolver to take an array of tokenId and returns the position of all the tokenIds.
  • Need to add a function here, named getPositionInfoByTokenIds which takes uint256[] memory tokenIds, and calls getPositionInfoByTokenId for every tokenId.

ERC4626 resolver

Resolver contains all the read related data so we can fetch entire details at once. We use to fetch all the user's token balances at once or details related to a protocol for example, all Maker vaults data or user's Aave position with details of all the tokens, etc.

You can take the reference of this resolver for now. This is the simplest ERC20 resolver. You can also check other resolvers to get some idea. We need to create the same for ERC4626 which accepts ERC4626 addresses and owner's address and return data related to that.

https://github.com/Instadapp/dsa-resolvers/tree/main/contracts/protocols/mainnet/erc20

Uniswap v3 strategy resolver

Strategy to rebalance users Uniswap position to a new range.

User UX:
The user will select a new ratio and range width. We'll collect the fee & withdraw all the assets from the existing NFT -> swap the required amount -> mint & deposit in the new NFT.

Resolver:
It's needed to calculate the accurate data as when the swap occurs the current tick moves meaning the range shifts. For bigger positions range shift is quite noticeable and if we are using 1inch or other aggregators then estimating the tick shift gets harder & complex.

What the resolver will do: (will be a write function which we will call as reading function using web3)

  • It'll take NFT ID, swap data, new ratio & new tick width.
  • It'll calculate the assets to withdraw from NFT.
  • Flashborrow the amount to withdraw.
  • Will execute swap with the required amount mentioned in the swap.
  • Calculate the new range from the new current tick. (have to factor the slots properly here)
  • Return the excess amount that was not able to deposit so the user can adjust the ratio or range accordingly.

Implement trader Joe resolver:

  • Trader Joe is a Defi protocol natively based on the avalanche network.

We have already implemented his lending and borrowing functionality on the connector level, similar to Compound.

  • Implement resolver for Trader Joe, similar to Compound on avalanche network.
  • Deploy the resolver.
  • Create backend API for it.

Trader Joe docs - https://docs.traderjoexyz.com/main/welcome/master
Landing page - https://traderjoexyz.com/lending

We will be implementing resolver only for lending and borrowing functionality.

Add Morpho Aave V3

In morpho aave v3, we won't have a lens contract. We need to fetch and calculate all the data through Morpho's core contracts.

Old morpho Lens contract - https://github.com/morpho-dao/morpho-v1/blob/main/src/aave-v2/lens/Lens.sol

We can use the getter functions included here

You can take reference for the functions to include in the resolver from morpho aave v2 resolver.

The main functions and their return values will remain the same -

  • getPositionAll returning UserData struct
  • getPosition returning UserData struct
  • getMorphoConfig returning MorphoData struct

Updates ->

  • In struct UserData, add a new field suppliedValue, which will be the total supplied value, pure + collateral.

You can see if it would also make sense to return collateral values anywhere else^

Update resolvers

  • Add Aave resolver to Avalanche (Will be same as mainnet & Polygon with addresses change and maybe minor updates).
  • Add Uniswap resolver to Arbitrum (should be same as mainnet)

Updates

  • Update the deployment script, and create a script that enables deploying from the command line. (check dsa-connectors script)
  • Add deployment table in readme.md like this,
resolver chain address
uniswap v3 polygon
  • Add "How to create a resolver section" in readme.md and as well in docs.

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.