@instadapp/interop-x 0.0.0-dev.ee3d74b → 0.0.0-dev.ef38dfb

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/dist/package.json +3 -1
  2. package/dist/src/abi/index.js +2 -0
  3. package/dist/src/abi/instList.json +232 -0
  4. package/dist/src/api/index.js +7 -0
  5. package/dist/src/constants/addresses.js +4 -2
  6. package/dist/src/db/models/transaction.js +15 -7
  7. package/dist/src/errors/index.js +10 -0
  8. package/dist/src/gnosis/actions/aaveV2/source.js +15 -4
  9. package/dist/src/gnosis/actions/aaveV2/target.js +78 -0
  10. package/dist/src/index.js +1 -1
  11. package/dist/src/tasks/InteropX/ProcessSubmitSubmitEvents.js +15 -3
  12. package/dist/src/tasks/InteropX/ProcessValidateEvents.js +184 -0
  13. package/dist/src/tasks/InteropX/SyncLogExecuteEvents.js +112 -0
  14. package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +1 -0
  15. package/dist/src/tasks/InteropX/SyncLogValidateEvents.js +105 -0
  16. package/dist/src/tasks/index.js +10 -1
  17. package/dist/src/typechain/InstList.js +2 -0
  18. package/dist/src/typechain/factories/InstList__factory.js +249 -0
  19. package/dist/src/typechain/factories/index.js +3 -1
  20. package/dist/src/typechain/index.js +3 -1
  21. package/dist/src/utils/async.js +18 -0
  22. package/dist/src/utils/dsa.js +24 -0
  23. package/dist/src/utils/formatting.js +17 -0
  24. package/dist/src/utils/gnosis.js +62 -0
  25. package/dist/src/utils/http.js +10 -0
  26. package/dist/src/utils/index.js +20 -219
  27. package/dist/src/utils/interop.js +16 -0
  28. package/dist/src/utils/web3.js +92 -0
  29. package/package.json +3 -1
  30. package/src/abi/index.ts +2 -0
  31. package/src/abi/instList.json +232 -0
  32. package/src/api/index.ts +8 -0
  33. package/src/constants/addresses.ts +5 -3
  34. package/src/db/models/transaction.ts +134 -80
  35. package/src/errors/index.ts +6 -0
  36. package/src/gnosis/actions/aaveV2/source.ts +19 -5
  37. package/src/gnosis/actions/aaveV2/target.ts +130 -2
  38. package/src/tasks/InteropX/ProcessSubmitSubmitEvents.ts +20 -3
  39. package/src/tasks/InteropX/ProcessValidateEvents.ts +274 -0
  40. package/src/tasks/InteropX/SyncLogExecuteEvents.ts +162 -0
  41. package/src/tasks/InteropX/SyncLogSubmitEvents.ts +1 -0
  42. package/src/tasks/InteropX/SyncLogValidateEvents.ts +152 -0
  43. package/src/tasks/index.ts +13 -1
  44. package/src/typechain/InstList.ts +402 -0
  45. package/src/typechain/factories/InstList__factory.ts +253 -0
  46. package/src/typechain/factories/index.ts +1 -0
  47. package/src/typechain/index.ts +2 -0
  48. package/src/utils/async.ts +22 -0
  49. package/src/utils/dsa.ts +30 -0
  50. package/src/utils/formatting.ts +15 -0
  51. package/src/utils/gnosis.ts +123 -0
  52. package/src/utils/http.ts +6 -0
  53. package/src/utils/index.ts +7 -365
  54. package/src/utils/interop.ts +28 -0
  55. package/src/utils/web3.ts +131 -0
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.ee3d74b",
3
+ "version": "0.0.0-dev.ef38dfb",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -53,6 +53,7 @@
53
53
  "sequelize": "6.18.0",
54
54
  "sqlite3": "^5.0.8",
55
55
  "waait": "^1.0.5",
56
+ "web3-eth-abi": "^1.7.3",
56
57
  "web3-utils": "^1.7.3"
57
58
  },
58
59
  "bin": {
@@ -61,6 +62,7 @@
61
62
  },
