├── .env.example
├── .github
├── release-drafter.yml
└── workflows
│ └── release-drafter.yml
├── .gitignore
├── LICENSE
├── README.md
├── babel.config.js
├── build
└── dsa.min.js
├── dev
├── app.js
├── index.html
└── node.js
├── guides
└── MakerDao.md
├── gulpfile.js
├── package-lock.json
├── package.json
├── scripts
└── getPackageJson.js
├── src
├── abi
│ ├── basics
│ │ └── erc20.json
│ ├── connectors
│ │ ├── 1inch.json
│ │ ├── aave.json
│ │ ├── aaveV1_import.json
│ │ ├── aaveV2_import.json
│ │ ├── aave_migrate.json
│ │ ├── aave_v2.json
│ │ ├── auth.json
│ │ ├── basic.json
│ │ ├── chi.json
│ │ ├── comp.json
│ │ ├── compound.json
│ │ ├── compoundImport.json
│ │ ├── compoundImport_v2.json
│ │ ├── curve.json
│ │ ├── curveClaim.json
│ │ ├── curveGauge.json
│ │ ├── curve_3pool.json
│ │ ├── dydx.json
│ │ ├── dydxFlashloan.json
│ │ ├── fee.json
│ │ ├── gelato.json
│ │ ├── instapool.json
│ │ ├── instapool_v2.json
│ │ ├── kyber.json
│ │ ├── maker.json
│ │ ├── maker_old.json
│ │ ├── math.json
│ │ ├── migrate.json
│ │ ├── oasis.json
│ │ ├── refinance.json
│ │ ├── staking.json
│ │ ├── swerve.json
│ │ └── uniswap.json
│ ├── core
│ │ ├── account.json
│ │ ├── connector.json
│ │ ├── events.json
│ │ ├── index.json
│ │ └── list.json
│ ├── gnosis
│ │ └── gnosisSafe.json
│ └── read
│ │ ├── 1inch.json
│ │ ├── aave.json
│ │ ├── chainlink.json
│ │ ├── compound.json
│ │ ├── core.json
│ │ ├── curveClaim.json
│ │ ├── curveGauge.json
│ │ ├── curve_3pool.json
│ │ ├── curve_sbtc.json
│ │ ├── curve_susd.json
│ │ ├── curve_y.json
│ │ ├── dydx.json
│ │ ├── erc20.json
│ │ ├── instapool_v2.json
│ │ ├── kyber.json
│ │ ├── maker.json
│ │ ├── oasis.json
│ │ ├── swerve.json
│ │ └── uniswap.json
├── constant
│ ├── abis.js
│ ├── addresses.js
│ ├── chainlinkTokens.js
│ └── tokensInfo.json
├── gnosis-safe
│ ├── index.js
│ └── utils
│ │ ├── offchainSigner
│ │ ├── EIP712Signer.js
│ │ ├── ethSigner.js
│ │ └── index.js
│ │ ├── safe-api.js
│ │ ├── safe-estimateGas.js
│ │ ├── safe-provider.js
│ │ └── safe-tnx.js
├── index.js
├── internal.js
├── resolvers
│ ├── 1inch.js
│ ├── aave.js
│ ├── account.js
│ ├── chainlink.js
│ ├── compound.js
│ ├── curve_claim.js
│ ├── curve_gauge.js
│ ├── curve_sbtc.js
│ ├── curve_susd.js
│ ├── curve_three.js
│ ├── curve_y.js
│ ├── dydx.js
│ ├── dydxFlashloan.js
│ ├── erc20.js
│ ├── instapool.js
│ ├── instapool_v2.js
│ ├── kyber.js
│ ├── maker.js
│ ├── oasis.js
│ ├── swerve.js
│ ├── tokens.js
│ └── uniswap.js
└── utils
│ ├── cast.js
│ ├── erc20.js
│ ├── math.js
│ └── txn.js
├── test.md
├── webpack.config.dev.js
└── webpack.config.js
/.env.example:
--------------------------------------------------------------------------------
1 | ETH_NODE_URL=https://mainnet.infura.io/v3/{API_KEY}
2 |
3 | PUBLIC_ADDRESS={PUBLIC_ADDRESS}
4 | PRIVATE_KEY={PRIVATE_KEY}
5 |
--------------------------------------------------------------------------------
/.github/release-drafter.yml:
--------------------------------------------------------------------------------
1 | categories:
2 | - title: '🚀 Features'
3 | label:
4 | - 'feature'
5 | - 'implement'
6 | - title: '🐛 Bug Fixes'
7 | labels:
8 | - 'fix'
9 | - 'bugfix'
10 | - 'bug'
11 | version-resolver:
12 | major:
13 | labels:
14 | - 'major'
15 | minor:
16 | labels:
17 | - 'minor'
18 | patch:
19 | labels:
20 | - 'patch'
21 | default: patch
22 | template: |
23 | ## Changes
24 |
25 | $CHANGES
26 |
--------------------------------------------------------------------------------
/.github/workflows/release-drafter.yml:
--------------------------------------------------------------------------------
1 | name: Release Drafter
2 |
3 | on:
4 | push:
5 | # branches to consider in the event; optional, defaults to all
6 | branches:
7 | - master
8 |
9 | jobs:
10 | update_release_draft:
11 | runs-on: ubuntu-latest
12 | steps:
13 | # Drafts your next Release notes as Pull Requests are merged into "master"
14 | - uses: release-drafter/release-drafter@v5
15 | # with:
16 | # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
17 | # config-name: my-config.yml
18 | env:
19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | lib-cov
2 | *.seed
3 | *.log
4 | *.csv
5 | *.dat
6 | *.out
7 | *.pid
8 | *.gz
9 | *.swp
10 |
11 | pids
12 | logs
13 | results
14 | tmp
15 |
16 | dist/*
17 | dev/test.js
18 |
19 | # Optional npm cache directory
20 | .npm
21 |
22 | #Build
23 | coverage
24 | public/css/main.css
25 | .nyc_output/*
26 |
27 | #Libraries from npm packages
28 | public/js/lib/bootstrap.min*
29 | public/js/lib/jquery.min*
30 | public/js/lib/popper.min*
31 |
32 | # API keys and secrets
33 | .env
34 |
35 | # Dependency directory
36 | node_modules
37 | bower_components
38 |
39 | # Editors
40 | .idea
41 | .vscode
42 | *.iml
43 | modules.xml
44 | *.ipr
45 |
46 | # Folder config file
47 | Desktop.ini
48 |
49 | # Recycle Bin used on file shares
50 | $RECYCLE.BIN/
51 |
52 | # OS metadata
53 | .DS_Store
54 | Thumbs.db
55 | .DocumentRevisions-V100
56 | .fseventsd
57 | .Spotlight-V100
58 | .TemporaryItems
59 | .Trashes
60 | .VolumeIcon.icns
61 | .com.apple.timemachine.donotpresent
62 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 INSTADAPP LABS LLC
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DeFi Smart Account SDK
2 |
3 | This has been archived. See the [latest SDK](https://github.com/Instadapp/dsa-connect)
4 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | [
4 | "@babel/preset-env", {
5 | "targets": {
6 | "node": "current"
7 | }
8 | }
9 | ],
10 | ["minify", {
11 | // https://github.com/babel/minify/issues/904
12 | builtIns: false,
13 | evaluate: false,
14 | mangle: false,
15 | "keepFnName": true
16 | }]
17 | ],
18 | plugins: [
19 | ["@babel/plugin-proposal-class-properties"]
20 | ]
21 | };
22 |
--------------------------------------------------------------------------------
/dev/app.js:
--------------------------------------------------------------------------------
1 | import DSA from "../src/index";
2 |
3 | // For ease of tesing
4 | window.DSA = DSA
5 | window.dsa = new DSA (window.web3)
--------------------------------------------------------------------------------
/dev/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | <%= htmlWebpackPlugin.options.title %>
6 |
7 |
8 |
9 | <%= htmlWebpackPlugin.options.header %>
10 | Init Web3
11 | After connecting to web3, type "dsa' into console to start jamming with building DeFi apps.
12 |
13 |
14 |
15 |
16 |
17 |
18 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/dev/node.js:
--------------------------------------------------------------------------------
1 | require('dotenv').config()
2 | const Web3 = require('web3')
3 | const web3 = new Web3(new Web3.providers.HttpProvider(process.env.ETH_NODE_URL))
4 |
5 | const DSA = require("../src/index");
6 |
7 | const dsa = new DSA({
8 | web3: web3,
9 | mode: "node",
10 | privateKey: process.env.PRIVATE_KEY,
11 | });
12 |
13 | // dsa.aave.getPosition("0xa7615CD307F323172331865181DC8b80a2834324", "token").then(console.log)
14 |
15 | // console.log(dsa.privateKey)
16 | // dsa.internal.getAddress().then(console.log)
17 |
18 | // const walletAddress = '0x73df02AABd68E6b7A6d7f314b1eb5A5424d2BFDF';
19 |
20 | // Test 0
21 | // dsa.build().then(console.log).catch(console.log)
22 |
23 | // // Test 1
24 | // let spells = dsa.Spell();
25 | // let borrowAmount = 0.01; // 20 DAI
26 | // let borrowAmtInWei = dsa.tokens.fromDecimal(borrowAmount, "dai"); // borrow flash loan and swap via Oasis
27 |
28 | // // Test 2
29 | // dsa.instance.address = walletAddress
30 | // spells.add({
31 | // connector: "basic",
32 | // method: "withdraw",
33 | // args: [dsa.tokens.info["dai"].address, borrowAmtInWei, dsa.internal.getAddress(), 0, 0]
34 | // });
35 | // dsa.cast(spells).then(console.log).catch(console.error)
36 |
37 | // // Test 3
38 | // dsa.instance.address = walletAddress
39 | // dsa.erc20.transfer({
40 | // token: "dai",
41 | // amount: "100000"
42 | // }).then(console.log).catch(console.error)
43 |
44 | // // Test 4
45 | // dsa.instance.address = walletAddress
46 | // dsa.erc20.transfer({
47 | // token: "eth",
48 | // amount: "100000"
49 | // }).then(console.log).catch(console.error)
50 |
51 | // OLD CODE
52 | // dsa.instapool.getLiquidity().then(console.log)
53 |
54 | // const walletAddress = '0x981C549A74Dc36Bd82fEd9097Bc19404E8db14f3';
55 |
56 | // dsa.count().then(console.log)
57 | // console.log(dsa.tokens.info);
58 | // console.log(
59 | // dsa.compound.ctokenMap("CETH")
60 | // )
61 | // console.log(dsa.compound.getCtokens())
62 | // dsa.maker.getVaults(walletAddress).then(console.log)
63 | // dsa.maker.getDaiRate().then(console.log)
64 | // dsa.maker.getCollateralInfo().then(console.log)
65 | // dsa.compound.getPosition(walletAddress, "token").then(console.log)
66 | // dsa.balances.getBalances(walletAddress).then(console.log)
67 | // dsa.kyber.getBuyAmount("usdc", "dai", "100", "1").then(console.log)
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 |
2 | const gulp = require('gulp');
3 | const path = require('path');
4 |
5 | const concat = require('gulp-concat');
6 | const rename = require('gulp-rename');
7 | const uglify = require('gulp-uglify-es').default;
8 |
9 | const dsaFiles = [
10 | path.resolve(__dirname, 'src/constant.js'),
11 | path.resolve(__dirname, 'src/helpers.js'),
12 | path.resolve(__dirname, 'src/index.js'),
13 | ]
14 |
15 | const dsaBundled = path.resolve(__dirname, 'build/');
16 |
17 | gulp.task('scripts', function() {
18 | return gulp.src(dsaFiles)
19 | .pipe(concat('dsa.js'))
20 | .pipe(gulp.dest(dsaBundled))
21 | .pipe(rename('dsa.min.js'))
22 | .pipe(uglify())
23 | .pipe(gulp.dest(dsaBundled));
24 | })
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dsa-sdk",
3 | "version": "1.5.15",
4 | "description": "DSA Starter Kit for building DeFi dapps",
5 | "main": "build/dsa.min.js",
6 | "scripts": {
7 | "build": "webpack --mode production",
8 | "build-dev": "webpack --mode development --config webpack.config.dev.js",
9 | "dev-server": "webpack-dev-server --mode development --config webpack.config.dev.js",
10 | "prepare": "npm run build",
11 | "trypublish": "npm publish || true",
12 | "postversion": "git push && git push --tags && npm publish && npm run open-releases",
13 | "open-releases": "open \"$(node -e 'console.log(`${require(\"./package.json\").repository}/releases`)')\""
14 | },
15 | "repository": {
16 | "type": "git",
17 | "url": "https://github.com/instadapp/dsa-sdk"
18 | },
19 | "author": "INSTADAPP LABS LLC ",
20 | "license": "MIT",
21 | "keywords": [
22 | "ethereum",
23 | "defi",
24 | "dapps"
25 | ],
26 | "devDependencies": {
27 | "@babel/cli": "^7.10.1",
28 | "@babel/core": "^7.9.0",
29 | "@babel/node": "^7.8.7",
30 | "@babel/plugin-proposal-class-properties": "^7.10.1",
31 | "@babel/polyfill": "^7.10.1",
32 | "@babel/preset-env": "^7.10.2",
33 | "babel-loader": "^8.1.0",
34 | "babel-preset-minify": "^0.5.0",
35 | "dotenv": "^8.2.0",
36 | "html-webpack-plugin": "^4.2.0",
37 | "prettier": "^2.0.5",
38 | "prettier-webpack-plugin": "^1.2.0",
39 | "web3": "^1.2.8",
40 | "webpack": "^4.42.1",
41 | "webpack-cli": "^3.3.11",
42 | "webpack-dev-server": "^3.11.0"
43 | },
44 | "dependencies": {
45 | "axios": "^0.19.2",
46 | "semver": "^7.3.2"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/scripts/getPackageJson.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const path = require('path');
3 |
4 | /**
5 | * A module to get package informations from package.json
6 | * @module getPackageJson
7 | * @param {...string} keys from package.json if no arguments passed it returns package.json content as object
8 | * @returns {object} with given keys or content of package.json as object
9 | */
10 |
11 | /**
12 | * Returns package info
13 | */
14 | const getPackageJson = function(...args) {
15 | const packageJSON = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json')));
16 | if (!args.length) {
17 | return packageJSON;
18 | }
19 | return args.reduce((out, key) => {
20 | out[key] = packageJSON[key];
21 | return out;
22 | }, {});
23 | };
24 |
25 | module.exports = getPackageJson;
--------------------------------------------------------------------------------
/src/abi/basics/erc20.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "constant": true,
4 | "inputs": [],
5 | "name": "name",
6 | "outputs": [
7 | {
8 | "name": "",
9 | "type": "string"
10 | }
11 | ],
12 | "payable": false,
13 | "stateMutability": "view",
14 | "type": "function"
15 | },
16 | {
17 | "constant": false,
18 | "inputs": [
19 | {
20 | "name": "_spender",
21 | "type": "address"
22 | },
23 | {
24 | "name": "_value",
25 | "type": "uint256"
26 | }
27 | ],
28 | "name": "approve",
29 | "outputs": [
30 | {
31 | "name": "",
32 | "type": "bool"
33 | }
34 | ],
35 | "payable": false,
36 | "stateMutability": "nonpayable",
37 | "type": "function"
38 | },
39 | {
40 | "constant": true,
41 | "inputs": [],
42 | "name": "totalSupply",
43 | "outputs": [
44 | {
45 | "name": "",
46 | "type": "uint256"
47 | }
48 | ],
49 | "payable": false,
50 | "stateMutability": "view",
51 | "type": "function"
52 | },
53 | {
54 | "constant": false,
55 | "inputs": [
56 | {
57 | "name": "_from",
58 | "type": "address"
59 | },
60 | {
61 | "name": "_to",
62 | "type": "address"
63 | },
64 | {
65 | "name": "_value",
66 | "type": "uint256"
67 | }
68 | ],
69 | "name": "transferFrom",
70 | "outputs": [
71 | {
72 | "name": "",
73 | "type": "bool"
74 | }
75 | ],
76 | "payable": false,
77 | "stateMutability": "nonpayable",
78 | "type": "function"
79 | },
80 | {
81 | "constant": true,
82 | "inputs": [],
83 | "name": "decimals",
84 | "outputs": [
85 | {
86 | "name": "",
87 | "type": "uint8"
88 | }
89 | ],
90 | "payable": false,
91 | "stateMutability": "view",
92 | "type": "function"
93 | },
94 | {
95 | "constant": true,
96 | "inputs": [
97 | {
98 | "name": "_owner",
99 | "type": "address"
100 | }
101 | ],
102 | "name": "balanceOf",
103 | "outputs": [
104 | {
105 | "name": "balance",
106 | "type": "uint256"
107 | }
108 | ],
109 | "payable": false,
110 | "stateMutability": "view",
111 | "type": "function"
112 | },
113 | {
114 | "constant": true,
115 | "inputs": [],
116 | "name": "symbol",
117 | "outputs": [
118 | {
119 | "name": "",
120 | "type": "string"
121 | }
122 | ],
123 | "payable": false,
124 | "stateMutability": "view",
125 | "type": "function"
126 | },
127 | {
128 | "constant": false,
129 | "inputs": [
130 | {
131 | "name": "_to",
132 | "type": "address"
133 | },
134 | {
135 | "name": "_value",
136 | "type": "uint256"
137 | }
138 | ],
139 | "name": "transfer",
140 | "outputs": [
141 | {
142 | "name": "",
143 | "type": "bool"
144 | }
145 | ],
146 | "payable": false,
147 | "stateMutability": "nonpayable",
148 | "type": "function"
149 | },
150 | {
151 | "constant": true,
152 | "inputs": [
153 | {
154 | "name": "_owner",
155 | "type": "address"
156 | },
157 | {
158 | "name": "_spender",
159 | "type": "address"
160 | }
161 | ],
162 | "name": "allowance",
163 | "outputs": [
164 | {
165 | "name": "",
166 | "type": "uint256"
167 | }
168 | ],
169 | "payable": false,
170 | "stateMutability": "view",
171 | "type": "function"
172 | },
173 | {
174 | "payable": true,
175 | "stateMutability": "payable",
176 | "type": "fallback"
177 | },
178 | {
179 | "anonymous": false,
180 | "inputs": [
181 | {
182 | "indexed": true,
183 | "name": "owner",
184 | "type": "address"
185 | },
186 | {
187 | "indexed": true,
188 | "name": "spender",
189 | "type": "address"
190 | },
191 | {
192 | "indexed": false,
193 | "name": "value",
194 | "type": "uint256"
195 | }
196 | ],
197 | "name": "Approval",
198 | "type": "event"
199 | },
200 | {
201 | "anonymous": false,
202 | "inputs": [
203 | {
204 | "indexed": true,
205 | "name": "from",
206 | "type": "address"
207 | },
208 | {
209 | "indexed": true,
210 | "name": "to",
211 | "type": "address"
212 | },
213 | {
214 | "indexed": false,
215 | "name": "value",
216 | "type": "uint256"
217 | }
218 | ],
219 | "name": "Transfer",
220 | "type": "event"
221 | }
222 | ]
223 |
--------------------------------------------------------------------------------
/src/abi/connectors/1inch.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [],
4 | "name": "connectorID",
5 | "outputs": [
6 | {
7 | "internalType": "uint256",
8 | "name": "model",
9 | "type": "uint256"
10 | },
11 | {
12 | "internalType": "uint256",
13 | "name": "id",
14 | "type": "uint256"
15 | }
16 | ],
17 | "stateMutability": "pure",
18 | "type": "function"
19 | },
20 | {
21 | "inputs": [],
22 | "name": "name",
23 | "outputs": [
24 | {
25 | "internalType": "string",
26 | "name": "",
27 | "type": "string"
28 | }
29 | ],
30 | "stateMutability": "view",
31 | "type": "function"
32 | },
33 | {
34 | "inputs": [
35 | {
36 | "internalType": "address",
37 | "name": "buyAddr",
38 | "type": "address"
39 | },
40 | {
41 | "internalType": "address",
42 | "name": "sellAddr",
43 | "type": "address"
44 | },
45 | {
46 | "internalType": "uint256",
47 | "name": "sellAmt",
48 | "type": "uint256"
49 | },
50 | {
51 | "internalType": "uint256",
52 | "name": "unitAmt",
53 | "type": "uint256"
54 | },
55 | {
56 | "internalType": "uint256",
57 | "name": "getId",
58 | "type": "uint256"
59 | },
60 | {
61 | "internalType": "uint256",
62 | "name": "setId",
63 | "type": "uint256"
64 | }
65 | ],
66 | "name": "sell",
67 | "outputs": [],
68 | "stateMutability": "payable",
69 | "type": "function"
70 | },
71 | {
72 | "inputs": [
73 | {
74 | "internalType": "address",
75 | "name": "buyAddr",
76 | "type": "address"
77 | },
78 | {
79 | "internalType": "address",
80 | "name": "sellAddr",
81 | "type": "address"
82 | },
83 | {
84 | "internalType": "uint256",
85 | "name": "sellAmt",
86 | "type": "uint256"
87 | },
88 | {
89 | "internalType": "uint256",
90 | "name": "unitAmt",
91 | "type": "uint256"
92 | },
93 | {
94 | "internalType": "bytes",
95 | "name": "callData",
96 | "type": "bytes"
97 | },
98 | {
99 | "internalType": "uint256",
100 | "name": "setId",
101 | "type": "uint256"
102 | }
103 | ],
104 | "name": "sellThree",
105 | "outputs": [],
106 | "stateMutability": "payable",
107 | "type": "function"
108 | },
109 | {
110 | "inputs": [
111 | {
112 | "internalType": "address",
113 | "name": "buyAddr",
114 | "type": "address"
115 | },
116 | {
117 | "internalType": "address",
118 | "name": "sellAddr",
119 | "type": "address"
120 | },
121 | {
122 | "internalType": "uint256",
123 | "name": "sellAmt",
124 | "type": "uint256"
125 | },
126 | {
127 | "internalType": "uint256",
128 | "name": "unitAmt",
129 | "type": "uint256"
130 | },
131 | {
132 | "internalType": "uint256[]",
133 | "name": "distribution",
134 | "type": "uint256[]"
135 | },
136 | {
137 | "internalType": "uint256",
138 | "name": "disableDexes",
139 | "type": "uint256"
140 | },
141 | {
142 | "internalType": "uint256",
143 | "name": "getId",
144 | "type": "uint256"
145 | },
146 | {
147 | "internalType": "uint256",
148 | "name": "setId",
149 | "type": "uint256"
150 | }
151 | ],
152 | "name": "sellTwo",
153 | "outputs": [],
154 | "stateMutability": "payable",
155 | "type": "function"
156 | }
157 | ]
158 |
--------------------------------------------------------------------------------
/src/abi/connectors/aaveV1_import.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [],
4 | "name": "connectorID",
5 | "outputs": [
6 | {
7 | "internalType": "uint256",
8 | "name": "model",
9 | "type": "uint256"
10 | },
11 | {
12 | "internalType": "uint256",
13 | "name": "id",
14 | "type": "uint256"
15 | }
16 | ],
17 | "stateMutability": "pure",
18 | "type": "function"
19 | },
20 | {
21 | "inputs": [
22 | {
23 | "internalType": "address",
24 | "name": "userAccount",
25 | "type": "address"
26 | },
27 | {
28 | "internalType": "address[]",
29 | "name": "tokens",
30 | "type": "address[]"
31 | }
32 | ],
33 | "name": "importAave",
34 | "outputs": [],
35 | "stateMutability": "payable",
36 | "type": "function"
37 | },
38 | {
39 | "inputs": [],
40 | "name": "name",
41 | "outputs": [
42 | {
43 | "internalType": "string",
44 | "name": "",
45 | "type": "string"
46 | }
47 | ],
48 | "stateMutability": "view",
49 | "type": "function"
50 | }
51 | ]
52 |
--------------------------------------------------------------------------------
/src/abi/connectors/aaveV2_import.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [],
4 | "name": "connectorID",
5 | "outputs": [
6 | {
7 | "internalType": "uint256",
8 | "name": "model",
9 | "type": "uint256"
10 | },
11 | {
12 | "internalType": "uint256",
13 | "name": "id",
14 | "type": "uint256"
15 | }
16 | ],
17 | "stateMutability": "pure",
18 | "type": "function"
19 | },
20 | {
21 | "inputs": [
22 | {
23 | "internalType": "address",
24 | "name": "userAccount",
25 | "type": "address"
26 | },
27 | {
28 | "internalType": "address[]",
29 | "name": "tokens",
30 | "type": "address[]"
31 | },
32 | {
33 | "internalType": "bool",
34 | "name": "convertStable",
35 | "type": "bool"
36 | }
37 | ],
38 | "name": "importAave",
39 | "outputs": [],
40 | "stateMutability": "payable",
41 | "type": "function"
42 | },
43 | {
44 | "inputs": [],
45 | "name": "name",
46 | "outputs": [
47 | {
48 | "internalType": "string",
49 | "name": "",
50 | "type": "string"
51 | }
52 | ],
53 | "stateMutability": "view",
54 | "type": "function"
55 | }
56 | ]
57 |
--------------------------------------------------------------------------------
/src/abi/connectors/aave_migrate.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": false,
7 | "internalType": "address[]",
8 | "name": "aTokens",
9 | "type": "address[]"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "uint256[]",
14 | "name": "aTknBals",
15 | "type": "uint256[]"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256[]",
20 | "name": "borrowBals",
21 | "type": "uint256[]"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256[]",
26 | "name": "borrowBalsFee",
27 | "type": "uint256[]"
28 | }
29 | ],
30 | "name": "LogMigrate",
31 | "type": "event"
32 | },
33 | {
34 | "anonymous": false,
35 | "inputs": [
36 | {
37 | "indexed": false,
38 | "internalType": "address",
39 | "name": "user",
40 | "type": "address"
41 | },
42 | {
43 | "indexed": false,
44 | "internalType": "address[]",
45 | "name": "aTokens",
46 | "type": "address[]"
47 | },
48 | {
49 | "indexed": false,
50 | "internalType": "uint256[]",
51 | "name": "aTknBals",
52 | "type": "uint256[]"
53 | },
54 | {
55 | "indexed": false,
56 | "internalType": "uint256[]",
57 | "name": "borrowBals",
58 | "type": "uint256[]"
59 | },
60 | {
61 | "indexed": false,
62 | "internalType": "uint256[]",
63 | "name": "borrowBalsFee",
64 | "type": "uint256[]"
65 | }
66 | ],
67 | "name": "LogMigrateUser",
68 | "type": "event"
69 | },
70 | {
71 | "inputs": [],
72 | "name": "connectorID",
73 | "outputs": [
74 | { "internalType": "uint256", "name": "model", "type": "uint256" },
75 | { "internalType": "uint256", "name": "id", "type": "uint256" }
76 | ],
77 | "stateMutability": "pure",
78 | "type": "function"
79 | },
80 | {
81 | "inputs": [
82 | { "internalType": "address[]", "name": "tokens", "type": "address[]" }
83 | ],
84 | "name": "migrate",
85 | "outputs": [],
86 | "stateMutability": "payable",
87 | "type": "function"
88 | },
89 | {
90 | "inputs": [
91 | { "internalType": "address", "name": "userAccount", "type": "address" },
92 | { "internalType": "address[]", "name": "tokens", "type": "address[]" }
93 | ],
94 | "name": "migrateUser",
95 | "outputs": [],
96 | "stateMutability": "payable",
97 | "type": "function"
98 | },
99 | {
100 | "inputs": [],
101 | "name": "name",
102 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
103 | "stateMutability": "view",
104 | "type": "function"
105 | }
106 | ]
107 |
--------------------------------------------------------------------------------
/src/abi/connectors/auth.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": true,
7 | "internalType": "address",
8 | "name": "_msgSender",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": true,
13 | "internalType": "address",
14 | "name": "_authority",
15 | "type": "address"
16 | }
17 | ],
18 | "name": "LogAddAuth",
19 | "type": "event"
20 | },
21 | {
22 | "anonymous": false,
23 | "inputs": [
24 | {
25 | "indexed": true,
26 | "internalType": "address",
27 | "name": "_msgSender",
28 | "type": "address"
29 | },
30 | {
31 | "indexed": true,
32 | "internalType": "address",
33 | "name": "_authority",
34 | "type": "address"
35 | }
36 | ],
37 | "name": "LogRemoveAuth",
38 | "type": "event"
39 | },
40 | {
41 | "inputs": [
42 | {
43 | "internalType": "address",
44 | "name": "authority",
45 | "type": "address"
46 | }
47 | ],
48 | "name": "add",
49 | "outputs": [],
50 | "stateMutability": "payable",
51 | "type": "function"
52 | },
53 | {
54 | "inputs": [],
55 | "name": "connectorID",
56 | "outputs": [
57 | {
58 | "internalType": "uint256",
59 | "name": "_type",
60 | "type": "uint256"
61 | },
62 | {
63 | "internalType": "uint256",
64 | "name": "_id",
65 | "type": "uint256"
66 | }
67 | ],
68 | "stateMutability": "pure",
69 | "type": "function"
70 | },
71 | {
72 | "inputs": [],
73 | "name": "name",
74 | "outputs": [
75 | {
76 | "internalType": "string",
77 | "name": "",
78 | "type": "string"
79 | }
80 | ],
81 | "stateMutability": "view",
82 | "type": "function"
83 | },
84 | {
85 | "inputs": [
86 | {
87 | "internalType": "address",
88 | "name": "authority",
89 | "type": "address"
90 | }
91 | ],
92 | "name": "remove",
93 | "outputs": [],
94 | "stateMutability": "payable",
95 | "type": "function"
96 | }
97 | ]
98 |
--------------------------------------------------------------------------------
/src/abi/connectors/basic.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": true,
7 | "internalType": "address",
8 | "name": "erc20",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "uint256",
14 | "name": "tokenAmt",
15 | "type": "uint256"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256",
20 | "name": "getId",
21 | "type": "uint256"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256",
26 | "name": "setId",
27 | "type": "uint256"
28 | }
29 | ],
30 | "name": "LogDeposit",
31 | "type": "event"
32 | },
33 | {
34 | "anonymous": false,
35 | "inputs": [
36 | {
37 | "indexed": true,
38 | "internalType": "address",
39 | "name": "erc20",
40 | "type": "address"
41 | },
42 | {
43 | "indexed": false,
44 | "internalType": "uint256",
45 | "name": "tokenAmt",
46 | "type": "uint256"
47 | },
48 | {
49 | "indexed": true,
50 | "internalType": "address",
51 | "name": "to",
52 | "type": "address"
53 | },
54 | {
55 | "indexed": false,
56 | "internalType": "uint256",
57 | "name": "getId",
58 | "type": "uint256"
59 | },
60 | {
61 | "indexed": false,
62 | "internalType": "uint256",
63 | "name": "setId",
64 | "type": "uint256"
65 | }
66 | ],
67 | "name": "LogWithdraw",
68 | "type": "event"
69 | },
70 | {
71 | "inputs": [],
72 | "name": "connectorID",
73 | "outputs": [
74 | { "internalType": "uint256", "name": "_type", "type": "uint256" },
75 | { "internalType": "uint256", "name": "_id", "type": "uint256" }
76 | ],
77 | "stateMutability": "pure",
78 | "type": "function"
79 | },
80 | {
81 | "inputs": [
82 | { "internalType": "address", "name": "erc20", "type": "address" },
83 | { "internalType": "uint256", "name": "tokenAmt", "type": "uint256" },
84 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
85 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
86 | ],
87 | "name": "deposit",
88 | "outputs": [],
89 | "stateMutability": "payable",
90 | "type": "function"
91 | },
92 | {
93 | "inputs": [],
94 | "name": "getEthAddr",
95 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
96 | "stateMutability": "pure",
97 | "type": "function"
98 | },
99 | {
100 | "inputs": [],
101 | "name": "getEventAddr",
102 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
103 | "stateMutability": "pure",
104 | "type": "function"
105 | },
106 | {
107 | "inputs": [],
108 | "name": "getMemoryAddr",
109 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
110 | "stateMutability": "pure",
111 | "type": "function"
112 | },
113 | {
114 | "inputs": [],
115 | "name": "name",
116 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
117 | "stateMutability": "view",
118 | "type": "function"
119 | },
120 | {
121 | "inputs": [
122 | { "internalType": "address", "name": "erc20", "type": "address" },
123 | { "internalType": "uint256", "name": "tokenAmt", "type": "uint256" },
124 | { "internalType": "address payable", "name": "to", "type": "address" },
125 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
126 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
127 | ],
128 | "name": "withdraw",
129 | "outputs": [],
130 | "stateMutability": "payable",
131 | "type": "function"
132 | }
133 | ]
134 |
--------------------------------------------------------------------------------
/src/abi/connectors/chi.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [{ "internalType": "uint256", "name": "amt", "type": "uint256" }],
4 | "name": "burn",
5 | "outputs": [],
6 | "stateMutability": "payable",
7 | "type": "function"
8 | },
9 | {
10 | "inputs": [],
11 | "name": "connectorID",
12 | "outputs": [
13 | { "internalType": "uint256", "name": "model", "type": "uint256" },
14 | { "internalType": "uint256", "name": "id", "type": "uint256" }
15 | ],
16 | "stateMutability": "view",
17 | "type": "function"
18 | },
19 | {
20 | "inputs": [{ "internalType": "uint256", "name": "amt", "type": "uint256" }],
21 | "name": "mint",
22 | "outputs": [],
23 | "stateMutability": "payable",
24 | "type": "function"
25 | },
26 | {
27 | "inputs": [],
28 | "name": "name",
29 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
30 | "stateMutability": "view",
31 | "type": "function"
32 | }
33 | ]
34 |
--------------------------------------------------------------------------------
/src/abi/connectors/comp.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | {
5 | "internalType": "uint256",
6 | "name": "setId",
7 | "type": "uint256"
8 | }
9 | ],
10 | "name": "ClaimComp",
11 | "outputs": [],
12 | "stateMutability": "payable",
13 | "type": "function"
14 | },
15 | {
16 | "inputs": [
17 | {
18 | "internalType": "address[]",
19 | "name": "supplyTokens",
20 | "type": "address[]"
21 | },
22 | {
23 | "internalType": "address[]",
24 | "name": "borrowTokens",
25 | "type": "address[]"
26 | },
27 | {
28 | "internalType": "uint256",
29 | "name": "setId",
30 | "type": "uint256"
31 | }
32 | ],
33 | "name": "ClaimCompThree",
34 | "outputs": [],
35 | "stateMutability": "payable",
36 | "type": "function"
37 | },
38 | {
39 | "inputs": [
40 | {
41 | "internalType": "address[]",
42 | "name": "tokens",
43 | "type": "address[]"
44 | },
45 | {
46 | "internalType": "uint256",
47 | "name": "setId",
48 | "type": "uint256"
49 | }
50 | ],
51 | "name": "ClaimCompTwo",
52 | "outputs": [],
53 | "stateMutability": "payable",
54 | "type": "function"
55 | },
56 | {
57 | "inputs": [
58 | {
59 | "internalType": "address",
60 | "name": "delegatee",
61 | "type": "address"
62 | }
63 | ],
64 | "name": "delegate",
65 | "outputs": [],
66 | "stateMutability": "payable",
67 | "type": "function"
68 | }
69 | ]
70 |
--------------------------------------------------------------------------------
/src/abi/connectors/compoundImport.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": false,
7 | "internalType": "address",
8 | "name": "user",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "uint256",
14 | "name": "times",
15 | "type": "uint256"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "address[]",
20 | "name": "cTokens",
21 | "type": "address[]"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256[]",
26 | "name": "cTknBals",
27 | "type": "uint256[]"
28 | },
29 | {
30 | "indexed": false,
31 | "internalType": "uint256[]",
32 | "name": "borrowBals",
33 | "type": "uint256[]"
34 | }
35 | ],
36 | "name": "LogImport",
37 | "type": "event"
38 | },
39 | {
40 | "anonymous": false,
41 | "inputs": [
42 | {
43 | "indexed": false,
44 | "internalType": "address",
45 | "name": "user",
46 | "type": "address"
47 | },
48 | {
49 | "indexed": false,
50 | "internalType": "address",
51 | "name": "token",
52 | "type": "address"
53 | },
54 | {
55 | "indexed": false,
56 | "internalType": "uint256",
57 | "name": "amt",
58 | "type": "uint256"
59 | },
60 | {
61 | "indexed": false,
62 | "internalType": "uint256",
63 | "name": "getId",
64 | "type": "uint256"
65 | },
66 | {
67 | "indexed": false,
68 | "internalType": "uint256",
69 | "name": "setId",
70 | "type": "uint256"
71 | }
72 | ],
73 | "name": "LogImportPayback",
74 | "type": "event"
75 | },
76 | {
77 | "inputs": [],
78 | "name": "connectorID",
79 | "outputs": [
80 | { "internalType": "uint256", "name": "model", "type": "uint256" },
81 | { "internalType": "uint256", "name": "id", "type": "uint256" }
82 | ],
83 | "stateMutability": "pure",
84 | "type": "function"
85 | },
86 | {
87 | "inputs": [
88 | { "internalType": "address", "name": "userAccount", "type": "address" },
89 | { "internalType": "address[]", "name": "tokens", "type": "address[]" },
90 | { "internalType": "uint256", "name": "times", "type": "uint256" }
91 | ],
92 | "name": "importCompound",
93 | "outputs": [],
94 | "stateMutability": "payable",
95 | "type": "function"
96 | },
97 | {
98 | "inputs": [
99 | { "internalType": "address", "name": "userAccount", "type": "address" },
100 | { "internalType": "address", "name": "token", "type": "address" },
101 | { "internalType": "uint256", "name": "amt", "type": "uint256" },
102 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
103 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
104 | ],
105 | "name": "importPaybackBehalf",
106 | "outputs": [],
107 | "stateMutability": "payable",
108 | "type": "function"
109 | },
110 | {
111 | "inputs": [],
112 | "name": "name",
113 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
114 | "stateMutability": "view",
115 | "type": "function"
116 | }
117 | ]
118 |
--------------------------------------------------------------------------------
/src/abi/connectors/compoundImport_v2.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": false,
7 | "internalType": "address",
8 | "name": "user",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "address[]",
14 | "name": "cTokens",
15 | "type": "address[]"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256[]",
20 | "name": "cTknBals",
21 | "type": "uint256[]"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256[]",
26 | "name": "borrowBals",
27 | "type": "uint256[]"
28 | }
29 | ],
30 | "name": "LogCompoundImport",
31 | "type": "event"
32 | },
33 | {
34 | "inputs": [],
35 | "name": "connectorID",
36 | "outputs": [
37 | { "internalType": "uint256", "name": "model", "type": "uint256" },
38 | { "internalType": "uint256", "name": "id", "type": "uint256" }
39 | ],
40 | "stateMutability": "pure",
41 | "type": "function"
42 | },
43 | {
44 | "inputs": [
45 | { "internalType": "address", "name": "userAccount", "type": "address" },
46 | { "internalType": "address[]", "name": "tokens", "type": "address[]" }
47 | ],
48 | "name": "importCompound",
49 | "outputs": [],
50 | "stateMutability": "payable",
51 | "type": "function"
52 | },
53 | {
54 | "inputs": [],
55 | "name": "name",
56 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
57 | "stateMutability": "view",
58 | "type": "function"
59 | }
60 | ]
61 |
--------------------------------------------------------------------------------
/src/abi/connectors/curve.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [],
4 | "name": "connectorID",
5 | "outputs": [
6 | {
7 | "internalType": "uint256",
8 | "name": "model",
9 | "type": "uint256"
10 | },
11 | {
12 | "internalType": "uint256",
13 | "name": "id",
14 | "type": "uint256"
15 | }
16 | ],
17 | "stateMutability": "pure",
18 | "type": "function"
19 | },
20 | {
21 | "inputs": [
22 | {
23 | "internalType": "address",
24 | "name": "token",
25 | "type": "address"
26 | },
27 | {
28 | "internalType": "uint256",
29 | "name": "amt",
30 | "type": "uint256"
31 | },
32 | {
33 | "internalType": "uint256",
34 | "name": "unitAmt",
35 | "type": "uint256"
36 | },
37 | {
38 | "internalType": "uint256",
39 | "name": "getId",
40 | "type": "uint256"
41 | },
42 | {
43 | "internalType": "uint256",
44 | "name": "setId",
45 | "type": "uint256"
46 | }
47 | ],
48 | "name": "deposit",
49 | "outputs": [],
50 | "stateMutability": "payable",
51 | "type": "function"
52 | },
53 | {
54 | "inputs": [],
55 | "name": "name",
56 | "outputs": [
57 | {
58 | "internalType": "string",
59 | "name": "",
60 | "type": "string"
61 | }
62 | ],
63 | "stateMutability": "view",
64 | "type": "function"
65 | },
66 | {
67 | "inputs": [
68 | {
69 | "internalType": "address",
70 | "name": "buyAddr",
71 | "type": "address"
72 | },
73 | {
74 | "internalType": "address",
75 | "name": "sellAddr",
76 | "type": "address"
77 | },
78 | {
79 | "internalType": "uint256",
80 | "name": "sellAmt",
81 | "type": "uint256"
82 | },
83 | {
84 | "internalType": "uint256",
85 | "name": "unitAmt",
86 | "type": "uint256"
87 | },
88 | {
89 | "internalType": "uint256",
90 | "name": "getId",
91 | "type": "uint256"
92 | },
93 | {
94 | "internalType": "uint256",
95 | "name": "setId",
96 | "type": "uint256"
97 | }
98 | ],
99 | "name": "sell",
100 | "outputs": [],
101 | "stateMutability": "payable",
102 | "type": "function"
103 | },
104 | {
105 | "inputs": [
106 | {
107 | "internalType": "address",
108 | "name": "token",
109 | "type": "address"
110 | },
111 | {
112 | "internalType": "uint256",
113 | "name": "amt",
114 | "type": "uint256"
115 | },
116 | {
117 | "internalType": "uint256",
118 | "name": "unitAmt",
119 | "type": "uint256"
120 | },
121 | {
122 | "internalType": "uint256",
123 | "name": "getId",
124 | "type": "uint256"
125 | },
126 | {
127 | "internalType": "uint256",
128 | "name": "setId",
129 | "type": "uint256"
130 | }
131 | ],
132 | "name": "withdraw",
133 | "outputs": [],
134 | "stateMutability": "payable",
135 | "type": "function"
136 | }
137 | ]
138 |
--------------------------------------------------------------------------------
/src/abi/connectors/curveClaim.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": false,
7 | "internalType": "address",
8 | "name": "account",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "uint256",
14 | "name": "claimAmount",
15 | "type": "uint256"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256",
20 | "name": "getId",
21 | "type": "uint256"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256",
26 | "name": "setId",
27 | "type": "uint256"
28 | }
29 | ],
30 | "name": "LogClaim",
31 | "type": "event"
32 | },
33 | {
34 | "inputs": [
35 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
36 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
37 | ],
38 | "name": "claim",
39 | "outputs": [],
40 | "stateMutability": "nonpayable",
41 | "type": "function"
42 | },
43 | {
44 | "inputs": [],
45 | "name": "connectorID",
46 | "outputs": [
47 | { "internalType": "uint256", "name": "model", "type": "uint256" },
48 | { "internalType": "uint256", "name": "id", "type": "uint256" }
49 | ],
50 | "stateMutability": "view",
51 | "type": "function"
52 | },
53 | {
54 | "inputs": [],
55 | "name": "name",
56 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
57 | "stateMutability": "view",
58 | "type": "function"
59 | }
60 | ]
61 |
--------------------------------------------------------------------------------
/src/abi/connectors/curveGauge.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": true,
7 | "internalType": "string",
8 | "name": "gaugePoolName",
9 | "type": "string"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "uint256",
14 | "name": "amount",
15 | "type": "uint256"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256",
20 | "name": "rewardAmt",
21 | "type": "uint256"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256",
26 | "name": "setId",
27 | "type": "uint256"
28 | },
29 | {
30 | "indexed": false,
31 | "internalType": "uint256",
32 | "name": "setIdReward",
33 | "type": "uint256"
34 | }
35 | ],
36 | "name": "LogClaimedReward",
37 | "type": "event"
38 | },
39 | {
40 | "anonymous": false,
41 | "inputs": [
42 | {
43 | "indexed": true,
44 | "internalType": "string",
45 | "name": "gaugePoolName",
46 | "type": "string"
47 | },
48 | {
49 | "indexed": false,
50 | "internalType": "uint256",
51 | "name": "amount",
52 | "type": "uint256"
53 | },
54 | {
55 | "indexed": false,
56 | "internalType": "uint256",
57 | "name": "getId",
58 | "type": "uint256"
59 | },
60 | {
61 | "indexed": false,
62 | "internalType": "uint256",
63 | "name": "setId",
64 | "type": "uint256"
65 | }
66 | ],
67 | "name": "LogDeposit",
68 | "type": "event"
69 | },
70 | {
71 | "anonymous": false,
72 | "inputs": [
73 | {
74 | "indexed": true,
75 | "internalType": "string",
76 | "name": "gaugePoolName",
77 | "type": "string"
78 | },
79 | {
80 | "indexed": false,
81 | "internalType": "uint256",
82 | "name": "amount",
83 | "type": "uint256"
84 | },
85 | {
86 | "indexed": false,
87 | "internalType": "uint256",
88 | "name": "getId",
89 | "type": "uint256"
90 | },
91 | {
92 | "indexed": false,
93 | "internalType": "uint256",
94 | "name": "setId",
95 | "type": "uint256"
96 | }
97 | ],
98 | "name": "LogWithdraw",
99 | "type": "event"
100 | },
101 | {
102 | "inputs": [
103 | { "internalType": "string", "name": "gaugePoolName", "type": "string" },
104 | { "internalType": "uint256", "name": "setId", "type": "uint256" },
105 | { "internalType": "uint256", "name": "setIdReward", "type": "uint256" }
106 | ],
107 | "name": "claimReward",
108 | "outputs": [],
109 | "stateMutability": "payable",
110 | "type": "function"
111 | },
112 | {
113 | "inputs": [],
114 | "name": "connectorID",
115 | "outputs": [
116 | { "internalType": "uint256", "name": "model", "type": "uint256" },
117 | { "internalType": "uint256", "name": "id", "type": "uint256" }
118 | ],
119 | "stateMutability": "view",
120 | "type": "function"
121 | },
122 | {
123 | "inputs": [
124 | { "internalType": "string", "name": "gaugePoolName", "type": "string" },
125 | { "internalType": "uint256", "name": "amt", "type": "uint256" },
126 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
127 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
128 | ],
129 | "name": "deposit",
130 | "outputs": [],
131 | "stateMutability": "payable",
132 | "type": "function"
133 | },
134 | {
135 | "inputs": [],
136 | "name": "name",
137 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
138 | "stateMutability": "view",
139 | "type": "function"
140 | },
141 | {
142 | "inputs": [
143 | { "internalType": "string", "name": "gaugePoolName", "type": "string" },
144 | { "internalType": "uint256", "name": "amt", "type": "uint256" },
145 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
146 | { "internalType": "uint256", "name": "setId", "type": "uint256" },
147 | { "internalType": "uint256", "name": "setIdCrv", "type": "uint256" },
148 | { "internalType": "uint256", "name": "setIdReward", "type": "uint256" }
149 | ],
150 | "name": "withdraw",
151 | "outputs": [],
152 | "stateMutability": "payable",
153 | "type": "function"
154 | }
155 | ]
156 |
--------------------------------------------------------------------------------
/src/abi/connectors/curve_3pool.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": true,
7 | "internalType": "address",
8 | "name": "buyToken",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": true,
13 | "internalType": "address",
14 | "name": "sellToken",
15 | "type": "address"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256",
20 | "name": "buyAmt",
21 | "type": "uint256"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256",
26 | "name": "sellAmt",
27 | "type": "uint256"
28 | },
29 | {
30 | "indexed": false,
31 | "internalType": "uint256",
32 | "name": "getId",
33 | "type": "uint256"
34 | },
35 | {
36 | "indexed": false,
37 | "internalType": "uint256",
38 | "name": "setId",
39 | "type": "uint256"
40 | }
41 | ],
42 | "name": "LogSell",
43 | "type": "event"
44 | },
45 | {
46 | "inputs": [],
47 | "name": "connectorID",
48 | "outputs": [
49 | { "internalType": "uint256", "name": "model", "type": "uint256" },
50 | { "internalType": "uint256", "name": "id", "type": "uint256" }
51 | ],
52 | "stateMutability": "view",
53 | "type": "function"
54 | },
55 | {
56 | "inputs": [],
57 | "name": "name",
58 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
59 | "stateMutability": "view",
60 | "type": "function"
61 | },
62 | {
63 | "inputs": [
64 | { "internalType": "address", "name": "buyAddr", "type": "address" },
65 | { "internalType": "address", "name": "sellAddr", "type": "address" },
66 | { "internalType": "uint256", "name": "sellAmt", "type": "uint256" },
67 | { "internalType": "uint256", "name": "unitAmt", "type": "uint256" },
68 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
69 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
70 | ],
71 | "name": "sell",
72 | "outputs": [],
73 | "stateMutability": "payable",
74 | "type": "function"
75 | }
76 | ]
77 |
--------------------------------------------------------------------------------
/src/abi/connectors/dydx.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | {
5 | "internalType": "address",
6 | "name": "token",
7 | "type": "address"
8 | },
9 | {
10 | "internalType": "uint256",
11 | "name": "amt",
12 | "type": "uint256"
13 | },
14 | {
15 | "internalType": "uint256",
16 | "name": "getId",
17 | "type": "uint256"
18 | },
19 | {
20 | "internalType": "uint256",
21 | "name": "setId",
22 | "type": "uint256"
23 | }
24 | ],
25 | "name": "borrow",
26 | "outputs": [],
27 | "stateMutability": "payable",
28 | "type": "function"
29 | },
30 | {
31 | "inputs": [],
32 | "name": "connectorID",
33 | "outputs": [
34 | {
35 | "internalType": "uint256",
36 | "name": "model",
37 | "type": "uint256"
38 | },
39 | {
40 | "internalType": "uint256",
41 | "name": "id",
42 | "type": "uint256"
43 | }
44 | ],
45 | "stateMutability": "pure",
46 | "type": "function"
47 | },
48 | {
49 | "inputs": [
50 | {
51 | "internalType": "address",
52 | "name": "token",
53 | "type": "address"
54 | },
55 | {
56 | "internalType": "uint256",
57 | "name": "amt",
58 | "type": "uint256"
59 | },
60 | {
61 | "internalType": "uint256",
62 | "name": "getId",
63 | "type": "uint256"
64 | },
65 | {
66 | "internalType": "uint256",
67 | "name": "setId",
68 | "type": "uint256"
69 | }
70 | ],
71 | "name": "deposit",
72 | "outputs": [],
73 | "stateMutability": "payable",
74 | "type": "function"
75 | },
76 | {
77 | "inputs": [],
78 | "name": "name",
79 | "outputs": [
80 | {
81 | "internalType": "string",
82 | "name": "",
83 | "type": "string"
84 | }
85 | ],
86 | "stateMutability": "view",
87 | "type": "function"
88 | },
89 | {
90 | "inputs": [
91 | {
92 | "internalType": "address",
93 | "name": "token",
94 | "type": "address"
95 | },
96 | {
97 | "internalType": "uint256",
98 | "name": "amt",
99 | "type": "uint256"
100 | },
101 | {
102 | "internalType": "uint256",
103 | "name": "getId",
104 | "type": "uint256"
105 | },
106 | {
107 | "internalType": "uint256",
108 | "name": "setId",
109 | "type": "uint256"
110 | }
111 | ],
112 | "name": "payback",
113 | "outputs": [],
114 | "stateMutability": "payable",
115 | "type": "function"
116 | },
117 | {
118 | "inputs": [
119 | {
120 | "internalType": "address",
121 | "name": "token",
122 | "type": "address"
123 | },
124 | {
125 | "internalType": "uint256",
126 | "name": "amt",
127 | "type": "uint256"
128 | },
129 | {
130 | "internalType": "uint256",
131 | "name": "getId",
132 | "type": "uint256"
133 | },
134 | {
135 | "internalType": "uint256",
136 | "name": "setId",
137 | "type": "uint256"
138 | }
139 | ],
140 | "name": "withdraw",
141 | "outputs": [],
142 | "stateMutability": "payable",
143 | "type": "function"
144 | }
145 | ]
146 |
--------------------------------------------------------------------------------
/src/abi/connectors/dydxFlashloan.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": true,
7 | "internalType": "address",
8 | "name": "token",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "uint256",
14 | "name": "tokenAmt",
15 | "type": "uint256"
16 | }
17 | ],
18 | "name": "LogDydxFlashLoan",
19 | "type": "event"
20 | },
21 | {
22 | "inputs": [
23 | { "internalType": "address", "name": "token", "type": "address" },
24 | { "internalType": "uint256", "name": "tokenAmt", "type": "uint256" },
25 | { "internalType": "bytes", "name": "data", "type": "bytes" }
26 | ],
27 | "name": "borrowAndCast",
28 | "outputs": [],
29 | "stateMutability": "payable",
30 | "type": "function"
31 | },
32 | {
33 | "inputs": [],
34 | "name": "connectorID",
35 | "outputs": [
36 | { "internalType": "uint256", "name": "model", "type": "uint256" },
37 | { "internalType": "uint256", "name": "id", "type": "uint256" }
38 | ],
39 | "stateMutability": "view",
40 | "type": "function"
41 | },
42 | {
43 | "inputs": [],
44 | "name": "name",
45 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
46 | "stateMutability": "view",
47 | "type": "function"
48 | }
49 | ]
50 |
--------------------------------------------------------------------------------
/src/abi/connectors/fee.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | { "internalType": "uint256", "name": "amount", "type": "uint256" },
5 | { "internalType": "uint256", "name": "fee", "type": "uint256" },
6 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
7 | {
8 | "internalType": "uint256",
9 | "name": "setIdAmtMinusFee",
10 | "type": "uint256"
11 | },
12 | { "internalType": "uint256", "name": "setIdFee", "type": "uint256" }
13 | ],
14 | "name": "calculateAmtMinusFee",
15 | "outputs": [],
16 | "stateMutability": "payable",
17 | "type": "function"
18 | },
19 | {
20 | "inputs": [
21 | { "internalType": "uint256", "name": "amount", "type": "uint256" },
22 | { "internalType": "uint256", "name": "fee", "type": "uint256" },
23 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
24 | { "internalType": "uint256", "name": "setId", "type": "uint256" },
25 | { "internalType": "uint256", "name": "setIdFee", "type": "uint256" }
26 | ],
27 | "name": "calculateFee",
28 | "outputs": [],
29 | "stateMutability": "payable",
30 | "type": "function"
31 | },
32 | {
33 | "inputs": [],
34 | "name": "connectorID",
35 | "outputs": [
36 | { "internalType": "uint256", "name": "_type", "type": "uint256" },
37 | { "internalType": "uint256", "name": "_id", "type": "uint256" }
38 | ],
39 | "stateMutability": "pure",
40 | "type": "function"
41 | },
42 | {
43 | "inputs": [],
44 | "name": "name",
45 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
46 | "stateMutability": "view",
47 | "type": "function"
48 | }
49 | ]
50 |
--------------------------------------------------------------------------------
/src/abi/connectors/instapool_v2.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": false,
7 | "internalType": "address[]",
8 | "name": "token",
9 | "type": "address[]"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "uint256[]",
14 | "name": "tokenAmt",
15 | "type": "uint256[]"
16 | }
17 | ],
18 | "name": "LogFlashBorrow",
19 | "type": "event"
20 | },
21 | {
22 | "anonymous": false,
23 | "inputs": [
24 | {
25 | "indexed": false,
26 | "internalType": "address[]",
27 | "name": "token",
28 | "type": "address[]"
29 | },
30 | {
31 | "indexed": false,
32 | "internalType": "uint256[]",
33 | "name": "tokenAmt",
34 | "type": "uint256[]"
35 | },
36 | {
37 | "indexed": false,
38 | "internalType": "uint256[]",
39 | "name": "totalAmtFee",
40 | "type": "uint256[]"
41 | }
42 | ],
43 | "name": "LogFlashPayback",
44 | "type": "event"
45 | },
46 | {
47 | "inputs": [
48 | { "internalType": "uint256", "name": "flashAmt", "type": "uint256" },
49 | { "internalType": "uint256", "name": "amt", "type": "uint256" },
50 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
51 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
52 | ],
53 | "name": "addFeeAmount",
54 | "outputs": [],
55 | "stateMutability": "payable",
56 | "type": "function"
57 | },
58 | {
59 | "inputs": [],
60 | "name": "connectorID",
61 | "outputs": [
62 | { "internalType": "uint256", "name": "_type", "type": "uint256" },
63 | { "internalType": "uint256", "name": "_id", "type": "uint256" }
64 | ],
65 | "stateMutability": "pure",
66 | "type": "function"
67 | },
68 | {
69 | "inputs": [
70 | { "internalType": "address", "name": "token", "type": "address" },
71 | { "internalType": "uint256", "name": "amt", "type": "uint256" },
72 | { "internalType": "uint256", "name": "route", "type": "uint256" },
73 | { "internalType": "bytes", "name": "data", "type": "bytes" }
74 | ],
75 | "name": "flashBorrowAndCast",
76 | "outputs": [],
77 | "stateMutability": "payable",
78 | "type": "function"
79 | },
80 | {
81 | "inputs": [
82 | { "internalType": "address[]", "name": "tokens", "type": "address[]" },
83 | { "internalType": "uint256[]", "name": "amts", "type": "uint256[]" },
84 | { "internalType": "uint256", "name": "route", "type": "uint256" },
85 | { "internalType": "bytes", "name": "data", "type": "bytes" }
86 | ],
87 | "name": "flashMultiBorrowAndCast",
88 | "outputs": [],
89 | "stateMutability": "payable",
90 | "type": "function"
91 | },
92 | {
93 | "inputs": [
94 | { "internalType": "address[]", "name": "tokens", "type": "address[]" },
95 | { "internalType": "uint256[]", "name": "amts", "type": "uint256[]" },
96 | { "internalType": "uint256[]", "name": "getId", "type": "uint256[]" },
97 | { "internalType": "uint256[]", "name": "setId", "type": "uint256[]" }
98 | ],
99 | "name": "flashMultiPayback",
100 | "outputs": [],
101 | "stateMutability": "payable",
102 | "type": "function"
103 | },
104 | {
105 | "inputs": [
106 | { "internalType": "address", "name": "token", "type": "address" },
107 | { "internalType": "uint256", "name": "amt", "type": "uint256" },
108 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
109 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
110 | ],
111 | "name": "flashPayback",
112 | "outputs": [],
113 | "stateMutability": "payable",
114 | "type": "function"
115 | },
116 | {
117 | "inputs": [],
118 | "name": "name",
119 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
120 | "stateMutability": "view",
121 | "type": "function"
122 | }
123 | ]
124 |
--------------------------------------------------------------------------------
/src/abi/connectors/kyber.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": true,
7 | "internalType": "address",
8 | "name": "buyToken",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": true,
13 | "internalType": "address",
14 | "name": "sellToken",
15 | "type": "address"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256",
20 | "name": "buyAmt",
21 | "type": "uint256"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256",
26 | "name": "sellAmt",
27 | "type": "uint256"
28 | },
29 | {
30 | "indexed": false,
31 | "internalType": "uint256",
32 | "name": "getId",
33 | "type": "uint256"
34 | },
35 | {
36 | "indexed": false,
37 | "internalType": "uint256",
38 | "name": "setId",
39 | "type": "uint256"
40 | }
41 | ],
42 | "name": "LogSell",
43 | "type": "event"
44 | },
45 | {
46 | "inputs": [],
47 | "name": "connectorID",
48 | "outputs": [
49 | {
50 | "internalType": "uint256",
51 | "name": "model",
52 | "type": "uint256"
53 | },
54 | {
55 | "internalType": "uint256",
56 | "name": "id",
57 | "type": "uint256"
58 | }
59 | ],
60 | "stateMutability": "pure",
61 | "type": "function"
62 | },
63 | {
64 | "inputs": [],
65 | "name": "name",
66 | "outputs": [
67 | {
68 | "internalType": "string",
69 | "name": "",
70 | "type": "string"
71 | }
72 | ],
73 | "stateMutability": "view",
74 | "type": "function"
75 | },
76 | {
77 | "inputs": [
78 | {
79 | "internalType": "address",
80 | "name": "buyAddr",
81 | "type": "address"
82 | },
83 | {
84 | "internalType": "address",
85 | "name": "sellAddr",
86 | "type": "address"
87 | },
88 | {
89 | "internalType": "uint256",
90 | "name": "sellAmt",
91 | "type": "uint256"
92 | },
93 | {
94 | "internalType": "uint256",
95 | "name": "unitAmt",
96 | "type": "uint256"
97 | },
98 | {
99 | "internalType": "uint256",
100 | "name": "getId",
101 | "type": "uint256"
102 | },
103 | {
104 | "internalType": "uint256",
105 | "name": "setId",
106 | "type": "uint256"
107 | }
108 | ],
109 | "name": "sell",
110 | "outputs": [],
111 | "stateMutability": "payable",
112 | "type": "function"
113 | }
114 | ]
115 |
--------------------------------------------------------------------------------
/src/abi/connectors/math.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | { "internalType": "uint256[]", "name": "getIds", "type": "uint256[]" },
5 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
6 | ],
7 | "name": "addIds",
8 | "outputs": [],
9 | "stateMutability": "payable",
10 | "type": "function"
11 | },
12 | {
13 | "inputs": [],
14 | "name": "connectorID",
15 | "outputs": [
16 | { "internalType": "uint256", "name": "_type", "type": "uint256" },
17 | { "internalType": "uint256", "name": "_id", "type": "uint256" }
18 | ],
19 | "stateMutability": "pure",
20 | "type": "function"
21 | },
22 | {
23 | "inputs": [],
24 | "name": "name",
25 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
26 | "stateMutability": "view",
27 | "type": "function"
28 | },
29 | {
30 | "inputs": [
31 | { "internalType": "uint256", "name": "getIdOne", "type": "uint256" },
32 | { "internalType": "uint256", "name": "getIdTwo", "type": "uint256" },
33 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
34 | ],
35 | "name": "subIds",
36 | "outputs": [],
37 | "stateMutability": "payable",
38 | "type": "function"
39 | }
40 | ]
41 |
--------------------------------------------------------------------------------
/src/abi/connectors/migrate.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [],
4 | "name": "connectorID",
5 | "outputs": [
6 | { "internalType": "uint256", "name": "model", "type": "uint256" },
7 | { "internalType": "uint256", "name": "id", "type": "uint256" }
8 | ],
9 | "stateMutability": "pure",
10 | "type": "function"
11 | },
12 | {
13 | "inputs": [
14 | { "internalType": "address", "name": "wallet", "type": "address" },
15 | { "internalType": "address[]", "name": "tokens", "type": "address[]" },
16 | { "internalType": "uint256", "name": "times", "type": "uint256" }
17 | ],
18 | "name": "migrateCompound",
19 | "outputs": [],
20 | "stateMutability": "payable",
21 | "type": "function"
22 | },
23 | {
24 | "inputs": [
25 | { "internalType": "address", "name": "wallet", "type": "address" },
26 | { "internalType": "address", "name": "token", "type": "address" },
27 | { "internalType": "uint256", "name": "amt", "type": "uint256" },
28 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
29 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
30 | ],
31 | "name": "migratePaybackBehalf",
32 | "outputs": [],
33 | "stateMutability": "payable",
34 | "type": "function"
35 | },
36 | {
37 | "inputs": [],
38 | "name": "name",
39 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
40 | "stateMutability": "view",
41 | "type": "function"
42 | }
43 | ]
44 |
--------------------------------------------------------------------------------
/src/abi/connectors/oasis.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": true,
7 | "internalType": "address",
8 | "name": "buyToken",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": true,
13 | "internalType": "address",
14 | "name": "sellToken",
15 | "type": "address"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256",
20 | "name": "buyAmt",
21 | "type": "uint256"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256",
26 | "name": "sellAmt",
27 | "type": "uint256"
28 | },
29 | {
30 | "indexed": false,
31 | "internalType": "uint256",
32 | "name": "getId",
33 | "type": "uint256"
34 | },
35 | {
36 | "indexed": false,
37 | "internalType": "uint256",
38 | "name": "setId",
39 | "type": "uint256"
40 | }
41 | ],
42 | "name": "LogBuy",
43 | "type": "event"
44 | },
45 | {
46 | "anonymous": false,
47 | "inputs": [
48 | {
49 | "indexed": true,
50 | "internalType": "address",
51 | "name": "buyToken",
52 | "type": "address"
53 | },
54 | {
55 | "indexed": true,
56 | "internalType": "address",
57 | "name": "sellToken",
58 | "type": "address"
59 | },
60 | {
61 | "indexed": false,
62 | "internalType": "uint256",
63 | "name": "buyAmt",
64 | "type": "uint256"
65 | },
66 | {
67 | "indexed": false,
68 | "internalType": "uint256",
69 | "name": "sellAmt",
70 | "type": "uint256"
71 | },
72 | {
73 | "indexed": false,
74 | "internalType": "uint256",
75 | "name": "getId",
76 | "type": "uint256"
77 | },
78 | {
79 | "indexed": false,
80 | "internalType": "uint256",
81 | "name": "setId",
82 | "type": "uint256"
83 | }
84 | ],
85 | "name": "LogSell",
86 | "type": "event"
87 | },
88 | {
89 | "inputs": [
90 | {
91 | "internalType": "address",
92 | "name": "buyAddr",
93 | "type": "address"
94 | },
95 | {
96 | "internalType": "address",
97 | "name": "sellAddr",
98 | "type": "address"
99 | },
100 | {
101 | "internalType": "uint256",
102 | "name": "buyAmt",
103 | "type": "uint256"
104 | },
105 | {
106 | "internalType": "uint256",
107 | "name": "unitAmt",
108 | "type": "uint256"
109 | },
110 | {
111 | "internalType": "uint256",
112 | "name": "getId",
113 | "type": "uint256"
114 | },
115 | {
116 | "internalType": "uint256",
117 | "name": "setId",
118 | "type": "uint256"
119 | }
120 | ],
121 | "name": "buy",
122 | "outputs": [],
123 | "stateMutability": "payable",
124 | "type": "function"
125 | },
126 | {
127 | "inputs": [],
128 | "name": "connectorID",
129 | "outputs": [
130 | {
131 | "internalType": "uint256",
132 | "name": "_type",
133 | "type": "uint256"
134 | },
135 | {
136 | "internalType": "uint256",
137 | "name": "_id",
138 | "type": "uint256"
139 | }
140 | ],
141 | "stateMutability": "pure",
142 | "type": "function"
143 | },
144 | {
145 | "inputs": [],
146 | "name": "name",
147 | "outputs": [
148 | {
149 | "internalType": "string",
150 | "name": "",
151 | "type": "string"
152 | }
153 | ],
154 | "stateMutability": "view",
155 | "type": "function"
156 | },
157 | {
158 | "inputs": [
159 | {
160 | "internalType": "address",
161 | "name": "buyAddr",
162 | "type": "address"
163 | },
164 | {
165 | "internalType": "address",
166 | "name": "sellAddr",
167 | "type": "address"
168 | },
169 | {
170 | "internalType": "uint256",
171 | "name": "sellAmt",
172 | "type": "uint256"
173 | },
174 | {
175 | "internalType": "uint256",
176 | "name": "unitAmt",
177 | "type": "uint256"
178 | },
179 | {
180 | "internalType": "uint256",
181 | "name": "getId",
182 | "type": "uint256"
183 | },
184 | {
185 | "internalType": "uint256",
186 | "name": "setId",
187 | "type": "uint256"
188 | }
189 | ],
190 | "name": "sell",
191 | "outputs": [],
192 | "stateMutability": "payable",
193 | "type": "function"
194 | }
195 | ]
196 |
--------------------------------------------------------------------------------
/src/abi/connectors/refinance.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [],
4 | "name": "connectorID",
5 | "outputs": [
6 | { "internalType": "uint256", "name": "_type", "type": "uint256" },
7 | { "internalType": "uint256", "name": "_id", "type": "uint256" }
8 | ],
9 | "stateMutability": "pure",
10 | "type": "function"
11 | },
12 | {
13 | "inputs": [],
14 | "name": "name",
15 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
16 | "stateMutability": "view",
17 | "type": "function"
18 | },
19 | {
20 | "inputs": [
21 | {
22 | "components": [
23 | {
24 | "internalType": "enum Helpers.Protocol",
25 | "name": "source",
26 | "type": "uint8"
27 | },
28 | {
29 | "internalType": "enum Helpers.Protocol",
30 | "name": "target",
31 | "type": "uint8"
32 | },
33 | {
34 | "internalType": "uint256",
35 | "name": "collateralFee",
36 | "type": "uint256"
37 | },
38 | { "internalType": "uint256", "name": "debtFee", "type": "uint256" },
39 | {
40 | "internalType": "address[]",
41 | "name": "tokens",
42 | "type": "address[]"
43 | },
44 | {
45 | "internalType": "uint256[]",
46 | "name": "borrowAmts",
47 | "type": "uint256[]"
48 | },
49 | {
50 | "internalType": "uint256[]",
51 | "name": "withdrawAmts",
52 | "type": "uint256[]"
53 | },
54 | {
55 | "internalType": "uint256[]",
56 | "name": "borrowRateModes",
57 | "type": "uint256[]"
58 | },
59 | {
60 | "internalType": "uint256[]",
61 | "name": "paybackRateModes",
62 | "type": "uint256[]"
63 | }
64 | ],
65 | "internalType": "struct RefinanceResolver.RefinanceData",
66 | "name": "data",
67 | "type": "tuple"
68 | }
69 | ],
70 | "name": "refinance",
71 | "outputs": [],
72 | "stateMutability": "payable",
73 | "type": "function"
74 | },
75 | {
76 | "inputs": [
77 | {
78 | "components": [
79 | {
80 | "internalType": "uint256",
81 | "name": "fromVaultId",
82 | "type": "uint256"
83 | },
84 | { "internalType": "uint256", "name": "toVaultId", "type": "uint256" },
85 | {
86 | "internalType": "enum Helpers.Protocol",
87 | "name": "source",
88 | "type": "uint8"
89 | },
90 | {
91 | "internalType": "enum Helpers.Protocol",
92 | "name": "target",
93 | "type": "uint8"
94 | },
95 | {
96 | "internalType": "uint256",
97 | "name": "collateralFee",
98 | "type": "uint256"
99 | },
100 | { "internalType": "uint256", "name": "debtFee", "type": "uint256" },
101 | { "internalType": "bool", "name": "isFrom", "type": "bool" },
102 | { "internalType": "string", "name": "colType", "type": "string" },
103 | { "internalType": "address", "name": "token", "type": "address" },
104 | { "internalType": "uint256", "name": "debt", "type": "uint256" },
105 | {
106 | "internalType": "uint256",
107 | "name": "collateral",
108 | "type": "uint256"
109 | },
110 | {
111 | "internalType": "uint256",
112 | "name": "borrowRateMode",
113 | "type": "uint256"
114 | },
115 | {
116 | "internalType": "uint256",
117 | "name": "paybackRateMode",
118 | "type": "uint256"
119 | }
120 | ],
121 | "internalType": "struct RefinanceResolver.RefinanceMakerData",
122 | "name": "data",
123 | "type": "tuple"
124 | }
125 | ],
126 | "name": "refinanceMaker",
127 | "outputs": [],
128 | "stateMutability": "payable",
129 | "type": "function"
130 | }
131 | ]
132 |
--------------------------------------------------------------------------------
/src/abi/connectors/staking.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": false,
7 | "internalType": "address",
8 | "name": "token",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "bytes32",
14 | "name": "stakingType",
15 | "type": "bytes32"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256",
20 | "name": "rewardAmt",
21 | "type": "uint256"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256",
26 | "name": "setId",
27 | "type": "uint256"
28 | }
29 | ],
30 | "name": "LogClaimedReward",
31 | "type": "event"
32 | },
33 | {
34 | "anonymous": false,
35 | "inputs": [
36 | {
37 | "indexed": false,
38 | "internalType": "address",
39 | "name": "token",
40 | "type": "address"
41 | },
42 | {
43 | "indexed": false,
44 | "internalType": "bytes32",
45 | "name": "stakingType",
46 | "type": "bytes32"
47 | },
48 | {
49 | "indexed": false,
50 | "internalType": "uint256",
51 | "name": "amount",
52 | "type": "uint256"
53 | },
54 | {
55 | "indexed": false,
56 | "internalType": "uint256",
57 | "name": "getId",
58 | "type": "uint256"
59 | },
60 | {
61 | "indexed": false,
62 | "internalType": "uint256",
63 | "name": "setId",
64 | "type": "uint256"
65 | }
66 | ],
67 | "name": "LogDeposit",
68 | "type": "event"
69 | },
70 | {
71 | "anonymous": false,
72 | "inputs": [
73 | {
74 | "indexed": false,
75 | "internalType": "address",
76 | "name": "token",
77 | "type": "address"
78 | },
79 | {
80 | "indexed": false,
81 | "internalType": "bytes32",
82 | "name": "stakingType",
83 | "type": "bytes32"
84 | },
85 | {
86 | "indexed": false,
87 | "internalType": "uint256",
88 | "name": "amount",
89 | "type": "uint256"
90 | },
91 | {
92 | "indexed": false,
93 | "internalType": "uint256",
94 | "name": "getId",
95 | "type": "uint256"
96 | },
97 | {
98 | "indexed": false,
99 | "internalType": "uint256",
100 | "name": "setId",
101 | "type": "uint256"
102 | }
103 | ],
104 | "name": "LogWithdraw",
105 | "type": "event"
106 | },
107 | {
108 | "inputs": [
109 | {
110 | "internalType": "string",
111 | "name": "stakingPoolName",
112 | "type": "string"
113 | },
114 | {
115 | "internalType": "uint256",
116 | "name": "setId",
117 | "type": "uint256"
118 | }
119 | ],
120 | "name": "claimReward",
121 | "outputs": [],
122 | "stateMutability": "payable",
123 | "type": "function"
124 | },
125 | {
126 | "inputs": [],
127 | "name": "connectorID",
128 | "outputs": [
129 | {
130 | "internalType": "uint256",
131 | "name": "model",
132 | "type": "uint256"
133 | },
134 | {
135 | "internalType": "uint256",
136 | "name": "id",
137 | "type": "uint256"
138 | }
139 | ],
140 | "stateMutability": "view",
141 | "type": "function"
142 | },
143 | {
144 | "inputs": [
145 | {
146 | "internalType": "string",
147 | "name": "stakingPoolName",
148 | "type": "string"
149 | },
150 | {
151 | "internalType": "uint256",
152 | "name": "amt",
153 | "type": "uint256"
154 | },
155 | {
156 | "internalType": "uint256",
157 | "name": "getId",
158 | "type": "uint256"
159 | },
160 | {
161 | "internalType": "uint256",
162 | "name": "setId",
163 | "type": "uint256"
164 | }
165 | ],
166 | "name": "deposit",
167 | "outputs": [],
168 | "stateMutability": "payable",
169 | "type": "function"
170 | },
171 | {
172 | "inputs": [],
173 | "name": "name",
174 | "outputs": [
175 | {
176 | "internalType": "string",
177 | "name": "",
178 | "type": "string"
179 | }
180 | ],
181 | "stateMutability": "view",
182 | "type": "function"
183 | },
184 | {
185 | "inputs": [
186 | {
187 | "internalType": "string",
188 | "name": "stakingPoolName",
189 | "type": "string"
190 | },
191 | {
192 | "internalType": "uint256",
193 | "name": "amt",
194 | "type": "uint256"
195 | },
196 | {
197 | "internalType": "uint256",
198 | "name": "getId",
199 | "type": "uint256"
200 | },
201 | {
202 | "internalType": "uint256",
203 | "name": "setIdAmount",
204 | "type": "uint256"
205 | },
206 | {
207 | "internalType": "uint256",
208 | "name": "setIdReward",
209 | "type": "uint256"
210 | }
211 | ],
212 | "name": "withdraw",
213 | "outputs": [],
214 | "stateMutability": "payable",
215 | "type": "function"
216 | }
217 | ]
218 |
--------------------------------------------------------------------------------
/src/abi/connectors/swerve.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": false,
7 | "internalType": "address",
8 | "name": "token",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": false,
13 | "internalType": "uint256",
14 | "name": "amt",
15 | "type": "uint256"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256",
20 | "name": "mintAmt",
21 | "type": "uint256"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "uint256",
26 | "name": "getId",
27 | "type": "uint256"
28 | },
29 | {
30 | "indexed": false,
31 | "internalType": "uint256",
32 | "name": "setId",
33 | "type": "uint256"
34 | }
35 | ],
36 | "name": "LogDeposit",
37 | "type": "event"
38 | },
39 | {
40 | "anonymous": false,
41 | "inputs": [
42 | {
43 | "indexed": true,
44 | "internalType": "address",
45 | "name": "buyToken",
46 | "type": "address"
47 | },
48 | {
49 | "indexed": true,
50 | "internalType": "address",
51 | "name": "sellToken",
52 | "type": "address"
53 | },
54 | {
55 | "indexed": false,
56 | "internalType": "uint256",
57 | "name": "buyAmt",
58 | "type": "uint256"
59 | },
60 | {
61 | "indexed": false,
62 | "internalType": "uint256",
63 | "name": "sellAmt",
64 | "type": "uint256"
65 | },
66 | {
67 | "indexed": false,
68 | "internalType": "uint256",
69 | "name": "getId",
70 | "type": "uint256"
71 | },
72 | {
73 | "indexed": false,
74 | "internalType": "uint256",
75 | "name": "setId",
76 | "type": "uint256"
77 | }
78 | ],
79 | "name": "LogSell",
80 | "type": "event"
81 | },
82 | {
83 | "anonymous": false,
84 | "inputs": [
85 | {
86 | "indexed": false,
87 | "internalType": "address",
88 | "name": "token",
89 | "type": "address"
90 | },
91 | {
92 | "indexed": false,
93 | "internalType": "uint256",
94 | "name": "amt",
95 | "type": "uint256"
96 | },
97 | {
98 | "indexed": false,
99 | "internalType": "uint256",
100 | "name": "burnAmt",
101 | "type": "uint256"
102 | },
103 | {
104 | "indexed": false,
105 | "internalType": "uint256",
106 | "name": "getId",
107 | "type": "uint256"
108 | },
109 | {
110 | "indexed": false,
111 | "internalType": "uint256",
112 | "name": "setId",
113 | "type": "uint256"
114 | }
115 | ],
116 | "name": "LogWithdraw",
117 | "type": "event"
118 | },
119 | {
120 | "inputs": [],
121 | "name": "connectorID",
122 | "outputs": [
123 | { "internalType": "uint256", "name": "model", "type": "uint256" },
124 | { "internalType": "uint256", "name": "id", "type": "uint256" }
125 | ],
126 | "stateMutability": "view",
127 | "type": "function"
128 | },
129 | {
130 | "inputs": [
131 | { "internalType": "address", "name": "token", "type": "address" },
132 | { "internalType": "uint256", "name": "amt", "type": "uint256" },
133 | { "internalType": "uint256", "name": "unitAmt", "type": "uint256" },
134 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
135 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
136 | ],
137 | "name": "deposit",
138 | "outputs": [],
139 | "stateMutability": "payable",
140 | "type": "function"
141 | },
142 | {
143 | "inputs": [],
144 | "name": "name",
145 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
146 | "stateMutability": "view",
147 | "type": "function"
148 | },
149 | {
150 | "inputs": [
151 | { "internalType": "address", "name": "buyAddr", "type": "address" },
152 | { "internalType": "address", "name": "sellAddr", "type": "address" },
153 | { "internalType": "uint256", "name": "sellAmt", "type": "uint256" },
154 | { "internalType": "uint256", "name": "unitAmt", "type": "uint256" },
155 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
156 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
157 | ],
158 | "name": "sell",
159 | "outputs": [],
160 | "stateMutability": "payable",
161 | "type": "function"
162 | },
163 | {
164 | "inputs": [
165 | { "internalType": "address", "name": "token", "type": "address" },
166 | { "internalType": "uint256", "name": "amt", "type": "uint256" },
167 | { "internalType": "uint256", "name": "unitAmt", "type": "uint256" },
168 | { "internalType": "uint256", "name": "getId", "type": "uint256" },
169 | { "internalType": "uint256", "name": "setId", "type": "uint256" }
170 | ],
171 | "name": "withdraw",
172 | "outputs": [],
173 | "stateMutability": "payable",
174 | "type": "function"
175 | }
176 | ]
177 |
--------------------------------------------------------------------------------
/src/abi/core/account.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": true,
7 | "internalType": "address",
8 | "name": "origin",
9 | "type": "address"
10 | },
11 | {
12 | "indexed": true,
13 | "internalType": "address",
14 | "name": "sender",
15 | "type": "address"
16 | },
17 | {
18 | "indexed": false,
19 | "internalType": "uint256",
20 | "name": "value",
21 | "type": "uint256"
22 | }
23 | ],
24 | "name": "LogCast",
25 | "type": "event"
26 | },
27 | {
28 | "anonymous": false,
29 | "inputs": [
30 | {
31 | "indexed": true,
32 | "internalType": "address",
33 | "name": "user",
34 | "type": "address"
35 | }
36 | ],
37 | "name": "LogDisable",
38 | "type": "event"
39 | },
40 | {
41 | "anonymous": false,
42 | "inputs": [
43 | {
44 | "indexed": true,
45 | "internalType": "address",
46 | "name": "user",
47 | "type": "address"
48 | }
49 | ],
50 | "name": "LogEnable",
51 | "type": "event"
52 | },
53 | {
54 | "anonymous": false,
55 | "inputs": [
56 | {
57 | "indexed": false,
58 | "internalType": "bool",
59 | "name": "_shield",
60 | "type": "bool"
61 | }
62 | ],
63 | "name": "LogSwitchShield",
64 | "type": "event"
65 | },
66 | {
67 | "inputs": [
68 | { "internalType": "address[]", "name": "_targets", "type": "address[]" },
69 | { "internalType": "bytes[]", "name": "_datas", "type": "bytes[]" },
70 | { "internalType": "address", "name": "_origin", "type": "address" }
71 | ],
72 | "name": "cast",
73 | "outputs": [],
74 | "stateMutability": "payable",
75 | "type": "function"
76 | },
77 | {
78 | "inputs": [
79 | { "internalType": "address", "name": "user", "type": "address" }
80 | ],
81 | "name": "disable",
82 | "outputs": [],
83 | "stateMutability": "nonpayable",
84 | "type": "function"
85 | },
86 | {
87 | "inputs": [
88 | { "internalType": "address", "name": "user", "type": "address" }
89 | ],
90 | "name": "enable",
91 | "outputs": [],
92 | "stateMutability": "nonpayable",
93 | "type": "function"
94 | },
95 | {
96 | "inputs": [],
97 | "name": "instaIndex",
98 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
99 | "stateMutability": "view",
100 | "type": "function"
101 | },
102 | {
103 | "inputs": [
104 | { "internalType": "address", "name": "user", "type": "address" }
105 | ],
106 | "name": "isAuth",
107 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
108 | "stateMutability": "view",
109 | "type": "function"
110 | },
111 | {
112 | "inputs": [],
113 | "name": "shield",
114 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
115 | "stateMutability": "view",
116 | "type": "function"
117 | },
118 | {
119 | "inputs": [{ "internalType": "bool", "name": "_shield", "type": "bool" }],
120 | "name": "switchShield",
121 | "outputs": [],
122 | "stateMutability": "nonpayable",
123 | "type": "function"
124 | },
125 | {
126 | "inputs": [],
127 | "name": "version",
128 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
129 | "stateMutability": "view",
130 | "type": "function"
131 | },
132 | { "stateMutability": "payable", "type": "receive" }
133 | ]
134 |
--------------------------------------------------------------------------------
/src/abi/core/events.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "anonymous": false,
4 | "inputs": [
5 | {
6 | "indexed": false,
7 | "internalType": "uint64",
8 | "name": "connectorType",
9 | "type": "uint64"
10 | },
11 | {
12 | "indexed": true,
13 | "internalType": "uint64",
14 | "name": "connectorID",
15 | "type": "uint64"
16 | },
17 | {
18 | "indexed": true,
19 | "internalType": "uint64",
20 | "name": "accountID",
21 | "type": "uint64"
22 | },
23 | {
24 | "indexed": true,
25 | "internalType": "bytes32",
26 | "name": "eventCode",
27 | "type": "bytes32"
28 | },
29 | {
30 | "indexed": false,
31 | "internalType": "bytes",
32 | "name": "eventData",
33 | "type": "bytes"
34 | }
35 | ],
36 | "name": "LogEvent",
37 | "type": "event"
38 | },
39 | {
40 | "inputs": [
41 | {
42 | "internalType": "uint256",
43 | "name": "_connectorType",
44 | "type": "uint256"
45 | },
46 | {
47 | "internalType": "uint256",
48 | "name": "_connectorID",
49 | "type": "uint256"
50 | },
51 | {
52 | "internalType": "bytes32",
53 | "name": "_eventCode",
54 | "type": "bytes32"
55 | },
56 | {
57 | "internalType": "bytes",
58 | "name": "_eventData",
59 | "type": "bytes"
60 | }
61 | ],
62 | "name": "emitEvent",
63 | "outputs": [],
64 | "stateMutability": "nonpayable",
65 | "type": "function"
66 | },
67 | {
68 | "inputs": [],
69 | "name": "instaList",
70 | "outputs": [
71 | {
72 | "internalType": "address",
73 | "name": "",
74 | "type": "address"
75 | }
76 | ],
77 | "stateMutability": "view",
78 | "type": "function"
79 | }
80 | ]
81 |
--------------------------------------------------------------------------------
/src/abi/core/list.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }],
4 | "name": "accountAddr",
5 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
6 | "stateMutability": "view",
7 | "type": "function"
8 | },
9 | {
10 | "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
11 | "name": "accountID",
12 | "outputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }],
13 | "stateMutability": "view",
14 | "type": "function"
15 | },
16 | {
17 | "inputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }],
18 | "name": "accountLink",
19 | "outputs": [
20 | { "internalType": "address", "name": "first", "type": "address" },
21 | { "internalType": "address", "name": "last", "type": "address" },
22 | { "internalType": "uint64", "name": "count", "type": "uint64" }
23 | ],
24 | "stateMutability": "view",
25 | "type": "function"
26 | },
27 | {
28 | "inputs": [
29 | { "internalType": "uint64", "name": "", "type": "uint64" },
30 | { "internalType": "address", "name": "", "type": "address" }
31 | ],
32 | "name": "accountList",
33 | "outputs": [
34 | { "internalType": "address", "name": "prev", "type": "address" },
35 | { "internalType": "address", "name": "next", "type": "address" }
36 | ],
37 | "stateMutability": "view",
38 | "type": "function"
39 | },
40 | {
41 | "inputs": [],
42 | "name": "accounts",
43 | "outputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }],
44 | "stateMutability": "view",
45 | "type": "function"
46 | },
47 | {
48 | "inputs": [
49 | { "internalType": "address", "name": "_owner", "type": "address" }
50 | ],
51 | "name": "addAuth",
52 | "outputs": [],
53 | "stateMutability": "nonpayable",
54 | "type": "function"
55 | },
56 | {
57 | "inputs": [
58 | { "internalType": "address", "name": "_account", "type": "address" }
59 | ],
60 | "name": "init",
61 | "outputs": [],
62 | "stateMutability": "nonpayable",
63 | "type": "function"
64 | },
65 | {
66 | "inputs": [],
67 | "name": "instaIndex",
68 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
69 | "stateMutability": "view",
70 | "type": "function"
71 | },
72 | {
73 | "inputs": [
74 | { "internalType": "address", "name": "_owner", "type": "address" }
75 | ],
76 | "name": "removeAuth",
77 | "outputs": [],
78 | "stateMutability": "nonpayable",
79 | "type": "function"
80 | },
81 | {
82 | "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
83 | "name": "userLink",
84 | "outputs": [
85 | { "internalType": "uint64", "name": "first", "type": "uint64" },
86 | { "internalType": "uint64", "name": "last", "type": "uint64" },
87 | { "internalType": "uint64", "name": "count", "type": "uint64" }
88 | ],
89 | "stateMutability": "view",
90 | "type": "function"
91 | },
92 | {
93 | "inputs": [
94 | { "internalType": "address", "name": "", "type": "address" },
95 | { "internalType": "uint64", "name": "", "type": "uint64" }
96 | ],
97 | "name": "userList",
98 | "outputs": [
99 | { "internalType": "uint64", "name": "prev", "type": "uint64" },
100 | { "internalType": "uint64", "name": "next", "type": "uint64" }
101 | ],
102 | "stateMutability": "view",
103 | "type": "function"
104 | }
105 | ]
106 |
--------------------------------------------------------------------------------
/src/abi/read/aave.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | { "internalType": "address", "name": "user", "type": "address" },
5 | { "internalType": "address[]", "name": "tokens", "type": "address[]" }
6 | ],
7 | "name": "getPosition",
8 | "outputs": [
9 | {
10 | "components": [
11 | {
12 | "internalType": "uint256",
13 | "name": "tokenPrice",
14 | "type": "uint256"
15 | },
16 | {
17 | "internalType": "uint256",
18 | "name": "supplyBalance",
19 | "type": "uint256"
20 | },
21 | {
22 | "internalType": "uint256",
23 | "name": "borrowBalance",
24 | "type": "uint256"
25 | },
26 | { "internalType": "uint256", "name": "borrowFee", "type": "uint256" },
27 | {
28 | "internalType": "uint256",
29 | "name": "supplyRate",
30 | "type": "uint256"
31 | },
32 | {
33 | "internalType": "uint256",
34 | "name": "borrowRate",
35 | "type": "uint256"
36 | },
37 | {
38 | "internalType": "uint256",
39 | "name": "borrowModal",
40 | "type": "uint256"
41 | },
42 | {
43 | "components": [
44 | { "internalType": "uint256", "name": "ltv", "type": "uint256" },
45 | {
46 | "internalType": "uint256",
47 | "name": "threshold",
48 | "type": "uint256"
49 | },
50 | {
51 | "internalType": "bool",
52 | "name": "usageAsCollEnabled",
53 | "type": "bool"
54 | },
55 | {
56 | "internalType": "bool",
57 | "name": "borrowEnabled",
58 | "type": "bool"
59 | },
60 | {
61 | "internalType": "bool",
62 | "name": "stableBorrowEnabled",
63 | "type": "bool"
64 | },
65 | { "internalType": "bool", "name": "isActive", "type": "bool" }
66 | ],
67 | "internalType": "struct AaveHelpers.AaveTokenData",
68 | "name": "aaveTokenData",
69 | "type": "tuple"
70 | }
71 | ],
72 | "internalType": "struct AaveHelpers.AaveUserTokenData[]",
73 | "name": "",
74 | "type": "tuple[]"
75 | },
76 | {
77 | "components": [
78 | {
79 | "internalType": "uint256",
80 | "name": "totalSupplyETH",
81 | "type": "uint256"
82 | },
83 | {
84 | "internalType": "uint256",
85 | "name": "totalCollateralETH",
86 | "type": "uint256"
87 | },
88 | {
89 | "internalType": "uint256",
90 | "name": "totalBorrowsETH",
91 | "type": "uint256"
92 | },
93 | {
94 | "internalType": "uint256",
95 | "name": "totalFeesETH",
96 | "type": "uint256"
97 | },
98 | {
99 | "internalType": "uint256",
100 | "name": "availableBorrowsETH",
101 | "type": "uint256"
102 | },
103 | {
104 | "internalType": "uint256",
105 | "name": "currentLiquidationThreshold",
106 | "type": "uint256"
107 | },
108 | { "internalType": "uint256", "name": "ltv", "type": "uint256" },
109 | {
110 | "internalType": "uint256",
111 | "name": "healthFactor",
112 | "type": "uint256"
113 | }
114 | ],
115 | "internalType": "struct AaveHelpers.AaveUserData",
116 | "name": "",
117 | "type": "tuple"
118 | }
119 | ],
120 | "stateMutability": "view",
121 | "type": "function"
122 | },
123 | {
124 | "inputs": [],
125 | "name": "name",
126 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
127 | "stateMutability": "view",
128 | "type": "function"
129 | }
130 | ]
131 |
--------------------------------------------------------------------------------
/src/abi/read/chainlink.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | { "internalType": "string[]", "name": "tokens", "type": "string[]" },
5 | {
6 | "internalType": "address[]",
7 | "name": "chainlinkFeeds",
8 | "type": "address[]"
9 | }
10 | ],
11 | "stateMutability": "nonpayable",
12 | "type": "constructor"
13 | },
14 | {
15 | "anonymous": false,
16 | "inputs": [
17 | {
18 | "indexed": false,
19 | "internalType": "string",
20 | "name": "tokenSymbol",
21 | "type": "string"
22 | },
23 | {
24 | "indexed": false,
25 | "internalType": "address",
26 | "name": "chainlinkFeed",
27 | "type": "address"
28 | }
29 | ],
30 | "name": "LogAddChainLinkMapping",
31 | "type": "event"
32 | },
33 | {
34 | "anonymous": false,
35 | "inputs": [
36 | {
37 | "indexed": false,
38 | "internalType": "string",
39 | "name": "tokenSymbol",
40 | "type": "string"
41 | },
42 | {
43 | "indexed": false,
44 | "internalType": "address",
45 | "name": "chainlinkFeed",
46 | "type": "address"
47 | }
48 | ],
49 | "name": "LogRemoveChainLinkMapping",
50 | "type": "event"
51 | },
52 | {
53 | "inputs": [
54 | { "internalType": "string[]", "name": "tokens", "type": "string[]" },
55 | {
56 | "internalType": "address[]",
57 | "name": "chainlinkFeeds",
58 | "type": "address[]"
59 | }
60 | ],
61 | "name": "addChainLinkMapping",
62 | "outputs": [],
63 | "stateMutability": "nonpayable",
64 | "type": "function"
65 | },
66 | {
67 | "inputs": [{ "internalType": "string", "name": "", "type": "string" }],
68 | "name": "chainLinkMapping",
69 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
70 | "stateMutability": "view",
71 | "type": "function"
72 | },
73 | {
74 | "inputs": [],
75 | "name": "connectors",
76 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
77 | "stateMutability": "view",
78 | "type": "function"
79 | },
80 | {
81 | "inputs": [],
82 | "name": "getGasPrice",
83 | "outputs": [
84 | { "internalType": "uint256", "name": "gasPrice", "type": "uint256" }
85 | ],
86 | "stateMutability": "view",
87 | "type": "function"
88 | },
89 | {
90 | "inputs": [
91 | { "internalType": "string[]", "name": "tokens", "type": "string[]" }
92 | ],
93 | "name": "getPrice",
94 | "outputs": [
95 | {
96 | "components": [
97 | { "internalType": "uint256", "name": "price", "type": "uint256" },
98 | { "internalType": "uint256", "name": "decimals", "type": "uint256" }
99 | ],
100 | "internalType": "struct Resolver.PriceData",
101 | "name": "ethPriceInUsd",
102 | "type": "tuple"
103 | },
104 | {
105 | "components": [
106 | { "internalType": "uint256", "name": "price", "type": "uint256" },
107 | { "internalType": "uint256", "name": "decimals", "type": "uint256" }
108 | ],
109 | "internalType": "struct Resolver.PriceData",
110 | "name": "btcPriceInUsd",
111 | "type": "tuple"
112 | },
113 | {
114 | "components": [
115 | { "internalType": "uint256", "name": "price", "type": "uint256" },
116 | { "internalType": "uint256", "name": "decimals", "type": "uint256" }
117 | ],
118 | "internalType": "struct Resolver.PriceData[]",
119 | "name": "tokensPriceInETH",
120 | "type": "tuple[]"
121 | }
122 | ],
123 | "stateMutability": "view",
124 | "type": "function"
125 | },
126 | {
127 | "inputs": [],
128 | "name": "instaIndex",
129 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
130 | "stateMutability": "view",
131 | "type": "function"
132 | },
133 | {
134 | "inputs": [],
135 | "name": "name",
136 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
137 | "stateMutability": "view",
138 | "type": "function"
139 | },
140 | {
141 | "inputs": [
142 | { "internalType": "string[]", "name": "tokens", "type": "string[]" }
143 | ],
144 | "name": "removeChainLinkMapping",
145 | "outputs": [],
146 | "stateMutability": "nonpayable",
147 | "type": "function"
148 | },
149 | {
150 | "inputs": [],
151 | "name": "version",
152 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
153 | "stateMutability": "view",
154 | "type": "function"
155 | }
156 | ]
157 |
--------------------------------------------------------------------------------
/src/abi/read/compound.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [],
4 | "name": "getCETHAddress",
5 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
6 | "stateMutability": "pure",
7 | "type": "function"
8 | },
9 | {
10 | "inputs": [],
11 | "name": "getCompReadAddress",
12 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
13 | "stateMutability": "pure",
14 | "type": "function"
15 | },
16 | {
17 | "inputs": [],
18 | "name": "getCompToken",
19 | "outputs": [
20 | {
21 | "internalType": "contract TokenInterface",
22 | "name": "",
23 | "type": "address"
24 | }
25 | ],
26 | "stateMutability": "pure",
27 | "type": "function"
28 | },
29 | {
30 | "inputs": [
31 | { "internalType": "address", "name": "owner", "type": "address" },
32 | { "internalType": "address[]", "name": "cAddress", "type": "address[]" }
33 | ],
34 | "name": "getCompoundData",
35 | "outputs": [
36 | {
37 | "components": [
38 | {
39 | "internalType": "uint256",
40 | "name": "tokenPriceInEth",
41 | "type": "uint256"
42 | },
43 | {
44 | "internalType": "uint256",
45 | "name": "tokenPriceInUsd",
46 | "type": "uint256"
47 | },
48 | {
49 | "internalType": "uint256",
50 | "name": "exchangeRateStored",
51 | "type": "uint256"
52 | },
53 | {
54 | "internalType": "uint256",
55 | "name": "balanceOfUser",
56 | "type": "uint256"
57 | },
58 | {
59 | "internalType": "uint256",
60 | "name": "borrowBalanceStoredUser",
61 | "type": "uint256"
62 | },
63 | {
64 | "internalType": "uint256",
65 | "name": "supplyRatePerBlock",
66 | "type": "uint256"
67 | },
68 | {
69 | "internalType": "uint256",
70 | "name": "borrowRatePerBlock",
71 | "type": "uint256"
72 | }
73 | ],
74 | "internalType": "struct Helpers.CompData[]",
75 | "name": "",
76 | "type": "tuple[]"
77 | }
78 | ],
79 | "stateMutability": "view",
80 | "type": "function"
81 | },
82 | {
83 | "inputs": [],
84 | "name": "getComptroller",
85 | "outputs": [
86 | {
87 | "internalType": "contract ComptrollerLensInterface",
88 | "name": "",
89 | "type": "address"
90 | }
91 | ],
92 | "stateMutability": "pure",
93 | "type": "function"
94 | },
95 | {
96 | "inputs": [],
97 | "name": "getOracleAddress",
98 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
99 | "stateMutability": "pure",
100 | "type": "function"
101 | },
102 | {
103 | "inputs": [
104 | { "internalType": "address", "name": "owner", "type": "address" },
105 | { "internalType": "address[]", "name": "cAddress", "type": "address[]" }
106 | ],
107 | "name": "getPosition",
108 | "outputs": [
109 | {
110 | "components": [
111 | {
112 | "internalType": "uint256",
113 | "name": "tokenPriceInEth",
114 | "type": "uint256"
115 | },
116 | {
117 | "internalType": "uint256",
118 | "name": "tokenPriceInUsd",
119 | "type": "uint256"
120 | },
121 | {
122 | "internalType": "uint256",
123 | "name": "exchangeRateStored",
124 | "type": "uint256"
125 | },
126 | {
127 | "internalType": "uint256",
128 | "name": "balanceOfUser",
129 | "type": "uint256"
130 | },
131 | {
132 | "internalType": "uint256",
133 | "name": "borrowBalanceStoredUser",
134 | "type": "uint256"
135 | },
136 | {
137 | "internalType": "uint256",
138 | "name": "supplyRatePerBlock",
139 | "type": "uint256"
140 | },
141 | {
142 | "internalType": "uint256",
143 | "name": "borrowRatePerBlock",
144 | "type": "uint256"
145 | }
146 | ],
147 | "internalType": "struct Helpers.CompData[]",
148 | "name": "",
149 | "type": "tuple[]"
150 | },
151 | {
152 | "components": [
153 | { "internalType": "uint256", "name": "balance", "type": "uint256" },
154 | { "internalType": "uint256", "name": "votes", "type": "uint256" },
155 | { "internalType": "address", "name": "delegate", "type": "address" },
156 | { "internalType": "uint256", "name": "allocated", "type": "uint256" }
157 | ],
158 | "internalType": "struct CompReadInterface.CompBalanceMetadataExt",
159 | "name": "",
160 | "type": "tuple"
161 | }
162 | ],
163 | "stateMutability": "nonpayable",
164 | "type": "function"
165 | },
166 | {
167 | "inputs": [
168 | { "internalType": "address", "name": "cToken", "type": "address" },
169 | { "internalType": "address", "name": "token", "type": "address" }
170 | ],
171 | "name": "getPriceInEth",
172 | "outputs": [
173 | { "internalType": "uint256", "name": "priceInETH", "type": "uint256" },
174 | { "internalType": "uint256", "name": "priceInUSD", "type": "uint256" }
175 | ],
176 | "stateMutability": "view",
177 | "type": "function"
178 | },
179 | {
180 | "inputs": [],
181 | "name": "name",
182 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
183 | "stateMutability": "view",
184 | "type": "function"
185 | }
186 | ]
187 |
--------------------------------------------------------------------------------
/src/abi/read/curveClaim.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | { "internalType": "address", "name": "user", "type": "address" }
5 | ],
6 | "name": "getPosition",
7 | "outputs": [
8 | { "internalType": "uint256", "name": "vestedBalance", "type": "uint256" },
9 | { "internalType": "uint256", "name": "unclaimedBal", "type": "uint256" },
10 | { "internalType": "uint256", "name": "claimedBal", "type": "uint256" },
11 | { "internalType": "uint256", "name": "lockedBalance", "type": "uint256" },
12 | { "internalType": "uint256", "name": "crvBalance", "type": "uint256" }
13 | ],
14 | "stateMutability": "view",
15 | "type": "function"
16 | },
17 | {
18 | "inputs": [],
19 | "name": "name",
20 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
21 | "stateMutability": "view",
22 | "type": "function"
23 | }
24 | ]
25 |
--------------------------------------------------------------------------------
/src/abi/read/curveGauge.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | { "internalType": "string", "name": "gaugeName", "type": "string" },
5 | { "internalType": "address", "name": "user", "type": "address" }
6 | ],
7 | "name": "getPosition",
8 | "outputs": [
9 | {
10 | "components": [
11 | { "internalType": "uint256", "name": "stakedBal", "type": "uint256" },
12 | { "internalType": "uint256", "name": "crvEarned", "type": "uint256" },
13 | {
14 | "internalType": "uint256",
15 | "name": "crvClaimed",
16 | "type": "uint256"
17 | },
18 | {
19 | "internalType": "uint256",
20 | "name": "rewardsEarned",
21 | "type": "uint256"
22 | },
23 | {
24 | "internalType": "uint256",
25 | "name": "rewardsClaimed",
26 | "type": "uint256"
27 | },
28 | { "internalType": "uint256", "name": "crvBal", "type": "uint256" },
29 | { "internalType": "uint256", "name": "rewardBal", "type": "uint256" },
30 | { "internalType": "bool", "name": "hasReward", "type": "bool" }
31 | ],
32 | "internalType": "struct Resolver.PositionData",
33 | "name": "positionData",
34 | "type": "tuple"
35 | }
36 | ],
37 | "stateMutability": "view",
38 | "type": "function"
39 | },
40 | {
41 | "inputs": [
42 | { "internalType": "string[]", "name": "gaugesName", "type": "string[]" },
43 | { "internalType": "address", "name": "user", "type": "address" }
44 | ],
45 | "name": "getPositions",
46 | "outputs": [
47 | {
48 | "components": [
49 | { "internalType": "uint256", "name": "stakedBal", "type": "uint256" },
50 | { "internalType": "uint256", "name": "crvEarned", "type": "uint256" },
51 | {
52 | "internalType": "uint256",
53 | "name": "crvClaimed",
54 | "type": "uint256"
55 | },
56 | {
57 | "internalType": "uint256",
58 | "name": "rewardsEarned",
59 | "type": "uint256"
60 | },
61 | {
62 | "internalType": "uint256",
63 | "name": "rewardsClaimed",
64 | "type": "uint256"
65 | },
66 | { "internalType": "uint256", "name": "crvBal", "type": "uint256" },
67 | { "internalType": "uint256", "name": "rewardBal", "type": "uint256" },
68 | { "internalType": "bool", "name": "hasReward", "type": "bool" }
69 | ],
70 | "internalType": "struct Resolver.PositionData[]",
71 | "name": "positions",
72 | "type": "tuple[]"
73 | }
74 | ],
75 | "stateMutability": "view",
76 | "type": "function"
77 | },
78 | {
79 | "inputs": [],
80 | "name": "name",
81 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
82 | "stateMutability": "view",
83 | "type": "function"
84 | }
85 | ]
86 |
--------------------------------------------------------------------------------
/src/abi/read/curve_3pool.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | { "internalType": "address", "name": "buyAddr", "type": "address" },
5 | { "internalType": "address", "name": "sellAddr", "type": "address" },
6 | { "internalType": "uint256", "name": "sellAmt", "type": "uint256" },
7 | { "internalType": "uint256", "name": "slippage", "type": "uint256" }
8 | ],
9 | "name": "getBuyAmount",
10 | "outputs": [
11 | { "internalType": "uint256", "name": "buyAmt", "type": "uint256" },
12 | { "internalType": "uint256", "name": "unitAmt", "type": "uint256" },
13 | { "internalType": "uint256", "name": "virtualPrice", "type": "uint256" }
14 | ],
15 | "stateMutability": "view",
16 | "type": "function"
17 | },
18 | {
19 | "inputs": [],
20 | "name": "name",
21 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
22 | "stateMutability": "view",
23 | "type": "function"
24 | }
25 | ]
26 |
--------------------------------------------------------------------------------
/src/abi/read/dydx.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | {
5 | "internalType": "address",
6 | "name": "user",
7 | "type": "address"
8 | },
9 | {
10 | "internalType": "uint256[]",
11 | "name": "marketId",
12 | "type": "uint256[]"
13 | }
14 | ],
15 | "name": "getPosition",
16 | "outputs": [
17 | {
18 | "components": [
19 | {
20 | "internalType": "uint256",
21 | "name": "tokenPrice",
22 | "type": "uint256"
23 | },
24 | {
25 | "internalType": "uint256",
26 | "name": "supplyBalance",
27 | "type": "uint256"
28 | },
29 | {
30 | "internalType": "uint256",
31 | "name": "borrowBalance",
32 | "type": "uint256"
33 | },
34 | {
35 | "internalType": "uint256",
36 | "name": "tokenUtil",
37 | "type": "uint256"
38 | }
39 | ],
40 | "internalType": "struct Helpers.DydxData[]",
41 | "name": "",
42 | "type": "tuple[]"
43 | }
44 | ],
45 | "stateMutability": "view",
46 | "type": "function"
47 | },
48 | {
49 | "inputs": [],
50 | "name": "name",
51 | "outputs": [
52 | {
53 | "internalType": "string",
54 | "name": "",
55 | "type": "string"
56 | }
57 | ],
58 | "stateMutability": "view",
59 | "type": "function"
60 | }
61 | ]
62 |
--------------------------------------------------------------------------------
/src/abi/read/erc20.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | {
5 | "internalType": "address",
6 | "name": "owner",
7 | "type": "address"
8 | },
9 | {
10 | "internalType": "address",
11 | "name": "spender",
12 | "type": "address"
13 | },
14 | {
15 | "internalType": "address[]",
16 | "name": "tknAddress",
17 | "type": "address[]"
18 | }
19 | ],
20 | "name": "getAllowances",
21 | "outputs": [
22 | {
23 | "internalType": "uint256[]",
24 | "name": "",
25 | "type": "uint256[]"
26 | }
27 | ],
28 | "stateMutability": "view",
29 | "type": "function"
30 | },
31 | {
32 | "inputs": [
33 | {
34 | "internalType": "address",
35 | "name": "owner",
36 | "type": "address"
37 | },
38 | {
39 | "internalType": "address[]",
40 | "name": "tknAddress",
41 | "type": "address[]"
42 | }
43 | ],
44 | "name": "getBalances",
45 | "outputs": [
46 | {
47 | "internalType": "uint256[]",
48 | "name": "",
49 | "type": "uint256[]"
50 | }
51 | ],
52 | "stateMutability": "view",
53 | "type": "function"
54 | },
55 | {
56 | "inputs": [],
57 | "name": "name",
58 | "outputs": [
59 | {
60 | "internalType": "string",
61 | "name": "",
62 | "type": "string"
63 | }
64 | ],
65 | "stateMutability": "view",
66 | "type": "function"
67 | }
68 | ]
69 |
--------------------------------------------------------------------------------
/src/abi/read/instapool_v2.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | { "internalType": "address", "name": "token", "type": "address" },
5 | { "internalType": "uint256", "name": "ethAmount", "type": "uint256" }
6 | ],
7 | "name": "getAaveData",
8 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
9 | "stateMutability": "view",
10 | "type": "function"
11 | },
12 | {
13 | "inputs": [
14 | {
15 | "internalType": "contract AaveProviderInterface",
16 | "name": "AaveProvider",
17 | "type": "address"
18 | },
19 | { "internalType": "address", "name": "token", "type": "address" }
20 | ],
21 | "name": "getAavePrices",
22 | "outputs": [
23 | { "internalType": "uint256", "name": "tokenPrice", "type": "uint256" },
24 | { "internalType": "uint256", "name": "ethPrice", "type": "uint256" }
25 | ],
26 | "stateMutability": "view",
27 | "type": "function"
28 | },
29 | {
30 | "inputs": [],
31 | "name": "getCETHAddress",
32 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
33 | "stateMutability": "pure",
34 | "type": "function"
35 | },
36 | {
37 | "inputs": [
38 | {
39 | "internalType": "contract CTokenInterface",
40 | "name": "cToken",
41 | "type": "address"
42 | }
43 | ],
44 | "name": "getCompPrice",
45 | "outputs": [
46 | { "internalType": "uint256", "name": "tokenPrice", "type": "uint256" },
47 | { "internalType": "uint256", "name": "ethPrice", "type": "uint256" }
48 | ],
49 | "stateMutability": "view",
50 | "type": "function"
51 | },
52 | {
53 | "inputs": [
54 | { "internalType": "address", "name": "token", "type": "address" },
55 | { "internalType": "uint256", "name": "ethAmount", "type": "uint256" }
56 | ],
57 | "name": "getCompoundData",
58 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
59 | "stateMutability": "view",
60 | "type": "function"
61 | },
62 | {
63 | "inputs": [],
64 | "name": "getComptroller",
65 | "outputs": [
66 | {
67 | "internalType": "contract ComptrollerLensInterface",
68 | "name": "",
69 | "type": "address"
70 | }
71 | ],
72 | "stateMutability": "pure",
73 | "type": "function"
74 | },
75 | {
76 | "inputs": [],
77 | "name": "getDaiAddress",
78 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
79 | "stateMutability": "pure",
80 | "type": "function"
81 | },
82 | {
83 | "inputs": [
84 | { "internalType": "address", "name": "token", "type": "address" },
85 | { "internalType": "uint256", "name": "ethAmt", "type": "uint256" }
86 | ],
87 | "name": "getMakerData",
88 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
89 | "stateMutability": "view",
90 | "type": "function"
91 | },
92 | {
93 | "inputs": [],
94 | "name": "getMcdAddresses",
95 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
96 | "stateMutability": "pure",
97 | "type": "function"
98 | },
99 | {
100 | "inputs": [],
101 | "name": "getOracleAddress",
102 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
103 | "stateMutability": "pure",
104 | "type": "function"
105 | },
106 | {
107 | "inputs": [],
108 | "name": "getSoloAddress",
109 | "outputs": [
110 | { "internalType": "address", "name": "addr", "type": "address" }
111 | ],
112 | "stateMutability": "pure",
113 | "type": "function"
114 | },
115 | {
116 | "inputs": [
117 | { "internalType": "address", "name": "token", "type": "address" }
118 | ],
119 | "name": "getTokenLimit",
120 | "outputs": [
121 | {
122 | "components": [
123 | { "internalType": "uint256", "name": "dydx", "type": "uint256" },
124 | { "internalType": "uint256", "name": "maker", "type": "uint256" },
125 | { "internalType": "uint256", "name": "compound", "type": "uint256" },
126 | { "internalType": "uint256", "name": "aave", "type": "uint256" }
127 | ],
128 | "internalType": "struct DydxFlashloanResolver.RouteData",
129 | "name": "",
130 | "type": "tuple"
131 | }
132 | ],
133 | "stateMutability": "view",
134 | "type": "function"
135 | },
136 | {
137 | "inputs": [
138 | { "internalType": "address[]", "name": "tokens", "type": "address[]" }
139 | ],
140 | "name": "getTokensLimit",
141 | "outputs": [
142 | {
143 | "components": [
144 | { "internalType": "uint256", "name": "dydx", "type": "uint256" },
145 | { "internalType": "uint256", "name": "maker", "type": "uint256" },
146 | { "internalType": "uint256", "name": "compound", "type": "uint256" },
147 | { "internalType": "uint256", "name": "aave", "type": "uint256" }
148 | ],
149 | "internalType": "struct DydxFlashloanResolver.RouteData[]",
150 | "name": "",
151 | "type": "tuple[]"
152 | }
153 | ],
154 | "stateMutability": "view",
155 | "type": "function"
156 | },
157 | {
158 | "inputs": [],
159 | "name": "name",
160 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
161 | "stateMutability": "view",
162 | "type": "function"
163 | }
164 | ]
165 |
--------------------------------------------------------------------------------
/src/abi/read/kyber.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [],
4 | "name": "getAddressETH",
5 | "outputs": [
6 | {
7 | "internalType": "address",
8 | "name": "",
9 | "type": "address"
10 | }
11 | ],
12 | "stateMutability": "pure",
13 | "type": "function"
14 | },
15 | {
16 | "inputs": [],
17 | "name": "getAddressKyber",
18 | "outputs": [
19 | {
20 | "internalType": "address",
21 | "name": "",
22 | "type": "address"
23 | }
24 | ],
25 | "stateMutability": "pure",
26 | "type": "function"
27 | },
28 | {
29 | "inputs": [
30 | {
31 | "internalType": "address",
32 | "name": "buyAddr",
33 | "type": "address"
34 | },
35 | {
36 | "internalType": "address",
37 | "name": "sellAddr",
38 | "type": "address"
39 | },
40 | {
41 | "internalType": "uint256",
42 | "name": "sellAmt",
43 | "type": "uint256"
44 | },
45 | {
46 | "internalType": "uint256",
47 | "name": "slippage",
48 | "type": "uint256"
49 | }
50 | ],
51 | "name": "getBuyAmount",
52 | "outputs": [
53 | {
54 | "internalType": "uint256",
55 | "name": "buyAmt",
56 | "type": "uint256"
57 | },
58 | {
59 | "internalType": "uint256",
60 | "name": "unitAmt",
61 | "type": "uint256"
62 | }
63 | ],
64 | "stateMutability": "view",
65 | "type": "function"
66 | },
67 | {
68 | "inputs": [],
69 | "name": "name",
70 | "outputs": [
71 | {
72 | "internalType": "string",
73 | "name": "",
74 | "type": "string"
75 | }
76 | ],
77 | "stateMutability": "view",
78 | "type": "function"
79 | }
80 | ]
81 |
--------------------------------------------------------------------------------
/src/abi/read/oasis.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | {
5 | "internalType": "address",
6 | "name": "buyAddr",
7 | "type": "address"
8 | },
9 | {
10 | "internalType": "address",
11 | "name": "sellAddr",
12 | "type": "address"
13 | },
14 | {
15 | "internalType": "uint256",
16 | "name": "sellAmt",
17 | "type": "uint256"
18 | },
19 | {
20 | "internalType": "uint256",
21 | "name": "slippage",
22 | "type": "uint256"
23 | }
24 | ],
25 | "name": "getBuyAmount",
26 | "outputs": [
27 | {
28 | "internalType": "uint256",
29 | "name": "buyAmt",
30 | "type": "uint256"
31 | },
32 | {
33 | "internalType": "uint256",
34 | "name": "unitAmt",
35 | "type": "uint256"
36 | }
37 | ],
38 | "stateMutability": "view",
39 | "type": "function"
40 | },
41 | {
42 | "inputs": [
43 | {
44 | "internalType": "address",
45 | "name": "sellAddr",
46 | "type": "address"
47 | }
48 | ],
49 | "name": "getMinSellAmount",
50 | "outputs": [
51 | {
52 | "internalType": "uint256",
53 | "name": "minAmt",
54 | "type": "uint256"
55 | }
56 | ],
57 | "stateMutability": "view",
58 | "type": "function"
59 | },
60 | {
61 | "inputs": [
62 | {
63 | "internalType": "address",
64 | "name": "buyAddr",
65 | "type": "address"
66 | },
67 | {
68 | "internalType": "address",
69 | "name": "sellAddr",
70 | "type": "address"
71 | },
72 | {
73 | "internalType": "uint256",
74 | "name": "buyAmt",
75 | "type": "uint256"
76 | },
77 | {
78 | "internalType": "uint256",
79 | "name": "slippage",
80 | "type": "uint256"
81 | }
82 | ],
83 | "name": "getSellAmount",
84 | "outputs": [
85 | {
86 | "internalType": "uint256",
87 | "name": "sellAmt",
88 | "type": "uint256"
89 | },
90 | {
91 | "internalType": "uint256",
92 | "name": "unitAmt",
93 | "type": "uint256"
94 | }
95 | ],
96 | "stateMutability": "view",
97 | "type": "function"
98 | },
99 | {
100 | "inputs": [],
101 | "name": "name",
102 | "outputs": [
103 | {
104 | "internalType": "string",
105 | "name": "",
106 | "type": "string"
107 | }
108 | ],
109 | "stateMutability": "view",
110 | "type": "function"
111 | }
112 | ]
113 |
--------------------------------------------------------------------------------
/src/abi/read/swerve.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | { "internalType": "address", "name": "buyAddr", "type": "address" },
5 | { "internalType": "address", "name": "sellAddr", "type": "address" },
6 | { "internalType": "uint256", "name": "sellAmt", "type": "uint256" },
7 | { "internalType": "uint256", "name": "slippage", "type": "uint256" }
8 | ],
9 | "name": "getBuyAmount",
10 | "outputs": [
11 | { "internalType": "uint256", "name": "buyAmt", "type": "uint256" },
12 | { "internalType": "uint256", "name": "unitAmt", "type": "uint256" },
13 | { "internalType": "uint256", "name": "virtualPrice", "type": "uint256" }
14 | ],
15 | "stateMutability": "view",
16 | "type": "function"
17 | },
18 | {
19 | "inputs": [
20 | { "internalType": "address", "name": "token", "type": "address" },
21 | { "internalType": "uint256", "name": "depositAmt", "type": "uint256" },
22 | { "internalType": "uint256", "name": "slippage", "type": "uint256" }
23 | ],
24 | "name": "getDepositAmount",
25 | "outputs": [
26 | { "internalType": "uint256", "name": "swerveAmt", "type": "uint256" },
27 | { "internalType": "uint256", "name": "unitAmt", "type": "uint256" },
28 | { "internalType": "uint256", "name": "virtualPrice", "type": "uint256" }
29 | ],
30 | "stateMutability": "view",
31 | "type": "function"
32 | },
33 | {
34 | "inputs": [
35 | { "internalType": "address", "name": "user", "type": "address" }
36 | ],
37 | "name": "getPosition",
38 | "outputs": [
39 | { "internalType": "uint256", "name": "userBal", "type": "uint256" },
40 | { "internalType": "uint256", "name": "totalSupply", "type": "uint256" },
41 | { "internalType": "uint256", "name": "virtualPrice", "type": "uint256" },
42 | { "internalType": "uint256", "name": "userShare", "type": "uint256" },
43 | { "internalType": "uint256", "name": "poolDaiBal", "type": "uint256" },
44 | { "internalType": "uint256", "name": "poolUsdcBal", "type": "uint256" },
45 | { "internalType": "uint256", "name": "poolUsdtBal", "type": "uint256" },
46 | { "internalType": "uint256", "name": "poolSusdBal", "type": "uint256" }
47 | ],
48 | "stateMutability": "view",
49 | "type": "function"
50 | },
51 | {
52 | "inputs": [
53 | { "internalType": "address", "name": "token", "type": "address" },
54 | { "internalType": "uint256", "name": "withdrawAmt", "type": "uint256" },
55 | { "internalType": "uint256", "name": "slippage", "type": "uint256" }
56 | ],
57 | "name": "getWithdrawSwerveAmount",
58 | "outputs": [
59 | { "internalType": "uint256", "name": "swerveAmt", "type": "uint256" },
60 | { "internalType": "uint256", "name": "unitAmt", "type": "uint256" },
61 | { "internalType": "uint256", "name": "virtualPrice", "type": "uint256" }
62 | ],
63 | "stateMutability": "view",
64 | "type": "function"
65 | },
66 | {
67 | "inputs": [
68 | { "internalType": "address", "name": "token", "type": "address" },
69 | { "internalType": "uint256", "name": "swerveAmt", "type": "uint256" },
70 | { "internalType": "uint256", "name": "slippage", "type": "uint256" }
71 | ],
72 | "name": "getWithdrawTokenAmount",
73 | "outputs": [
74 | { "internalType": "uint256", "name": "tokenAmt", "type": "uint256" },
75 | { "internalType": "uint256", "name": "unitAmt", "type": "uint256" },
76 | { "internalType": "uint256", "name": "virtualPrice", "type": "uint256" }
77 | ],
78 | "stateMutability": "view",
79 | "type": "function"
80 | },
81 | {
82 | "inputs": [],
83 | "name": "name",
84 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
85 | "stateMutability": "view",
86 | "type": "function"
87 | }
88 | ]
89 |
--------------------------------------------------------------------------------
/src/constant/abis.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | core: {
3 | index: require("../abi/core/index.json"),
4 | list: require("../abi/core/list.json"),
5 | account: require("../abi/core/account.json"),
6 | connector: require("../abi/core/connector.json"),
7 | events: require("../abi/core/events.json"),
8 | },
9 | connectors: {
10 | basic: require("../abi/connectors/basic.json"),
11 | auth: require("../abi/connectors/auth.json"),
12 | authority: require("../abi/connectors/auth.json"), // same json file as of "auth" to not break things with upgrade
13 | compound: require("../abi/connectors/compound.json"),
14 | maker: require("../abi/connectors/maker.json"),
15 | maker_old: require("../abi/connectors/maker_old.json"),
16 | instapool: require("../abi/connectors/instapool.json"),
17 | oasis: require("../abi/connectors/oasis.json"),
18 | kyber: require("../abi/connectors/kyber.json"),
19 | curve: require("../abi/connectors/curve.json"),
20 | curve_susd: require("../abi/connectors/curve.json"),
21 | curve_sbtc: require("../abi/connectors/curve.json"),
22 | curve_y: require("../abi/connectors/curve.json"),
23 | oneInch: require("../abi/connectors/1inch.json"),
24 | dydx: require("../abi/connectors/dydx.json"),
25 | aave: require("../abi/connectors/aave.json"),
26 | migrate: require("../abi/connectors/migrate.json"),
27 | compoundImport: require("../abi/connectors/compoundImport.json"),
28 | uniswap: require("../abi/connectors/uniswap.json"),
29 | comp: require("../abi/connectors/comp.json"),
30 | staking: require("../abi/connectors/staking.json"),
31 | chi: require("../abi/connectors/chi.json"),
32 | curve_claim: require("../abi/connectors/curveClaim.json"),
33 | curve_gauge: require("../abi/connectors/curveGauge.json"),
34 | gelato: require("../abi/connectors/gelato.json"),
35 | dydx_flash: require("../abi/connectors/dydxFlashloan.json"),
36 | swerve: require("../abi/connectors/swerve.json"),
37 | curve_three: require("../abi/connectors/curve_3pool.json"),
38 | instapool_v2: require("../abi/connectors/instapool_v2.json"),
39 | math: require("../abi/connectors/math.json"),
40 | compoundImport_v2: require("../abi/connectors/compoundImport_v2.json"),
41 | aave_v2: require("../abi/connectors/aave_v2.json"),
42 | aave_migrate: require("../abi/connectors/aave_migrate.json"),
43 | fee: require("../abi/connectors/fee.json"),
44 | refinance: require("../abi/connectors/refinance.json"),
45 | aave_v2_import: require("../abi/connectors/aaveV2_import.json"),
46 | aave_v1_import: require("../abi/connectors/aaveV1_import.json"),
47 | },
48 | read: {
49 | core: require("../abi/read/core.json"),
50 | compound: require("../abi/read/compound.json"),
51 | maker: require("../abi/read/maker.json"),
52 | erc20: require("../abi/read/erc20.json"),
53 | oasis: require("../abi/read/oasis.json"),
54 | kyber: require("../abi/read/kyber.json"),
55 | curve: require("../abi/read/curve_susd.json"),
56 | curve_susd: require("../abi/read/curve_susd.json"),
57 | curve_sbtc: require("../abi/read/curve_sbtc.json"),
58 | curve_y: require("../abi/read/curve_y.json"),
59 | oneInch: require("../abi/read/1inch.json"),
60 | dydx: require("../abi/read/dydx.json"),
61 | aave: require("../abi/read/aave.json"),
62 | uniswap: require("../abi/read/uniswap.json"),
63 | curve_claim: require("../abi/read/curveClaim.json"),
64 | chainlink: require("../abi/read/chainlink.json"),
65 | curve_gauge: require("../abi/read/curveGauge.json"),
66 | swerve: require("../abi/read/swerve.json"),
67 | curve_three: require("../abi/read/curve_3pool.json"),
68 | instapool_v2: require("../abi/read/instapool_v2.json"),
69 | },
70 | basic: {
71 | erc20: require("../abi/basics/erc20.json"),
72 | },
73 | gnosisSafe: require("../abi/gnosis/gnosisSafe.json"),
74 | };
75 |
--------------------------------------------------------------------------------
/src/constant/addresses.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | genesis: "0x0000000000000000000000000000000000000000",
3 | core: {
4 | index: "0x2971AdFa57b20E5a416aE5a708A8655A9c74f723",
5 | list: "0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb",
6 | account: "0x939Daad09fC4A9B8f8A9352A485DAb2df4F4B3F8",
7 | connector: "0xD6A602C01a023B98Ecfb29Df02FBA380d3B21E0c",
8 | events: "0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97",
9 | instapool: "0x06cb7c24990cbe6b9f99982f975f9147c000fec6",
10 | dydx_flash: "0xf5b16af97B5CBa4Babe786238FF6016daE6bb890",
11 | },
12 | connectors: {
13 | basic: "0xe5398f279175962E56fE4c5E0b62dc7208EF36c6",
14 | auth: "0xd1aff9f2acf800c876c409100d6f39aea93fc3d9",
15 | authority: "0xd1aff9f2acf800c876c409100d6f39aea93fc3d9", // same address as of "auth" to not break things with upgrade
16 | compound: "0x15fdd1e902cac70786fe7d31013b1a806764b5a2",
17 | maker: "0x0F3979aC12b74878Af11cfee67B9bBB2520b3ba6",
18 | maker_old: "0xac02030d8a8F49eD04b2f52C394D3F901A10F8A9",
19 | instapool: "0xCeF5f3c402d4fef76A038e89a4357176963e1464",
20 | oasis: "0xE554c84c030bd5e850cDbd17f6583818b8dE5b1F",
21 | kyber: "0x7043FC2E21865c091EEaE37C38E3d82BcCDF5D5C",
22 | curve: "0xC74902Ad45C8223da10EfdCfF2DeD12184e9D9b5",
23 | curve_susd: "0xC74902Ad45C8223da10EfdCfF2DeD12184e9D9b5",
24 | curve_sbtc: "0xe3bC928D9DAA89A0f08Cf77b227B7080B9a5105d",
25 | curve_y: "0x861a2250FcDBe57041289623561D5D79585DF5dc",
26 | oneInch: "0xC639E779eBEDCC9394DD534a3cf8A2d164f1Ee97",
27 | dydx: "0x6AF6C791c869DfA65f8A2fa042fA47D1535Bef25",
28 | aave: "0x1d662Fe55b10759CE69c3A6805259eb545BD5738",
29 | migrate: "0xcb5cbc3f397e0024fac67cf6dd465e02ca91c215",
30 | compoundImport: "0xdc9f393d5f4c12f1c1049035c20d58bd624510e3",
31 | uniswap: "0x3f4b307d501417CA0F928958a27191AA6657D38d",
32 | comp: "0xB4a04F1C194bEed64FCE27843B5b3079339cdaD4",
33 | staking: "0xe5b66b785bd6b6708BB814482180C136Ddbcd687",
34 | chi: "0xb86437e80709015d05354c35e54b7c8b11a58687",
35 | curve_claim: "0xF5e14d35706971B6AaD7A67B1A8E9a1EF7870Be9",
36 | curve_gauge: "0xAf615b36Db171fD5A369A0060b9bCB88fFf0190d",
37 | gelato: "0x25aD59adbe00C2d80c86d01e2E05e1294DA84823",
38 | dydx_flash: "0xE5a7bdd3336245142Ad3a153838ecFB490A5e044",
39 | swerve: "0x8b302dc8a97a63eb468715b8c30f7003b86e9f01",
40 | curve_three: "0x1568a9D336A7aC051DCC4bdcc4A0B09299DE5Daf",
41 | instapool_v2: "0xeb4bf86589f808f90eec8e964dbf16bd4d284905",
42 | compoundImport_v2: "0x85b669261c2a65db4cd48e22ec134a09c2271568",
43 | math: "0xa007f98ab41b0b4520701cb2ac75e802c460db4c",
44 | aave_v2: "0x53Edf7Fc8bB9c249694EA0a2174043553b34Db27",
45 | aave_migrate: "0xd3914a73367F8015070f073D5C69602F3a48B80D",
46 | fee: "0x5fa9455cE54BD5723443C6D3D614693E3429B57F",
47 | refinance: "0x0D16C7134ce24D1e22D64bC7bc0B4862Faa9AdB9",
48 | aave_v2_import: "0xCFC2a047887A4026A7E866f7ec1404f30D6A6F31",
49 | aave_v1_import: "0x4a9e4827e884cB3e49406e3A1A678F75910B1BB9",
50 | },
51 | read: {
52 | core: "0x621AD080ad3B839e7b19e040C77F05213AB71524",
53 | erc20: "0x6d9c624844e61280c19fd7ef588d79a6de893d64",
54 | compound: "0x1f22D77365d8BFE3b901C33C83C01B584F946617",
55 | maker: "0x0A7008B38E7015F8C36A49eEbc32513ECA8801E5",
56 | oasis: "0xa3d13105397F3b13Dd47cd1f90a50F95A60cdd56",
57 | kyber: "0x8240b601d9B565e2BefaA3DA82Cc984E76cB3499",
58 | curve: "0x734c90119A0012eF744e3a0ee74691b4f05A2D7e",
59 | curve_susd: "0x734c90119A0012eF744e3a0ee74691b4f05A2D7e",
60 | curve_sbtc: "0xc8ff9e290e65972a1b3fc67e1ab7451088a74752",
61 | curve_y: "0xaf122FB1C70b913AF467a9D924890f92c109bfc3",
62 | oneInch: "0x40c71a20938ff932bea18f674e73be670ea47ccf",
63 | dydx: "0xcb704D9505Fbbf61478F06741C75F34eA84Ec85C",
64 | aave: "0xe04Cd009fF68628BC663058dDAA7E5Bf7979BEaF",
65 | uniswap: "0x492e5f3f01d20513fc0d53ca0215b6499faec8a0",
66 | curve_claim: "0xc501F3c50DabB377c4afe5C0cD44BF7173b0F833",
67 | chainlink: "0xF72Ee0Cc52C119F00B19c35a4d4ee2f445573D3e",
68 | curve_gauge: "0x3Dfb98C045d4f4Be168bBE60ba2eb0A3ccf8fBC3",
69 | swerve: "0x51432D11431cE6280FF8CFC61C280b3B27E67B28",
70 | curve_three: "0x65c20364071C5dd21081fd1e0D9DbC72C8a87CC0",
71 | instapool_v2: "0xa004a5afba04b74037e9e52ba1f7eb02b5e61509",
72 | },
73 | };
74 |
--------------------------------------------------------------------------------
/src/constant/chainlinkTokens.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Instadapp/dsa-sdk/3515dba295c953a2f068a8961e06897a87c98186/src/constant/chainlinkTokens.js
--------------------------------------------------------------------------------
/src/gnosis-safe/utils/offchainSigner/EIP712Signer.js:
--------------------------------------------------------------------------------
1 | module.exports = class EIP712Signer {
2 | constructor(_dsa) {
3 | this.web3 = _dsa.web3;
4 | this.EIP712_NOT_SUPPORTED_ERROR_MSG = "ETH_SIGN_NOT_SUPPORTED";
5 | }
6 | async generateTypedDataFrom({
7 | baseGas,
8 | data,
9 | gasPrice,
10 | gasToken,
11 | nonce,
12 | operation,
13 | refundReceiver,
14 | safeAddress,
15 | safeTxGas,
16 | to,
17 | valueInWei,
18 | }) {
19 | const typedData = {
20 | types: {
21 | EIP712Domain: [
22 | {
23 | type: "address",
24 | name: "verifyingContract",
25 | },
26 | ],
27 | SafeTx: [
28 | { type: "address", name: "to" },
29 | { type: "uint256", name: "value" },
30 | { type: "bytes", name: "data" },
31 | { type: "uint8", name: "operation" },
32 | { type: "uint256", name: "safeTxGas" },
33 | { type: "uint256", name: "baseGas" },
34 | { type: "uint256", name: "gasPrice" },
35 | { type: "address", name: "gasToken" },
36 | { type: "address", name: "refundReceiver" },
37 | { type: "uint256", name: "nonce" },
38 | ],
39 | },
40 | domain: {
41 | verifyingContract: safeAddress,
42 | },
43 | primaryType: "SafeTx",
44 | message: {
45 | to,
46 | value: valueInWei,
47 | data,
48 | operation,
49 | safeTxGas,
50 | baseGas,
51 | gasPrice,
52 | gasToken,
53 | refundReceiver,
54 | nonce: Number(nonce),
55 | },
56 | };
57 |
58 | return typedData;
59 | }
60 |
61 | getEIP712Signer(version) {
62 | return async (txArgs) => {
63 | const typedData = await this.generateTypedDataFrom(txArgs);
64 |
65 | let method = "eth_signTypedData_v3";
66 | if (version === "v4") {
67 | method = "eth_signTypedData_v4";
68 | }
69 | if (!version) {
70 | method = "eth_signTypedData";
71 | }
72 |
73 | const jsonTypedData = JSON.stringify(typedData);
74 | const signedTypedData = {
75 | jsonrpc: "2.0",
76 | method,
77 | params:
78 | version === "v3" || version === "v4"
79 | ? [txArgs.sender, jsonTypedData]
80 | : [jsonTypedData, txArgs.sender],
81 | from: txArgs.sender,
82 | id: new Date().getTime(),
83 | };
84 |
85 | const web3 = this.web3;
86 |
87 | return new Promise((resolve, reject) => {
88 | web3.currentProvider.sendAsync(signedTypedData, (err, signature) => {
89 | if (err) {
90 | reject(err);
91 | return;
92 | }
93 |
94 | if (signature.result == null) {
95 | reject(new Error(EIP712_NOT_SUPPORTED_ERROR_MSG));
96 | return;
97 | }
98 |
99 | resolve(signature.result.replace("0x", ""));
100 | });
101 | });
102 | };
103 | }
104 | };
105 |
--------------------------------------------------------------------------------
/src/gnosis-safe/utils/offchainSigner/ethSigner.js:
--------------------------------------------------------------------------------
1 | module.exports = class ETHSigner {
2 | // 1. we try to sign via EIP-712 if user's wallet supports it
3 | // 2. If not, try to use eth_sign (Safe version has to be >1.1.1)
4 | // If eth_sign, doesn't work continue with the regular flow (on-chain signatures, more in createTransaction.ts)
5 | constructor(_dsa) {
6 | this.web3 = _dsa.web3;
7 | this.ETH_SIGN_NOT_SUPPORTED_ERROR_MSG = "ETH_SIGN_NOT_SUPPORTED";
8 | }
9 |
10 | async ethSigner({
11 | baseGas,
12 | data,
13 | gasPrice,
14 | gasToken,
15 | nonce,
16 | operation,
17 | refundReceiver,
18 | safeInstance,
19 | safeTxGas,
20 | sender,
21 | to,
22 | valueInWei,
23 | }) {
24 | const txHash = await safeInstance.methods
25 | .getTransactionHash(
26 | to,
27 | valueInWei,
28 | data,
29 | operation,
30 | safeTxGas,
31 | baseGas,
32 | gasPrice,
33 | gasToken,
34 | refundReceiver,
35 | nonce,
36 | {
37 | from: sender,
38 | }
39 | )
40 | .call();
41 |
42 | const web3 = this.web3;
43 |
44 | return new Promise(function (resolve, reject) {
45 | web3.currentProvider.sendAsync(
46 | {
47 | jsonrpc: "2.0",
48 | method: "eth_sign",
49 | params: [sender, txHash],
50 | id: new Date().getTime(),
51 | },
52 | async function (err, signature) {
53 | if (err) {
54 | return reject(err);
55 | }
56 |
57 | if (signature.result == null) {
58 | reject(new Error(this.ETH_SIGN_NOT_SUPPORTED_ERROR_MSG));
59 | return;
60 | }
61 |
62 | const sig = signature.result.replace("0x", "");
63 | let sigV = parseInt(sig.slice(-2), 16);
64 |
65 | // Metamask with ledger returns v = 01, this is not valid for ethereum
66 | // For ethereum valid V is 27 or 28
67 | // In case V = 0 or 01 we add it to 27 and then add 4
68 | // Adding 4 is required to make signature valid for safe contracts:
69 | // https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#eth-sign-signature
70 | switch (sigV) {
71 | case 0:
72 | case 1:
73 | sigV += 31;
74 | break;
75 | case 27:
76 | case 28:
77 | sigV += 4;
78 | break;
79 | default:
80 | throw new Error("Invalid signature");
81 | }
82 |
83 | resolve(sig.slice(0, -2) + sigV.toString(16));
84 | }
85 | );
86 | });
87 | }
88 | };
89 |
--------------------------------------------------------------------------------
/src/gnosis-safe/utils/offchainSigner/index.js:
--------------------------------------------------------------------------------
1 | const ETHSigner = require("./ethSigner");
2 | const EIP712Signer = require("./EIP712Signer");
3 |
4 | // 1. we try to sign via EIP-712 if user's wallet supports it
5 | // 2. If not, try to use eth_sign (Safe version has to be >1.1.1)
6 | // If eth_sign, doesn't work continue with the regular flow (on-chain signatures, more in createTransaction.ts)
7 | module.exports = class OffChainSign {
8 | constructor(_dsa) {
9 | this.web3 = _dsa.web3;
10 | this.SAFE_VERSION_FOR_OFFCHAIN_SIGNATURES = ">=1.1.1";
11 | this.ethSigner = new ETHSigner(this);
12 | this.eip712Signer = new EIP712Signer(this);
13 | this.SIGNERS = {
14 | EIP712_V3: this.eip712Signer.getEIP712Signer("v3"),
15 | EIP712_V4: this.eip712Signer.getEIP712Signer("v4"),
16 | EIP712: this.eip712Signer.getEIP712Signer(),
17 | ETH_SIGN: this.ethSigner.ethSigner,
18 | };
19 | }
20 |
21 | // hardware wallets support eth_sign only
22 | getSignersByWallet(isHW) {
23 | return isHW
24 | ? [this.SIGNERS.ETH_SIGN]
25 | : [
26 | this.SIGNERS.EIP712_V3,
27 | this.SIGNERS.EIP712_V4,
28 | this.SIGNERS.EIP712,
29 | this.SIGNERS.ETH_SIGN,
30 | ];
31 | }
32 |
33 | async tryOffchainSigning(txArgs, isHW) {
34 | let signature;
35 |
36 | const signerByWallet = this.getSignersByWallet(isHW);
37 | for (const signingFunc of signerByWallet) {
38 | try {
39 | signature = await signingFunc(txArgs);
40 |
41 | break;
42 | } catch (err) {
43 | console.error(err);
44 | // Metamask sign request error code
45 | if (err.code === 4001) {
46 | throw new Error("User denied sign request");
47 | }
48 | }
49 | }
50 |
51 | return signature;
52 | }
53 | };
54 |
--------------------------------------------------------------------------------
/src/gnosis-safe/utils/safe-api.js:
--------------------------------------------------------------------------------
1 | const axios = require("axios");
2 |
3 | module.exports = class APIHelpers {
4 | constructor(_dsa) {
5 | this.web3 = _dsa.web3;
6 | this.internal = _dsa.internal;
7 | this.TX_SERVICE_HOST = "tsh";
8 | this.SIGNATURES_VIA_METAMASK = "svm";
9 | this.config = {
10 | [this.TX_SERVICE_HOST]:
11 | "https://safe-transaction.mainnet.gnosis.io/api/v1/",
12 | };
13 | }
14 |
15 | getTxServiceHost() {
16 | return this.config[this.TX_SERVICE_HOST];
17 | }
18 |
19 | getTxServiceUriFrom(safeAddress) {
20 | return `safes/${safeAddress}/transactions/`;
21 | }
22 |
23 | getSafeUriFrom(safeAddress) {
24 | return `safes/${safeAddress}/`;
25 | }
26 |
27 | getOwnersUriFrom(ownerAddress) {
28 | return `owners/${ownerAddress}/`;
29 | }
30 |
31 | getIncomingTxServiceUriTo(safeAddress) {
32 | return `safes/${safeAddress}/incoming-transfers/`;
33 | }
34 |
35 | getSafeCreationTxUri(safeAddress) {
36 | return `safes/${safeAddress}/creation/`;
37 | }
38 |
39 | signaturesViaMetamask() {
40 | return this.config[SIGNATURES_VIA_METAMASK];
41 | }
42 |
43 | async getSafeAddresses(address) {
44 | let _addr = address ? address : await this.internal.getAddress();
45 | if (!_addr) throw new Error("Error getting account address");
46 | _addr = this.web3.utils.toChecksumAddress(_addr);
47 | const host = this.getTxServiceHost();
48 | const base = this.getOwnersUriFrom(_addr);
49 | const url = `${host}${base}`;
50 | const response = await axios.get(url);
51 | const SUCCESS_STATUS = 200;
52 | if (response.status !== SUCCESS_STATUS) {
53 | return Promise.reject(new Error("Error getting safe addresses"));
54 | } else {
55 | return response.data.safes;
56 | }
57 | }
58 |
59 | async getSafeOwners(safeAddress) {
60 | let _addr = safeAddress;
61 | if (!_addr) throw new Error("`safeAddress` is not defined.");
62 | _addr = this.web3.utils.toChecksumAddress(_addr);
63 | const host = this.getTxServiceHost();
64 | const base = this.getSafeUriFrom(_addr);
65 | const url = `${host}${base}`;
66 | const response = await axios.get(url);
67 | const SUCCESS_STATUS = 200;
68 | if (response.status !== SUCCESS_STATUS) {
69 | return Promise.reject(new Error("Error getting safe addresses"));
70 | } else {
71 | return response.data.owners;
72 | }
73 | }
74 |
75 | async calculateBodyFrom(
76 | safeInstance,
77 | to,
78 | valueInWei,
79 | data,
80 | operation,
81 | nonce,
82 | safeTxGas,
83 | baseGas,
84 | gasPrice,
85 | gasToken,
86 | refundReceiver,
87 | transactionHash,
88 | sender,
89 | origin,
90 | signature
91 | ) {
92 | const contractTransactionHash = await safeInstance.methods
93 | .getTransactionHash(
94 | to,
95 | valueInWei,
96 | data,
97 | operation,
98 | safeTxGas,
99 | baseGas,
100 | gasPrice,
101 | gasToken,
102 | refundReceiver,
103 | nonce
104 | )
105 | .call();
106 |
107 | const web3 = this.web3;
108 | return {
109 | to: web3.utils.toChecksumAddress(to),
110 | value: valueInWei,
111 | data,
112 | operation,
113 | nonce,
114 | safeTxGas,
115 | baseGas,
116 | gasPrice,
117 | gasToken,
118 | refundReceiver,
119 | contractTransactionHash,
120 | transactionHash,
121 | sender: web3.utils.toChecksumAddress(sender),
122 | origin,
123 | signature,
124 | };
125 | }
126 |
127 | async buildTxServiceUrl(safeAddress) {
128 | const host = this.getTxServiceHost();
129 | const address = this.web3.utils.toChecksumAddress(safeAddress);
130 | const base = this.getTxServiceUriFrom(address);
131 | return `${host}${base}?has_confirmations=True`;
132 | }
133 |
134 | async saveTxToHistory({
135 | baseGas,
136 | data,
137 | gasPrice,
138 | gasToken,
139 | nonce,
140 | operation,
141 | origin,
142 | refundReceiver,
143 | safeInstance,
144 | safeTxGas,
145 | sender,
146 | signature,
147 | to,
148 | txHash,
149 | valueInWei,
150 | }) {
151 | const url = await this.buildTxServiceUrl(safeInstance._address);
152 | const body = await this.calculateBodyFrom(
153 | safeInstance,
154 | to,
155 | valueInWei,
156 | data,
157 | operation,
158 | nonce,
159 | safeTxGas,
160 | baseGas,
161 | gasPrice,
162 | gasToken,
163 | refundReceiver,
164 | txHash || null,
165 | sender,
166 | origin || null,
167 | signature
168 | );
169 | const response = await axios.post(url, body);
170 | const SUCCESS_STATUS = 201; // CREATED status
171 |
172 | if (response.status !== SUCCESS_STATUS) {
173 | return Promise.reject(new Error("Error submitting the transaction"));
174 | }
175 |
176 | return Promise.resolve();
177 | }
178 | };
179 |
--------------------------------------------------------------------------------
/src/gnosis-safe/utils/safe-estimateGas.js:
--------------------------------------------------------------------------------
1 | const BigNumber = require("bignumber.js");
2 |
3 | module.exports = class GasEstimate {
4 | constructor(_dsa) {
5 | this.web3 = _dsa.web3;
6 | this.transactionsHelpers = _dsa.transactionsHelpers;
7 | }
8 |
9 | estimateDataGasCosts(data) {
10 | const reducer = (accumulator, currentValue) => {
11 | if (currentValue === "0x") {
12 | return accumulator + 0;
13 | }
14 | if (currentValue === "00") {
15 | return accumulator + 4;
16 | }
17 | return accumulator + 16;
18 | };
19 | return data.match(/.{2}/g).reduce(reducer, 0);
20 | }
21 |
22 | async estimateSafeTxGas(safe, safeAddress, data, to, valueInWei, operation) {
23 | return new Promise(async (resolves, reject) => {
24 | try {
25 | let safeInstance = safe;
26 | if (!safeInstance) {
27 | safeInstance = await this.transactionsHelpers.getGnosisSafeInstanceAt(
28 | safeAddress
29 | );
30 | }
31 | const estimateData = safeInstance.methods
32 | .requiredTxGas(to, valueInWei, data, operation)
33 | .encodeABI();
34 | const estimateResponse = await this.web3.eth.call({
35 | to: safeAddress,
36 | from: safeAddress,
37 | data: estimateData,
38 | });
39 | const txGasEstimation =
40 | new BigNumber(estimateResponse.substring(138), 16).toNumber() + 10000;
41 |
42 | // 21000 - additional gas costs (e.g. base tx costs, transfer costs)
43 | const dataGasEstimation =
44 | this.estimateDataGasCosts(estimateData) + 21000;
45 | const additionalGasBatches = [
46 | 10000,
47 | 20000,
48 | 40000,
49 | 80000,
50 | 160000,
51 | 320000,
52 | 640000,
53 | 1280000,
54 | 2560000,
55 | 5120000,
56 | ];
57 |
58 | const batch = new this.web3.BatchRequest();
59 | const estimationRequests = additionalGasBatches.map(
60 | (additionalGas) =>
61 | new Promise((resolve) => {
62 | // there are no type definitions for .request, so for now ts-ignore is there
63 | // Issue link: https://github.com/ethereum/web3.js/issues/3144
64 | // eslint-disable-next-line
65 | // @ts-ignore
66 | const request = this.web3.eth.call.request(
67 | {
68 | to: safeAddress,
69 | from: safeAddress,
70 | data: estimateData,
71 | gasPrice: 0,
72 | gasLimit: txGasEstimation + dataGasEstimation + additionalGas,
73 | },
74 | (error, res) => {
75 | // res.data check is for OpenEthereum/Parity revert messages format
76 | const isOpenEthereumRevertMsg =
77 | res && typeof res.data === "string";
78 |
79 | const isEstimationSuccessful =
80 | !error &&
81 | ((typeof res === "string" && res !== "0x") ||
82 | (isOpenEthereumRevertMsg && res.data.slice(9) !== "0x"));
83 |
84 | resolve({
85 | success: isEstimationSuccessful,
86 | estimation: txGasEstimation + additionalGas,
87 | });
88 | }
89 | );
90 |
91 | batch.add(request);
92 | })
93 | );
94 | batch.execute();
95 |
96 | const estimationResponses = await Promise.all(estimationRequests);
97 | const firstSuccessfulRequest = estimationResponses.find(
98 | (res) => res.success
99 | );
100 |
101 | if (firstSuccessfulRequest) {
102 | return resolves(firstSuccessfulRequest.estimation);
103 | }
104 |
105 | reject("Transaction might fail.");
106 | } catch (error) {
107 | reject("Error calculating tx gas estimation", error);
108 | }
109 | });
110 | }
111 | };
112 |
--------------------------------------------------------------------------------
/src/gnosis-safe/utils/safe-provider.js:
--------------------------------------------------------------------------------
1 | module.exports = class GnosisSafeWeb3 {
2 | constructor(_dsa) {
3 | this.internal = _dsa.internal;
4 | this.web3 = _dsa.web3;
5 | this.WALLET_PROVIDER = {
6 | SAFE: "SAFE",
7 | METAMASK: "METAMASK",
8 | REMOTE: "REMOTE",
9 | TORUS: "TORUS",
10 | PORTIS: "PORTIS",
11 | FORTMATIC: "FORTMATIC",
12 | SQUARELINK: "SQUARELINK",
13 | UNILOGIN: "UNILOGIN",
14 | WALLETCONNECT: "WALLETCONNECT",
15 | OPERA: "OPERA",
16 | DAPPER: "DAPPER",
17 | WALLETLINK: "WALLETLINK",
18 | AUTHEREUM: "AUTHEREUM",
19 | LEDGER: "LEDGER",
20 | TREZOR: "TREZOR",
21 | };
22 | }
23 |
24 | sameAddress(firstAddress, secondAddress) {
25 | if (!firstAddress) {
26 | return false;
27 | }
28 |
29 | if (!secondAddress) {
30 | return false;
31 | }
32 |
33 | return firstAddress.toLowerCase() === secondAddress.toLowerCase();
34 | }
35 |
36 | isHardwareWallet(walletName) {
37 | return (
38 | this.sameAddress(this.WALLET_PROVIDER.LEDGER, walletName) ||
39 | this.sameAddress(this.WALLET_PROVIDER.TREZOR, walletName)
40 | );
41 | }
42 |
43 | async isSmartContractWallet(account) {
44 | const contractCode = await web3.eth.getCode(account);
45 |
46 | return contractCode.replace("0x", "").replace(/0/g, "") !== "";
47 | }
48 |
49 | async getProviderInfo(fromAddr, providerName = "Wallet") {
50 | const account = fromAddr ? fromAddr : await this.internal.getAddress();
51 | const smartContractWallet = await this.isSmartContractWallet(account);
52 | const hardwareWallet = this.isHardwareWallet(providerName);
53 |
54 | return {
55 | smartContractWallet,
56 | hardwareWallet,
57 | };
58 | }
59 | };
60 |
--------------------------------------------------------------------------------
/src/gnosis-safe/utils/safe-tnx.js:
--------------------------------------------------------------------------------
1 | const axios = require("axios");
2 |
3 | module.exports = class TransactionHelpers {
4 | constructor(_dsa) {
5 | this.internal = _dsa.internal;
6 | this.web3 = _dsa.web3;
7 | this.ABI = _dsa.ABI;
8 | this.apiHelpers = _dsa.apiHelpers;
9 | }
10 |
11 | async getGnosisSafeInstanceAt(safeAddress) {
12 | return await new this.web3.eth.Contract(
13 | this.ABI.gnosisSafe.abi,
14 | safeAddress
15 | );
16 | }
17 |
18 | async getLastTx(safeAddress) {
19 | try {
20 | const url = await this.apiHelpers.buildTxServiceUrl(safeAddress);
21 | const response = await axios.get(url, { params: { limit: 1 } });
22 | return response.data.results[0] || null;
23 | } catch (e) {
24 | console.error("failed to retrieve last Tx from server", e);
25 | return null;
26 | }
27 | }
28 |
29 | async getNewTxNonce(txNonce, lastTx, safeInstance) {
30 | if (!Number.isInteger(Number.parseInt(txNonce, 10))) {
31 | return lastTx === null
32 | ? // use current's safe nonce as fallback
33 | (await safeInstance.methods.nonce().call()).toString()
34 | : `${lastTx.nonce + 1}`;
35 | }
36 | return txNonce;
37 | }
38 |
39 | async shouldExecuteTransaction(safeInstance, nonce, lastTx) {
40 | const threshold = await safeInstance.methods.getThreshold().call();
41 |
42 | // Tx will automatically be executed if and only if the threshold is 1
43 | if (Number(threshold) === 1) {
44 | const isFirstTransaction = Number.parseInt(nonce) === 0;
45 | // if the previous tx is not executed, it's delayed using the approval mechanisms,
46 | // once the previous tx is executed, the current tx will be available to be executed
47 | // by the user using the exec button.
48 | const canExecuteCurrentTransaction = lastTx && lastTx.isExecuted;
49 |
50 | return isFirstTransaction || canExecuteCurrentTransaction;
51 | }
52 | return false;
53 | }
54 |
55 | async getApprovalTransaction({
56 | baseGas,
57 | data,
58 | gasPrice,
59 | gasToken,
60 | nonce,
61 | operation,
62 | refundReceiver,
63 | safeInstance,
64 | safeTxGas,
65 | sender,
66 | to,
67 | valueInWei,
68 | }) {
69 | const txHash = await safeInstance.methods
70 | .getTransactionHash(
71 | to,
72 | valueInWei,
73 | data,
74 | operation,
75 | safeTxGas,
76 | baseGas,
77 | gasPrice,
78 | gasToken,
79 | refundReceiver,
80 | nonce
81 | )
82 | .call({
83 | from: sender,
84 | });
85 |
86 | try {
87 | return safeInstance.methods.approveHash(txHash);
88 | } catch (err) {
89 | console.error(`Error while approving transaction: ${err}`);
90 | throw err;
91 | }
92 | }
93 |
94 | async getExecutionTransaction({
95 | baseGas,
96 | data,
97 | gasPrice,
98 | gasToken,
99 | operation,
100 | refundReceiver,
101 | safeInstance,
102 | safeTxGas,
103 | sigs,
104 | to,
105 | valueInWei,
106 | }) {
107 | try {
108 | const web3 = this.web3;
109 | const contract = new web3.eth.Contract(
110 | this.ABI.gnosisSafe.abi,
111 | safeInstance._address
112 | );
113 |
114 | return contract.methods.execTransaction(
115 | to,
116 | valueInWei,
117 | data,
118 | operation,
119 | safeTxGas,
120 | baseGas,
121 | gasPrice,
122 | gasToken,
123 | refundReceiver,
124 | sigs
125 | );
126 | } catch (err) {
127 | console.error(`Error while creating transaction: ${err}`);
128 | throw err;
129 | }
130 | }
131 | };
132 |
--------------------------------------------------------------------------------
/src/internal.js:
--------------------------------------------------------------------------------
1 | module.exports = class Internal {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.web3 = _dsa.web3;
9 | this.mode = _dsa.mode;
10 | this.privateKey = _dsa.privateKey;
11 | }
12 |
13 | /**
14 | * returns the input interface required for cast()
15 | */
16 | getTarget(_co) {
17 | const _t = this.address.connectors[_co];
18 | if (_t) return _t;
19 | else return console.error(`${_co} is invalid connector.`);
20 | }
21 |
22 | /**
23 | * returns txObj for any calls
24 | * * @param _d.from
25 | * * @param _d.to
26 | * * @param _d.callData
27 | * * @param _d.type
28 | * * @param _d.value (optional)
29 | * * @param _d.gas (optional)
30 | * * @param _d.gasPrice (optional only for "browser" mode)
31 | * * @param _d.nonce (optional) mostly for "node" mode
32 | */
33 | async getTxObj(_d) {
34 | if (!_d.from) throw new Error("'from' is not defined.");
35 | if (!_d.callData) throw new Error("'calldata' is not defined.");
36 | if (!_d.to) throw new Error("'to' is not defined.");
37 | if (_d.type != 0 && !_d.type) _d.type = 0;
38 |
39 | let txObj = {};
40 | txObj.from = _d.from;
41 | txObj.to = _d.to;
42 | txObj.data = _d.callData != "0x" ? _d.callData : "0x";
43 | txObj.value = _d.value ? _d.value : 0;
44 | // need above 4 params to estimate the gas
45 | if (_d.type == 0) {
46 | let txObjClone = { ...txObj };
47 | txObj.gas = _d.gas
48 | ? _d.gas
49 | : ((await this.web3.eth.estimateGas(txObjClone)) * 1.1).toFixed(0); // increasing gas cost by 10% for margin
50 |
51 | if (this.mode == "node") {
52 | if (!_d.gasPrice) throw new Error("`gasPrice` is not defined.");
53 |
54 | txObj.nonce = _d.nonce
55 | ? _d.nonce
56 | : await this.web3.eth.getTransactionCount(txObj.from);
57 | }
58 | if (_d.gasPrice) txObj.gasPrice = _d.gasPrice;
59 | }
60 |
61 | return txObj;
62 | }
63 |
64 | /**
65 | * returns the ABI interface for any DSA contract
66 | */
67 | getInterface(_type, _co, _m) {
68 | const _abi = this.ABI[_type][_co];
69 | for (let i = 0; i < _abi.length; i++) {
70 | if (_abi[i].name == _m) {
71 | return _abi[i];
72 | }
73 | }
74 | return console.error(`${_m} is invalid method.`);
75 | }
76 |
77 | /**
78 | * returns the input interface for any connector
79 | */
80 | getConnectorInterface(_co, _m) {
81 | return this.getInterface("connectors", _co, _m);
82 | }
83 |
84 | /**
85 | * returns encoded data of any calls
86 | * * @param _d.connector
87 | * * @param _d.method
88 | * * @param _d.args
89 | */
90 | encodeMethod(_d) {
91 | let _co = _d.connector;
92 | let _m = _d.method;
93 | let _a = _d.args; // []
94 | let _i = this.getInterface("connectors", _co, _m);
95 | return this.web3.eth.abi.encodeFunctionCall(_i, _a);
96 | }
97 |
98 | /**
99 | * returns encoded data of spells (used via cast() mostly)
100 | * @param _d the spells instance
101 | * OR
102 | * @param _d.spells the spells instance
103 | */
104 | encodeSpells(_d) {
105 | let _s;
106 | if (Array.isArray(_d.data)) {
107 | _s = _d.data; // required
108 | } else {
109 | _s = _d.spells.data; // required
110 | }
111 | let _ta = [];
112 | let _eda = [];
113 | for (let i = 0; i < _s.length; i++) {
114 | _ta.push(this.getTarget(_s[i].connector));
115 | _eda.push(this.encodeMethod(_s[i]));
116 | }
117 | return [_ta, _eda];
118 | }
119 |
120 | /**
121 | * returns the input interface required for cast()
122 | */
123 | async getAddress() {
124 | if (this.mode == "node")
125 | return this.web3.eth.accounts.privateKeyToAccount(this.privateKey)
126 | .address;
127 |
128 | // otherwise, browser
129 | let address = await this.web3.eth.getAccounts();
130 | if (address.length == 0)
131 | return console.log("No ethereum address detected.");
132 | return address[0];
133 | }
134 |
135 | /**
136 | * returns the address from token key OR checksum the address if not
137 | */
138 | filterAddress(token) {
139 | var isAddress = this.web3.utils.isAddress(token.toLowerCase());
140 | if (isAddress) {
141 | return this.web3.utils.toChecksumAddress(token.toLowerCase());
142 | } else {
143 | let tokenInfo = require("./constant/tokensInfo.json");
144 | if (Object.keys(tokenInfo).indexOf(token.toLowerCase()) == -1)
145 | throw new Error("'token' symbol not found.");
146 | return this.web3.utils.toChecksumAddress(
147 | tokenInfo[token.toLowerCase()].address
148 | );
149 | }
150 | }
151 |
152 | /**
153 | * returns the estimate gas cost
154 | * @param _d.from the from address
155 | * @param _d.to the to address
156 | * @param {Object} _d.abi the ABI method single interface
157 | * @param {Array} _d.args the method arguments
158 | * @param _d.value the call ETH value
159 | */
160 | async estimateGas(_d) {
161 | let encodeHash = this.web3.eth.abi.encodeFunctionCall(_d.abi, _d.args);
162 | let _web3 = this.web3;
163 | return new Promise(async (resolve, reject) => {
164 | await _web3.eth
165 | .estimateGas({
166 | from: _d.from,
167 | to: _d.to,
168 | data: encodeHash,
169 | value: _d.value,
170 | })
171 | .then((gas) => {
172 | resolve(gas);
173 | })
174 | .catch((err) => {
175 | reject({
176 | error: err,
177 | data: {
178 | abi: _d.abi,
179 | args: _d.args,
180 | from: _d.from,
181 | to: _d.to,
182 | data: encodeHash,
183 | value: _d.value,
184 | },
185 | });
186 | console.error(err);
187 | });
188 | });
189 | }
190 | };
191 |
--------------------------------------------------------------------------------
/src/resolvers/aave.js:
--------------------------------------------------------------------------------
1 | module.exports = class Aave {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.tokens = _dsa.tokens;
9 | this.web3 = _dsa.web3;
10 | this.instance = _dsa.instance;
11 | this.dsa = _dsa;
12 | }
13 |
14 | getAtokens() {
15 | var tokens = this.tokens.info;
16 | var _atokens = {};
17 | Object.keys(tokens).forEach((token) => {
18 | if (tokens[token].type == "atoken") _atokens[token] = tokens[token];
19 | });
20 | return _atokens;
21 | }
22 |
23 | getAtokensAddresses(_atokens) {
24 | if (!_atokens) _atokens = getAtokens();
25 | var _addresses = [];
26 | Object.keys(_atokens).forEach((_key) => {
27 | _addresses.push(_atokens[_key].address);
28 | });
29 | return _addresses;
30 | }
31 |
32 | getTokensAddresses(_atokens) {
33 | var tokens = this.tokens.info;
34 | var _addresses = [];
35 | Object.keys(_atokens).forEach((_key) => {
36 | _addresses.push(tokens[_atokens[_key].root].address);
37 | });
38 | return _addresses;
39 | }
40 |
41 | /**
42 | * get properly formatted Aave position details
43 | * @param {string} address the owner address
44 | * @param {string} key (optional) default - "token". Options:- "address", "atoken". key of object to return
45 | */
46 | getPosition(address, key) {
47 | var _address;
48 | !address ? (_address = this.instance.address) : (_address = address);
49 | var _aTokens = this.getAtokens();
50 | var _addresses = this.getTokensAddresses(_aTokens);
51 | var _obj = {
52 | protocol: "aave",
53 | method: "getPosition",
54 | args: [_address, _addresses],
55 | };
56 | return new Promise(async (resolve, reject) => {
57 | await this.dsa
58 | .read(_obj)
59 | .then((res) => {
60 | var _position = {};
61 | var _totalSupplyInEth = 0;
62 | var _totalBorrowInEth = 0;
63 | var _maxBorrowLimitInEth = 0;
64 | var _liquidationLimitInEth = 0;
65 | Object.keys(_aTokens).forEach((_atoken, i) => {
66 | var _root = _aTokens[_atoken].root;
67 | var _key;
68 | key == "atoken"
69 | ? (_key = _atoken)
70 | : key == "address"
71 | ? (_key = this.tokens.info[_root].address)
72 | : (_key = _root);
73 | var _res = res[0][i];
74 | var _decimals = this.tokens.info[_root].decimals;
75 | _position[_key] = {};
76 | var _priceInEth = _res[0] / 10 ** 18;
77 | _position[_key].priceInEth = _priceInEth;
78 | var _supply = _res[1] / 10 ** _decimals;
79 | _position[_key].supply = _supply;
80 | _totalSupplyInEth += _supply * _priceInEth;
81 | _position[_key].ltv = _res[7].ltv / 100;
82 | _position[_key].maxRatio =
83 | _res[7].ltv == 0 ? 0 : _res[7].threshold / 100;
84 | _maxBorrowLimitInEth += _supply * _priceInEth * _position[_key].ltv;
85 | _liquidationLimitInEth +=
86 | _supply * _priceInEth * _position[_key].maxRatio;
87 | var _borrow = _res[2] / 10 ** _decimals;
88 | _position[_key].borrow = _borrow;
89 | var _fee = _res[3] / 10 ** _decimals;
90 | _position[_key].borrowFee = _fee;
91 | _position[_key].borrowYield = (_res[5] / 1e27) * 100; // Multiply with 100 to make it in percent
92 | _position[_key].supplyYield = (_res[4] / 1e27) * 100; // Multiply with 100 to make it in percent
93 | _position[_key].isVariableBorrow = Number(_res[6]) == 2;
94 | // _position[_key].isStableBorrowAllowed = Boolean(
95 | // _res[7].stableBorrowEnabled
96 | // );
97 | });
98 | _position.totalSupplyInEth = _totalSupplyInEth;
99 | _position.totalBorrowInEth = Number(res[1][2]) / 1e18;
100 | _position.totalFeeInETH = Number(res[1][3]) / 1e18;
101 | _position.totalMaxRatio = Number(res[1][5]) / 1e2;
102 | _position.maxBorrowLimitInEth = _maxBorrowLimitInEth;
103 | _position.liquidationLimitInEth = _liquidationLimitInEth;
104 | var _status = _totalBorrowInEth / _totalSupplyInEth;
105 | _position.status = _status;
106 | var _maxBorrowRatio = _maxBorrowLimitInEth / _totalSupplyInEth;
107 | _position.maxBorrowRatio = _maxBorrowRatio;
108 | var _liquidation = _liquidationLimitInEth / _totalSupplyInEth;
109 | _position.liquidation = _liquidation;
110 | resolve(_position);
111 | })
112 | .catch((err) => {
113 | reject(err);
114 | });
115 | });
116 | }
117 | };
118 |
--------------------------------------------------------------------------------
/src/resolvers/account.js:
--------------------------------------------------------------------------------
1 | /**
2 | * account resolver
3 | */
4 | module.exports = class Account {
5 | /**
6 | * @param {Object} _dsa the dsa instance to access data stores
7 | */
8 | constructor(_dsa) {
9 | this.web3 = _dsa.web3;
10 | this.ABI = _dsa.ABI;
11 | this.address = _dsa.address;
12 | this.internal = _dsa.internal;
13 | }
14 |
15 | /**
16 | * global number of DSAs
17 | */
18 | async count() {
19 | var _c = new this.web3.eth.Contract(
20 | this.ABI.core.list,
21 | this.address.core.list
22 | );
23 | return new Promise((resolve, reject) => {
24 | return _c.methods
25 | .accounts()
26 | .call({ from: this.address.genesis })
27 | .then((count) => {
28 | resolve(count);
29 | })
30 | .catch((err) => {
31 | reject(err);
32 | });
33 | });
34 | }
35 |
36 | /**
37 | * returns accounts in a simple array of objects for addresses owned by the address
38 | * @param _authority the ethereum address or .eth name
39 | */
40 | async getAccounts(_authority) {
41 | if (_authority.includes(".eth"))
42 | _authority = await this.internal.web3.eth.ens.getAddress(_authority);
43 | if (!_authority) _authority = await this.internal.getAddress();
44 | var _c = new this.web3.eth.Contract(
45 | this.ABI.read.core,
46 | this.address.read.core
47 | );
48 | return new Promise((resolve, reject) => {
49 | return _c.methods
50 | .getAuthorityDetails(_authority)
51 | .call({ from: this.address.genesis })
52 | .then((_d) => {
53 | var _l = _d.IDs.length;
54 | var accounts = [];
55 | for (var i = 0; i < _l; i++) {
56 | accounts.push({
57 | id: _d.IDs[i],
58 | address: _d.accounts[i],
59 | version: _d.versions[i],
60 | });
61 | }
62 | resolve(accounts);
63 | })
64 | .catch((err) => {
65 | reject(err);
66 | });
67 | });
68 | }
69 |
70 | /**
71 | * returns accounts in a simple array of objects
72 | * @param _id the DSA number
73 | */
74 | async getAuthById(_id) {
75 | var _c = new this.web3.eth.Contract(
76 | this.ABI.read.core,
77 | this.address.read.core
78 | );
79 | return new Promise((resolve, reject) => {
80 | return _c.methods
81 | .getIDAuthorities(_id)
82 | .call({ from: this.address.genesis })
83 | .then((data) => {
84 | resolve(data);
85 | })
86 | .catch((err) => {
87 | reject(err);
88 | });
89 | });
90 | }
91 |
92 | /**
93 | * returns accounts in a simple array of objects
94 | * @param _addr the DSA address
95 | */
96 | async getAuthByAddress(_addr) {
97 | var _c = new this.web3.eth.Contract(
98 | this.ABI.read.core,
99 | this.address.read.core
100 | );
101 | return new Promise((resolve, reject) => {
102 | return _c.methods
103 | .getAccountAuthorities(_addr)
104 | .call({ from: this.address.genesis })
105 | .then((data) => {
106 | resolve(data);
107 | })
108 | .catch((err) => {
109 | reject(err);
110 | });
111 | });
112 | }
113 |
114 | /**
115 | * returns authorities with its type in a simple array of objects.
116 | * @param dsaAddr the DSA address
117 | */
118 | async getAuthoritiesTypes(dsaAddr) {
119 | var _c = new this.web3.eth.Contract(
120 | this.ABI.read.core,
121 | this.address.read.core
122 | );
123 | return new Promise((resolve, reject) => {
124 | return _c.methods
125 | .getAccountAuthoritiesTypes(dsaAddr)
126 | .call({ from: this.address.genesis })
127 | .then((data) => {
128 | resolve(data);
129 | })
130 | .catch((err) => {
131 | reject(err);
132 | });
133 | });
134 | }
135 | };
136 |
--------------------------------------------------------------------------------
/src/resolvers/chainlink.js:
--------------------------------------------------------------------------------
1 | module.exports = class Curve {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.tokens = _dsa.tokens;
9 | this.web3 = _dsa.web3;
10 | this.math = _dsa.math;
11 | this.dsa = _dsa;
12 | }
13 |
14 | /**
15 | * get token prices
16 | */
17 | async getTokenPrices() {
18 | var _tokenSyms = Object.values(this.tokens.getTokenByType("token")).map(
19 | (a) => a.symbol
20 | );
21 | var _obj = {
22 | protocol: "chainlink",
23 | method: "getPrice",
24 | args: [_tokenSyms],
25 | };
26 |
27 | return new Promise((resolve, reject) => {
28 | return this.dsa
29 | .read(_obj)
30 | .then((res) => {
31 | let _res = {};
32 | let ethPrice = res.ethPriceInUsd[0] / 10 ** res.ethPriceInUsd[1];
33 | _res.BTC = res.btcPriceInUsd[0] / 10 ** res.btcPriceInUsd[1];
34 | _res.ETH = ethPrice;
35 | _tokenSyms.forEach((sym, i) => {
36 | if (sym != "ETH") {
37 | let _priceData = res.tokensPriceInETH[i];
38 | _res[sym] = (_priceData[0] / 10 ** _priceData[1]) * ethPrice;
39 | }
40 | });
41 | resolve(_res);
42 | })
43 | .catch((err) => {
44 | reject(err);
45 | });
46 | });
47 | }
48 |
49 | /**
50 | * get gas price
51 | */
52 | async getFastGasPrice() {
53 | var _obj = {
54 | protocol: "chainlink",
55 | method: "getGasPrice",
56 | args: [],
57 | };
58 |
59 | return new Promise((resolve, reject) => {
60 | return this.dsa
61 | .read(_obj)
62 | .then((res) => {
63 | resolve(Number(res));
64 | })
65 | .catch((err) => {
66 | reject(err);
67 | });
68 | });
69 | }
70 | };
71 |
--------------------------------------------------------------------------------
/src/resolvers/compound.js:
--------------------------------------------------------------------------------
1 | module.exports = class Compound {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.tokens = _dsa.tokens;
9 | this.web3 = _dsa.web3;
10 | this.instance = _dsa.instance;
11 | this.dsa = _dsa;
12 | }
13 |
14 | /**
15 | * get the root underlying token symbol of ctoken
16 | * @param {String} cTokenSymbol the ctoken symbol
17 | */
18 | ctokenMap(cTokenSymbol) {
19 | const cTokens = this.tokens.getList({ type: "ctoken" });
20 | for (const key in cTokens) {
21 | if (cTokens[key].symbol === cTokenSymbol) {
22 | return cTokens[key].root;
23 | }
24 | }
25 | }
26 |
27 | getCtokens() {
28 | var _tokens = this.tokens.info;
29 | var _ctokens = {};
30 | Object.keys(_tokens).forEach((_token, i) => {
31 | if (_tokens[_token].type == "ctoken") _ctokens[_token] = _tokens[_token];
32 | });
33 | return _ctokens;
34 | }
35 |
36 | getCtokensAddresses(_ctokens) {
37 | if (!_ctokens) _ctokens = getCtokens();
38 | var _cAddresses = [];
39 | Object.keys(_ctokens).forEach((_key, i) => {
40 | _cAddresses.push(_ctokens[_key].address);
41 | });
42 | return _cAddresses;
43 | }
44 |
45 | /**
46 | * get properly formatted compound position details
47 | * @param {string} address the owner address
48 | * @param {string} key (optional) default - "token". Options:- "ctoken", "caddress", "address". key of object to return
49 | * @param {string} cTokens the cToken address
50 | */
51 | getPosition(address, key) {
52 | var _address;
53 | !address ? (_address = this.instance.address) : (_address = address);
54 | var _ctokens = this.getCtokens();
55 | var _cAddresses = this.getCtokensAddresses(_ctokens);
56 | var _obj = {
57 | protocol: "compound",
58 | method: "getPosition",
59 | args: [_address, _cAddresses],
60 | };
61 | return new Promise(async (resolve, reject) => {
62 | await this.dsa
63 | .read(_obj)
64 | .then((res) => {
65 | var _position = {};
66 | var _totalSupplyInEth = 0;
67 | var _totalBorrowInEth = 0;
68 | var _maxBorrowLimitInEth = 0;
69 | Object.keys(_ctokens).forEach((_ctoken, i) => {
70 | var _root = _ctokens[_ctoken].root;
71 | var _key;
72 | key == "ctoken"
73 | ? (_key = _ctoken)
74 | : key == "caddress"
75 | ? (_key = _ctokens[_ctoken].address)
76 | : key == "address"
77 | ? (_key = this.tokens.info[_root].address)
78 | : (_key = _root);
79 | var _res = res[0][i];
80 | var _decimals = this.tokens.info[_ctokens[_ctoken].root].decimals;
81 | _position[_key] = {};
82 | var _priceInEth = _res[0] / 10 ** 18;
83 | var _priceInUsd = _res[1] / 10 ** 18;
84 | _position[_key].priceInEth = _priceInEth;
85 | _position[_key].priceInUsd = _priceInUsd;
86 | var _exchangeRate = _res[2] / 1e18;
87 | _position[_key].exchangeRate = _exchangeRate;
88 | _position[_key].ctknBalance = Number(_res[3]);
89 | var _supply = (_res[3] * _exchangeRate) / 10 ** _decimals;
90 | _position[_key].supply = _supply;
91 | _totalSupplyInEth += _supply * _priceInEth;
92 | _maxBorrowLimitInEth +=
93 | _supply * _priceInEth * _ctokens[_ctoken].factor;
94 | var _borrow = _res[4] / 10 ** _decimals;
95 | _position[_key].borrow = _borrow;
96 | _totalBorrowInEth += _borrow * _priceInEth;
97 | var _supplyRate = (_res[5] * 2102400) / 1e18;
98 | _position[_key].supplyRate = _supplyRate * 100; // Multiply with 100 to make it in percent
99 | var _supplyYield = (1 + _supplyRate / 365) ** 365 - 1;
100 | _position[_key].supplyYield = _supplyYield * 100; // Multiply with 100 to make it in percent
101 | var _borrowRate = (_res[6] * 2102400) / 1e18;
102 | _position[_key].borrowRate = _borrowRate * 100; // Multiply with 100 to make it in percent
103 | var _borrowYield = (1 + _borrowRate / 365) ** 365 - 1;
104 | _position[_key].borrowYield = _borrowYield * 100; // Multiply with 100 to make it in percent
105 | });
106 | _position.totalSupplyInEth = _totalSupplyInEth;
107 | _position.totalBorrowInEth = _totalBorrowInEth;
108 | _position.maxBorrowLimitInEth = _maxBorrowLimitInEth;
109 | var _status = _totalBorrowInEth / _totalSupplyInEth;
110 | _position.status = _status;
111 | var _liquidation = _maxBorrowLimitInEth / _totalSupplyInEth;
112 | _position.liquidation = _liquidation;
113 | _position.compBalance = res[1].balance / 10 ** 18;
114 | _position.compAccrued = res[1].allocated / 10 ** 18;
115 | _position.compDelegate = res[1].delegate;
116 | _position.compVotes = res[1].votes;
117 | resolve(_position);
118 | })
119 | .catch((err) => {
120 | reject(err);
121 | });
122 | });
123 | }
124 | };
125 |
--------------------------------------------------------------------------------
/src/resolvers/curve_claim.js:
--------------------------------------------------------------------------------
1 | module.exports = class Curve {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.tokens = _dsa.tokens;
9 | this.web3 = _dsa.web3;
10 | this.instance = _dsa.instance;
11 | this.math = _dsa.math;
12 | this.dsa = _dsa;
13 | }
14 |
15 | /**
16 | * get properly formatted Curve position details
17 | * @param {string} address the owner address
18 | */
19 | async getPosition(address) {
20 | var _address = !address ? this.instance.address : address;
21 |
22 | var _obj = {
23 | protocol: "curve_claim",
24 | method: "getPosition",
25 | args: [_address],
26 | };
27 |
28 | return new Promise((resolve, reject) => {
29 | return this.dsa
30 | .read(_obj)
31 | .then((res) => {
32 | let _position = {};
33 | _position.vestedBalance = this.tokens.toDecimal(res[0], "CRV");
34 | _position.unclaimedBalance = this.tokens.toDecimal(res[1], "CRV");
35 | _position.claimedBalance = res[2] / 10 ** 18;
36 | _position.lockedBalance = this.tokens.toDecimal(res[3], "CRV");
37 | _position.crvBalance = this.tokens.toDecimal(res[4], "CRV");
38 | resolve(_position);
39 | })
40 | .catch((err) => {
41 | reject(err);
42 | });
43 | });
44 | }
45 | };
46 |
--------------------------------------------------------------------------------
/src/resolvers/curve_gauge.js:
--------------------------------------------------------------------------------
1 | module.exports = class Curve {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.tokens = _dsa.tokens;
9 | this.web3 = _dsa.web3;
10 | this.instance = _dsa.instance;
11 | this.math = _dsa.math;
12 | this.dsa = _dsa;
13 | }
14 |
15 | /**
16 | * get properly formatted Curve position details
17 | * @param {string} address the owner address
18 | */
19 | async getPosition(address) {
20 | var _address = !address ? this.instance.address : address;
21 | var _pools = ["susd", "y", "sbtc"];
22 | var _poolReward = {
23 | susd: "snx",
24 | sbtc: "snx_ren",
25 | };
26 | var _obj = {
27 | protocol: "curve_gauge",
28 | method: "getPositions",
29 | args: [_pools.map((a) => `gauge-${a}`), _address],
30 | };
31 |
32 | return new Promise((resolve, reject) => {
33 | return this.dsa
34 | .read(_obj)
35 | .then((res) => {
36 | let _position = {};
37 | res.forEach((_res, i) => {
38 | let _pool = _pools[i];
39 | _position[_pool] = {
40 | stakedBalance: this.tokens.toDecimal(_res[0], `curve${_pool}`),
41 | crvEarned: this.tokens.toDecimal(_res[1], "crv"),
42 | crvClaimed: this.tokens.toDecimal(_res[2], "crv"),
43 | crvBalance: this.tokens.toDecimal(_res[5], "crv"),
44 | };
45 | _position[_pool].crvUnclaimed =
46 | _position[_pool].crvEarned - _position[_pool].crvClaimed;
47 |
48 | if (_res[7]) {
49 | _position[_pool].rewardClaimed = this.tokens.toDecimal(
50 | _res[4],
51 | _poolReward[_pool]
52 | );
53 | _position[_pool].rewardEarned = this.tokens.toDecimal(
54 | _res[3],
55 | _poolReward[_pool]
56 | );
57 | _position[_pool].rewardBalance = this.tokens.toDecimal(
58 | _res[6],
59 | _poolReward[_pool]
60 | );
61 | _position[_pool].rewardToken = _poolReward[_pool];
62 | _position[_pool].rewardsUnclaimed =
63 | _position[_pool].rewardEarned - _position[_pool].rewardClaimed;
64 | }
65 | });
66 | resolve(_position);
67 | })
68 | .catch((err) => {
69 | reject(err);
70 | });
71 | });
72 | }
73 | };
74 |
--------------------------------------------------------------------------------
/src/resolvers/curve_three.js:
--------------------------------------------------------------------------------
1 | module.exports = class CurveThree {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.tokens = _dsa.tokens;
9 | this.web3 = _dsa.web3;
10 | this.instance = _dsa.instance;
11 | this.math = _dsa.math;
12 | this.dsa = _dsa;
13 | }
14 |
15 | /**
16 | * returns buy/dest amount and unit Amount
17 | * @param buyToken buy token symbol
18 | * @param sellToken sell token symbol
19 | * @param sellAmt sell token amount in decimal
20 | * @param slippage slippage of trade
21 | */
22 | async getBuyAmount(buyToken, sellToken, sellAmt, slippage) {
23 | let _slippage = !slippage ? 10 ** 16 : slippage * 10 ** 16;
24 | _slippage = String(this.math.bigNumInString(_slippage));
25 |
26 | var _obj = {
27 | protocol: "curve_three",
28 | method: "getBuyAmount",
29 | args: [
30 | this.tokens.info[buyToken.toLowerCase()].address,
31 | this.tokens.info[sellToken.toLowerCase()].address,
32 | this.tokens.fromDecimal(sellAmt, sellToken),
33 | this.math.bigNumInString(_slippage),
34 | ],
35 | };
36 |
37 | return new Promise((resolve, reject) => {
38 | return this.dsa
39 | .read(_obj)
40 | .then((res) => {
41 | var _res = {
42 | buyAmt: this.tokens.toDecimal(res[0], buyToken),
43 | buyAmtRaw: res[0],
44 | virtualPrice: res[2] / 10 ** 18,
45 | unitAmt: res[1],
46 | };
47 | resolve(_res);
48 | })
49 | .catch((err) => {
50 | reject(err);
51 | });
52 | });
53 | }
54 | };
55 |
--------------------------------------------------------------------------------
/src/resolvers/dydx.js:
--------------------------------------------------------------------------------
1 | var markets = {
2 | "0": {
3 | name: "eth",
4 | factor: 10 / 11.5,
5 | },
6 | "2": {
7 | name: "usdc",
8 | factor: 10 / 11.5,
9 | },
10 | "3": {
11 | name: "dai",
12 | factor: 10 / 11.5,
13 | },
14 | };
15 |
16 | module.exports = class Dydx {
17 | /**
18 | * @param {Object} _dsa the dsa instance to access data stores
19 | */
20 | constructor(_dsa) {
21 | this.ABI = _dsa.ABI;
22 | this.address = _dsa.address;
23 | this.tokens = _dsa.tokens;
24 | this.web3 = _dsa.web3;
25 | this.instance = _dsa.instance;
26 | this.dsa = _dsa;
27 | }
28 |
29 | /**
30 | * get properly formatted Curve position details
31 | * @param {string} address the owner address
32 | * @param {string} key (optional) default - "token". Options:- "market", "address". key of object to return
33 | */
34 | async getPosition(address, key) {
35 | var _address;
36 | !address ? (_address = this.instance.address) : (_address = address);
37 |
38 | var _markets = Object.keys(markets);
39 | var _obj = {
40 | protocol: "dydx",
41 | method: "getPosition",
42 | args: [_address, _markets],
43 | };
44 |
45 | return new Promise((resolve, reject) => {
46 | return this.dsa
47 | .read(_obj)
48 | .then((res) => {
49 | var _position = {};
50 | var _totalSupplyInEth = 0;
51 | var _totalBorrowInEth = 0;
52 | var _maxBorrowLimitInEth = 0;
53 | var _ethPrice = res[0][0] / 10 ** 18;
54 | _markets.forEach((market, i) => {
55 | var _tokenName = markets[market].name;
56 | var _decimals = this.tokens.info[_tokenName].decimals;
57 | var _res = res[i];
58 | var _key =
59 | key == "market"
60 | ? market
61 | : key == "address"
62 | ? this.tokens.info[_tokenName].address
63 | : _tokenName;
64 |
65 | _position[_key] = {};
66 |
67 | _position[_key].price = _res[0] / 10 ** (18 + (18 - _decimals));
68 | var _priceInEth = _position[_key].price / _ethPrice;
69 |
70 | var _supply = this.tokens.toDecimal(_res[1], _tokenName);
71 | var _borrow = this.tokens.toDecimal(_res[2], _tokenName);
72 | _position[_key].supply = _supply;
73 | _position[_key].borrow = _borrow;
74 |
75 | _totalSupplyInEth += _supply * _priceInEth;
76 | _maxBorrowLimitInEth +=
77 | _supply * _priceInEth * markets[market].factor;
78 | _totalBorrowInEth += _borrow * _priceInEth;
79 |
80 | var tokenUtil = _res[3] / 10 ** 18;
81 | var borrowRate =
82 | 0.1 * tokenUtil + 0.1 * tokenUtil ** 32 + 0.3 * tokenUtil ** 64;
83 | var suppyRate = 0.95 * borrowRate * tokenUtil;
84 | var borrowYeild = (1 + borrowRate / 365) ** 365 - 1;
85 | var supplyYield = (1 + suppyRate / 365) ** 365 - 1;
86 | _position[_key].borrowRate = borrowRate * 100;
87 | _position[_key].borrowYield = borrowYeild * 100;
88 | _position[_key].SupplyRate = suppyRate * 100;
89 | _position[_key].supplyYield = supplyYield * 100;
90 | });
91 | _position.totalSupplyInEth = _totalSupplyInEth;
92 | _position.totalBorrowInEth = _totalBorrowInEth;
93 | _position.maxBorrowLimitInEth = _maxBorrowLimitInEth;
94 | var _status = _totalBorrowInEth / _totalSupplyInEth;
95 | _position.status = _status;
96 | var _liquidation = _maxBorrowLimitInEth / _totalSupplyInEth;
97 | _position.liquidation = _liquidation;
98 | resolve(_position);
99 | })
100 | .catch((err) => {
101 | reject(err);
102 | });
103 | });
104 | }
105 | };
106 |
--------------------------------------------------------------------------------
/src/resolvers/dydxFlashloan.js:
--------------------------------------------------------------------------------
1 | module.exports = class DydxFlashLoan {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.web3 = _dsa.web3;
7 | this.address = _dsa.address;
8 | this.dsa = _dsa;
9 | this.internal = _dsa.internal;
10 | this.tokens = _dsa.tokens;
11 | }
12 |
13 | async getLiquidity() {
14 | var dydxSoloAddr = "0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e";
15 | var wethAddr = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
16 | var daiAddr = this.tokens.info.dai.address;
17 | var usdcAddr = this.tokens.info.usdc.address;
18 | var _obj = {
19 | protocol: "erc20",
20 | method: "getBalances",
21 | args: [dydxSoloAddr, [wethAddr, daiAddr, usdcAddr]],
22 | };
23 |
24 | return new Promise((resolve, reject) => {
25 | return this.dsa
26 | .read(_obj)
27 | .then((res) => {
28 | var _max = 0.99;
29 | var _liquidityAvailable = {
30 | eth: this.tokens.toDecimal(res[0], "eth") * _max,
31 | dai: this.tokens.toDecimal(res[1], "dai") * _max,
32 | usdc: this.tokens.toDecimal(res[2], "usdc") * _max,
33 | };
34 | resolve(_liquidityAvailable);
35 | })
36 | .catch((err) => {
37 | reject(err);
38 | });
39 | });
40 | }
41 |
42 | encodeFlashCastData(token, amount, spells) {
43 | if (!token) throw new Error(`'token' not defined`);
44 | if (!amount) throw new Error(`'amount' not defined`);
45 |
46 | let encodeSpellsData = this.internal.encodeSpells(spells);
47 | let argTypes = ["address", "uint256", "address[]", "bytes[]"];
48 | return this.web3.eth.abi.encodeParameters(argTypes, [
49 | token,
50 | amount,
51 | encodeSpellsData[0],
52 | encodeSpellsData[1],
53 | ]);
54 | }
55 | };
56 |
--------------------------------------------------------------------------------
/src/resolvers/erc20.js:
--------------------------------------------------------------------------------
1 | module.exports = class ERC20 {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.tokens = _dsa.tokens;
9 | this.web3 = _dsa.web3;
10 | this.instance = _dsa.instance;
11 | this.dsa = _dsa;
12 | }
13 |
14 | /**
15 | * returns token balances.
16 | */
17 | async getBalances(address, type) {
18 | var _address;
19 | !address ? (_address = this.instance.address) : (_address = address);
20 |
21 | var _type;
22 | type ? (_type = type) : (_type = "token");
23 |
24 | const _tokens = this.tokens.getTokenByType(_type);
25 |
26 | var _tokensAddr = this.tokens.getTokensField("address", _tokens);
27 |
28 | var _obj = {
29 | protocol: "erc20",
30 | method: "getBalances",
31 | args: [_address, Object.values(_tokensAddr)],
32 | };
33 |
34 | return new Promise((resolve, reject) => {
35 | return this.dsa
36 | .read(_obj)
37 | .then((res) => {
38 | var _balances = {};
39 | Object.keys(_tokens).forEach((key, i) => {
40 | _balances[key] = res[i] / 10 ** _tokens[key].decimals;
41 | });
42 | resolve(_balances);
43 | })
44 | .catch((err) => {
45 | reject(err);
46 | });
47 | });
48 | }
49 |
50 | /**
51 | * returns token allowances.
52 | */
53 | async getAllowances(address, spender, type) {
54 | var _address = !address ? this.instance.address : address;
55 | if (!spender) throw new Error("`spender` not defined.");
56 |
57 | var _type = type ? type : "token";
58 | const _tokens = this.tokens.getTokenByType(_type);
59 |
60 | var _tokensAddr = this.tokens.getTokensField("address", _tokens);
61 |
62 | var _obj = {
63 | protocol: "erc20",
64 | method: "getAllowances",
65 | args: [_address, spender, Object.values(_tokensAddr)],
66 | };
67 |
68 | return new Promise((resolve, reject) => {
69 | return this.dsa
70 | .read(_obj)
71 | .then((res) => {
72 | var _allowance = {};
73 | Object.keys(_tokens).forEach((key, i) => {
74 | _allowance[key] = res[i] / 10 ** _tokens[key].decimals;
75 | });
76 | resolve(_allowance);
77 | })
78 | .catch((err) => {
79 | reject(err);
80 | });
81 | });
82 | }
83 | };
84 |
--------------------------------------------------------------------------------
/src/resolvers/instapool.js:
--------------------------------------------------------------------------------
1 | module.exports = class InstaPool {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.web3 = _dsa.web3;
7 | this.address = _dsa.address;
8 | this.compound = _dsa.compound;
9 | this.dsa = _dsa;
10 | }
11 |
12 | async getLiquidity() {
13 | return new Promise(async (resolve, reject) => {
14 | await this.compound
15 | .getPosition(this.address.core.instapool, "token")
16 | .then((_position) => {
17 | var _maxBorrowLimitInEth = _position.maxBorrowLimitInEth * 0.995;
18 | var _liquidityAvailable = {
19 | eth: _maxBorrowLimitInEth,
20 | dai: _maxBorrowLimitInEth / _position.dai.priceInEth,
21 | usdc: _maxBorrowLimitInEth / _position.usdc.priceInEth,
22 | usdt: _maxBorrowLimitInEth / _position.usdt.priceInEth,
23 | bat: _maxBorrowLimitInEth / _position.bat.priceInEth,
24 | zrx: _maxBorrowLimitInEth / _position.zrx.priceInEth,
25 | wbtc: _maxBorrowLimitInEth / _position.wbtc.priceInEth,
26 | rep: _maxBorrowLimitInEth / _position.rep.priceInEth,
27 | };
28 | resolve(_liquidityAvailable);
29 | })
30 | .catch((err) => {
31 | reject(err);
32 | });
33 | });
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/src/resolvers/instapool_v2.js:
--------------------------------------------------------------------------------
1 | module.exports = class DydxFlashLoan {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.web3 = _dsa.web3;
7 | this.address = _dsa.address;
8 | this.dsa = _dsa;
9 | this.internal = _dsa.internal;
10 | this.tokens = _dsa.tokens;
11 | }
12 |
13 | async getLiquidity(tokensArr) {
14 | let _tokens = [];
15 | let _tokensAddrArr = [];
16 | if (tokensArr) {
17 | tokensArr.forEach((x) => {
18 | let token = this.tokens.info[x.toLowerCase()];
19 | if (!token) `${x} not found in sdk token list`;
20 | _tokensAddrArr.push(token.address);
21 | _tokens.push(x.toLowerCase());
22 | });
23 | } else {
24 | let _atoken = this.tokens.getTokenByType("atoken");
25 | _tokens = Object.values(_atoken).map((a) => a.root);
26 | let _ctoken = this.tokens.getTokenByType("ctoken");
27 | let _ctokenRoot = Object.values(_ctoken)
28 | .filter((a) => _tokens.indexOf(a.root) === -1)
29 | .map((a) => a.root);
30 | _tokens = [..._tokens, ..._ctokenRoot];
31 | _tokensAddrArr = _tokens.map((b) => this.tokens.info[b].address);
32 | }
33 | var _obj = {
34 | protocol: "instapool_v2",
35 | method: "getTokensLimit",
36 | args: [_tokensAddrArr],
37 | };
38 |
39 | return new Promise((resolve, reject) => {
40 | return this.dsa
41 | .read(_obj)
42 | .then((res) => {
43 | let _liquidityAvailable = {};
44 | _tokens.forEach((token, i) => {
45 | _liquidityAvailable[token] = {
46 | dydx: this.tokens.toDecimal(res[i].dydx, token),
47 | aave: res[i].aave / 1e18,
48 | maker: res[i].maker / 1e18,
49 | compound: res[i].compound / 1e18,
50 | };
51 | });
52 | resolve(_liquidityAvailable);
53 | })
54 | .catch((err) => {
55 | reject(err);
56 | });
57 | });
58 | }
59 |
60 | encodeFlashCastData(spells) {
61 | let encodeSpellsData = this.internal.encodeSpells(spells);
62 | let argTypes = ["address[]", "bytes[]"];
63 | return this.web3.eth.abi.encodeParameters(argTypes, [
64 | encodeSpellsData[0],
65 | encodeSpellsData[1],
66 | ]);
67 | }
68 | };
69 |
--------------------------------------------------------------------------------
/src/resolvers/kyber.js:
--------------------------------------------------------------------------------
1 | module.exports = class Kyber {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.tokens = _dsa.tokens;
9 | this.web3 = _dsa.web3;
10 | this.instance = _dsa.instance;
11 | this.math = _dsa.math;
12 | this.internal = _dsa.internal;
13 | this.erc20 = _dsa.erc20;
14 | this.dsa = _dsa;
15 | }
16 |
17 | /**
18 | * returns buy/dest amount and unit Amount
19 | * @param buyToken buy token symbol
20 | * @param sellToken sell token symbol
21 | * @param sellAmt sell token amount in decimal
22 | * @param slippage slippage of trade
23 | */
24 | async getBuyAmount(buyToken, sellToken, sellAmt, slippage) {
25 | let _slippage = !slippage ? 10 ** 16 : slippage * 10 ** 16;
26 | _slippage = String(this.math.bigNumInString(_slippage));
27 |
28 | let _sellToken = this.tokens.isToken(sellToken);
29 | let _sellAmount = !_sellToken
30 | ? await this.erc20.fromDecimalInternal(sellAmt, sellToken)
31 | : this.tokens.fromDecimal(sellAmt, _sellToken);
32 |
33 | var _obj = {
34 | protocol: "kyber",
35 | method: "getBuyAmount",
36 | args: [
37 | this.internal.filterAddress(buyToken),
38 | this.internal.filterAddress(sellToken),
39 | _sellAmount,
40 | this.math.bigNumInString(_slippage),
41 | ],
42 | };
43 |
44 | return new Promise((resolve, reject) => {
45 | return this.dsa
46 | .read(_obj)
47 | .then(async (res) => {
48 | let _buyToken = this.tokens.isToken(buyToken);
49 | let _buyAmt = !_buyToken
50 | ? await this.erc20.toDecimalInternal(res[0], buyToken)
51 | : this.tokens.toDecimal(res[0], _buyToken);
52 |
53 | var _res = {
54 | buyAmt: _buyAmt,
55 | buyAmtRaw: res[0],
56 | unitAmt: res[1],
57 | };
58 | resolve(_res);
59 | })
60 | .catch((err) => {
61 | reject(err);
62 | });
63 | });
64 | }
65 | };
66 |
--------------------------------------------------------------------------------
/src/resolvers/oasis.js:
--------------------------------------------------------------------------------
1 | module.exports = class Oasis {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | this.ABI = _dsa.ABI;
7 | this.address = _dsa.address;
8 | this.tokens = _dsa.tokens;
9 | this.math = _dsa.math;
10 | this.web3 = _dsa.web3;
11 | this.instance = _dsa.instance;
12 | this.dsa = _dsa;
13 | }
14 |
15 | /**
16 | * returns buy/dest amount and unit Amount
17 | * @param buyToken buy token symbol
18 | * @param sellToken sell token symbol
19 | * @param sellAmt sell token amount in decimal
20 | * @param slippage slippage of trade
21 | */
22 | async getBuyAmount(buyToken, sellToken, sellAmt, slippage) {
23 | let _slippage = !slippage ? 10 ** 16 : slippage * 10 ** 16;
24 | _slippage = String(this.math.bigNumInString(_slippage));
25 |
26 | var _obj = {
27 | protocol: "oasis",
28 | method: "getBuyAmount",
29 | args: [
30 | this.tokens.info[buyToken.toLowerCase()].address,
31 | this.tokens.info[sellToken.toLowerCase()].address,
32 | this.tokens.fromDecimal(sellAmt, sellToken),
33 | this.math.bigNumInString(_slippage),
34 | ],
35 | };
36 |
37 | return new Promise((resolve, reject) => {
38 | return this.dsa
39 | .read(_obj)
40 | .then((res) => {
41 | var _res = {
42 | buyAmt: this.tokens.toDecimal(res[0], buyToken),
43 | buyAmtRaw: res[0],
44 | unitAmt: res[1],
45 | };
46 | resolve(_res);
47 | })
48 | .catch((err) => {
49 | reject(err);
50 | });
51 | });
52 | }
53 |
54 | /**
55 | * returns sell/src amount and unit Amount
56 | * @param buyToken buy token symbol
57 | * @param sellToken sell token symbol
58 | * @param buyAmt buy token amount in decimal
59 | * @param slippage slippage of trade
60 | */
61 | async getSellAmount(buyToken, sellToken, buyAmt, slippage) {
62 | let _slippage = !slippage ? 10 ** 16 : slippage * 10 ** 16;
63 | _slippage = String(this.math.bigNumInString(_slippage));
64 |
65 | var _obj = {
66 | protocol: "oasis",
67 | method: "getSellAmount",
68 | args: [
69 | this.tokens.info[buyToken.toLowerCase()].address,
70 | this.tokens.info[sellToken.toLowerCase()].address,
71 | this.tokens.fromDecimal(buyAmt, buyToken),
72 | this.math.bigNumInString(_slippage),
73 | ],
74 | };
75 |
76 | return new Promise((resolve, reject) => {
77 | return this.dsa
78 | .read(_obj)
79 | .then((res) => {
80 | var _res = {
81 | sellAmt: this.tokens.toDecimal(res[0], sellToken),
82 | sellAmtRaw: res[0],
83 | unitAmt: res[1],
84 | };
85 | resolve(_res);
86 | })
87 | .catch((err) => {
88 | reject(err);
89 | });
90 | });
91 | }
92 | };
93 |
--------------------------------------------------------------------------------
/src/resolvers/tokens.js:
--------------------------------------------------------------------------------
1 | module.exports = class Tokens {
2 | /**
3 | * @param {Object} _dsa the dsa instance to access data stores
4 | */
5 | constructor(_dsa) {
6 | /**
7 | * @param type
8 | * @param symbol
9 | * @param name
10 | * @param address
11 | * @param decimal
12 | * @param factor (optional) collateral factor, used in ctokens
13 | * @param root (optional) underlying token, used in ctokens
14 | */
15 | this.info = require("../constant/tokensInfo.json");
16 | this.web3 = _dsa.web3;
17 | this.math = _dsa.math;
18 | }
19 |
20 | /**
21 | * Returns token amount in wei.
22 | * @param {Number | String} amount - Amount to convert.
23 | * @param {String} tokenName - Token Symbol.
24 | * @returns {String} Amount in bigNumInString format.
25 | */
26 | fromDecimal(amount, tokenName) {
27 | if (Object.keys(this.info).indexOf(tokenName.toLowerCase()) == -1)
28 | throw new Error("'token' symbol not found.");
29 | var token = this.info[tokenName.toLowerCase()];
30 | return this.math.bigNumInString(
31 | (Number(amount) * 10 ** token.decimals).toFixed(0)
32 | );
33 | }
34 |
35 | /**
36 | * Returns token amount in decimal.
37 | * @param {Number | String} amount - Amount to convert.
38 | * @param {String} tokenName - Token Symbol.
39 | * @returns {Number} Amount in decimal.
40 | */
41 | toDecimal(amount, tokenName) {
42 | if (Object.keys(this.info).indexOf(tokenName.toLowerCase()) == -1)
43 | throw new Error("'token' symbol not found.");
44 | var token = this.info[tokenName.toLowerCase()];
45 | return Number(amount) / 10 ** token.decimals;
46 | }
47 |
48 | /**
49 | * Returns token amount in wei.
50 | * @param {String | address} token - Token.
51 | * @returns {Bool}
52 | */
53 | isToken(token) {
54 | var isAddress = this.web3.utils.isAddress(token.toLowerCase());
55 | let tokenInfo = this.info;
56 | if (isAddress) {
57 | return Object.keys(tokenInfo).filter(
58 | (_token) =>
59 | tokenInfo[_token].address.toLowerCase() == token.toLowerCase()
60 | )[0];
61 | } else {
62 | if (Object.keys(tokenInfo).indexOf(token.toLowerCase()) == -1)
63 | return false;
64 | return token.toLowerCase();
65 | }
66 | }
67 |
68 | /**
69 | * Returns all tokens of similar type.
70 | * if type == "all" then returns whole tokens list.
71 | */
72 | getTokenByType(type) {
73 | var tokens = this.info;
74 | var _tokens = {};
75 | if (type == "all") {
76 | _tokens = tokens;
77 | } else {
78 | Object.keys(tokens).forEach((key, i) => {
79 | if (tokens[key].type == type) _tokens[key] = tokens[key];
80 | });
81 | }
82 | return _tokens;
83 | }
84 |
85 | /**
86 | * Returns token mapping with specific field in it.
87 | * @param {String} field - if field is address then below
88 | * eg:- {eth: {symbol: "ETH", address: "0x"}} => {eth: "0x"}
89 | * @returns {JSON}
90 | */
91 | getTokensField(field, tokens) {
92 | if (!tokens) tokens = this.info;
93 | var _field = {};
94 | Object.keys(tokens).forEach((key, i) => {
95 | _field[key] = tokens[key][field];
96 | });
97 | return _field;
98 | }
99 |
100 | /**
101 | * Returns a list of token objects filtered by the type
102 | */
103 | getList({ type = null }) {
104 | return Object.keys(this.info).reduce((list, key) => {
105 | if (this.info[key].type != type) {
106 | return list;
107 | }
108 | list.push(this.info[key]);
109 | return list;
110 | }, []);
111 | }
112 |
113 | /**
114 | * Returns a list filtered by the token type and the field needed
115 | * example: getData({type:"ctoken",field:"address"}) will return all the ctoken addresses in a list
116 | */
117 | getDataList({ type = null, field = null }) {
118 | return Object.values(this.info)
119 | .filter((a) => {
120 | return type ? a.type == type : true;
121 | })
122 | .map((a) => {
123 | return field ? a[field] : a;
124 | });
125 | }
126 | };
127 |
--------------------------------------------------------------------------------
/src/utils/cast.js:
--------------------------------------------------------------------------------
1 | /**
2 | * cast helpers
3 | */
4 | module.exports = class CastHelper {
5 | /**
6 | * @param {Object} _dsa the dsa instance to access data stores
7 | */
8 | constructor(_dsa) {
9 | this.ABI = _dsa.ABI;
10 | this.address = _dsa.address;
11 | this.internal = _dsa.internal;
12 | this.web3 = _dsa.web3;
13 | this.instance = _dsa.instance;
14 | this.origin = _dsa.origin;
15 | this.dsa = _dsa;
16 | }
17 |
18 | /**
19 | * returns cast encoded data
20 | * @param _d.connector the from address
21 | * @param _d.method the to address
22 | */
23 | encoded(_d) {
24 | var _internal = this.internal;
25 | var _args = _internal.encodeSpells(_d);
26 | return {
27 | targets: _args[0],
28 | spells: _args[1],
29 | };
30 | }
31 |
32 | /**
33 | * returns the estimate gas cost
34 | * @param _d.from the from address
35 | * @param _d.to the to address
36 | * @param _d.value eth value
37 | * @param _d.spells cast spells
38 | */
39 | async estimateGas(_d) {
40 | var _internal = this.internal;
41 | var _args = _internal.encodeSpells(_d);
42 | _args.push(this.origin);
43 | if (!_d.to) _d.to = this.instance.address;
44 | if (_d.to == this.address.genesis)
45 | throw new Error(
46 | `Please configure the DSA instance by calling dsa.setInstance(dsaId). More details: https://docs.instadapp.io/setup`
47 | );
48 | if (!_d.from) _d.from = await _internal.getAddress();
49 | if (!_d.value) _d.value = "0";
50 | var _abi = _internal.getInterface("core", "account", "cast");
51 | var _obj = {
52 | abi: _abi,
53 | args: _args,
54 | from: _d.from,
55 | to: _d.to,
56 | value: _d.value,
57 | };
58 | return new Promise((resolve, reject) => {
59 | _internal
60 | .estimateGas(_obj)
61 | .then((gas) => {
62 | resolve(gas);
63 | })
64 | .catch((err) => {
65 | reject(err);
66 | });
67 | });
68 | }
69 |
70 | /**
71 | * returns the encoded cast ABI byte code to send via a transaction or call.
72 | * @param _d the spells instance
73 | * OR
74 | * @param _d.spells the spells instance
75 | * @param _d.to (optional) the address of the smart contract to call
76 | * @param _d.origin (optional) the transaction origin source
77 | */
78 | encodeABI(_d) {
79 | let _enodedSpell = this.internal.encodeSpells(_d);
80 | if (!_d.to) _d.to = this.instance.address;
81 | if (_d.to == this.address.genesis)
82 | throw new Error(
83 | `Please configure the DSA instance by calling dsa.setInstance(dsaId). More details: https://docs.instadapp.io/setup`
84 | );
85 | if (!_d.origin) _d.origin = this.origin;
86 | let _contract = new this.web3.eth.Contract(this.ABI.core.account, _d.to);
87 | return _contract.methods.cast(..._enodedSpell, _d.origin).encodeABI();
88 | }
89 | };
90 |
--------------------------------------------------------------------------------
/src/utils/math.js:
--------------------------------------------------------------------------------
1 | module.exports = class MathHelpers {
2 | constructor(_dsa) {
3 | this.web3 = _dsa.web3;
4 | }
5 |
6 | divWithDec(num, power) {
7 | power = power ? power : 0;
8 | return Number(num) / 10 ** power;
9 | }
10 |
11 | bigNumInString(x) {
12 | if (Math.abs(x) < 1.0) {
13 | var e = parseInt(x.toString().split("e-")[1]);
14 | if (e) {
15 | x *= Math.pow(10, e - 1);
16 | x = "0." + new Array(e).join("0") + x.toString().substring(2);
17 | }
18 | } else {
19 | var e = parseInt(x.toString().split("+")[1]);
20 | if (e > 20) {
21 | e -= 20;
22 | x /= Math.pow(10, e);
23 | x += new Array(e + 1).join("0");
24 | }
25 | }
26 | return String(x);
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/src/utils/txn.js:
--------------------------------------------------------------------------------
1 | /**
2 | * txn helpers
3 | */
4 | module.exports = class TxnHelper {
5 | /**
6 | * @param {Object} _dsa the dsa instance to access data stores
7 | */
8 | constructor(_dsa) {
9 | this.ABI = _dsa.ABI;
10 | this.address = _dsa.address;
11 | this.internal = _dsa.internal;
12 | this.web3 = _dsa.web3;
13 | this.mode = _dsa.mode;
14 | this.privateKey = _dsa.privateKey;
15 | this.dsa = _dsa;
16 | }
17 |
18 | /**
19 | * to send transaction functions and get raw data return
20 | */
21 | async send(_h) {
22 | return new Promise((resolve, reject) => {
23 | if (_h.to == this.address.genesis)
24 | return reject(
25 | `Please configure the DSA instance by calling dsa.setInstance(dsaId). More details: https://docs.instadapp.io/setup`
26 | );
27 | if (this.mode == "node") {
28 | this.web3.eth.accounts
29 | .signTransaction(_h, this.privateKey)
30 | .then((rawTx) => {
31 | this.web3.eth
32 | .sendSignedTransaction(rawTx.rawTransaction)
33 | .on("transactionHash", (txHash) => {
34 | resolve(txHash);
35 | })
36 | .on("error", (error) => {
37 | reject(error);
38 | });
39 | });
40 | } else {
41 | this.web3.eth
42 | .sendTransaction(_h)
43 | .on("transactionHash", (txHash) => {
44 | resolve(txHash);
45 | })
46 | .on("error", (error) => {
47 | reject(error);
48 | });
49 | }
50 | });
51 | }
52 |
53 | /**
54 | * Cancel transaction.
55 | * @param {number} _h.nonce - transaction hash.
56 | * @param {number} _h.gasPrice - transaction hash.
57 | * @returns {String} transaction hash.
58 | */
59 | async cancel(_h) {
60 | if (!_h.nonce) reject("'nonce` not defined.");
61 | if (!_h.gasPrice) reject("'gasPrice` not defined.");
62 | return new Promise(async (resolve, reject) => {
63 | let _userAddr = await this.internal.getAddress();
64 | let _txObj = {
65 | from: _userAddr,
66 | to: _userAddr,
67 | value: 0,
68 | data: "0x",
69 | gasPrice: _h.gasPrice,
70 | gas: "27500",
71 | nonce: _h.nonce,
72 | };
73 | await this.send(_txObj)
74 | .then((data) => resolve(data))
75 | .catch((err) => reject(err));
76 | });
77 | }
78 |
79 | /**
80 | * Speed up transaction.
81 | * @param {String} _h.txHash - transaction hash.
82 | * @param {number} _h.gasPrice - transaction hash.
83 | * @returns {String} transaction hash.
84 | */
85 | async speedUp(_h) {
86 | return new Promise(async (resolve, reject) => {
87 | let _userAddr = await this.internal.getAddress();
88 | if (!_h.txHash) reject("'txHash` not defined.");
89 | if (!_h.gasPrice) reject("'gasPrice` not defined.");
90 | this.web3.eth
91 | .getTransaction(_h.txHash)
92 | .then(async (txData) => {
93 | if (txData.from.toLowerCase() != _userAddr.toLowerCase())
94 | reject("'from' address doesnt match.");
95 | let _txObj = {
96 | from: txData.from,
97 | to: txData.to,
98 | value: txData.value,
99 | data: txData.input,
100 | gasPrice: _h.gasPrice.toFixed(0),
101 | gas: txData.gas,
102 | nonce: txData.nonce,
103 | };
104 | await this.send(_txObj)
105 | .then((data) => resolve(data))
106 | .catch((err) => reject(err));
107 | })
108 | .catch((err) => reject(err));
109 | });
110 | }
111 |
112 | /**
113 | * Get transaction Nonce.
114 | * @param {string} tx - transaction hash to get nonce.
115 | */
116 | async getTxNonce(tx) {
117 | return new Promise(async (resolve, reject) => {
118 | this.web3.eth
119 | .getTransaction(tx)
120 | .then((_tx) => resolve(_tx.nonce))
121 | .catch((err) => reject(err));
122 | });
123 | }
124 |
125 | /**
126 | * Get transaction count.
127 | * @param {address} address - transaction count of address.
128 | */
129 | async getTxCount(address) {
130 | return new Promise(async (resolve, reject) => {
131 | this.web3.eth
132 | .getTransactionCount(address)
133 | .then((nonce) => resolve(nonce))
134 | .catch((err) => reject(err));
135 | });
136 | }
137 | };
138 |
--------------------------------------------------------------------------------
/test.md:
--------------------------------------------------------------------------------
1 | ## Test In Browser
2 |
3 | 1. Run `npm install` to install needed dependencies
4 | 2. Run `npm run dev-server` to start
5 | 3. Navigate to `localhost:8080`
6 | 4. Call `InitWeb3()` in debugger console
7 | 5. Access the DSA object via `window.dsa`
8 | 6. Note that you need to call dsa= new DSA(web3) again. (fix coming up)
--------------------------------------------------------------------------------
/webpack.config.dev.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const webpack = require('webpack');
3 | const getPackageJson = require('./scripts/getPackageJson');
4 | const HtmlWebpackPlugin = require("html-webpack-plugin");
5 |
6 | const {
7 | version,
8 | name,
9 | license,
10 | repository,
11 | author,
12 | } = getPackageJson('version', 'name', 'license', 'repository', 'author');
13 |
14 | const banner = `
15 | ${name} v${version}
16 | ${repository.url}
17 |
18 | Copyright (c) ${author.replace(/ *\<[^)]*\> */g, " ")}
19 |
20 | This source code is licensed under the ${license} license found in the
21 | LICENSE file in the root directory of this source tree.
22 | `;
23 |
24 | module.exports = {
25 | mode: "development",
26 | entry: './dev/app.js',
27 | output: {
28 | filename: 'dsa.js',
29 | path: path.resolve(__dirname, 'dist')
30 | },
31 | module: {
32 | rules: [
33 | {
34 | test: /\.m?js$/,
35 | exclude: /(node_modules|bower_components)/,
36 | use: {
37 | loader: 'babel-loader'
38 | }
39 | }
40 | ]
41 | },
42 | plugins: [
43 | new HtmlWebpackPlugin({
44 | hash: true,
45 | title: 'Testing Page For SDK',
46 | header: 'Use the console to test the DSA SDK',
47 | template: './dev/index.html',
48 | filename: 'index.html'
49 | }),
50 | new webpack.BannerPlugin(banner),
51 | ],
52 | devServer: {
53 | contentBase: './dist',
54 | port: 8080
55 | }
56 | }
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const webpack = require('webpack');
3 | const PrettierPlugin = require("prettier-webpack-plugin");
4 | const getPackageJson = require('./scripts/getPackageJson');
5 |
6 | const {
7 | version,
8 | name,
9 | license,
10 | repository,
11 | author,
12 | } = getPackageJson('version', 'name', 'license', 'repository', 'author');
13 |
14 | const banner = `
15 | ${name} v${version}
16 | ${repository.url}
17 |
18 | Copyright (c) ${author.replace(/ *\<[^)]*\> */g, " ")}
19 |
20 | This source code is licensed under the ${license} license found in the
21 | LICENSE file in the root directory of this source tree.
22 | `;
23 |
24 | module.exports = {
25 | mode: "production",
26 | entry: './src/index.js',
27 | output: {
28 | filename: 'dsa.min.js',
29 | path: path.resolve(__dirname, 'build'),
30 | library: 'DSA',
31 | libraryTarget: 'umd',
32 | globalObject: 'this'
33 | },
34 | module: {
35 | rules: [
36 | {
37 | test: /\.m?js$/,
38 | exclude: /(node_modules|bower_components)/,
39 | use: {
40 | loader: 'babel-loader'
41 | }
42 | }
43 | ]
44 | },
45 | plugins: [
46 | new PrettierPlugin(),
47 | new webpack.BannerPlugin(banner)
48 | ]
49 | };
--------------------------------------------------------------------------------