Giter Club home page Giter Club logo

defi-sdk's Introduction

Build status Test status Coverage status Lint status License Discord Twitter Follow

DeFi SDK is an open-source system of smart contracts that allows you to execute trades with ERC20 tokens and track balances on different protocols.

If you have any questions about DeFi SDK, feel free to reach out to us on our Discord server.

Features

💸Trade any ERC20 tokens on L2 chains using single Router contract

See How to swap ERC20 tokens using DeFi SDK Router

💥Query user assets and debt deposited in DeFi protocols like Maker, Aave, dYdX, etc.

How much debt does 0xdead..beef have on Compound?

📊Get the underlying components of complex derivative ERC20 tokens

How much cUSDC vs ETH does ETHMACOAPY have?

✨Interact with multiple DeFi protocols in a unified way

See How to interact with DeFi SDK contracts

Trading Features

  • Trade any ERC20 token
  • Two types of amounts: absolute (usual amount) and relative (percentage of balance)
  • Three types of permit() functions for approving tokens in the same transaction (EIP2612, DAI-like, Yearn-like)
  • Two types of swaps: with fixed input amount or fixed output amount
  • Two types of fees:
    • protocol fee managed by the Router contract owner with possibility of one-time discounts requiring signature of an address with the special role
    • marketplace fee managed by the transaction creator
  • Relayed transactions requiring just an EIP712 signature of the user

How to Add Your Adapter

Read-only and interactive adapters are maintained in master and interactive-updates branches of defi-sdk repo respectively.

The full instructions on how to add a custom adapters may be found in our docs.

If you have questions and/or want to add your adapter to Zerion reach out to us on our Discord server.

Addresses

All the deployed contracts' addresses are available here.

Security Vulnerabilities 🛡

If you discover a security vulnerability within DeFi SDK, please send us an e-mail at [email protected]. All security vulnerabilities will be promptly addressed.

The project uses Slither for security analysis. It should be previously installed (e.g. via pip).

Run npm run slither to run security checks.

Dev Notes

We use Hardhat, which runs tests extremely fast!

Also, we use Truffle Dashboard for secure deployment.

Installation

Run npm install to install all the dependencies.

Deployment

Run npm run truffle-dashboard to start the Truffle Dashboard.

Run npm run deploy:router:truffle-dashboard to deploy the Router contract. Sign deployment transaction in your browser at http://localhost:24012/.

Fill in address of newly deployed contract to scripts/deployment.js.

The same instruction applies to the SimpleCaller contract with deploy:sc:truffle-dashboard command.

After filling in fee beneficiary for the chosen network in scripts/deployment.js, initialize:router:truffle-dashboard command may be run.

Run npm run verify to verify contract on any block explorer. The respective <BLOCK_EXPLORER>_API_KEY filled in .env file is required for this step. See the hardhat.config.ts file for the details (etherscan field of config variable uses these API keys).

Testing & Coverage

The Router contract and its dependencies is fully covered with tests.

Run npm run test and npm run coverage to run tests or coverage respectively. INFURA_API_KEY filled in .env file is required for this step. REPORT_GAS filled in .env file enables/disables gas reports during tests.

Linting

Run npm run lint for both JS and Solidity linters.

Run npm run lint:eslint and npm run lint:solhint to run linter for JS and Solidity separately.

Serve docs

npm run docs:serve

License

All smart contracts are released under GNU LGPLv3 license.

defi-sdk's People

Contributors

0xbuidlman avatar abalyasnikov avatar bugduino avatar coreycaplan3 avatar cr-igor avatar evgeth avatar mickdegraaf avatar omahs avatar rockfridrich avatar sobolev-igor avatar sparrowdom 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  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  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

defi-sdk's Issues

Aave result from adapter contract getBalances() does not contain LEND deposit

Hello guys!

In parallel with other querying methods we started utilizing your Adapter contracts to get some overview of DeFi balances in Rotki.
https://github.com/rotki/rotki/blob/19204d766a88407e35cd056a327fddaf625659ac/rotkehlchen/chain/ethereum/zerion.py

We noticed that if the balance of an address is queried that has LEND deposited in the Aave Lending Pool then this is not returned by the Adapter contract. So we had to make a "special case" fix for it: rotki/rotki#1137. Essentially querying the lending pool directly for LEND balances for each address.

Are you aware of the problem? Any idea if a fix can be provided at some point so we can get rid of our ugly fix?

Update DMM Controller Address

The DeFi Money Market Controller address is outdated now.

The old address was 0x4CB120Dd1D33C9A3De8Bc15620C7Cd43418d77E2

The new one is 0xB07EB3426d742cda9120931e7028d54F9dF34A3e

RealT read-only adapter

Все что у меня есть:

  • Сайт: https://realt.co/
  • Список активных ассетов :
    {"results":[{"name":"9943 MARLOWE ST.","address":"0xe5f7ef61443fc36ae040650aa585b0395aef77c8","totalTokens":1000,"price":63.75,"ownedTokens":"0","balance":0},{"name":"16200 FULLERTON","address":"0x22c8ecf727c23422f47093b562ec53c139805301","totalTokens":3800,"price":161.84,"ownedTokens":"0","balance":0},{"name":"18483 MANSFIELD","address":"0xb1d42642c6da784a5498180fdc64df8f8f2bb773","totalTokens":900,"price":68.52,"ownedTokens":"0","balance":0},{"name":"5942 AUDUBON RD","address":"0x43688910273f199b8ae2ca018c13918fb3d37b58","totalTokens":750,"price":77.73,"ownedTokens":"0","balance":0},{"name":"10024 APPOLINE ST","address":"0x5807ca447851c98569c567963b25b1c83d41bebc","totalTokens":4000,"price":145.56,"ownedTokens":"0","balance":0},{"name":"9336 PATTON ST","address":"0xed42cedcadbfbcaa3e6f411b09567c2c0b5ad28f","totalTokens":1000,"price":62.7,"ownedTokens":"0","balance":0},{"name":"20200 LESURE ST","address":"0x395c47a421c254ae42253764a7f56e0ee0cddac5","totalTokens":1000,"price":69.4,"ownedTokens":"0","balance":0}]}

Direct Uniswap trades via DeFi SDK

нужно сделать по аналогию с Curve, если трейд идет 100% на Uniswap:

  • проверяем есть ли у юзера уже approve на Uniswap, отправляем на Uniswap
  • если Approve нет, отправляем транзитом через DeFi SDK

Out of gas in getBalances

HI.

Contract address - 0x06FE76B2f432fdfEcAEf1a7d4f6C3d41B5861672
function - getBalances
arg - 0xD032a14D09C10f788fC79e8C8e3E295c82cA679d

result - [ getBalances(address) method Response ]
tuple[] : Error: Returned error: out of gas

I am use etherscan -> contract -> read contract

Feature Request: For certain protocols provide info on whether the deposited asset is enabled for use as collateral

Certain DeFi Protocols (e.g. Compound, Aave), let a user use their deposited assets as collateral in order to take out loans (borrow). The user must enable this on a per asset basis. Since there is thus a differentiation between deposited assets and deposited assets enabled as collateral, it would be nice if this information was exposed in the protocolBalances calls. Since this property isn't common across all protocols perhaps it would go into something like an extendedInformation property within the metadata for the token.

As an example, here is one of the Aave methods that exposes this information: https://docs.aave.com/developers/developing-on-aave/the-protocol/lendingpool#getuserreservedata (see usageAsCollateralEnabled).

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.