updated readme.md

This commit is contained in:
pradyuman-verma 2022-03-19 13:24:15 +05:30
parent 798690b99e
commit 2563e7a921
No known key found for this signature in database
GPG Key ID: E36FD6BC8923221F

View File

@ -47,8 +47,25 @@ Run all the tests:
```sh ```sh
$ npm run test $ npm run test
``` ```
(Striclty use this envirnment to test, or otherwise make suitable changes in config file before testing). (Striclty use this envirnment to test, or otherwise make suitable changes in config file before testing).
### Deploy
To deploy a connector using interactive CLI
```sh
$ npm run deploy:runner
```
### checks
To check that code is compatible with github actions
```sh
$ npm run check
```
## How to add a new connector ## How to add a new connector
You can create a new PR to add a new connector. To get the PR merged, certain requirements needs to be met which will be explained here. You can create a new PR to add a new connector. To get the PR merged, certain requirements needs to be met which will be explained here.
@ -57,39 +74,39 @@ You can create a new PR to add a new connector. To get the PR merged, certain re
Common files for all connectors are in `contracts/common` directory. Common files for all connectors are in `contracts/common` directory.
* `math.sol` has methods for mathematical operations (`DSMath`) - `math.sol` has methods for mathematical operations (`DSMath`)
* `interfaces.sol` contains the common interfaces - `interfaces.sol` contains the common interfaces
* `TokenInterface` for ERC-20 interface including WETH - `TokenInterface` for ERC-20 interface including WETH
* `stores.sol` contains the global constants as well as methods `getId` & `setId` (`Stores`) - `stores.sol` contains the global constants as well as methods `getId` & `setId` (`Stores`)
* `basic.sol` inherits `DSMath` & `Stores` contracts. This contains few details explained below - `basic.sol` inherits `DSMath` & `Stores` contracts. This contains few details explained below
* Wrapping & unwrapping ETH (`convertEthToWeth` & `convertWethToEth`) - Wrapping & unwrapping ETH (`convertEthToWeth` & `convertWethToEth`)
* Getting token & ETH balance of DSA - Getting token & ETH balance of DSA
Connectors are under `contracts/connectors` directory, and should be formatted as follows: Connectors are under `contracts/connectors` directory, and should be formatted as follows:
* Connector events should be in a separate contract: `events.sol` - Connector events should be in a separate contract: `events.sol`
* Interfaces should be defined in a seperate file: `interface.sol` - Interfaces should be defined in a seperate file: `interface.sol`
* If the connector has helper methods & constants (including interface instances), this should be defined in a separate file: `helpers.sol` - If the connector has helper methods & constants (including interface instances), this should be defined in a separate file: `helpers.sol`
* `Helpers` contract should inherit `Basic` contract from common directory - `Helpers` contract should inherit `Basic` contract from common directory
* If the connector doesn't have any helper methods, the main contract should inherit `Basic` contract - If the connector doesn't have any helper methods, the main contract should inherit `Basic` contract
* The main logic of the contract should be under `main.sol`, and the contract should inherit `Helpers` (if exists, otherwise `Basic`) & `Events` - The main logic of the contract should be under `main.sol`, and the contract should inherit `Helpers` (if exists, otherwise `Basic`) & `Events`
Few things to consider while writing the connector: Few things to consider while writing the connector:
* Connector should have a public constant string declared `name`, which will be the name of the connector. This will be versioned. Ex: `Compound-v1` - Connector should have a public constant string declared `name`, which will be the name of the connector. This will be versioned. Ex: `Compound-v1`
* Contract name should start with `ConnectV2` appended with protocol name. Eg: `ConnectV2Compound` - Contract name should start with `ConnectV2` appended with protocol name. Eg: `ConnectV2Compound`
* User interacting methods (`external` methods) will not be emitting events, rather the methods will be returning 2 variables: - User interacting methods (`external` methods) will not be emitting events, rather the methods will be returning 2 variables:
* `_eventName` of `string` type: This will be the event signture defined in the `Events` contract. Ex: `LogDeposit(address,address,uint256,uint256,uint256)` - `_eventName` of `string` type: This will be the event signture defined in the `Events` contract. Ex: `LogDeposit(address,address,uint256,uint256,uint256)`
* `_eventParam` of `bytes` type: This will be the abi encoded event parameters - `_eventParam` of `bytes` type: This will be the abi encoded event parameters
* The contracts should not have `selfdestruct()` - The contracts should not have `selfdestruct()`
* The contracts should not have `delegatecall()` - The contracts should not have `delegatecall()`
* Use `uint(-1)` of `type(uint256).max` for maximum amount everywhere - Use `uint(-1)` of `type(uint256).max` for maximum amount everywhere
* Use `ethAddr` (declared in `Stores`) to denote Ethereum (non-ERC20) - Use `ethAddr` (declared in `Stores`) to denote Ethereum (non-ERC20)
* Use `address(this)` instead of `msg.sender` for fetching balance on-chain, etc - Use `address(this)` instead of `msg.sender` for fetching balance on-chain, etc
* Only `approve()` (declared in `Basic`) limited amount while giving ERC20 allowance, which strictly needs to be 0 by the end of the spell. - Only `approve()` (declared in `Basic`) limited amount while giving ERC20 allowance, which strictly needs to be 0 by the end of the spell.
* User interacting functions should have natspec comments(@dev, @notice, @param). - User interacting functions should have natspec comments(@dev, @notice, @param).
* Use `getUint()` (declared in `Stores`) for getting value that saved from previous spell - Use `getUint()` (declared in `Stores`) for getting value that saved from previous spell
* Use `setUint()` (declared in `Stores`) for setting value to save for the future spell - Use `setUint()` (declared in `Stores`) for setting value to save for the future spell
### Support ### Support