• Stars
    star
    121
  • Rank 293,836 (Top 6 %)
  • Language
    Solidity
  • License
    MIT License
  • Created almost 4 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DSA Connectors

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. The process to add a new connector is explained below.

List of all the mainnet connector for referrence is here

Usage

Pre Requisites

Before running any command, make sure to install dependencies:

$ npm install

Compile

Compile the smart contracts with Hardhat:

$ npm run compile

TypeChain

Compile the smart contracts and generate TypeChain artifacts:

$ npm run typechain

Test

Run tests using interactive CLI

$ npm run test:runner

Run all the tests:

$ npm run test

(Striclty use this envirnment to test, or otherwise make suitable changes in config file before testing).

Deploy

To deploy a connector using interactive CLI

$ npm run deploy:runner

(To deploy script manually use scripts/deployment/deployManually.ts script)

checks

To check that code is compatible with github actions

$ npm run check

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.

New connector should follow the current directory structure

Common files for all connectors are in contracts/common directory.

  • math.sol has methods for mathematical operations (DSMath)
  • interfaces.sol contains the common interfaces
    • TokenInterface for ERC-20 interface including WETH
  • 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
    • Wrapping & unwrapping ETH (convertEthToWeth & convertWethToEth)
    • Getting token & ETH balance of DSA

Connectors are under contracts/connectors directory, and should be formatted as follows:

  • Connector events should be in a separate contract: events.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
    • 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
  • 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:

  • 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
  • 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)
    • _eventParam of bytes type: This will be the abi encoded event parameters
  • The contracts should not have selfdestruct()
  • The contracts should not have delegatecall()
  • Use uint(-1) of type(uint256).max for maximum amount everywhere
  • Use ethAddr (declared in Stores) to denote Ethereum (non-ERC20)
  • 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.
  • User interacting functions should have natspec comments(@dev, @notice, @param).
  • 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

Support

If you can't find something you're looking for or have any questions, ask them at our developers community on Discord or simply send an Email.

More Repositories

1

dsa-contracts

DeFi Smart Accounts
TypeScript
188
star
2

dsa-sdk

Build DeFi apps instantly using our SDK
JavaScript
79
star
3

dsa-connectors-old

Awesome list of DSA Connectors
Solidity
65
star
4

dsa-connect

Development quickstart to interact with DSA smart contracts.
TypeScript
64
star
5

smart-contract

InstaDApp Smart Contracts.
Solidity
63
star
6

flashloan-aggregator

Flashloan Aggregator on all major chains.
Solidity
51
star
7

InstaContract

Smart contracts comprising the business logic of the InstaDApp
Solidity
39
star
8

assembly

The Open Source Dashboard for the Instadapp Protocol
Vue
34
star
9

infinite-proxy

Solidity
30
star
10

vue-web3

Vue 2/3 wrapper for web3 built on top of react-web3@v6
TypeScript
23
star
11

fluid-contracts-public

Public repository for the Fluid Contracts from Instadapp
Solidity
21
star
12

dsa-resolvers

DSA Resolvers
Solidity
19
star
13

dsa-flashloan

Solidity
15
star
14

dsa-polygon-migration

Solidity
11
star
15

InstaDApp-Dashboard

InstaDApp Alternate Dashboard.
HTML
10
star
16

yield-contract

Yield Smart Contracts
JavaScript
9
star
17

brand

Instadapp brand resource
8
star
18

all-things-instadapp

All Things InstaDApp.
7
star
19

dsa-resolvers-deprecated

Solidity
7
star
20

avocado-sdk

TypeScript
7
star
21

dsa-ecosystem

Integration guides, spells etc
6
star
22

docs

Instadapp documentation
JavaScript
6
star
23

smart-lookup

Vue
4
star
24

dsa-developers

DSA developer guide
3
star
25

instadapp-docs

3
star
26

avocado-contracts-public

TypeScript
3
star
27

utils

TypeScript
2
star
28

inst-governance

Solidity
2
star
29

dsa-periphery-contract

DSA periphery contracts
Solidity
1
star
30

dsa-connect-data

1
star
31

avocado-integration

Avocado Docs 🥑
1
star
32

yield-flusher

DSA flusher contracts
Solidity
1
star
33

assets

1
star
34

gov-proposals

Instadapp Governance Proposals
1
star
35

avocado-audits

1
star