62
63
  "devDependencies": {
63
64
  "@typechain/ethers-v5": "^10.0.0",
65
+ "@types/async-retry": "^1.4.4",
64
66
  "@types/bn.js": "^5.1.0",
65
67
  "@types/fs-extra": "^9.0.13",
66
68
  "@types/node": "^17.0.33",
@@ -7,9 +7,11 @@ const gnosisSafe_json_1 = __importDefault(require("./gnosisSafe.json"));
7
7
  const erc20_json_1 = __importDefault(require("./erc20.json"));
8
8
  const interopX_json_1 = __importDefault(require("./interopX.json"));
9
9
  const connectors_1 = require("./connectors");
10
+ const instList_json_1 = __importDefault(require("./instList.json"));
10
11
  exports.default = {
11
12
  gnosisSafe: gnosisSafe_json_1.default,
12
13
  erc20: erc20_json_1.default,
13
14
  interopX: interopX_json_1.default,
14
15
  connectors: connectors_1.connectors,
16
+ instList: instList_json_1.default,
15
17
  };
@@ -0,0 +1,232 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "address",
6
+ "name": "_instaIndex",
7
+ "type": "address"
8
+ }
9
+ ],
10
+ "stateMutability": "nonpayable",
11
+ "type": "constructor"
12
+ },
13
+ {
14
+ "inputs": [
15
+ {
16
+ "internalType": "uint64",
17
+ "name": "",
18
+ "type": "uint64"
19
+ }
20
+ ],
21
+ "name": "accountAddr",
22
+ "outputs": [
23
+ {
24
+ "internalType": "address",
25
+ "name": "",
26
+ "type": "address"
27
+ }
28
+ ],
29
+ "stateMutability": "view",
30
+ "type": "function"
31
+ },
32
+ {
33
+ "inputs": [
34
+ {
35
+ "internalType": "address",
36
+ "name": "",
37
+ "type": "address"
38
+ }
39
+ ],
40
+ "name": "accountID",
41
+ "outputs": [
42
+ {
43
+ "internalType": "uint64",
44
+ "name": "",
45
+ "type": "uint64"
46
+ }
47
+ ],
48
+ "stateMutability": "view",
49
+ "type": "function"
50
+ },
51
+ {
52
+ "inputs": [
53
+ {
54
+ "internalType": "uint64",
55
+ "name": "",
56
+ "type": "uint64"
57
+ }
58
+ ],
59
+ "name": "accountLink",
60
+ "outputs": [
61
+ {
62
+ "internalType": "address",
63
+ "name": "first",
64
+ "type": "address"
65
+ },
66
+ {
67
+ "internalType": "address",
68
+ "name": "last",
69
+ "type": "address"
70
+ },
71
+ {
72
+ "internalType": "uint64",
73
+ "name": "count",
74
+ "type": "uint64"
75
+ }
76
+ ],
77
+ "stateMutability": "view",
78
+ "type": "function"
79
+ },
80
+ {
81
+ "inputs": [
82
+ {
83
+ "internalType": "uint64",
84
+ "name": "",
85
+ "type": "uint64"
86
+ },
87
+ {
88
+ "internalType": "address",
89
+ "name": "",
90
+ "type": "address"
91
+ }
92
+ ],
93
+ "name": "accountList",
94
+ "outputs": [
95
+ {
96
+ "internalType": "address",
97
+ "name": "prev",
98
+ "type": "address"
99
+ },
100
+ {
101
+ "internalType": "address",
102
+ "name": "next",
103
+ "type": "address"
104
+ }
105
+ ],
106
+ "stateMutability": "view",
107
+ "type": "function"
108
+ },
109
+ {
110
+ "inputs": [],
111
+ "name": "accounts",
112
+ "outputs": [
113
+ {
114
+ "internalType": "uint64",
115
+ "name": "",
116
+ "type": "uint64"
117
+ }
118
+ ],
119
+ "stateMutability": "view",
120
+ "type": "function"
121
+ },
122
+ {
123
+ "inputs": [
124
+ {
125
+ "internalType": "address",
126
+ "name": "_owner",
127
+ "type": "address"
128
+ }
129
+ ],
130
+ "name": "addAuth",
131
+ "outputs": [],
132
+ "stateMutability": "nonpayable",
133
+ "type": "function"
134
+ },
135
+ {
136
+ "inputs": [
137
+ {
138
+ "internalType": "address",
139
+ "name": "_account",
140
+ "type": "address"
141
+ }
142
+ ],
143
+ "name": "init",
144
+ "outputs": [],
145
+ "stateMutability": "nonpayable",
146
+ "type": "function"
147
+ },
148
+ {
149
+ "inputs": [],
150
+ "name": "instaIndex",
151
+ "outputs": [
152
+ {
153
+ "internalType": "address",
154
+ "name": "",
155
+ "type": "address"
156
+ }
157
+ ],
158
+ "stateMutability": "view",
159
+ "type": "function"
160
+ },
161
+ {
162
+ "inputs": [
163
+ {
164
+ "internalType": "address",
165
+ "name": "_owner",
166
+ "type": "address"
167
+ }
168
+ ],
169
+ "name": "removeAuth",
170
+ "outputs": [],
171
+ "stateMutability": "nonpayable",
172
+ "type": "function"
173
+ },
174
+ {
175
+ "inputs": [
176
+ {
177
+ "internalType": "address",
178
+ "name": "",
179
+ "type": "address"
180
+ }
181
+ ],
182
+ "name": "userLink",
183
+ "outputs": [
184
+ {
185
+ "internalType": "uint64",
186
+ "name": "first",
187
+ "type": "uint64"
188
+ },
189
+ {
190
+ "internalType": "uint64",
191
+ "name": "last",
192
+ "type": "uint64"
193
+ },
194
+ {
195
+ "internalType": "uint64",
196
+ "name": "count",
197
+ "type": "uint64"
198
+ }
199
+ ],
200
+ "stateMutability": "view",
201
+ "type": "function"
202
+ },
203
+ {
204
+ "inputs": [
205
+ {
206
+ "internalType": "address",
207
+ "name": "",
208
+ "type": "address"
209
+ },
210
+ {
211
+ "internalType": "uint64",
212
+ "name": "",
213
+ "type": "uint64"
214
+ }
215
+ ],
216
+ "name": "userList",
217
+ "outputs": [
218
+ {
219
+ "internalType": "uint64",
220
+ "name": "prev",
221
+ "type": "uint64"
222
+ },
223
+ {
224
+ "internalType": "uint64",
225
+ "name": "next",
226
+ "type": "uint64"
227
+ }
228
+ ],
229
+ "stateMutability": "view",
230
+ "type": "function"
231
+ }
232
+ ]
@@ -25,6 +25,13 @@ const startApiServer = async () => {
25
25
  ]
