instadapp / dsa-resolvers Goto Github PK
View Code? Open in Web Editor NEWDSA Resolvers
DSA 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:
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:-
Polygon:-
These are good to start with. We'll work on more going forward.
Deploy:
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 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 marketgetMarketDetailsAll
should return all the market detailsYou 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/
Create a new function here.
It'll take the user address as input and will return supply tokens and borrow tokens of the user.
For reference - https://docs.aave.com/developers/the-core-protocol/lendingpool#getuserconfiguration
Reference material ->
SDK - https://www.npmjs.com/package/@morpho-org/morpho-aave-v3-sdk
Snippets Repo - https://github.com/morpho-org/morpho-snippets
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.
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.
Follow mainnet implementation from #29 and implement it on polygon as well.
Create a resolver for CompoundV3 (USDC market) on Polygon. Use the existing InstaCompoundIIIResolver
resolver.
Additional things =>
InstaCompoundIIIPolygonResolver
Mainnet Resolver - https://github.com/Instadapp/dsa-resolvers/tree/main/contracts/protocols/mainnet/compound_iii
Description:
Create a resolver for CompoundV3 on Arbitrum. Use the existing InstaCompoundIIIResolver Polygon resolver.
Additional things =>
InstaCompoundIIIArbitrumResolver
getPositionByTokenId
and getPositionByTokenIds
returns only the details about the tokenIds, need to include this params as well:
getPositionInfoByTokenIds
which takes uint256[] memory tokenIds
, and calls getPositionInfoByTokenId
for every tokenId.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
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)
We have already implemented his lending and borrowing functionality on the connector level, similar to Compound.
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.
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
structgetPosition
returning UserData
structgetMorphoConfig
returning MorphoData
structUpdates ->
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^
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.