@instadapp/interop-x 0.0.0-dev.c279cb8 → 0.0.0-dev.c696e38

Sign up to get free protection for your applications and to get access to all the features.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.c279cb8",
3
+ "version": "0.0.0-dev.c696e38",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -11,7 +11,7 @@ exports.addresses = {
11
11
  43114: {
12
12
  gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
13
13
  multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
14
- interopX: '0xd61f55C6d9deD35B9d13243b816c4BcC1d78592b',
14
+ interopX: '0xA82A87096709E3D8648c9d9a22f31133bC4B6d32',
15
15
  dsaAddress: '0xFcB7d826E32081c4799de2f83b47b49df600dc8c',
16
16
  }
17
17
  };
@@ -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,16 @@ 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,
65
69
  },
66
70
  status: {
67
71
  type: sequelize_2.DataTypes.STRING,
68
- defaultValue: 'pending'
72
+ defaultValue: "pending",
69
73
  },
70
74
  createdAt: sequelize_2.DataTypes.DATE,
71
75
  updatedAt: sequelize_2.DataTypes.DATE,
72
- }, { sequelize: sequelize_1.sequelize, tableName: 'transactions' });
76
+ }, { sequelize: sequelize_1.sequelize, tableName: "transactions" });
@@ -28,9 +28,18 @@ async function default_1(transaction) {
28
28
  args: [withdraw.sourceToken, withdraw.amount, "2", "0", "0"],
29
29
  };
30
30
  sourceSpells.push({
31
- connector: spellData.method,
31
+ connector: spellData.connector,
32
32
  data: (0, utils_1.encodeConnectorMethod)(spellData),
33
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
+ });
34
43
  }