26
26
  });
27
27
  });
28
+ server.get('/transactions/:transaction', async (req) => {
29
+ return await db_1.Transaction.findOne({
30
+ where: {
31
+ transactionHash: req.params.transaction
32
+ }
33
+ });
34
+ });
28
35
  await server.listen(PORT, HOST);
29
36
  logger.log(`RPC Server listening at http://${HOST}:${PORT}`);
30
37
  }
@@ -7,11 +7,13 @@ exports.addresses = {
7
7
  multisend: '0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761',
8
8
  interopX: '0xDB6083df37C5F224a3dF84A4B5f9fB60b6c8670a',
9
9
  dsaAddress: '0x9Fbd453a8e7a158510fBae5D9935958507cf4b19',
10
+ instList: "0x839c2D3aDe63DF5b0b8F3E57D5e145057Ab41556",
10
11
  },
11
12
  43114: {
12
13
  gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
13
14
  multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
14
- interopX: '0xd61f55C6d9deD35B9d13243b816c4BcC1d78592b',
15
- dsaAddress: '0xFcB7d826E32081c4799de2f83b47b49df600dc8c',
15
+ interopX: '0xA82A87096709E3D8648c9d9a22f31133bC4B6d32',
16
+ dsaAddress: '0x995e67a652d2be45a8bff438b3dfac66dfff1c46',
17
+ instList: "0x9926955e0Dd681Dc303370C52f4Ad0a4dd061687",
16
18
  }
17
19
  };
