From a9f48419e7e492fc6859156fd6470f6e80dfee8b Mon Sep 17 00:00:00 2001 From: Mubaris NK Date: Sat, 20 Feb 2021 23:57:56 +0530 Subject: [PATCH 1/5] docs wip --- README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e3153fd1..b1706342 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,31 @@ # DSA connectors -Awesome list of DSA connectors. +Connectors are standard proxy logics contract that let DeFi Smart Account (DSA) interact with various smart contracts, and make the important actions accessible like cross protocol interoperability. + +DSAs are powerful because they can easily be extended with connectors. Every new connector that is added is immediately usable by any developer building on top of DSAs. Connectors can either be base connectors to protocols, auth connectors, higher level connectors with more specific use cases like optimized lending, or connectors to native liquidity pools. + +You can create a PR to request a support for specific protocol or external contracts. Following is the list of all the supported connectors. Following is the list of all the primary connectors used to cast spells: + +## MakerDAO + +[Code](contracts/connectors_old/makerdao.sol) + +### `open(collateralType)` + +**Open a Maker vault** of the `collateralType`. E.g. "ETH-A", "USDC-B", etc... + +### `deposit(vault, amt, getId, setId)` + +**Deposit collateral to a Maker vault.** + +`vault` - Vault ID (Use 0 for last opened vault) + +`amt` - Amount of collteral to deposit + +### `withdraw(vault, amt, getId, setId)` + +**Withdraw collateral from a Maker vault.** + +`vault` - Vault ID (Use 0 for last opened vault) + +`amt` - Amount of collteral to withdraw From 3170d354ceba97671c358e1c279e47aace173e5a Mon Sep 17 00:00:00 2001 From: Mubaris NK Date: Sun, 21 Feb 2021 00:23:11 +0530 Subject: [PATCH 2/5] Add Maker --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index b1706342..3a9b8d03 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,12 @@ You can create a PR to request a support for specific protocol or external contr **Open a Maker vault** of the `collateralType`. E.g. "ETH-A", "USDC-B", etc... +### `close(vault)` + +**Close a Maker vault** + +`vault` - Vault ID (Use 0 for last opened vault) + ### `deposit(vault, amt, getId, setId)` **Deposit collateral to a Maker vault.** @@ -29,3 +35,37 @@ You can create a PR to request a support for specific protocol or external contr `vault` - Vault ID (Use 0 for last opened vault) `amt` - Amount of collteral to withdraw + +### `borrow(vault, amt, getId, setId)` + +**Borrow DAI from a Maker vault.** + +`vault` - Vault ID (Use 0 for last opened vault) + +`amt` - Amount of DAI to borrow + +### `payback(vault, amt, getId, setId)` + +**Payback DAI to a Maker vault.** + +`vault` - Vault ID (Use 0 for last opened vault) + +`amt` - Amount of DAI to payback + +### `withdrawLiquidated(vault, amt, getId, setId)` + +**Withdraw leftover collateral after liquidation.** + +`vault` - Vault ID (Use 0 for last opened vault) + +`amt` - Amount of collateral to withdraw + +### `depositAndBorrow(vault, depositAmt, borrowAmt, getIdDeposit, getIdBorrow, setIdDeposit, setIdBorrow)` + +**Deposit collateral & borrow DAI from a vault.** + +`vault` - Vault ID (Use 0 for last opened vault) + +`depositAmt` - Amount of collateral to deposit + +`borrowAmt` - Amount of DAI to borrow From 08524cc42f3f9a23309393c0c885b22e4c58c975 Mon Sep 17 00:00:00 2001 From: Mubaris NK Date: Tue, 23 Feb 2021 12:08:42 +0530 Subject: [PATCH 3/5] Add more connector docs --- README.md | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/README.md b/README.md index 3a9b8d03..f23039e9 100644 --- a/README.md +++ b/README.md @@ -69,3 +69,116 @@ You can create a PR to request a support for specific protocol or external contr `depositAmt` - Amount of collateral to deposit `borrowAmt` - Amount of DAI to borrow + +## Compound + +[Code](contracts/connectors_old/compound.sol) + +### `deposit(token, amt, getId, setId)` + +**Deposit token to Compound.** + +`token` - Address of the token to deposit + +`amt` - Amount of token to deposit + +### `withdraw(token, amt, getId, setId)` + +**Withdraw token from Compound.** + +`token` - Address of the token to withdraw + +`amt` - Amount of token to withdraw + +### `borrow(token, amt, getId, setId)` + +**Borrow token from Compound.** + +`token` - Address of the token to borrow + +`amt` - Amount of token to borrow + +### `payback(token, amt, getId, setId)` + +**Payback debt to Compound.** + +`token` - Address of the token to payback + +`amt` - Amount of token to payback + +## Aave v1 + +[Code](contracts/connectors_old/aave.sol) + +### `deposit(token, amt, getId, setId)` + +**Deposit token to Aave.** + +`token` - Address of the token to deposit + +`amt` - Amount of token to deposit + +### `withdraw(token, amt, getId, setId)` + +**Withdraw token from Aave.** + +`token` - Address of the token to withdraw + +`amt` - Amount of token to withdraw + +### `borrow(token, amt, getId, setId)` + +**Borrow token from Aave.** + +`token` - Address of the token to borrow + +`amt` - Amount of token to borrow + +### `payback(token, amt, getId, setId)` + +**Payback debt to Aave.** + +`token` - Address of the token to payback + +`amt` - Amount of token to payback + +## Aave v2 + +[Code](contracts/connectors_old/aave_v2.sol) + +### `deposit(token, amt, getId, setId)` + +**Deposit token to Aave.** + +`token` - Address of the token to deposit + +`amt` - Amount of token to deposit + +### `withdraw(token, amt, getId, setId)` + +**Withdraw token from Aave.** + +`token` - Address of the token to withdraw + +`amt` - Amount of token to withdraw + +### `borrow(token, amt, rateMode, getId, setId)` + +**Borrow token from Aave.** + +`token` - Address of the token to borrow + +`amt` - Amount of token to borrow + +`rateMode` - Borrow interest rate mode (1 = Stable & 2 = Variable) + +### `payback(token, amt, rateMode, getId, setId)` + +**Payback debt to Aave.** + +`token` - Address of the token to payback + +`amt` - Amount of token to payback + +`rateMode` - Borrow interest rate mode (1 = Stable & 2 = Variable) + From 1e6cbbe8a518f62e6bf0f4aefd18e7b68af204ee Mon Sep 17 00:00:00 2001 From: Mubaris NK Date: Tue, 23 Feb 2021 12:50:31 +0530 Subject: [PATCH 4/5] Add more docs --- README.md | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/README.md b/README.md index f23039e9..cafcaac0 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,44 @@ DSAs are powerful because they can easily be extended with connectors. Every new You can create a PR to request a support for specific protocol or external contracts. Following is the list of all the supported connectors. Following is the list of all the primary connectors used to cast spells: +## Authority + +[Code](contracts/connectors_old/authority.sol) + +### `add(authority)` + +**Add an address authority** + +`authority` - Address of the authority to add + +### `remove(authority)` + +**Remove an address authority** + +`authority` - Address of the authority to remove + +## Basic + +[Code](contracts/connectors_old/basic.sol) + +### `deposit(erc20, amt, getId, setId)` + +**Deposit a token or ETH to DSA.** + +`erc20` - Address of the token to deposit. ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE + +`amt` - Amount of token to deposit + +In case of an ERC20 Token, allowance must be given to DSA before depositing + +### `withdraw(erc20, amt, getId, setId)` + +**Withdraw a token or ETH from DSA.** + +`erc20` - Address of the token to withdraw. ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE + +`amt` - Amount of token to withdraw + ## MakerDAO [Code](contracts/connectors_old/makerdao.sol) @@ -106,6 +144,34 @@ You can create a PR to request a support for specific protocol or external contr `amt` - Amount of token to payback +## COMP + +[Code](contracts/connectors_old/COMP.sol) + +### `ClaimComp(setId)` + +**Claim unclaimed COMP** + +### `ClaimCompTwo(tokens, setId)` + +**Claim unclaimed COMP** + +`tokens` - List of tokens supplied or borrowed + +### `ClaimCompThree(supplyTokens, borrowTokens, setId)` + +**Claim unclaimed COMP** + +`supplyTokens` - List of tokens supplied + +`borrowTokens` - List of tokens borrowed + +### `delegate(delegatee)` + +**Delegate COMP votes** + +`delegatee` - Address of the delegatee + ## Aave v1 [Code](contracts/connectors_old/aave.sol) @@ -182,3 +248,95 @@ You can create a PR to request a support for specific protocol or external contr `rateMode` - Borrow interest rate mode (1 = Stable & 2 = Variable) +## dYdX + +[Code](contracts/connectors_old/dydx.sol) + +### `deposit(token, amt, getId, setId)` + +**Deposit token to dYdX.** + +`token` - Address of the token to deposit + +`amt` - Amount of token to deposit + +### `withdraw(token, amt, getId, setId)` + +**Withdraw token from dYdX.** + +`token` - Address of the token to withdraw + +`amt` - Amount of token to withdraw + +### `borrow(token, amt, getId, setId)` + +**Borrow token from dYdX.** + +`token` - Address of the token to borrow + +`amt` - Amount of token to borrow + +### `payback(token, amt, getId, setId)` + +**Payback debt to dYdX.** + +`token` - Address of the token to payback + +`amt` - Amount of token to payback + +## Uniswap + +[Code](contracts/connectors_old/uniswap.sol) + +### `deposit(tokenA, tokenB, amtA, unitAmt, slippage, getId, setId)` + +**Deposit liquidity to tokenA/tokenB pool** + +`tokenA` - Address of token A + +`tokenB` - Address of token B + +`amtA` - Amount of token A to deposit + +`unitAmt` - Unit amount of amtB/amtA with slippage. + +`slippage` - Slippage amount in wei + + +### `withdraw(tokenA, tokenB, uniAmt, unitAmtA, unitAmtB, getId, setId)` + +**Withdraw liquidity from tokenA/tokenB pool** + +`tokenA` - Address of token A + +`tokenB` - Address of token B + +`uniAmt` - Amount of LP tokens to withdraw + +`unitAmtA` - Unit amount of amtA/uniAmt with slippage. + +`unitAmtB` - Unit amount of amtB/uniAmt with slippage. + +### `buy(buyAddr, sellAddr, buyAmt, unitAmt, getId, setId)` + +**Buy a token/ETH** + +`buyAddr` - Address of the buying token + +`sellAddr` - Address of the selling token + +`buyAmt` - Amount of tokens to buy + +`unitAmt` - Unit amount of sellAmt/buyAmt with slippage + +### `sell(buyAddr, sellAddr, sellAmt, unitAmt, getId, setId)` + +**Buy a token/ETH** + +`buyAddr` - Address of the buying token + +`sellAddr` - Address of the selling token + +`sellAmt` - Amount of tokens to sell + +`unitAmt` - Unit amount of buyAmt/sellAmt with slippage From c6692f580ad65b5fc2419d142bb6c2c873e71d26 Mon Sep 17 00:00:00 2001 From: Mubaris NK Date: Fri, 5 Mar 2021 12:13:22 +0530 Subject: [PATCH 5/5] Update docs --- README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cafcaac0..9c37c876 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ DSAs are powerful because they can easily be extended with connectors. Every new You can create a PR to request a support for specific protocol or external contracts. Following is the list of all the supported connectors. Following is the list of all the primary connectors used to cast spells: +[Read this post to learn about getId and setId used in the connectors](https://discuss.instadapp.io/t/how-to-use-getid-setid/104) + ## Authority [Code](contracts/connectors_old/authority.sol) @@ -331,7 +333,7 @@ In case of an ERC20 Token, allowance must be given to DSA before depositing ### `sell(buyAddr, sellAddr, sellAmt, unitAmt, getId, setId)` -**Buy a token/ETH** +**Sell a token/ETH** `buyAddr` - Address of the buying token @@ -340,3 +342,51 @@ In case of an ERC20 Token, allowance must be given to DSA before depositing `sellAmt` - Amount of tokens to sell `unitAmt` - Unit amount of buyAmt/sellAmt with slippage + +## 1Inch + +[Code](contracts/connectors_old/1inch.sol) + +### `sell(buyAddr, sellAddr, sellAmt, unitAmt, getId, setId)` + +**Sell ETH/ERC20 using 1proto** + +`buyAddr` - Address of the buying token + +`sellAddr` - Address of the selling token + +`sellAmt` - Amount of tokens to sell + +`unitAmt` - Unit amount of buyAmt/sellAmt with slippage + +### `sellTwo(buyAddr, sellAddr, sellAmt, unitAmt, getId, setId)` + +**Sell ETH/ERC20 using 1proto** + +`buyAddr` - Address of the buying token + +`sellAddr` - Address of the selling token + +`sellAmt` - Amount of tokens to sell + +`unitAmt` - Unit amount of buyAmt/sellAmt with slippage + +`[]distribution` - Distribution of swap across different dex. + +`disableDexes` - Disable a dex. (To disable none: 0) + +### `sellTwo(buyAddr, sellAddr, sellAmt, unitAmt, getId, setId)` + +**Sell ETH/ERC20 using 1inch** + +Use [1Inch API](https://docs.1inch.exchange/api/) for calldata + +`buyAddr` - Address of the buying token + +`sellAddr` - Address of the selling token + +`sellAmt` - Amount of tokens to sell + +`unitAmt` - Unit amount of buyAmt/sellAmt with slippage + +`callData` - Data from 1inch API