@instadapp/interop-x 0.0.0-dev.a9cd1d2 → 0.0.0-dev.acc4865
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/ci.yml +19 -0
- package/dist/package.json +3 -2
- package/dist/src/abi/connectors/index.js +36 -0
- package/dist/src/abi/connectors/v1/aave.js +148 -0
- package/dist/src/abi/connectors/v1/aave_claim.js +4 -0
- package/dist/src/abi/connectors/v1/aave_migrate.js +109 -0
- package/dist/src/abi/connectors/v1/aave_polygon_migrate.js +110 -0
- package/dist/src/abi/connectors/v1/aave_stake.js +4 -0
- package/dist/src/abi/connectors/v1/aave_v1_import.js +54 -0
- package/dist/src/abi/connectors/v1/aave_v2.js +230 -0
- package/dist/src/abi/connectors/v1/aave_v2_import.js +59 -0
- package/dist/src/abi/connectors/v1/authority.js +100 -0
- package/dist/src/abi/connectors/v1/basic.js +136 -0
- package/dist/src/abi/connectors/v1/chi.js +36 -0
- package/dist/src/abi/connectors/v1/comp.js +4 -0
- package/dist/src/abi/connectors/v1/compound.js +4 -0
- package/dist/src/abi/connectors/v1/compoundImport.js +69 -0
- package/dist/src/abi/connectors/v1/compoundImport_v2.js +4 -0
- package/dist/src/abi/connectors/v1/compound_old.js +448 -0
- package/dist/src/abi/connectors/v1/curve.js +140 -0
- package/dist/src/abi/connectors/v1/curve_claim.js +63 -0
- package/dist/src/abi/connectors/v1/curve_gauge.js +158 -0
- package/dist/src/abi/connectors/v1/curve_sbtc.js +140 -0
- package/dist/src/abi/connectors/v1/curve_susd.js +140 -0
- package/dist/src/abi/connectors/v1/curve_three.js +79 -0
- package/dist/src/abi/connectors/v1/curve_y.js +140 -0
- package/dist/src/abi/connectors/v1/dsa_migrate_v1_to_v2.js +4 -0
- package/dist/src/abi/connectors/v1/dydx.js +148 -0
- package/dist/src/abi/connectors/v1/dydx_flash.js +52 -0
- package/dist/src/abi/connectors/v1/fee.js +50 -0
- package/dist/src/abi/connectors/v1/gelato.js +1138 -0
- package/dist/src/abi/connectors/v1/index.js +58 -0
- package/dist/src/abi/connectors/v1/instapool.js +439 -0
- package/dist/src/abi/connectors/v1/instapool_v2.js +126 -0
- package/dist/src/abi/connectors/v1/kyber.js +117 -0
- package/dist/src/abi/connectors/v1/maker.js +480 -0
- package/dist/src/abi/connectors/v1/maker_old.js +300 -0
- package/dist/src/abi/connectors/v1/math.js +43 -0
- package/dist/src/abi/connectors/v1/migrate.js +46 -0
- package/dist/src/abi/connectors/v1/oasis.js +198 -0
- package/dist/src/abi/connectors/v1/oneInch.js +160 -0
- package/dist/src/abi/connectors/v1/polygon_bridge.js +4 -0
- package/dist/src/abi/connectors/v1/refinance.js +4 -0
- package/dist/src/abi/connectors/v1/staking.js +220 -0
- package/dist/src/abi/connectors/v1/swerve.js +179 -0
- package/dist/src/abi/connectors/v1/uniswap.js +297 -0
- package/dist/src/abi/connectors/v2/1INCH-A.js +4 -0
- package/dist/src/abi/connectors/v2/1INCH-B.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-CLAIM-A.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-CLAIM-B.js +166 -0
- package/dist/src/abi/connectors/v2/AAVE-STAKE-A.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-V1-A.js +130 -0
- package/dist/src/abi/connectors/v2/AAVE-V1-IMPORT-A.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-V2-A.js +230 -0
- package/dist/src/abi/connectors/v2/AAVE-V2-IMPORT-A.js +4 -0
- package/dist/src/abi/connectors/v2/AAVE-V2-IMPORT-B.js +225 -0
- package/dist/src/abi/connectors/v2/AUTHORITY-A.js +100 -0
- package/dist/src/abi/connectors/v2/B-COMPOUND-A.js +4 -0
- package/dist/src/abi/connectors/v2/B-LIQUITY-A.js +4 -0
- package/dist/src/abi/connectors/v2/B-MAKERDAO-A.js +4 -0
- package/dist/src/abi/connectors/v2/BASIC-A.js +136 -0
- package/dist/src/abi/connectors/v2/BASIC-B.js +4 -0
- package/dist/src/abi/connectors/v2/BASIC-C.js +4 -0
- package/dist/src/abi/connectors/v2/COMP-A.js +4 -0
- package/dist/src/abi/connectors/v2/COMPOUND-A.js +4 -0
- package/dist/src/abi/connectors/v2/COMPOUND-IMPORT-A.js +4 -0
- package/dist/src/abi/connectors/v2/COMPOUND-IMPORT-B.js +195 -0
- package/dist/src/abi/connectors/v2/G-UNISWAP-A.js +4 -0
- package/dist/src/abi/connectors/v2/GELATO-AAVE-A.js +4 -0
- package/dist/src/abi/connectors/v2/INST-A.js +4 -0
- package/dist/src/abi/connectors/v2/INST-LM-A.js +4 -0
- package/dist/src/abi/connectors/v2/INST-STAKING-A.js +4 -0
- package/dist/src/abi/connectors/v2/INST-STAKING-B.js +4 -0
- package/dist/src/abi/connectors/v2/INSTAPOOL-A.js +4 -0
- package/dist/src/abi/connectors/v2/LIQUITY-A.js +4 -0
- package/dist/src/abi/connectors/v2/MAKERDAO-A.js +4 -0
- package/dist/src/abi/connectors/v2/MAKERDAO-CLAIM-A.js +136 -0
- package/dist/src/abi/connectors/v2/PARASWAP-A.js +4 -0
- package/dist/src/abi/connectors/v2/POLYGON-BRIDGE-A.js +4 -0
- package/dist/src/abi/connectors/v2/REFINANCE-A.js +4 -0
- package/dist/src/abi/connectors/v2/REFLEXER-A.js +4 -0
- package/dist/src/abi/connectors/v2/STAKE-ERC20-A.js +4 -0
- package/dist/src/abi/connectors/v2/UNISWAP-A.js +297 -0
- package/dist/src/abi/connectors/v2/UNISWAP-V2-A.js +4 -0
- package/dist/src/abi/connectors/v2/UNISWAP-V3-A.js +4 -0
- package/dist/src/abi/connectors/v2/UNISWAP-V3-STAKE-A.js +4 -0
- package/dist/src/abi/connectors/v2/WETH-A.js +4 -0
- package/dist/src/abi/connectors/v2/YEARN-VAULT-A.js +4 -0
- package/dist/src/abi/connectors/v2/index.js +89 -0
- package/dist/src/abi/index.js +2 -0
- package/dist/src/constants/addresses.js +2 -0
- package/dist/src/constants/blockConfirmations.js +8 -0
- package/dist/src/constants/index.js +1 -0
- package/dist/src/db/models/transaction.js +2 -2
- package/dist/src/gnosis/actions/aaveV2/index.js +11 -0
- package/dist/src/gnosis/actions/aaveV2/source.js +62 -0
- package/dist/src/gnosis/actions/aaveV2/target.js +8 -0
- package/dist/src/gnosis/actions/index.js +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/net/protocol/dial/SignatureDialProtocol.js +2 -2
- package/dist/src/tasks/InteropX/ProcessSubmitSubmitEvents.js +168 -0
- package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +5 -3
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +4 -3
- package/dist/src/tasks/index.js +5 -0
- package/dist/src/utils/index.js +57 -30
- package/package.json +3 -2
- package/src/abi/connectors/index.ts +14 -0
- package/src/abi/connectors/v1/aave.ts +147 -0
- package/src/abi/connectors/v1/aave_claim.ts +3 -0
- package/src/abi/connectors/v1/aave_migrate.ts +108 -0
- package/src/abi/connectors/v1/aave_polygon_migrate.ts +109 -0
- package/src/abi/connectors/v1/aave_stake.ts +3 -0
- package/src/abi/connectors/v1/aave_v1_import.ts +53 -0
- package/src/abi/connectors/v1/aave_v2.ts +229 -0
- package/src/abi/connectors/v1/aave_v2_import.ts +58 -0
- package/src/abi/connectors/v1/authority.ts +99 -0
- package/src/abi/connectors/v1/basic.ts +135 -0
- package/src/abi/connectors/v1/chi.ts +35 -0
- package/src/abi/connectors/v1/comp.ts +3 -0
- package/src/abi/connectors/v1/compound.ts +3 -0
- package/src/abi/connectors/v1/compoundImport.ts +68 -0
- package/src/abi/connectors/v1/compoundImport_v2.ts +3 -0
- package/src/abi/connectors/v1/compound_old.ts +447 -0
- package/src/abi/connectors/v1/curve.ts +139 -0
- package/src/abi/connectors/v1/curve_claim.ts +62 -0
- package/src/abi/connectors/v1/curve_gauge.ts +157 -0
- package/src/abi/connectors/v1/curve_sbtc.ts +139 -0
- package/src/abi/connectors/v1/curve_susd.ts +139 -0
- package/src/abi/connectors/v1/curve_three.ts +78 -0
- package/src/abi/connectors/v1/curve_y.ts +139 -0
- package/src/abi/connectors/v1/dsa_migrate_v1_to_v2.ts +3 -0
- package/src/abi/connectors/v1/dydx.ts +147 -0
- package/src/abi/connectors/v1/dydx_flash.ts +51 -0
- package/src/abi/connectors/v1/fee.ts +49 -0
- package/src/abi/connectors/v1/gelato.ts +1137 -0
- package/src/abi/connectors/v1/index.ts +42 -0
- package/src/abi/connectors/v1/instapool.ts +438 -0
- package/src/abi/connectors/v1/instapool_v2.ts +125 -0
- package/src/abi/connectors/v1/kyber.ts +116 -0
- package/src/abi/connectors/v1/maker.ts +479 -0
- package/src/abi/connectors/v1/maker_old.ts +299 -0
- package/src/abi/connectors/v1/math.ts +42 -0
- package/src/abi/connectors/v1/migrate.ts +45 -0
- package/src/abi/connectors/v1/oasis.ts +197 -0
- package/src/abi/connectors/v1/oneInch.ts +159 -0
- package/src/abi/connectors/v1/polygon_bridge.ts +3 -0
- package/src/abi/connectors/v1/refinance.ts +3 -0
- package/src/abi/connectors/v1/staking.ts +219 -0
- package/src/abi/connectors/v1/swerve.ts +178 -0
- package/src/abi/connectors/v1/uniswap.ts +297 -0
- package/src/abi/connectors/v2/1INCH-A.ts +3 -0
- package/src/abi/connectors/v2/1INCH-B.ts +3 -0
- package/src/abi/connectors/v2/AAVE-CLAIM-A.ts +3 -0
- package/src/abi/connectors/v2/AAVE-CLAIM-B.ts +165 -0
- package/src/abi/connectors/v2/AAVE-STAKE-A.ts +3 -0
- package/src/abi/connectors/v2/AAVE-V1-A.ts +130 -0
- package/src/abi/connectors/v2/AAVE-V1-IMPORT-A.ts +3 -0
- package/src/abi/connectors/v2/AAVE-V2-A.ts +229 -0
- package/src/abi/connectors/v2/AAVE-V2-IMPORT-A.ts +3 -0
- package/src/abi/connectors/v2/AAVE-V2-IMPORT-B.ts +224 -0
- package/src/abi/connectors/v2/AUTHORITY-A.ts +99 -0
- package/src/abi/connectors/v2/B-COMPOUND-A.ts +3 -0
- package/src/abi/connectors/v2/B-LIQUITY-A.ts +3 -0
- package/src/abi/connectors/v2/B-MAKERDAO-A.ts +3 -0
- package/src/abi/connectors/v2/BASIC-A.ts +135 -0
- package/src/abi/connectors/v2/BASIC-B.ts +3 -0
- package/src/abi/connectors/v2/BASIC-C.ts +3 -0
- package/src/abi/connectors/v2/COMP-A.ts +3 -0
- package/src/abi/connectors/v2/COMPOUND-A.ts +3 -0
- package/src/abi/connectors/v2/COMPOUND-IMPORT-A.ts +3 -0
- package/src/abi/connectors/v2/COMPOUND-IMPORT-B.ts +194 -0
- package/src/abi/connectors/v2/G-UNISWAP-A.ts +3 -0
- package/src/abi/connectors/v2/GELATO-AAVE-A.ts +3 -0
- package/src/abi/connectors/v2/INST-A.ts +3 -0
- package/src/abi/connectors/v2/INST-LM-A.ts +3 -0
- package/src/abi/connectors/v2/INST-STAKING-A.ts +3 -0
- package/src/abi/connectors/v2/INST-STAKING-B.ts +3 -0
- package/src/abi/connectors/v2/INSTAPOOL-A.ts +3 -0
- package/src/abi/connectors/v2/LIQUITY-A.ts +3 -0
- package/src/abi/connectors/v2/MAKERDAO-A.ts +3 -0
- package/src/abi/connectors/v2/MAKERDAO-CLAIM-A.ts +135 -0
- package/src/abi/connectors/v2/PARASWAP-A.ts +3 -0
- package/src/abi/connectors/v2/POLYGON-BRIDGE-A.ts +3 -0
- package/src/abi/connectors/v2/REFINANCE-A.ts +3 -0
- package/src/abi/connectors/v2/REFLEXER-A.ts +3 -0
- package/src/abi/connectors/v2/STAKE-ERC20-A.ts +3 -0
- package/src/abi/connectors/v2/UNISWAP-A.ts +297 -0
- package/src/abi/connectors/v2/UNISWAP-V2-A.ts +3 -0
- package/src/abi/connectors/v2/UNISWAP-V3-A.ts +3 -0
- package/src/abi/connectors/v2/UNISWAP-V3-STAKE-A.ts +3 -0
- package/src/abi/connectors/v2/WETH-A.ts +3 -0
- package/src/abi/connectors/v2/YEARN-VAULT-A.ts +3 -0
- package/src/abi/connectors/v2/index.ts +87 -0
- package/src/abi/index.ts +6 -4
- package/src/constants/addresses.ts +3 -1
- package/src/constants/blockConfirmations.ts +5 -0
- package/src/constants/index.ts +1 -0
- package/src/db/models/transaction.ts +2 -2
- package/src/gnosis/actions/aaveV2/index.ts +9 -0
- package/src/gnosis/actions/aaveV2/source.ts +104 -0
- package/src/gnosis/actions/aaveV2/target.ts +13 -0
- package/src/gnosis/actions/index.ts +2 -2
- package/src/net/protocol/dial/SignatureDialProtocol.ts +3 -2
- package/src/tasks/InteropX/ProcessSubmitSubmitEvents.ts +252 -0
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +118 -116
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +4 -3
- package/src/tasks/index.ts +6 -1
- package/src/utils/index.ts +169 -93
- package/dist/src/gnosis/actions/withdraw/index.js +0 -114
- package/src/gnosis/actions/withdraw/index.ts +0 -155
@@ -0,0 +1,87 @@
|
|
1
|
+
import {ONEINCH_A} from './1INCH-A'
|
2
|
+
import {AAVE_CLAIM_A} from './AAVE-CLAIM-A'
|
3
|
+
import {AAVE_CLAIM_B} from './AAVE-CLAIM-B'
|
4
|
+
import {AAVE_STAKE_A} from './AAVE-STAKE-A'
|
5
|
+
import {AAVE_V1} from './AAVE-V1-A'
|
6
|
+
import {AAVE_V2} from './AAVE-V2-A'
|
7
|
+
import {AUTHORITY_A} from './AUTHORITY-A'
|
8
|
+
import {BASIC_A} from './BASIC-A'
|
9
|
+
import {COMP_A} from './COMP-A'
|
10
|
+
import {COMPOUND_A} from './COMPOUND-A'
|
11
|
+
import {MAKERDAO_A} from './MAKERDAO-A'
|
12
|
+
import {POLYGON_BRIDGE_A} from './POLYGON-BRIDGE-A'
|
13
|
+
import {UNISWAP_A} from './UNISWAP-A'
|
14
|
+
import {AAVE_V1_IMPORT_A} from './AAVE-V1-IMPORT-A'
|
15
|
+
import {AAVE_V2_IMPORT_A} from './AAVE-V2-IMPORT-A'
|
16
|
+
import {COMPOUND_IMPORT_A} from './COMPOUND-IMPORT-A'
|
17
|
+
import {INSTAPOOL_A} from './INSTAPOOL-A'
|
18
|
+
import {PARASWAP_A} from './PARASWAP-A'
|
19
|
+
|
20
|
+
import {AAVE_V2_IMPORT_B} from './AAVE-V2-IMPORT-B'
|
21
|
+
import {COMPOUND_IMPORT_B} from './COMPOUND-IMPORT-B'
|
22
|
+
import {MAKERDAO_CLAIM_A} from './MAKERDAO-CLAIM-A'
|
23
|
+
import {G_UNISWAP_A} from './G-UNISWAP-A'
|
24
|
+
import {STAKE_ERC20_A} from './STAKE-ERC20-A'
|
25
|
+
import {INST_STAKING_A} from './INST-STAKING-A'
|
26
|
+
import {ONEINCH_B} from './1INCH-B'
|
27
|
+
import {WETH_A} from './WETH-A'
|
28
|
+
import {INST_A} from './INST-A'
|
29
|
+
import {REFINANCE_A} from './REFINANCE-A'
|
30
|
+
import {INST_LM_A} from './INST-LM-A'
|
31
|
+
import {UNISWAP_V2_A} from './UNISWAP-V2-A'
|
32
|
+
import {LIQUITY_A} from './LIQUITY-A'
|
33
|
+
import {REFLEXER_A} from './REFLEXER-A'
|
34
|
+
import {UNISWAP_V3_A} from './UNISWAP-V3-A'
|
35
|
+
import {B_COMPOUND_A} from './B-COMPOUND-A'
|
36
|
+
import {B_MAKERDAO_A} from './B-MAKERDAO-A'
|
37
|
+
import {B_LIQUITY_A} from './B-LIQUITY-A'
|
38
|
+
import {BASIC_B} from './BASIC-B'
|
39
|
+
import {BASIC_C} from './BASIC-C'
|
40
|
+
import {UNISWAP_V3_STAKE_A} from './UNISWAP-V3-STAKE-A'
|
41
|
+
import {YEARN_VAULT_A} from './YEARN-VAULT-A'
|
42
|
+
import {INST_STAKING_B} from './INST-STAKING-B'
|
43
|
+
import {GELATO_AAVE_A} from './GELATO-AAVE-A'
|
44
|
+
export const connectorsV2_M1 = {
|
45
|
+
"GELATO-AAVE-A": GELATO_AAVE_A,
|
46
|
+
"INST-STAKING-B": INST_STAKING_B,
|
47
|
+
"YEARN-VAULT-A": YEARN_VAULT_A,
|
48
|
+
"UNISWAP-V3-STAKE-A": UNISWAP_V3_STAKE_A,
|
49
|
+
"BASIC-C": BASIC_C,
|
50
|
+
"BASIC-B": BASIC_B,
|
51
|
+
"B-LIQUITY-A": B_LIQUITY_A,
|
52
|
+
"B-MAKERDAO-A": B_MAKERDAO_A,
|
53
|
+
"B-COMPOUND-A": B_COMPOUND_A,
|
54
|
+
"UNISWAP-V3-A": UNISWAP_V3_A,
|
55
|
+
"REFLEXER-A": REFLEXER_A,
|
56
|
+
"LIQUITY-A": LIQUITY_A,
|
57
|
+
"UNISWAP-V2-A": UNISWAP_V2_A,
|
58
|
+
"INST-LM-A": INST_LM_A,
|
59
|
+
"REFINANCE-A": REFINANCE_A,
|
60
|
+
"INST-A": INST_A,
|
61
|
+
"WETH-A": WETH_A,
|
62
|
+
"1INCH-B": ONEINCH_B,
|
63
|
+
"INST-STAKING-A": INST_STAKING_A,
|
64
|
+
"STAKE-ERC20-A": STAKE_ERC20_A,
|
65
|
+
"G-UNISWAP-A": G_UNISWAP_A,
|
66
|
+
"INSTAPOOL-A": INSTAPOOL_A,
|
67
|
+
"COMPOUND-IMPORT-A": COMPOUND_IMPORT_A,
|
68
|
+
"AAVE-V2-IMPORT-A": AAVE_V2_IMPORT_A,
|
69
|
+
"AAVE-V1-IMPORT-A": AAVE_V1_IMPORT_A,
|
70
|
+
"1INCH-A": ONEINCH_A,
|
71
|
+
"AAVE-CLAIM-A": AAVE_CLAIM_A,
|
72
|
+
"AAVE-CLAIM-B": AAVE_CLAIM_B,
|
73
|
+
"AAVE-V1-A": AAVE_V1,
|
74
|
+
"AAVE-V2-A": AAVE_V2,
|
75
|
+
"AUTHORITY-A": AUTHORITY_A,
|
76
|
+
"BASIC-A": BASIC_A,
|
77
|
+
"COMP-A": COMP_A,
|
78
|
+
"COMPOUND-A": COMPOUND_A,
|
79
|
+
"MAKERDAO-A": MAKERDAO_A,
|
80
|
+
"UNISWAP-A": UNISWAP_A,
|
81
|
+
"POLYGON-BRIDGE-A": POLYGON_BRIDGE_A,
|
82
|
+
"AAVE-STAKE-A": AAVE_STAKE_A,
|
83
|
+
"PARASWAP-A": PARASWAP_A,
|
84
|
+
"COMPOUND-IMPORT-B": COMPOUND_IMPORT_B,
|
85
|
+
"AAVE-V2-IMPORT-B": AAVE_V2_IMPORT_B,
|
86
|
+
"MAKERDAO-CLAIM-A": MAKERDAO_CLAIM_A,
|
87
|
+
}
|
package/src/abi/index.ts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
import gnosisSafe from "./gnosisSafe.json";
|
2
2
|
import erc20 from "./erc20.json";
|
3
3
|
import interopX from "./interopX.json";
|
4
|
+
import { connectors } from "./connectors";
|
4
5
|
|
5
6
|
export default {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
gnosisSafe,
|
8
|
+
erc20,
|
9
|
+
interopX,
|
10
|
+
connectors,
|
11
|
+
};
|
@@ -3,10 +3,12 @@ export const addresses = {
|
|
3
3
|
gnosisSafe: '0x5635d2910e51da33d9DC0422c893CF4F28B69A25',
|
4
4
|
multisend: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
|
5
5
|
interopX: '0xDB6083df37C5F224a3dF84A4B5f9fB60b6c8670a',
|
6
|
+
dsaAddress: '0x9Fbd453a8e7a158510fBae5D9935958507cf4b19',
|
6
7
|
},
|
7
8
|
43114: {
|
8
9
|
gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
|
9
10
|
multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
|
10
11
|
interopX: '0xd61f55C6d9deD35B9d13243b816c4BcC1d78592b',
|
12
|
+
dsaAddress: '0xFcB7d826E32081c4799de2f83b47b49df600dc8c',
|
11
13
|
}
|
12
|
-
} as Record<number, { gnosisSafe: string, multisend: string, interopX: string }>
|
14
|
+
} as Record<number, { gnosisSafe: string, multisend: string, interopX: string, dsaAddress: string }>
|
package/src/constants/index.ts
CHANGED
@@ -87,7 +87,7 @@ Transaction.init({
|
|
87
87
|
sourceBlockNumber: DataTypes.NUMBER,
|
88
88
|
sourceStatus: {
|
89
89
|
type: DataTypes.STRING,
|
90
|
-
defaultValue: '
|
90
|
+
defaultValue: 'pending'
|
91
91
|
},
|
92
92
|
sourceErrors: {
|
93
93
|
type: DataTypes.JSON,
|
@@ -109,7 +109,7 @@ Transaction.init({
|
|
109
109
|
targetBlockNumber: DataTypes.NUMBER,
|
110
110
|
targetStatus: {
|
111
111
|
type: DataTypes.STRING,
|
112
|
-
defaultValue: '
|
112
|
+
defaultValue: 'pending'
|
113
113
|
},
|
114
114
|
targetErrors: {
|
115
115
|
type: DataTypes.JSON,
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Transaction } from "@/db";
|
2
|
+
import source from "./source";
|
3
|
+
import target from "./target";
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
export default async function (transaction: Transaction, type: 'source' | 'target') {
|
8
|
+
return type === 'source' ? source(transaction) : target(transaction);
|
9
|
+
}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import abi from "@/abi";
|
2
|
+
import config from "@/config";
|
3
|
+
import { addresses } from "@/constants";
|
4
|
+
import { Transaction } from "@/db";
|
5
|
+
import { InteropX } from "@/typechain";
|
6
|
+
import { ChainId } from "@/types";
|
7
|
+
import { encodeConnectorMethod, getContract, getRpcProviderUrl } from "@/utils";
|
8
|
+
import { ethers } from "ethers";
|
9
|
+
import { MetaTransaction, OperationType } from "ethers-multisend";
|
10
|
+
|
11
|
+
export default async function (transaction: Transaction) {
|
12
|
+
const transactions: MetaTransaction[] = [];
|
13
|
+
const logs: any[] = [];
|
14
|
+
|
15
|
+
const {
|
16
|
+
position,
|
17
|
+
actionId,
|
18
|
+
actionIdHashHash,
|
19
|
+
sourceSender,
|
20
|
+
sourceDsaId,
|
21
|
+
targetDsaId,
|
22
|
+
sourceChainId,
|
23
|
+
targetChainId,
|
24
|
+
vnonce,
|
25
|
+
metadata,
|
26
|
+
} = transaction.submitEvent;
|
27
|
+
|
28
|
+
const sourceChainProvider = new ethers.providers.JsonRpcProvider(
|
29
|
+
getRpcProviderUrl(sourceChainId as ChainId)
|
30
|
+
);
|
31
|
+
const sourceWallet = new ethers.Wallet(
|
32
|
+
config.privateKey,
|
33
|
+
sourceChainProvider
|
34
|
+
);
|
35
|
+
const interopAddress = addresses[sourceChainId].interopX;
|
36
|
+
const contract = getContract<InteropX>(
|
37
|
+
interopAddress,
|
38
|
+
abi.interopX,
|
39
|
+
sourceWallet
|
40
|
+
);
|
41
|
+
|
42
|
+
const sourceSpells: any[] = [];
|
43
|
+
const commonSpells = [];
|
44
|
+
|
45
|
+
for (const withdraw of position.withdraw) {
|
46
|
+
let spellData = {
|
47
|
+
connector: "AAVE-V2-A",
|
48
|
+
method: "payback",
|
49
|
+
args: [withdraw.sourceToken, withdraw.amount, "2", "0", "0"],
|
50
|
+
};
|
51
|
+
|
52
|
+
sourceSpells.push({
|
53
|
+
connector: spellData.method,
|
54
|
+
data: encodeConnectorMethod(spellData),
|
55
|
+
});
|
56
|
+
}
|
57
|
+
|
58
|
+
for (const supply of position.supply) {
|
59
|
+
let spellDataWithdraw = {
|
60
|
+
connector: "AAVE-V2-A",
|
61
|
+
method: "withdraw",
|
62
|
+
args: [supply.sourceToken, supply.amount, "0", "0"],
|
63
|
+
};
|
64
|
+
|
65
|
+
sourceSpells.push({
|
66
|
+
connector: spellDataWithdraw.method,
|
67
|
+
data: encodeConnectorMethod(spellDataWithdraw),
|
68
|
+
});
|
69
|
+
|
70
|
+
let spellDataBasicWithdraw = {
|
71
|
+
connector: "BASIC-A",
|
72
|
+
method: "withdraw",
|
73
|
+
args: [supply.sourceToken, supply.amount, interopAddress, "0", "0"],
|
74
|
+
};
|
75
|
+
|
76
|
+
sourceSpells.push({
|
77
|
+
connector: spellDataBasicWithdraw.method,
|
78
|
+
data: encodeConnectorMethod(spellDataBasicWithdraw),
|
79
|
+
});
|
80
|
+
}
|
81
|
+
|
82
|
+
const { data } = await contract.populateTransaction.sourceAction(
|
83
|
+
sourceSpells,
|
84
|
+
commonSpells,
|
85
|
+
position,
|
86
|
+
actionId,
|
87
|
+
sourceSender,
|
88
|
+
sourceDsaId,
|
89
|
+
targetDsaId,
|
90
|
+
sourceChainId,
|
91
|
+
targetChainId,
|
92
|
+
vnonce,
|
93
|
+
metadata
|
94
|
+
);
|
95
|
+
|
96
|
+
transactions.push({
|
97
|
+
to: interopAddress,
|
98
|
+
data: data!,
|
99
|
+
value: "0",
|
100
|
+
operation: OperationType.Call,
|
101
|
+
});
|
102
|
+
|
103
|
+
return { transactions, logs };
|
104
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
import { Transaction } from "@/db";
|
4
|
+
import { MetaTransaction, OperationType } from "ethers-multisend";
|
5
|
+
|
6
|
+
|
7
|
+
export default async function (transaction: Transaction) {
|
8
|
+
const transactions: MetaTransaction[] = [];
|
9
|
+
const logs: any[] = [];
|
10
|
+
|
11
|
+
|
12
|
+
return { transactions, logs }
|
13
|
+
}
|
@@ -12,6 +12,7 @@ export interface ISignatureRequest {
|
|
12
12
|
transactionHash: string
|
13
13
|
safeTxGas: string
|
14
14
|
safeNonce: string
|
15
|
+
chainId: number
|
15
16
|
}
|
16
17
|
export interface ISignatureResponse {
|
17
18
|
signer: string,
|
@@ -54,9 +55,9 @@ export class SignatureDialProtocol extends BaseDialProtocol<ISignatureRequest, I
|
|
54
55
|
const { data: gnosisData } = await buildGnosisAction(transaction, data.type);
|
55
56
|
|
56
57
|
const signedData = await signGnosisSafeTx({
|
57
|
-
to: addresses[
|
58
|
+
to: addresses[data.chainId].multisend,
|
58
59
|
data: gnosisData,
|
59
|
-
chainId:
|
60
|
+
chainId: data.chainId as ChainId,
|
60
61
|
safeTxGas: data.safeTxGas,
|
61
62
|
nonce: data.safeNonce,
|
62
63
|
}, { signer });
|
@@ -0,0 +1,252 @@
|
|
1
|
+
import { BaseTask } from "../BaseTask";
|
2
|
+
import Logger from "@/logger";
|
3
|
+
import { ethers, Wallet } from "ethers";
|
4
|
+
import abi from "@/abi";
|
5
|
+
import { Transaction } from "@/db";
|
6
|
+
import {
|
7
|
+
buildSignatureBytes,
|
8
|
+
generateGnosisTransaction,
|
9
|
+
generateInteropTransactionHash,
|
10
|
+
getContract,
|
11
|
+
getRpcProviderUrl,
|
12
|
+
LiquidityError,
|
13
|
+
Signature,
|
14
|
+
} from "@/utils";
|
15
|
+
import { addresses, blockConfirmations } from "@/constants";
|
16
|
+
import { ChainId } from "@/types";
|
17
|
+
import config from "@/config";
|
18
|
+
import { GnosisSafe, InteropX } from "@/typechain";
|
19
|
+
import moment from "moment";
|
20
|
+
import { Op } from "sequelize";
|
21
|
+
import { buildGnosisAction } from "@/gnosis";
|
22
|
+
import { peerPool, protocol } from "@/net";
|
23
|
+
import { LogDescription } from "ethers/lib/utils";
|
24
|
+
import wait from "waait";
|
25
|
+
|
26
|
+
class ProcessSubmitSubmitEvents extends BaseTask {
|
27
|
+
sourceProvider: ethers.providers.JsonRpcProvider;
|
28
|
+
sourceGnosisContract: GnosisSafe;
|
29
|
+
sourceWallet: Wallet;
|
30
|
+
chainId: ChainId;
|
31
|
+
leadNodeOnly: boolean = true;
|
32
|
+
blockConfirmationsCount: number = 12;
|
33
|
+
|
34
|
+
constructor({ chainId }: { chainId: ChainId }) {
|
35
|
+
super({
|
36
|
+
logger: new Logger("InteropX::ProcessSubmitSubmitEvents"),
|
37
|
+
});
|
38
|
+
this.chainId = chainId;
|
39
|
+
}
|
40
|
+
|
41
|
+
async pollHandler() {
|
42
|
+
const currentBlockNumber = await this.sourceProvider.getBlockNumber();
|
43
|
+
|
44
|
+
const transaction = await Transaction.findOne({
|
45
|
+
where: {
|
46
|
+
status: "pending",
|
47
|
+
sourceStatus: "pending",
|
48
|
+
sourceChainId: this.chainId,
|
49
|
+
submitBlockNumber: {
|
50
|
+
[Op.lt]: currentBlockNumber - this.blockConfirmationsCount,
|
51
|
+
},
|
52
|
+
sourceDelayUntil: {
|
53
|
+
[Op.or]: {
|
54
|
+
[Op.is]: null,
|
55
|
+
[Op.lt]: new Date(),
|
56
|
+
},
|
57
|
+
},
|
58
|
+
|
59
|
+
submitEvent: { $ne: null },
|
60
|
+
|
61
|
+
createdAt: {
|
62
|
+
[Op.gt]: moment().subtract({ hours: 12 }).toDate(),
|
63
|
+
},
|
64
|
+
},
|
65
|
+
});
|
66
|
+
|
67
|
+
if (!transaction) {
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
|
71
|
+
transaction.sourceStatus = "proccessing";
|
72
|
+
await transaction.save();
|
73
|
+
|
74
|
+
const ownersThreshold = await this.sourceGnosisContract.getThreshold();
|
75
|
+
await wait(10000);
|
76
|
+
|
77
|
+
let data,
|
78
|
+
logs = [];
|
79
|
+
|
80
|
+
try {
|
81
|
+
({ data, logs } = await buildGnosisAction(transaction, "source"));
|
82
|
+
} catch (error) {
|
83
|
+
if (error instanceof LiquidityError) {
|
84
|
+
await transaction.save();
|
85
|
+
transaction.sourceDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
|
86
|
+
transaction.sourceStatus = "pending";
|
87
|
+
|
88
|
+
await transaction.save();
|
89
|
+
|
90
|
+
throw error;
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
|
94
|
+
transaction.sourceStatus = "failed";
|
95
|
+
transaction.sourceErrors = [error.message];
|
96
|
+
transaction.targetStatus = "failed";
|
97
|
+
|
98
|
+
transaction.status = "failed";
|
99
|
+
await transaction.save();
|
100
|
+
protocol.sendTransaction(transaction);
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
let gnosisTx = await generateGnosisTransaction(
|
105
|
+
{
|
106
|
+
baseGas: "0",
|
107
|
+
data,
|
108
|
+
gasPrice: "0",
|
109
|
+
gasToken: "0x0000000000000000000000000000000000000000",
|
110
|
+
nonce: "0",
|
111
|
+
operation: "1",
|
112
|
+
refundReceiver: "0x0000000000000000000000000000000000000000",
|
113
|
+
safeAddress: this.sourceGnosisContract.address,
|
114
|
+
safeTxGas: "79668",
|
115
|
+
to: addresses[transaction.sourceChainId].multisend,
|
116
|
+
value: "0",
|
117
|
+
},
|
118
|
+
this.sourceGnosisContract
|
119
|
+
);
|
120
|
+
|
121
|
+
const owners = await this.sourceGnosisContract
|
122
|
+
.getOwners()
|
123
|
+
.then((owners) => owners.map((owner) => owner.toLowerCase()));
|
124
|
+
|
125
|
+
const ownerPeerIds = peerPool.activePeers
|
126
|
+
.filter((peer) => owners.includes(peer.publicAddress.toLowerCase()))
|
127
|
+
.map((peer) => peer.id);
|
128
|
+
|
129
|
+
console.log(
|
130
|
+
`Collecting signatures for execution ${transaction.transactionHash}`
|
131
|
+
);
|
132
|
+
|
133
|
+
console.log(ownerPeerIds);
|
134
|
+
|
135
|
+
const signatures = await protocol.requestSignatures(
|
136
|
+
{
|
137
|
+
type: "source",
|
138
|
+
transactionHash: transaction.transactionHash,
|
139
|
+
safeTxGas: gnosisTx.safeTxGas,
|
140
|
+
safeNonce: gnosisTx.nonce,
|
141
|
+
chainId: this.chainId,
|
142
|
+
},
|
143
|
+
ownerPeerIds
|
144
|
+
);
|
145
|
+
|
146
|
+
const validSignatures = signatures.filter(
|
147
|
+
(s) => !!s.data && s.data !== "0x"
|
148
|
+
) as Signature[];
|
149
|
+
|
150
|
+
console.log({
|
151
|
+
signatures,
|
152
|
+
validSignatures,
|
153
|
+
ownersThreshold: ownersThreshold.toString(),
|
154
|
+
});
|
155
|
+
|
156
|
+
if (
|
157
|
+
validSignatures.length === 0 ||
|
158
|
+
ownersThreshold.gt(validSignatures.length)
|
159
|
+
) {
|
160
|
+
await transaction.save();
|
161
|
+
transaction.sourceDelayUntil = new Date(Date.now() + 30 * 1000);
|
162
|
+
transaction.sourceStatus = "pending";
|
163
|
+
|
164
|
+
await transaction.save();
|
165
|
+
const errorMessage = signatures.find((s) => !!s.error)?.error;
|
166
|
+
throw new Error(
|
167
|
+
`Not enough signatures` + (errorMessage ? `: ${errorMessage}` : "")
|
168
|
+
);
|
169
|
+
}
|
170
|
+
|
171
|
+
console.log(
|
172
|
+
`Executing transaction for execution ${transaction.transactionHash}`
|
173
|
+
);
|
174
|
+
|
175
|
+
const { data: txData } =
|
176
|
+
await this.sourceGnosisContract.populateTransaction.execTransaction(
|
177
|
+
gnosisTx.to,
|
178
|
+
gnosisTx.value,
|
179
|
+
gnosisTx.data,
|
180
|
+
gnosisTx.operation,
|
181
|
+
gnosisTx.safeTxGas,
|
182
|
+
gnosisTx.baseGas,
|
183
|
+
gnosisTx.gasPrice,
|
184
|
+
gnosisTx.gasToken,
|
185
|
+
gnosisTx.refundReceiver,
|
186
|
+
buildSignatureBytes(validSignatures)
|
187
|
+
);
|
188
|
+
|
189
|
+
const txSent = await this.sourceWallet.sendTransaction({
|
190
|
+
from: this.sourceWallet.address,
|
191
|
+
gasPrice: ethers.BigNumber.from(120 * 10 ** 9),
|
192
|
+
to: this.sourceGnosisContract.address,
|
193
|
+
data: txData,
|
194
|
+
});
|
195
|
+
|
196
|
+
console.log(txSent);
|
197
|
+
|
198
|
+
const receipt = await txSent.wait();
|
199
|
+
|
200
|
+
const parsedLogs: LogDescription[] = [];
|
201
|
+
|
202
|
+
receipt.logs.forEach((log) => {
|
203
|
+
try {
|
204
|
+
parsedLogs.push(this.sourceGnosisContract.interface.parseLog(log));
|
205
|
+
} catch (e) {}
|
206
|
+
});
|
207
|
+
|
208
|
+
if (parsedLogs.find((e) => e.name === "ExecutionSuccess")) {
|
209
|
+
console.log("ExecutionSuccess");
|
210
|
+
transaction.sourceStatus = "success";
|
211
|
+
if (txSent.blockNumber)
|
212
|
+
transaction.sourceBlockNumber = txSent.blockNumber;
|
213
|
+
transaction.sourceTransactionHash = txSent.hash;
|
214
|
+
transaction.sourceLogs = logs;
|
215
|
+
await transaction.save();
|
216
|
+
} else {
|
217
|
+
console.log("ExecutionFailure");
|
218
|
+
transaction.sourceStatus = "failed";
|
219
|
+
if (txSent.blockNumber)
|
220
|
+
transaction.sourceBlockNumber = txSent.blockNumber;
|
221
|
+
transaction.sourceTransactionHash = txSent.hash;
|
222
|
+
transaction.sourceTransactionHash = txSent.hash;
|
223
|
+
transaction.status = "failed";
|
224
|
+
await transaction.save();
|
225
|
+
}
|
226
|
+
|
227
|
+
protocol.sendTransaction(transaction);
|
228
|
+
}
|
229
|
+
|
230
|
+
async start(): Promise<void> {
|
231
|
+
this.blockConfirmationsCount = blockConfirmations[this.chainId] + 1;
|
232
|
+
|
233
|
+
this.sourceProvider = new ethers.providers.JsonRpcProvider(
|
234
|
+
getRpcProviderUrl(this.chainId)
|
235
|
+
);
|
236
|
+
|
237
|
+
this.sourceWallet = new ethers.Wallet(
|
238
|
+
config.privateKey!,
|
239
|
+
this.sourceProvider
|
240
|
+
);
|
241
|
+
|
242
|
+
this.sourceGnosisContract = getContract<GnosisSafe>(
|
243
|
+
addresses[this.chainId].gnosisSafe,
|
244
|
+
abi.interopX,
|
245
|
+
this.sourceWallet
|
246
|
+
);
|
247
|
+
|
248
|
+
await super.start();
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
export default ProcessSubmitSubmitEvents;
|