@@ -10,7 +10,7 @@ Transaction.init({
10
10
  id: {
11
11
  type: sequelize_2.DataTypes.INTEGER,
12
12
  autoIncrement: true,
13
- primaryKey: true
13
+ primaryKey: true,
14
14
  },
15
15
  transactionHash: sequelize_2.DataTypes.STRING,
16
16
  actionId: sequelize_2.DataTypes.STRING,
@@ -26,7 +26,7 @@ Transaction.init({
26
26
  sourceBlockNumber: sequelize_2.DataTypes.NUMBER,
27
27
  sourceStatus: {
28
28
  type: sequelize_2.DataTypes.STRING,
29
- defaultValue: 'pending'
29
+ defaultValue: "pending",
30
30
  },
31
31
  sourceErrors: {
32
32
  type: sequelize_2.DataTypes.JSON,
@@ -38,7 +38,7 @@ Transaction.init({
38
38
  },
39
39
  sourceCreatedAt: {
40
40
  type: sequelize_2.DataTypes.DATE,
41
- defaultValue: Date.now()
41
+ defaultValue: Date.now(),
42
42
  },
43
43
  sourceDelayUntil: sequelize_2.DataTypes.STRING,
44
44
  targetChainId: sequelize_2.DataTypes.NUMBER,
@@ -47,7 +47,7 @@ Transaction.init({
47
47
  targetBlockNumber: sequelize_2.DataTypes.NUMBER,
48
48
  targetStatus: {
49
49
  type: sequelize_2.DataTypes.STRING,
50
- defaultValue: 'pending'
50
+ defaultValue: "pending",
51
51
  },
52
52
  targetErrors: {
53
53
  type: sequelize_2.DataTypes.JSON,
@@ -61,12 +61,20 @@ Transaction.init({
61
61
  targetDelayUntil: sequelize_2.DataTypes.DATE,
62
62
  submitEvent: {
63
63
  type: sequelize_2.DataTypes.JSON,
64
- allowNull: false
64
+ allowNull: false,
65
+ },
66
+ validateEvent: {
67
+ type: sequelize_2.DataTypes.JSON,
68
+ allowNull: true,
69
+ },
70
+ executeEvent: {
71
+ type: sequelize_2.DataTypes.JSON,
72
+ allowNull: true,
65
73
  },
66
74
  status: {
67
75
  type: sequelize_2.DataTypes.STRING,
68
- defaultValue: 'pending'
76
+ defaultValue: "pending",
69
77
  },
70
78
  createdAt: sequelize_2.DataTypes.DATE,
71
79
  updatedAt: sequelize_2.DataTypes.DATE,
72
- }, { sequelize: sequelize_1.sequelize, tableName: 'transactions' });
80
+ }, { sequelize: sequelize_1.sequelize, tableName: "transactions" });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LiquidityError = void 0;
4
+ class LiquidityError extends Error {
5
+ constructor(message) {
6
+ super(message || "Not enough liquidity");
7
+ Object.setPrototypeOf(this, new.target.prototype);
8
+ }
9
+ }
10
+ exports.LiquidityError = LiquidityError;
@@ -15,6 +15,8 @@ async function default_1(transaction) {
15
15
  const { position, actionId, actionIdHashHash, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata, } = transaction.submitEvent;
16
16
  const sourceChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(sourceChainId));
17
17
  const sourceWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, sourceChainProvider);
18
+ const dsaAddress = constants_1.addresses[sourceChainId].dsaAddress;
19
+ const sourceUserAddress = Number(sourceDsaId) == 0 ? sourceSender : dsaAddress;
18
20
  const interopAddress = constants_1.addresses[sourceChainId].interopX;
19
21
  const contract = (0, utils_1.getContract)(interopAddress, abi_1.default.interopX, sourceWallet);
20
22
  const sourceSpells = [];
@@ -26,9 +28,18 @@ async function default_1(transaction) {
26
28
  args: [withdraw.sourceToken, withdraw.amount, "2", "0", "0"],
27
29
  };
28
30
  sourceSpells.push({
29
- connector: spellData.method,
31
+ connector: spellData.connector,
30
32
  data: (0, utils_1.encodeConnectorMethod)(spellData),
31
33
  });
34
+ let spellDataBasicWithdraw = {
35
+ connector: "BASIC-A",
36
+ method: "withdraw",
37
+ args: [withdraw.sourceToken, withdraw.amount, sourceUserAddress, "0", "0"],
38
+ };
39
+ commonSpells.push({
40
+ connector: spellDataBasicWithdraw.connector,
41
+ data: (0, utils_1.encodeConnectorMethod)(spellDataBasicWithdraw),
42
+ });
32
43
  }
33
44
  for (const supply of position.supply) {
34
45
  let spellDataWithdraw = {
@@ -37,16 +48,16 @@ async function default_1(transaction) {
37
48
  args: [supply.sourceToken, supply.amount, "0", "0"],
38
49
  };
39
50
  sourceSpells.push({
40
- connector: spellDataWithdraw.method,
51
+ connector: spellDataWithdraw.connector,
41
52
  data: (0, utils_1.encodeConnectorMethod)(spellDataWithdraw),
42
53
  });
43
54
  let spellDataBasicWithdraw = {
44
55
  connector: "BASIC-A",
45
56
  method: "withdraw",
46
- args: [supply.sourceToken, supply.amount, interopAddress, "0", "0"],
57
+ args: [supply.sourceToken, supply.amount, dsaAddress, "0", "0"],
47
58
  };
48
59
  sourceSpells.push({
49
- connector: spellDataBasicWithdraw.method,
60
+ connector: spellDataBasicWithdraw.connector,
50
61
  data: (0, utils_1.encodeConnectorMethod)(spellDataBasicWithdraw),
51
62
  });
52
63
  }
@@ -1,8 +1,86 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const abi_1 = __importDefault(require("@/abi"));
7
+ const config_1 = __importDefault(require("@/config"));
8
+ const constants_1 = require("@/constants");
9
+ const utils_1 = require("@/utils");
10
+ const ethers_1 = require("ethers");
11
+ const ethers_multisend_1 = require("ethers-multisend");
3
12
  async function default_1(transaction) {
4
13
  const transactions = [];
5
14
  const logs = [];
15
+ const { sourceSpells, position, actionId, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata, } = transaction.validateEvent;
16
+ const targetChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(targetChainId));
17
+ const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetChainProvider);
18
+ const targetInstListContract = (0, utils_1.getContract)(constants_1.addresses[targetChainId].instList, abi_1.default.instList, targetChainProvider);
19
+ const targetDsaAddress = await targetInstListContract.accountAddr(targetDsaId);
20
+ const dsaAddress = constants_1.addresses[targetChainId].dsaAddress;
21
+ const interopAddress = constants_1.addresses[targetChainId].interopX;
22
+ const contract = (0, utils_1.getContract)(interopAddress, abi_1.default.interopX, targetWallet);
23
+ const targetSpells = [];
24
+ const commonSpells = [];
25
+ for (const supplyToken of position.supply) {
26
+ let spellData = {
27
+ connector: "AAVE-V2-A",
28
+ method: "deposit",
29
+ args: [supplyToken.targetToken, supplyToken.amount, "0", "0"],
30
+ };
31
+ targetSpells.push({
32
+ connector: spellData.connector,
33
+ data: (0, utils_1.encodeConnectorMethod)(spellData),
34
+ });
35
+ let spellDataBasicWithdraw = {
36
+ connector: "BASIC-A",
37
+ method: "withdraw",
38
+ args: [supplyToken.targetToken, supplyToken.amount, targetDsaAddress, "0", "0"],
39
+ };
40
+ commonSpells.push({
41
+ connector: spellDataBasicWithdraw.connector,
42
+ data: (0, utils_1.encodeConnectorMethod)(spellDataBasicWithdraw),
43
+ });
44
+ }
45
+ for (const withdrawToken of position.withdraw) {
46
+ let spellData = {
47
+ connector: "AAVE-V2-A",
48
+ method: "borrow",
49
+ args: [
50
+ withdrawToken.targetToken,
51
+ withdrawToken.amount,
52
+ "2",
53
+ "0",
54
+ "0",
55
+ ],
56
+ };
57
+ targetSpells.push({
58
+ connector: spellData.connector,
59
+ data: (0, utils_1.encodeConnectorMethod)(spellData),
60
+ });
61
+ let spellData2 = {
62
+ connector: "BASIC-A",
63
+ method: "withdraw",
64
+ args: [
65
+ withdrawToken.targetToken,
66
+ withdrawToken.amount,
67
+ dsaAddress,
68
+ "0",
69
+ "0",
70
+ ],
71
+ };
72
+ targetSpells.push({
73
+ connector: spellData.connector,
74
+ data: (0, utils_1.encodeConnectorMethod)(spellData2),
75
+ });
76
+ }
77
+ const { data } = await contract.populateTransaction.targetAction(sourceSpells, targetSpells, commonSpells, position, actionId, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata);
78
+ transactions.push({
79
+ to: interopAddress,
80
+ data: data,
81
+ value: "0",
82
+ operation: ethers_multisend_1.OperationType.Call,
83
+ });
6
84
  return { transactions, logs };
7
85
  }
8
86
  exports.default = default_1;
package/dist/src/index.js CHANGED
@@ -13,7 +13,7 @@ const package_json_1 = __importDefault(require("../package.json"));
13
13
  dotenv_1.default.config();
14
14
  const logger_1 = __importDefault(require("@/logger"));
15
15
  const logger = new logger_1.default('Process');
16
- const GIT_SHORT_HASH = 'ee3d74b';
16
+ const GIT_SHORT_HASH = 'ef38dfb';
17
17
  const printUsage = () => {
18
18
  console.log();
19
19
  console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
@@ -16,6 +16,7 @@ const sequelize_1 = require("sequelize");
16
16
  const gnosis_1 = require("@/gnosis");
17
17
  const net_1 = require("@/net");
18
18
  const waait_1 = __importDefault(require("waait"));
19
+ const errors_1 = require("@/errors");
19
20
  class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
20
21
  constructor({ chainId }) {
21
22
  super({
@@ -51,16 +52,18 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
51
52
  if (!transaction) {
52
53
  return;
53
54
  }
55
+ this.logger.debug(`Processing transaction ${transaction.transactionHash}`);
54
56
  transaction.sourceStatus = "proccessing";
55
57
  await transaction.save();
56
58
  const ownersThreshold = await this.sourceGnosisContract.getThreshold();
57
59
  await (0, waait_1.default)(10000);
60
+ this.logger.debug(`Build gnosis action for ${transaction.transactionHash}`);
58
61
  let data, logs = [];
59
62
  try {
60
63
  ({ data, logs } = await (0, gnosis_1.buildGnosisAction)(transaction, "source"));
61
64
  }
62
65
  catch (error) {
63
- if (error instanceof utils_1.LiquidityError) {
66
+ if (error instanceof errors_1.LiquidityError) {
64
67
  await transaction.save();
65
68
  transaction.sourceDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
66
69
  transaction.sourceStatus = "pending";
@@ -76,6 +79,7 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
76
79
  net_1.protocol.sendTransaction(transaction);
77
80
  return;
78
81
  }
82
+ this.logger.debug(`Generating gnosis tx for ${transaction.transactionHash}`);
79
83
  let gnosisTx = await (0, utils_1.generateGnosisTransaction)({
80
84
  baseGas: "0",
81
85
  data,
@@ -121,10 +125,19 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
121
125
  }
122
126
  console.log(`Executing transaction for execution ${transaction.transactionHash}`);
123
127
  const { data: txData } = await this.sourceGnosisContract.populateTransaction.execTransaction(gnosisTx.to, gnosisTx.value, gnosisTx.data, gnosisTx.operation, gnosisTx.safeTxGas, gnosisTx.baseGas, gnosisTx.gasPrice, gnosisTx.gasToken, gnosisTx.refundReceiver, (0, utils_1.buildSignatureBytes)(validSignatures));
128
+ const [gasPrice, gasLimit] = await Promise.all([
129
+ this.sourceProvider.getGasPrice(),
130
+ this.sourceProvider.estimateGas({
131
+ from: this.sourceWallet.address,
132
+ to: this.sourceGnosisContract.address,
133
+ data: txData,
134
+ }),
135
+ ]);
124
136
  const txSent = await this.sourceWallet.sendTransaction({
125
137
  from: this.sourceWallet.address,
126
- gasPrice: ethers_1.ethers.BigNumber.from(120 * 10 ** 9),
127
138
  to: this.sourceGnosisContract.address,
139
+ gasPrice: gasPrice.mul(120).div(100),
140
+ gasLimit: 5000000,
128
141
  data: txData,
129
142
  });
130
143
  console.log(txSent);
@@ -151,7 +164,6 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
151
164
  if (txSent.blockNumber)
152
165
  transaction.sourceBlockNumber = txSent.blockNumber;
153
166
  transaction.sourceTransactionHash = txSent.hash;
154
- transaction.sourceTransactionHash = txSent.hash;
155
167
  transaction.status = "failed";
156
168
  await transaction.save();
157
169
  }