diff --git a/Connectors.md b/Connectors.md deleted file mode 100644 index 90599c4..0000000 --- a/Connectors.md +++ /dev/null @@ -1,441 +0,0 @@ -# Connectors -Connectors are used for the interaction between DSA and Protocols / other contracts. Connectors are called by the help of `cast` function in DSA. - -Note: Most of the connectors function have 2 extra parameters as `setId` and `getId`. They will be used to set/store data from one connector and use it in another connector which will make cross protocol transaction possible without the need of solidity. - - -## Basics - -Used to do basic operations like depositing and withdrawing tokens from DSA. - -Connector address - `0x9370236a085A99Aa359f4bD2f0424b8c3bf25C99` - -### deposit() - -To Deposit ETH/tokens into the DSA. There are two ways to deposit in DSA:- -1. Normal ETH/Token transfer to DSA address. -2. Give `Allowance` of Tokens to DSA and deposit by using the below function. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "basic", // name - method: "deposit", // method - args: ["token_address", "amount", "getId", "uint setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`token_address` (address) - Address of token to deposit. You can get tokens details from `dsa.tokens.info`. -`amount` (uint) - Amount of token to deposit. Eg:- if user wants to deposit `1` ETH then `amount` will be `1000000000000000000`. -`getId` (uint) - Used to get data stored in particular Id. If not set then it'll return `0`. If not needed then send `0`. -`setId` (uint) - Used to set data stored in particular Id. If not needed then send `0`. - - -### withdraw() - -To Withdraw ETH/tokens from the DSA. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "basic", // name - method: "withdraw", // method - args: ["token_address", "amount", "withdraw_address", "getId", "uint setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`token_address` (address) - Address of token to withdraw. You can get tokens details from `dsa.tokens.info`. -`amount` (uint) - Amount of token to withdraw. Eg:- if user wants to withdraw `1` ETH then `amount` will be `1000000000000000000`. -`withdraw_address` (address) - Address on which tokens needs to be withdrawn. Note:- `Address should be an Authority`. -`getId` (uint) - Used to get data stored in particular Id. If not set then it'll return `0`. By default keep it `0`. -`setId` (uint) - Used to set data stored in particular Id. If not needed then send `0`. - - -## Auth - -Used to add/remove authority from DSA. - -Connector address - `0x627cd0DbD5eE33F8456Aa8143aCd68a13d641588` - -### addModule() - -To Add Auth module (Authority) - an address. It can be Owner, Guardian, manager, etc. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "auth", // name - method: "addModule", // method - args: ["authority"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`authority` (address) - Address of new authority. - - -### removeModule() - -To remove Auth module (Authority) - an address. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "auth", // name - method: "removeModule", // method - args: ["authority"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`authority` (address) - Address of authority to remove. - - -## Compound - -For Compound Protocol interaction. Eg:- deposit, borrow, etc. - -Connector address - `0x547f1508A2a1AB0cB84DCe4b3e09beB560Bb44Cb` - -### deposit() - -To deposit/supply tokens into Compound as Lending or Collateral. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "compound", // name - method: "deposit", // method - args: ["token_address", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`token_address` (address) - Address of token. You can get tokens details from `dsa.tokens.info`. -`amount` (uint) - Amount of token. Send `"-1"` to deposit 100%. -`getId` (uint) - Id will be used to get the amount of token to deposit. -`setId` (uint) - Id will be used to set the amount of token deposited. - - -### withdraw() - -To withdraw tokens from Compound that you've supplied. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "compound", // name - method: "withdraw", // method - args: ["token_address", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`token_address` (address) - Address of token. You can get tokens details from `dsa.tokens.info`. -`amount` (uint) - Amount of token. Send `"-1"` to withdraw 100%. -`getId` (uint) - Id will be used to get the amount of token to withdraw. -`setId` (uint) - Id will be used to set the amount of token withdrawn. - - -### borrow() - -To borrow tokens from Compound. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "compound", // name - method: "borrow", // method - args: ["token_address", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`token_address` (address) - Address of token. You can get tokens details from `dsa.tokens.info`. -`amount` (uint) - Amount of token. -`getId` (uint) - Id will be used to get the amount of token to borrow. -`setId` (uint) - Id will be used to set the amount of token borrowed. - - -### payback() - -To payback tokens from Compound. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "compound", // name - method: "payback", // method - args: ["token_address", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`token_address` (address) - Address of token. You can get tokens details from `dsa.tokens.info`. -`amount` (uint) - Amount of token. Send `"-1"` to payback 100%. -`getId` (uint) - Id will be used to get the amount of token to payback. -`setId` (uint) - Id will be used to set the amount of token payed back. - - -### Extras functions - -### depositCToken() - -To deposit/supply tokens into Compound as Lending or Collateral. The only difference between this and deposit is it'll set in CToken amount. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "compound", // name - method: "depositCToken", // method - args: ["token_address", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`token_address` (address) - Address of token. You can get tokens details from `dsa.tokens.info`. -`amount` (uint) - Amount of token. Eg:- if user wants to deposit `1` ETH then `amount` will be `1000000000000000000`. -`getId` (uint) - Id will be used to get the amount of token to deposit. -`setId` (uint) - Id will be used to set the amount of ctoken minted. - -### withdrawCToken() - -To withdraw tokens from Compound. The only difference between this and withdraw amount and getId. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "compound", // name - method: "withdrawCToken", // method - args: ["token_address", "ctoken_amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`token_address` (address) - Address of token. You can get tokens details from `dsa.tokens.info`. -`ctoken_amount` (uint) - Amount of token to withdraw in terms of CToken. Eg:- if user wants to deposit `1` ETH then `amount` will be `1000000000000000000`. -`getId` (uint) - Id will be used to get the amount of ctoken to withdraw. (You'll recieve tokens) -`setId` (uint) - Id will be used to set the amount of token withdrawn. - - -### paybackBehalf() - -To payback tokens on behalf of someone else. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "compound", // name - method: "paybackBehalf", // method - args: ["borrower", "token_address", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`borrower` (address) - Address of which Ctokens needs to be payed back. -`token_address` (address) - Address of token. You can get tokens details from `dsa.tokens.info`. -`amount` (uint) - Amount of token. Send `"-1"` to payback 100%. -`getId` (uint) - Id will be used to get the amount of token to payback. -`setId` (uint) - Id will be used to set the amount of token payed back. - - - -## Maker - -For MakerDAO Protocol interaction. Eg:- Vault management, DSR DAI, etc. - -Connector address - `0x3dF605ca85E8d677C8f6E2665EbcdDbd801Ee9f9` - - -### open() - -To Open a New Vault. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "maker", // name - method: "open", // method - args: ["colName"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`colName` (string) - Collateral name. Eg:- `ETH-A`, `BAT-A`, `USDC-A`, etc. - - -### close() - -To Close a Vault. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "maker", // name - method: "close", // method - args: ["vaultId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`vaultId` (uint) - Vault ID. Note:- Vault assets should be 0 in order to close it. - - -### deposit() - -Token to deposit as Collateral in Vault. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "maker", // name - method: "deposit", // method - args: ["vaultId", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`vaultId` (uint) - Vault ID. -`amount` (uint) - Amount of token to deposit. -`getId` (uint) - Id will be used to get the amount of token to deposit. -`setId` (uint) - Id will be used to set the amount of token deposited. - - -### withdraw() - -Token to withdraw from Vault. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "maker", // name - method: "withdraw", // method - args: ["vaultId", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`vaultId` (uint) - Vault ID. -`amount` (uint) - Amount of token. -`getId` (uint) - Id will be used to get the amount of token to withdraw. -`setId` (uint) - Id will be used to set the amount of token withdrawn. - - -### borrow() - -DAI to borrow from Vault. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "maker", // name - method: "borrow", // method - args: ["vaultId", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`vaultId` (uint) - Vault ID. -`amount` (uint) - Amount of DAI. -`getId` (uint) - Id will be used to get the amount of DAI to borrow. -`setId` (uint) - Id will be used to set the amount of DAI borrowed. - - -### payback() - -DAI to payback to Vault. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "maker", // name - method: "payback", // method - args: ["vaultId", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`vaultId` (uint) - Vault ID. -`amount` (uint) - Amount of DAI. -`getId` (uint) - Id will be used to get the amount of DAI to payback. -`setId` (uint) - Id will be used to set the amount of DAI payed back. - - -### withdrawLiquidated() - -Withdraw liquidated collateral. When Vault gets liquidated the collateral gets unlocked means it's not available in Vault to be used as a collateral. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "maker", // name - method: "withdrawLiquidated", // method - args: ["vaultId", "amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`vaultId` (uint) - Vault ID. -`amount` (uint) - Amount of liquidated Col. -`getId` (uint) - Id will be used to get the amount of liquidated Collateral to withdraw. -`setId` (uint) - Id will be used to set the amount of liquidated Collateral withdrawn. - - -### depositDai() - -Deposit DAI in DSR. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "maker", // name - method: "depositDai", // method - args: ["amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`amount` (uint) - Amount of DAI. -`getId` (uint) - Id will be used to get the amount of DAI to deposit. -`setId` (uint) - Id will be used to set the amount of DAI deposited. - - -### withdrawDai() - -Withdraw DAI from DSR. - -```js -let spells = dsa.Spell(); -spells.add({ - connector: "maker", // name - method: "withdrawDai", // method - args: ["amount", "getId", "setId"] // method arguments -}); -dsa.cast(spells); -``` - -### Parameters -`amount` (uint) - Amount of DAI. -`getId` (uint) - Id will be used to get the amount of DAI to withdraw. -`setId` (uint) - Id will be used to set the amount of DAI withdrawn. diff --git a/Overview.md b/Overview.md deleted file mode 100644 index 984edf3..0000000 --- a/Overview.md +++ /dev/null @@ -1,77 +0,0 @@ -# DeFi Smart Accounts Overview -DeFi Smart Accounts (DSA) are contract accounts developed by [Instadapp](http://instadapp.io) and **trustlessly owned by the users**. In this guide, we will explain the three key entities in the system: DeFi smart accounts, connectors and authentication modules. - -## Developers - -- Front end developers, including wallets, can build DeFi and smart wallet capabilities on top of their existing products. As new modules are added to the ecosystem, they can extend their DeFi capabilities and business model without the need for any smart contract or security expertise. -- DeFi developers can create complex cross protocol transactions like Instadapp’s protocol bridge with only web2 code. -- Protocol developers can make their systems accessible all DSA users and devs by collaborating with us to build connectors. - -For further context about motivation and likely use cases, read the accompanying [blog post](https://blog.instadapp.io/defi-smart-accounts/). - -## Key Entities -There are 3 key entities in DSAs: - -1. **Defi Accounts**, which are trustlessly owned by the users. Assets are stored here. DSAs can execute composed transactions across connectors. -2. **Connectors**, which are standardized modules that interact with the various protocols, and make the important actions accessible to smart accounts. -3. **Authentication Modules**, which users can use to set guardians, managers or automation bots to manage their DSA. Permissions can be modular down to connector levels. For example, users can allow the wallet provider to rebalance his assets to minimize interest payment or maximize yields, but nothing else. - -Screenshot 2020-03-15 at 6 41 46 PM - -Let us review each of these in more detail: - -## 1. DeFi Smart Accounts -DSAs are created by regular Ethereum accounts (or EOAs). Each Ethereum can create as many DeFi accounts as they want. DeFi accounts are fully trustless, so users can choose to withdraw their assets anytime to the owners. - -DeFi accounts can compose and execute any number of actions from connectors in a single web3 transaction. Using only web3 calls, frontend developers will be able to string together the available actions in the connectors to create innovative new transactions. - -For example, to build the protocol bridge function, the DSA will string together functions across the compound, maker and liquidity bridge connectors. We call these “spells”, and we will be elaborating on them in more detail. - -To get started, the `build` function will be called, after which a DeFi smart account will be created belonging to the EOA. The developer can also help user build custom DSAs with one transaction, for example, create a DSA and deposit assets directly, or provide a 3rd party or bot with permissions to manage the assets for example. - -## 2. Connectors -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. - -Let's review what these are, and then we will give an example of how they can be used to allow developers to build complex cross protocol transactions. - -### Types Of Connectors -Different types of connectors provide different set of capabilities towards DSAs. Each connector has a set of functions that can be executed by the DSA owner or managers (depending on authentication settings). - -1. Protocol connectors: Access key protocol functions directly. -2. Auth connectors: Update permissions of the smart accounts. -3. Use case specific connectors: Execute higher level use cases that cannot be done or expensive with stringing basic functions. -4. Instapool connectors*: Access the native short term liquidity pool for features that require asset porting, or "flash loans" for example, porting debt positions, interest payment minimization or yield maximization. - -* Liquidity pools is not launched at the moment. It will be free to use. - -### Casting Spells - -`Spells` denotes a sequence of connector functions that will achieve a given use case. Spells can comprise of any number of functions across any number of connectors. - -For example, to build the protocol bridge to migrate debt from Maker To Compound, the DSA will `cast` the following `spell` across the Instapool, Maker and Compound connectors. - -1. Instapool: Access liquidity -2. Maker: Payback DAI -3. Maker: Withdraw ETH -4. Compound: deposit ETH -5. Compound: borrow DAI -6. Instapool: Return liquidity - -Developers can trigger these spells from web2 code (or just the chrome console). They can also be called by a different account who has the right permissions delegated to them by the main account. - -## 3. Authentication Modules - -Users will be able to grant permissions to other accounts to serve specific functions on behalf of them. These functions includes, but is not limited to: - -- Guardians for account recovery -- Co-owner for shared admin management -- Managers for fund management, e.g. yield optimization -- Bots for automation, e.g. vault saving - -Because authentication modules can be granular to the level of connectors, access can be provided at multiple levels: -- For the whole DeFi account -- For specific sets of connectors -- To achieve a very high level of authentication granularity - an developer can create a highly use case specific connector. - -It is up to the developer to optimize for the right balance of trustlessness and power, and we believe that users will reward the developers who provide the most amount of value in a safe and secure manner. - diff --git a/Resolvers.md b/Resolvers.md deleted file mode 100644 index 4d48d0c..0000000 --- a/Resolvers.md +++ /dev/null @@ -1,170 +0,0 @@ -# Resolvers - -Resolvers functions for Protocols & balances. These function will provide you all the essential protocol details to move forward with the integration. Details like:- - -## Balances - -### .getBalances() - -Get the balances for the tokens of a specific Ethereum address. - -```js -dsa.balances.getBalances(address, type) - .then(data => { - return data - }) - .catch(error => { - return error - }) -``` - -### Parameters -`address` (optional) - An ethereum address. Eg:- "0xa7...3423". Default:- DSA address selected at the time of setup. -`type` (optional) - Balances of what type of tokens. Default:- "token". List of types of tokens currently available:- -* "token" - Normal Tokens. Eg:- ETH, DAI, USDC, etc. -* "ctoken" - Compound interest bearing CTokens. Eg:- CETH, CDAI, CUSDC, etc. -* "all" - Get Balances of all the tokens in the list. - -### Returns -`List` of tokens, where the key is the symbol and the value is the formatted balance {eth: 2, dai: 50.1} - - -## MakerDAO - -### .getVaults() - -Get all the vaults details needed for address in one call. - -```js -dsa.balances.getVaults(address) - .then(data => { - return data - }) - .catch(error => { - return error - }) -``` - -### Parameters -`address` (optional) - An ethereum address. Eg:- "0xa7...3423". Default:- DSA address selected at the time of setup. - -### Returns -`List` of all things Compound. Eg:- -* `owner` - Owner of the Vault. Same as address parameter. -* `colName` - Collateral type. Eg:- ETH-A, BAT-A, USDC-A, etc. -* `token` - Collateral token. Eg:- ETH, BAT, USDC, etc. -* `col` - Collateral Deposited. -* `debt` - DAI Borrowed. -* `liquidatedCol` - Remaining colletral after Vault got liquidated. (unlock collateral - still in vault but not being used as collateral) -* `rate` - Borrow APY. -* `price` - Collateral Token Price from Maker's oracle. -* `status` - Debt / Collateral ratio. -* `liquidation` - Point at which vault will break. When `status` > `liquidation` vault breaks. -* `urn` - Vault Ethereum address. -```js -{ '7903': - { owner: '0x981C549A74Dc36Bd82fEd9097Bc19404E8db14f3', - colName: 'ETH-A', - token: 'ETH', - col: 0.4, - debt: 25.001729254489607, - liquidatedCol: 0, - rate: 0.5001431422658964, - price: 154.168734, - status: 0.4054280106900535, - liquidation: 0.6666666666666667, - urn: '0xcC0e5E76eC81aD472D6Df9fC83eaE22E1000Fe53' }, - { ... } ... -} -``` - -### .getCollateralInfo() - -Get all the Collerals details needed in one call. - -```js -dsa.balances.getCollateralInfo() - .then(data => { - return data - }) - .catch(error => { - return error - }) -``` - -### Returns -`List` of all Maker's Collateral Types. Eg:- -* `ETH-A'` - Collateral Name. Eg:- ETH-A, BAT-A, USDC-A, etc. -* `token` - Collateral token. Eg:- ETH, BAT, USDC, etc. -* `rate` - Borrow APY. -* `price` - Collateral Price from Maker's oracle. -* `ratio` - Liquidation point. -```js -{ 'ETH-A': - { token: 'ETH', - rate: 0.5001431422658964, - price: 154.168734, - ratio: 0.6666666666666667 } - { ... } ... -} -``` - - -## Compound Finanace - -### .getPosition() - -Get all the details needed for Compound integration in one call. - -```js -dsa.balances.getBalances(address, key) - .then(data => { - return data - }) - .catch(error => { - return error - }) -``` - -### Parameters -`address` (optional) - An ethereum address. Eg:- "0xa7...3423". Default:- DSA address selected at the time of setup. -`key` (optional) - key for the object is it going to return. Default:- "token". Eg:- {eth: {...}} or {ceth: {...}} or {"0x..23": {...}}. List of key available. -* "token" - key as underlying token symbol of ctoken. For ceth it's eth. Eg:- {eth: {...}} -* "ctoken" - key as ctoken symbol. Eg:- {ceth: {...}} -* "address" - key as underlying token address of ctoken. Eg:- {"0x...24": {...}} -* "caddress" - key as ctoken address. Eg:- {"0x...32": {...}} - -### Returns -`List` of all things Compound. Eg:- -* `priceInEth` - Tokens price from Compound oracle contracts. Prices are w.r.t "ETH" not "USD". -* `exchangeRate` - CToken to token conversion rate. `CToken balance` * `exchangeRate` = `token balance`. -* `supply` - token balance supplied/deposited. -* `borrow` - token balance borrowed. -* `supplyRate` - Supply APR. -* `supplyYield` - Supply APY. -* `borrowRate` - Borrow APR. -* `borrowYield` - Borrow APY. -* `borrowYield` - Borrow APY. -* `totalSupplyInEth` - Total supply in ETH not in USD. -* `totalBorrowInEth` - Total borrow in ETH not in USD. -* `maxBorrowLimitInEth` - Max borrow limit in ETH not in USD. -* `status` - `totalBorrowInEth` / `totalSupplyInEth`. -* `liquidation` - `maxBorrowLimitInEth` / `totalSupplyInEth`. -```js -{ eth: - { priceInEth: 1, - exchangeRate: 200117674.2320281, - supply: 0.20000024558102408, - borrow: 0, - supplyRate: 0.0098989117776, - supplyYield: 0.009899400394752789, - borrowRate: 2.05355820729888, - borrowYield: 2.0747298274359505 }, - { ... } ..., - totalSupplyInEth: 0.20000024558102408, - totalBorrowInEth: 0.08513266988268917, - maxBorrowLimitInEth: 0.15000018418576805, - status: 0.4256628267398813, - liquidation: 0.7499999999999999 -} -``` diff --git a/mainnetFork.pdf b/mainnetFork.pdf deleted file mode 100644 index ce00695..0000000 Binary files a/mainnetFork.pdf and /dev/null differ diff --git a/tenderly.pdf b/tenderly.pdf deleted file mode 100644 index d9fac20..0000000 Binary files a/tenderly.pdf and /dev/null differ