35
44
  for (const supply of position.supply) {
36
45
  let spellDataWithdraw = {
@@ -39,30 +48,19 @@ async function default_1(transaction) {
39
48
  args: [supply.sourceToken, supply.amount, "0", "0"],
40
49
  };
41
50
  sourceSpells.push({
42
- connector: spellDataWithdraw.method,
51
+ connector: spellDataWithdraw.connector,
43
52
  data: (0, utils_1.encodeConnectorMethod)(spellDataWithdraw),
44
53
  });
45
54
  let spellDataBasicWithdraw = {
46
55
  connector: "BASIC-A",
47
56
  method: "withdraw",
48
- args: [supply.sourceToken, supply.amount, sourceUserAddress, "0", "0"],
57
+ args: [supply.sourceToken, supply.amount, dsaAddress, "0", "0"],
49
58
  };
50
- commonSpells.push({
51
- connector: spellDataBasicWithdraw.method,
59
+ sourceSpells.push({
60
+ connector: spellDataBasicWithdraw.connector,
52
61
  data: (0, utils_1.encodeConnectorMethod)(spellDataBasicWithdraw),
53
62
  });
54
63
  }
55
- // for (const withdraw of position.withdraw) {
56
- // let spellDataBasicWithdraw = {
57
- // connector: "BASIC-A",
58
- // method: "withdraw",
59
- // args: [withdraw.sourceToken, withdraw.amount, sourceUserAddress, "0", "0"],
60
- // };
61
- // commonSpells.push({
62
- // connector: spellDataBasicWithdraw.method,
63
- // data: encodeConnectorMethod(spellDataBasicWithdraw),
64
- // });
65
- // }
66
64
  const { data } = await contract.populateTransaction.sourceAction(sourceSpells, commonSpells, position, actionId, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata);
67
65
  transactions.push({
68
66
  to: interopAddress,
@@ -1,8 +1,85 @@
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 dsaAddress = constants_1.addresses[targetChainId].dsaAddress;
19
+ const sourceUserAddress = Number(sourceDsaId) == 0 ? sourceSender : dsaAddress;
20
+ const interopAddress = constants_1.addresses[targetChainId].interopX;
21
+ const contract = (0, utils_1.getContract)(interopAddress, abi_1.default.interopX, targetWallet);
22
+ const targetSpells = [];
23
+ const commonSpells = [];
24
+ for (const supplyToken of position.supply) {
25
+ let spellData = {
26
+ connector: "AAVE-V2-A",
27
+ method: "deposit",
28
+ args: [supplyToken.targetToken, supplyToken.amount, "0", "0"],
29
+ };
30
+ targetSpells.push({
31
+ connector: spellData.connector,
32
+ data: (0, utils_1.encodeConnectorMethod)(spellData),
33
+ });
34
+ let spellDataBasicWithdraw = {
35
+ connector: "BASIC-A",
36
+ method: "withdraw",
37
+ args: [supplyToken.targetToken, supplyToken.amount, sourceUserAddress, "0", "0"],
38
+ };
39
+ commonSpells.push({
40
+ connector: spellDataBasicWithdraw.connector,
41
+ data: (0, utils_1.encodeConnectorMethod)(spellDataBasicWithdraw),
42
+ });
43
+ }
44
+ for (const withdrawToken of position.withdraw) {
45
+ let spellData = {
46
+ connector: "AAVE-V2-A",
47
+ method: "borrow",
48
+ args: [
49
+ withdrawToken.targetToken,
50
+ withdrawToken.amount,
51
+ "2",
52
+ "0",
53
+ "0",
54
+ ],
55
+ };
56
+ targetSpells.push({
57
+ connector: spellData.connector,
58
+ data: (0, utils_1.encodeConnectorMethod)(spellData),
59
+ });
60
+ let spellData2 = {
61
+ connector: "BASIC-A",
62
+ method: "withdraw",
63
+ args: [
64
+ withdrawToken.targetToken,
65
+ withdrawToken.amount,
66
+ dsaAddress,
67
+ "0",
68
+ "0",
69
+ ],
70
+ };
71
+ targetSpells.push({
72
+ connector: spellData.connector,
73
+ data: (0, utils_1.encodeConnectorMethod)(spellData2),
74
+ });
75
+ }
76
+ const { data } = await contract.populateTransaction.targetAction(sourceSpells, targetSpells, commonSpells, position, actionId, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata);
77
+ transactions.push({
78
+ to: interopAddress,
79
+ data: data,
80
+ value: "0",
81
+ operation: ethers_multisend_1.OperationType.Call,
82
+ });
6
83
  return { transactions, logs };
7
84
  }
8
85
  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 = 'c279cb8';
16
+ const GIT_SHORT_HASH = 'c696e38';
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})`);
@@ -136,7 +136,7 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
136
136
  from: this.sourceWallet.address,
137
137
  to: this.sourceGnosisContract.address,
138
138
  gasPrice: gasPrice.mul(120).div(100),
139
- gasLimit: gasLimit.mul(120).div(100),
139
+ gasLimit: 5000000,
140
140
  data: txData,
141
141
  });
142
142
  console.log(txSent);
@@ -163,7 +163,6 @@ class ProcessSubmitSubmitEvents extends BaseTask_1.BaseTask {
163
163
  if (txSent.blockNumber)
164
164
  transaction.sourceBlockNumber = txSent.blockNumber;
165
165
  transaction.sourceTransactionHash = txSent.hash;
166
- transaction.sourceTransactionHash = txSent.hash;
167
166
  transaction.status = "failed";
168
167
  await transaction.save();
169
168
  }
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseTask_1 = require("../BaseTask");
7
+ const logger_1 = __importDefault(require("@/logger"));
8
+ const ethers_1 = require("ethers");
9
+ const abi_1 = __importDefault(require("@/abi"));
10
+ const db_1 = require("@/db");
11
+ const utils_1 = require("@/utils");
12
+ const constants_1 = require("@/constants");
13
+ const config_1 = __importDefault(require("@/config"));
14
+ const moment_1 = __importDefault(require("moment"));
15
+ const sequelize_1 = require("sequelize");
16
+ const gnosis_1 = require("@/gnosis");
17
+ const net_1 = require("@/net");
18
+ const waait_1 = __importDefault(require("waait"));
19
+ class ProcessValidateEvents extends BaseTask_1.BaseTask {
20
+ constructor({ chainId }) {
21
+ super({
22
+ logger: new logger_1.default("InteropX::ProcessValidateEvents"),
23
+ });
24
+ this.leadNodeOnly = true;
25
+ this.blockConfirmationsCount = 12;
26
+ this.chainId = chainId;
27
+ }
28
+ async pollHandler() {
29
+ var _a;
30
+ const currentBlockNumber = await this.sourceProvider.getBlockNumber();
31
+ const transaction = await db_1.Transaction.findOne({
32
+ where: {
33
+ status: "pending",
34
+ sourceStatus: "success",
35
+ targetStatus: "pending",
36
+ sourceChainId: this.chainId,
37
+ sourceBlockNumber: {
38
+ [sequelize_1.Op.lt]: currentBlockNumber - this.blockConfirmationsCount,
39
+ },
40
+ targetDelayUntil: {
41
+ [sequelize_1.Op.or]: {
42
+ [sequelize_1.Op.is]: null,
43
+ [sequelize_1.Op.lt]: new Date(),
44
+ },
45
+ },
46
+ submitEvent: { $ne: null },
47
+ validateEvent: { $ne: null },
48
+ createdAt: {
49
+ [sequelize_1.Op.gt]: (0, moment_1.default)().subtract({ hours: 12 }).toDate(),
50
+ },
51
+ },
52
+ });
53
+ if (!transaction) {
54
+ return;
55
+ }
56
+ this.logger.debug(`Processing transaction ${transaction.transactionHash}`);
57
+ transaction.targetStatus = "proccessing";
58
+ await transaction.save();
59
+ const { sourceChainId, targetChainId } = transaction.validateEvent;
60
+ const targetProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(targetChainId));
61
+ const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetProvider);
62
+ const targetGnosisContract = (0, utils_1.getContract)(constants_1.addresses[targetChainId].gnosisSafe, abi_1.default.gnosisSafe, targetWallet);
63
+ const ownersThreshold = await targetGnosisContract.getThreshold();
64
+ await (0, waait_1.default)(10000);
65
+ this.logger.debug(`Build gnosis action for ${transaction.transactionHash}`);
66
+ let data, logs = [];
67
+ try {
68
+ ({ data, logs } = await (0, gnosis_1.buildGnosisAction)(transaction, "target"));
69
+ }
70
+ catch (error) {
71
+ if (error instanceof utils_1.LiquidityError) {
72
+ await transaction.save();
73
+ transaction.targetDelayUntil = new Date(Date.now() + 60 * 5 * 1000);
74
+ transaction.targetStatus = "pending";
75
+ await transaction.save();
76
+ throw error;
77
+ return;
78
+ }
79
+ transaction.targetStatus = "failed";
80
+ transaction.targetErrors = [error.message];
81
+ transaction.status = "failed";
82
+ await transaction.save();
83
+ net_1.protocol.sendTransaction(transaction);
84
+ return;
85
+ }
86
+ this.logger.debug(`Generating gnosis tx for ${transaction.transactionHash}`);
87
+ let gnosisTx = await (0, utils_1.generateGnosisTransaction)({
88
+ baseGas: "0",
89
+ data,
90
+ gasPrice: "0",
91
+ gasToken: "0x0000000000000000000000000000000000000000",
92
+ nonce: "0",
93
+ operation: "1",
94
+ refundReceiver: "0x0000000000000000000000000000000000000000",
95
+ safeAddress: targetGnosisContract.address,
96
+ safeTxGas: "79668",
97
+ to: constants_1.addresses[transaction.targetChainId].multisend,
98
+ value: "0",
99
+ }, targetGnosisContract);
100
+ const owners = await targetGnosisContract
101
+ .getOwners()
102
+ .then((owners) => owners.map((owner) => owner.toLowerCase()));
103
+ const ownerPeerIds = net_1.peerPool.activePeers
104
+ .filter((peer) => owners.includes(peer.publicAddress.toLowerCase()))
105
+ .map((peer) => peer.id);
106
+ console.log(`Collecting signatures for execution ${transaction.transactionHash}`);
107
+ console.log(ownerPeerIds);
108
+ const signatures = await net_1.protocol.requestSignatures({
109
+ type: "target",
110
+ transactionHash: transaction.transactionHash,
111
+ safeTxGas: gnosisTx.safeTxGas,
112
+ safeNonce: gnosisTx.nonce,
113
+ chainId: targetChainId,
114
+ }, ownerPeerIds);
115
+ const validSignatures = signatures.filter((s) => !!s.data && s.data !== "0x");
116
+ console.log({
117
+ signatures,
118
+ validSignatures,
119
+ ownersThreshold: ownersThreshold.toString(),
120
+ });
121
+ if (validSignatures.length === 0 ||
122
+ ownersThreshold.gt(validSignatures.length)) {
123
+ await transaction.save();
124
+ transaction.targetDelayUntil = new Date(Date.now() + 30 * 1000);
125
+ transaction.targetStatus = "pending";
126
+ await transaction.save();
127
+ const errorMessage = (_a = signatures.find((s) => !!s.error)) === null || _a === void 0 ? void 0 : _a.error;
128
+ throw new Error(`Not enough signatures` + (errorMessage ? `: ${errorMessage}` : ""));
129
+ }
130
+ console.log(`Executing transaction for execution ${transaction.transactionHash}`);
131
+ const { data: txData } = await targetGnosisContract.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));
132
+ const [gasPrice, gasLimit] = await Promise.all([
133
+ targetProvider.getGasPrice(),
134
+ targetProvider.estimateGas({
135
+ from: targetWallet.address,
136
+ to: targetGnosisContract.address,
137
+ data: txData,
138
+ }),
139
+ ]);
140
+ const txSent = await targetWallet.sendTransaction({
141
+ from: targetWallet.address,
142
+ to: targetGnosisContract.address,
143
+ gasPrice: gasPrice.mul(120).div(100),
144
+ gasLimit: 5000000,
145
+ data: txData,
146
+ });
147
+ console.log(txSent);
148
+ const receipt = await txSent.wait();
149
+ const parsedLogs = [];
150
+ receipt.logs.forEach((log) => {
151
+ try {
152
+ parsedLogs.push(targetGnosisContract.interface.parseLog(log));
153
+ }
154
+ catch (e) { }
155
+ });
156
+ if (parsedLogs.find((e) => e.name === "ExecutionSuccess")) {
157
+ console.log("ExecutionSuccess");
158
+ transaction.targetStatus = "success";
159
+ transaction.status = "success";
160
+ if (txSent.blockNumber)
161
+ transaction.targetBlockNumber = txSent.blockNumber;
162
+ transaction.targetTransactionHash = txSent.hash;
163
+ transaction.targetLogs = logs;
164
+ await transaction.save();
165
+ }
166
+ else {
167
+ console.log("ExecutionFailure");
168
+ transaction.targetStatus = "failed";
169
+ if (txSent.blockNumber)
170
+ transaction.targetBlockNumber = txSent.blockNumber;
171
+ transaction.targetTransactionHash = txSent.hash;
172
+ transaction.status = "failed";
173
+ await transaction.save();
174
+ }
175
+ net_1.protocol.sendTransaction(transaction);
176
+ }
177
+ async start() {
178
+ this.blockConfirmationsCount = constants_1.blockConfirmations[this.chainId] + 1;
179
+ this.sourceProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
180
+ await super.start();
181
+ }
182
+ }
183
+ exports.default = ProcessValidateEvents;
@@ -47,6 +47,7 @@ class SyncLogSubmitEvents extends BaseTask_1.BaseTask {
47
47
  await db_1.Transaction.create(Object.assign(Object.assign({ transactionHash }, uniqueIdentifier), { submitChainId: this.chainId, submitTransactionHash: event.transactionHash, submitBlockNumber: event.blockNumber, submitCreatedAt: new Date(), submitEvent: {
48
48
  actionId,
49
49
  actionIdHashHash,
50
+ actionIdHash: actionIdHashHash,
50
51
  vnonce: vnonce.toString(),
51
52
  position: {
52
53
  withdraw: position.withdraw.map((v) => ({
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseTask_1 = require("../BaseTask");
7
+ const logger_1 = __importDefault(require("@/logger"));
8
+ const ethers_1 = require("ethers");
9
+ const abi_1 = __importDefault(require("@/abi"));
10
+ const db_1 = require("@/db");
11
+ const utils_1 = require("@/utils");
12
+ const constants_1 = require("@/constants");
13
+ const config_1 = __importDefault(require("@/config"));
14
+ const sequelize_1 = require("sequelize");
15
+ class SyncLogValidateEvents extends BaseTask_1.BaseTask {
16
+ constructor({ chainId }) {
17
+ super({
18
+ logger: new logger_1.default("InteropX::SyncLogValidateEvents"),
19
+ });
20
+ this.chainId = chainId;
21
+ }
22
+ async pollHandler() {
23
+ const currentBlock = await this.provider.getBlockNumber();
24
+ const events = await this.contract.queryFilter(this.contract.filters.LogValidate(), currentBlock - 2000, currentBlock);
25
+ let processedEvents = 0;
26
+ for (const event of events) {
27
+ try {
28
+ if (!event.args) {
29
+ continue;
30
+ }
31
+ const { sourceSpells, position, actionId, actionIdHash, sourceSender, sourceDsaId, targetDsaId, sourceChainId, targetChainId, vnonce, metadata, } = event.args;
32
+ const uniqueIdentifier = {
33
+ actionId,
34
+ vnonce: vnonce.toString(),
35
+ sourceSender: sourceSender.toString(),
36
+ sourceChainId: sourceChainId.toNumber(),
37
+ targetChainId: targetChainId.toNumber(),
38
+ sourceDsaId: sourceDsaId.toString(),
39
+ targetDsaId: targetDsaId.toString(),
40
+ };
41
+ let transactionHash = (0, utils_1.generateInteropTransactionHash)(uniqueIdentifier);
42
+ const transaction = await db_1.Transaction.findOne({
43
+ where: {
44
+ transactionHash,
45
+ validateEvent: { [sequelize_1.Op.eq]: null },
46
+ },
47
+ });
48
+ if (!transaction) {
49
+ continue;
50
+ }
51
+ if (transaction.sourceStatus != "success") {
52
+ transaction.sourceStatus = "success";
53
+ }
54
+ if (!transaction.sourceCreatedAt) {
55
+ transaction.sourceCreatedAt = new Date();
56
+ }
57
+ transaction.sourceTransactionHash = event.transactionHash;
58
+ transaction.sourceBlockNumber = event.blockNumber;
59
+ transaction.sourceLogs = [];
60
+ (transaction.validateEvent = {
61
+ actionId,
62
+ actionIdHashHash: actionIdHash,
63
+ actionIdHash,
64
+ vnonce: vnonce.toString(),
65
+ sourceSpells: sourceSpells.map(({ connector, data }) => ({
66
+ connector,
67
+ data,
68
+ })),
69
+ position: {
70
+ withdraw: position.withdraw.map((v) => ({
71
+ sourceToken: v.sourceToken,
72
+ targetToken: v.targetToken,
73
+ amount: v.amount.toString(),
74
+ })),
75
+ supply: position.supply.map((v) => ({
76
+ sourceToken: v.sourceToken,
77
+ targetToken: v.targetToken,
78
+ amount: v.amount.toString(),
79
+ })),
80
+ },
81
+ sourceChainId: sourceChainId.toNumber(),
82
+ targetChainId: targetChainId.toNumber(),
83
+ sourceSender,
84
+ sourceDsaId: sourceDsaId.toString(),
85
+ targetDsaId: targetDsaId.toString(),
86
+ metadata,
87
+ }),
88
+ await transaction.save();
89
+ this.logger.info(`New InteropX tranaction: ${transactionHash} `);
90
+ }
91
+ catch (error) {
92
+ this.logger.error(error);
93
+ }
94
+ }
95
+ if (processedEvents > 0)
96
+ this.logger.info(`${processedEvents} events processed`);
97
+ }
98
+ async start() {
99
+ this.contractAddress = constants_1.addresses[this.chainId].interopX;
100
+ this.provider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
101
+ this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopX, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
102
+ await super.start();
103
+ }
104
+ }
105
+ exports.default = SyncLogValidateEvents;
@@ -9,6 +9,8 @@ const SyncTransactionStatusTask_1 = __importDefault(require("./Transactions/Sync
9
9
  const AutoUpdateTask_1 = __importDefault(require("./AutoUpdateTask"));
10
10
  const SyncLogSubmitEvents_1 = __importDefault(require("./InteropX/SyncLogSubmitEvents"));
11
11
  const ProcessSubmitSubmitEvents_1 = __importDefault(require("./InteropX/ProcessSubmitSubmitEvents"));
12
+ const SyncLogValidateEvents_1 = __importDefault(require("./InteropX/SyncLogValidateEvents"));
13
+ const ProcessValidateEvents_1 = __importDefault(require("./InteropX/ProcessValidateEvents"));
12
14
  class Tasks {
13
15
  constructor() {
14
16
  this.tasks = [
@@ -19,6 +21,10 @@ class Tasks {
19
21
  new SyncLogSubmitEvents_1.default({ chainId: 43114 }),
20
22
  new ProcessSubmitSubmitEvents_1.default({ chainId: 137 }),
21
23
  new ProcessSubmitSubmitEvents_1.default({ chainId: 43114 }),
24
+ new SyncLogValidateEvents_1.default({ chainId: 137 }),
25
+ new SyncLogValidateEvents_1.default({ chainId: 43114 }),
26
+ new ProcessValidateEvents_1.default({ chainId: 137 }),
27
+ new ProcessValidateEvents_1.default({ chainId: 43114 }),
22
28
  new SyncTransactionStatusTask_1.default(),
23
29
  ];
24
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.c279cb8",
3
+ "version": "0.0.0-dev.c696e38",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -8,7 +8,7 @@ export const addresses = {
8
8
  43114: {
9
9
  gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
10
10
  multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
11
- interopX: '0xd61f55C6d9deD35B9d13243b816c4BcC1d78592b',
11
+ interopX: '0xA82A87096709E3D8648c9d9a22f31133bC4B6d32',
12
12
  dsaAddress: '0xFcB7d826E32081c4799de2f83b47b49df600dc8c',
13
13
  }
14
14
  } as Record<number, { gnosisSafe: string, multisend: string, interopX: string, dsaAddress: string }>