@shapeshiftoss/unchained-client 6.10.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/bitcoin/index.d.ts +0 -1
- package/dist/bitcoin/index.js +5 -2
- package/dist/bitcoin/parser/index.d.ts +0 -1
- package/dist/bitcoin/parser/index.js +43 -54
- package/dist/bitcoin/parser/utils.d.ts +0 -1
- package/dist/bitcoin/parser/utils.js +0 -1
- package/dist/bitcoin/types.d.ts +0 -1
- package/dist/bitcoin/types.js +0 -1
- package/dist/cosmos/index.d.ts +0 -1
- package/dist/cosmos/index.js +5 -2
- package/dist/cosmos/parser/index.d.ts +4 -5
- package/dist/cosmos/parser/index.js +55 -50
- package/dist/cosmos/parser/utils.d.ts +3 -4
- package/dist/cosmos/parser/utils.js +28 -25
- package/dist/cosmos/types.d.ts +4 -1
- package/dist/cosmos/types.js +0 -1
- package/dist/ethereum/index.d.ts +0 -1
- package/dist/ethereum/index.js +5 -2
- package/dist/ethereum/parser/abi/erc20.d.ts +0 -1
- package/dist/ethereum/parser/abi/erc20.js +69 -70
- package/dist/ethereum/parser/abi/foxyStaking.d.ts +0 -1
- package/dist/ethereum/parser/abi/foxyStaking.js +161 -162
- package/dist/ethereum/parser/abi/multiSig.d.ts +0 -1
- package/dist/ethereum/parser/abi/multiSig.js +79 -80
- package/dist/ethereum/parser/abi/shapeShiftRouter.d.ts +0 -1
- package/dist/ethereum/parser/abi/shapeShiftRouter.js +119 -120
- package/dist/ethereum/parser/abi/thor.d.ts +0 -1
- package/dist/ethereum/parser/abi/thor.js +28 -29
- package/dist/ethereum/parser/abi/uniV2.d.ts +0 -1
- package/dist/ethereum/parser/abi/uniV2.js +55 -56
- package/dist/ethereum/parser/abi/weth.d.ts +0 -1
- package/dist/ethereum/parser/abi/weth.js +66 -67
- package/dist/ethereum/parser/abi/yearnVault.d.ts +0 -1
- package/dist/ethereum/parser/abi/yearnVault.js +95 -96
- package/dist/ethereum/parser/constants.d.ts +0 -1
- package/dist/ethereum/parser/constants.js +0 -1
- package/dist/ethereum/parser/foxy.d.ts +8 -9
- package/dist/ethereum/parser/foxy.js +27 -59
- package/dist/ethereum/parser/index.d.ts +0 -1
- package/dist/ethereum/parser/index.js +52 -59
- package/dist/ethereum/parser/thor.d.ts +6 -5
- package/dist/ethereum/parser/thor.js +33 -49
- package/dist/ethereum/parser/uniV2.d.ts +5 -5
- package/dist/ethereum/parser/uniV2.js +75 -82
- package/dist/ethereum/parser/utils.d.ts +0 -1
- package/dist/ethereum/parser/utils.js +2 -3
- package/dist/ethereum/parser/weth.d.ts +6 -5
- package/dist/ethereum/parser/weth.js +76 -99
- package/dist/ethereum/parser/yearn.d.ts +11 -12
- package/dist/ethereum/parser/yearn.js +51 -62
- package/dist/ethereum/parser/zrx.d.ts +1 -2
- package/dist/ethereum/parser/zrx.js +18 -30
- package/dist/ethereum/types.d.ts +0 -1
- package/dist/ethereum/types.js +0 -1
- package/dist/generated/bitcoin/api.d.ts +117 -121
- package/dist/generated/bitcoin/api.js +82 -111
- package/dist/generated/bitcoin/base.d.ts +3 -4
- package/dist/generated/bitcoin/base.js +2 -3
- package/dist/generated/bitcoin/common.d.ts +3 -4
- package/dist/generated/bitcoin/common.js +23 -39
- package/dist/generated/bitcoin/configuration.d.ts +1 -2
- package/dist/generated/bitcoin/configuration.js +1 -2
- package/dist/generated/bitcoin/index.d.ts +1 -2
- package/dist/generated/bitcoin/index.js +6 -3
- package/dist/generated/cosmos/api.d.ts +143 -144
- package/dist/generated/cosmos/api.js +89 -115
- package/dist/generated/cosmos/base.d.ts +2 -3
- package/dist/generated/cosmos/base.js +0 -1
- package/dist/generated/cosmos/common.d.ts +2 -3
- package/dist/generated/cosmos/common.js +22 -38
- package/dist/generated/cosmos/configuration.d.ts +0 -1
- package/dist/generated/cosmos/configuration.js +0 -1
- package/dist/generated/cosmos/index.d.ts +0 -1
- package/dist/generated/cosmos/index.js +5 -2
- package/dist/generated/ethereum/api.d.ts +74 -78
- package/dist/generated/ethereum/api.js +74 -101
- package/dist/generated/ethereum/base.d.ts +3 -4
- package/dist/generated/ethereum/base.js +2 -3
- package/dist/generated/ethereum/common.d.ts +3 -4
- package/dist/generated/ethereum/common.js +23 -39
- package/dist/generated/ethereum/configuration.d.ts +1 -2
- package/dist/generated/ethereum/configuration.js +1 -2
- package/dist/generated/ethereum/index.d.ts +1 -2
- package/dist/generated/ethereum/index.js +6 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +5 -2
- package/dist/types.d.ts +12 -2
- package/dist/types.js +0 -1
- package/dist/utils.d.ts +2 -3
- package/dist/utils.js +23 -23
- package/dist/websocket.d.ts +1 -2
- package/dist/websocket.js +78 -80
- package/package.json +21 -13
- package/dist/bitcoin/index.d.ts.map +0 -1
- package/dist/bitcoin/index.js.map +0 -1
- package/dist/bitcoin/parser/index.d.ts.map +0 -1
- package/dist/bitcoin/parser/index.js.map +0 -1
- package/dist/bitcoin/parser/utils.d.ts.map +0 -1
- package/dist/bitcoin/parser/utils.js.map +0 -1
- package/dist/bitcoin/types.d.ts.map +0 -1
- package/dist/bitcoin/types.js.map +0 -1
- package/dist/cosmos/index.d.ts.map +0 -1
- package/dist/cosmos/index.js.map +0 -1
- package/dist/cosmos/parser/index.d.ts.map +0 -1
- package/dist/cosmos/parser/index.js.map +0 -1
- package/dist/cosmos/parser/utils.d.ts.map +0 -1
- package/dist/cosmos/parser/utils.js.map +0 -1
- package/dist/cosmos/types.d.ts.map +0 -1
- package/dist/cosmos/types.js.map +0 -1
- package/dist/ethereum/index.d.ts.map +0 -1
- package/dist/ethereum/index.js.map +0 -1
- package/dist/ethereum/parser/abi/erc20.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/erc20.js.map +0 -1
- package/dist/ethereum/parser/abi/foxyStaking.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/foxyStaking.js.map +0 -1
- package/dist/ethereum/parser/abi/multiSig.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/multiSig.js.map +0 -1
- package/dist/ethereum/parser/abi/shapeShiftRouter.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/shapeShiftRouter.js.map +0 -1
- package/dist/ethereum/parser/abi/thor.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/thor.js.map +0 -1
- package/dist/ethereum/parser/abi/uniV2.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/uniV2.js.map +0 -1
- package/dist/ethereum/parser/abi/weth.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/weth.js.map +0 -1
- package/dist/ethereum/parser/abi/yearnVault.d.ts.map +0 -1
- package/dist/ethereum/parser/abi/yearnVault.js.map +0 -1
- package/dist/ethereum/parser/constants.d.ts.map +0 -1
- package/dist/ethereum/parser/constants.js.map +0 -1
- package/dist/ethereum/parser/foxy.d.ts.map +0 -1
- package/dist/ethereum/parser/foxy.js.map +0 -1
- package/dist/ethereum/parser/index.d.ts.map +0 -1
- package/dist/ethereum/parser/index.js.map +0 -1
- package/dist/ethereum/parser/thor.d.ts.map +0 -1
- package/dist/ethereum/parser/thor.js.map +0 -1
- package/dist/ethereum/parser/uniV2.d.ts.map +0 -1
- package/dist/ethereum/parser/uniV2.js.map +0 -1
- package/dist/ethereum/parser/utils.d.ts.map +0 -1
- package/dist/ethereum/parser/utils.js.map +0 -1
- package/dist/ethereum/parser/weth.d.ts.map +0 -1
- package/dist/ethereum/parser/weth.js.map +0 -1
- package/dist/ethereum/parser/yearn.d.ts.map +0 -1
- package/dist/ethereum/parser/yearn.js.map +0 -1
- package/dist/ethereum/parser/zrx.d.ts.map +0 -1
- package/dist/ethereum/parser/zrx.js.map +0 -1
- package/dist/ethereum/types.d.ts.map +0 -1
- package/dist/ethereum/types.js.map +0 -1
- package/dist/generated/bitcoin/api.d.ts.map +0 -1
- package/dist/generated/bitcoin/api.js.map +0 -1
- package/dist/generated/bitcoin/base.d.ts.map +0 -1
- package/dist/generated/bitcoin/base.js.map +0 -1
- package/dist/generated/bitcoin/common.d.ts.map +0 -1
- package/dist/generated/bitcoin/common.js.map +0 -1
- package/dist/generated/bitcoin/configuration.d.ts.map +0 -1
- package/dist/generated/bitcoin/configuration.js.map +0 -1
- package/dist/generated/bitcoin/index.d.ts.map +0 -1
- package/dist/generated/bitcoin/index.js.map +0 -1
- package/dist/generated/cosmos/api.d.ts.map +0 -1
- package/dist/generated/cosmos/api.js.map +0 -1
- package/dist/generated/cosmos/base.d.ts.map +0 -1
- package/dist/generated/cosmos/base.js.map +0 -1
- package/dist/generated/cosmos/common.d.ts.map +0 -1
- package/dist/generated/cosmos/common.js.map +0 -1
- package/dist/generated/cosmos/configuration.d.ts.map +0 -1
- package/dist/generated/cosmos/configuration.js.map +0 -1
- package/dist/generated/cosmos/index.d.ts.map +0 -1
- package/dist/generated/cosmos/index.js.map +0 -1
- package/dist/generated/ethereum/api.d.ts.map +0 -1
- package/dist/generated/ethereum/api.js.map +0 -1
- package/dist/generated/ethereum/base.d.ts.map +0 -1
- package/dist/generated/ethereum/base.js.map +0 -1
- package/dist/generated/ethereum/common.d.ts.map +0 -1
- package/dist/generated/ethereum/common.js.map +0 -1
- package/dist/generated/ethereum/configuration.d.ts.map +0 -1
- package/dist/generated/ethereum/configuration.js.map +0 -1
- package/dist/generated/ethereum/index.d.ts.map +0 -1
- package/dist/generated/ethereum/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -4970
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
- package/dist/websocket.d.ts.map +0 -1
- package/dist/websocket.js.map +0 -1
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -17,114 +8,116 @@ const caip_1 = require("@shapeshiftoss/caip");
|
|
|
17
8
|
const types_1 = require("@shapeshiftoss/types");
|
|
18
9
|
const ethers_1 = require("ethers");
|
|
19
10
|
const types_2 = require("../../types");
|
|
20
|
-
const uniV2_1 = __importDefault(require("./abi/uniV2"));
|
|
21
11
|
const erc20_1 = __importDefault(require("./abi/erc20"));
|
|
22
|
-
const
|
|
12
|
+
const uniV2_1 = __importDefault(require("./abi/uniV2"));
|
|
23
13
|
const constants_1 = require("./constants");
|
|
14
|
+
const utils_1 = require("./utils");
|
|
24
15
|
class Parser {
|
|
25
16
|
constructor(args) {
|
|
26
17
|
this.abiInterface = new ethers_1.ethers.utils.Interface(uniV2_1.default);
|
|
18
|
+
this.supportedFunctions = {
|
|
19
|
+
addLiquidityEthSigHash: this.abiInterface.getSighash('addLiquidityETH'),
|
|
20
|
+
removeLiquidityEthSigHash: this.abiInterface.getSighash('removeLiquidityETH')
|
|
21
|
+
};
|
|
27
22
|
this.network = args.network;
|
|
28
23
|
this.provider = args.provider;
|
|
29
|
-
this.addLiquidityEthSigHash = this.abiInterface.getSighash('addLiquidityETH');
|
|
30
|
-
this.removeLiquidityEthSigHash = this.abiInterface.getSighash('removeLiquidityETH');
|
|
31
24
|
this.wethContract = {
|
|
32
25
|
mainnet: constants_1.WETH_CONTRACT_MAINNET,
|
|
33
|
-
ropsten: constants_1.WETH_CONTRACT_ROPSTEN
|
|
26
|
+
ropsten: constants_1.WETH_CONTRACT_ROPSTEN
|
|
34
27
|
}[this.network];
|
|
35
28
|
}
|
|
36
|
-
parse(tx) {
|
|
37
|
-
var _a;
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (!((_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data))
|
|
40
|
-
return;
|
|
41
|
-
if (!utils_1.txInteractsWithContract(tx, constants_1.UNI_V2_ROUTER_CONTRACT))
|
|
42
|
-
return;
|
|
43
|
-
if (!(tx.confirmations === 0))
|
|
44
|
-
return;
|
|
45
|
-
const transfers = yield this.getTransfers(tx);
|
|
46
|
-
const decoded = this.abiInterface.parseTransaction({ data: tx.ethereumSpecific.data });
|
|
47
|
-
return {
|
|
48
|
-
transfers,
|
|
49
|
-
data: {
|
|
50
|
-
parser: types_2.TxParser.UniV2,
|
|
51
|
-
method: decoded.name,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
static pairFor(tokenA, tokenB) {
|
|
57
|
-
const [token0, token1] = tokenA < tokenB ? [tokenA, tokenB] : [tokenB, tokenA];
|
|
58
|
-
const factoryContract = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
|
|
59
|
-
const salt = ethers_1.ethers.utils.solidityKeccak256(['address', 'address'], [token0, token1]);
|
|
60
|
-
const initCodeHash = '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'; // https://github.com/Uniswap/v2-periphery/blob/dda62473e2da448bc9cb8f4514dadda4aeede5f4/contracts/libraries/UniswapV2Library.sol#L24
|
|
61
|
-
return ethers_1.ethers.utils.getCreate2Address(factoryContract, salt, initCodeHash);
|
|
62
|
-
}
|
|
63
|
-
getTransfers(tx) {
|
|
29
|
+
async parse(tx) {
|
|
64
30
|
var _a, _b, _c;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
31
|
+
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
32
|
+
if (!(0, utils_1.txInteractsWithContract)(tx, constants_1.UNI_V2_ROUTER_CONTRACT))
|
|
33
|
+
return;
|
|
34
|
+
if (!txData)
|
|
35
|
+
return;
|
|
36
|
+
if (tx.confirmations)
|
|
37
|
+
return;
|
|
38
|
+
const txSigHash = (0, utils_1.getSigHash)(txData);
|
|
39
|
+
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
40
|
+
return;
|
|
41
|
+
const decoded = this.abiInterface.parseTransaction({ data: txData });
|
|
42
|
+
// failed to decode input data
|
|
43
|
+
if (!decoded)
|
|
44
|
+
return;
|
|
45
|
+
const sendAddress = (_c = (_b = tx.vin[0].addresses) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '';
|
|
46
|
+
const tokenAddress = ethers_1.ethers.utils.getAddress(decoded.args.token.toLowerCase());
|
|
47
|
+
const lpTokenAddress = Parser.pairFor(tokenAddress, this.wethContract);
|
|
48
|
+
const transfers = await (async () => {
|
|
49
|
+
switch ((0, utils_1.getSigHash)(txData)) {
|
|
50
|
+
case this.supportedFunctions.addLiquidityEthSigHash: {
|
|
75
51
|
const contract = new ethers_1.ethers.Contract(tokenAddress, erc20_1.default, this.provider);
|
|
76
|
-
const decimals =
|
|
77
|
-
const name =
|
|
78
|
-
const symbol =
|
|
79
|
-
const value =
|
|
52
|
+
const decimals = await contract.decimals();
|
|
53
|
+
const name = await contract.name();
|
|
54
|
+
const symbol = await contract.symbol();
|
|
55
|
+
const value = decoded.args.amountTokenDesired.toString();
|
|
56
|
+
const assetId = (0, caip_1.toCAIP19)({
|
|
57
|
+
chain: types_1.ChainTypes.Ethereum,
|
|
58
|
+
network: (0, utils_1.toNetworkType)(this.network),
|
|
59
|
+
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
60
|
+
assetReference: tokenAddress
|
|
61
|
+
});
|
|
80
62
|
return [
|
|
81
63
|
{
|
|
82
64
|
type: types_2.TransferType.Send,
|
|
83
65
|
from: sendAddress,
|
|
84
66
|
to: lpTokenAddress,
|
|
85
|
-
caip19:
|
|
86
|
-
|
|
87
|
-
network: utils_1.toNetworkType(this.network),
|
|
88
|
-
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
89
|
-
assetReference: tokenAddress,
|
|
90
|
-
}),
|
|
67
|
+
caip19: assetId,
|
|
68
|
+
assetId,
|
|
91
69
|
totalValue: value,
|
|
92
70
|
components: [{ value }],
|
|
93
|
-
token: { contract: tokenAddress, decimals, name, symbol }
|
|
94
|
-
}
|
|
71
|
+
token: { contract: tokenAddress, decimals, name, symbol }
|
|
72
|
+
}
|
|
95
73
|
];
|
|
96
74
|
}
|
|
97
|
-
case this.removeLiquidityEthSigHash: {
|
|
98
|
-
const result = this.abiInterface.decodeFunctionData(this.removeLiquidityEthSigHash, data);
|
|
99
|
-
const tokenAddress = ethers_1.ethers.utils.getAddress(result.token.toLowerCase());
|
|
100
|
-
const lpTokenAddress = Parser.pairFor(tokenAddress, this.wethContract);
|
|
75
|
+
case this.supportedFunctions.removeLiquidityEthSigHash: {
|
|
101
76
|
const contract = new ethers_1.ethers.Contract(lpTokenAddress, erc20_1.default, this.provider);
|
|
102
|
-
const decimals =
|
|
103
|
-
const name =
|
|
104
|
-
const symbol =
|
|
105
|
-
const value =
|
|
77
|
+
const decimals = await contract.decimals();
|
|
78
|
+
const name = await contract.name();
|
|
79
|
+
const symbol = await contract.symbol();
|
|
80
|
+
const value = decoded.args.liquidity.toString();
|
|
81
|
+
const assetId = (0, caip_1.toCAIP19)({
|
|
82
|
+
chain: types_1.ChainTypes.Ethereum,
|
|
83
|
+
network: (0, utils_1.toNetworkType)(this.network),
|
|
84
|
+
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
85
|
+
assetReference: lpTokenAddress
|
|
86
|
+
});
|
|
106
87
|
return [
|
|
107
88
|
{
|
|
108
89
|
type: types_2.TransferType.Send,
|
|
109
90
|
from: sendAddress,
|
|
110
91
|
to: lpTokenAddress,
|
|
111
|
-
caip19:
|
|
112
|
-
|
|
113
|
-
network: utils_1.toNetworkType(this.network),
|
|
114
|
-
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
115
|
-
assetReference: lpTokenAddress,
|
|
116
|
-
}),
|
|
92
|
+
caip19: assetId,
|
|
93
|
+
assetId,
|
|
117
94
|
totalValue: value,
|
|
118
95
|
components: [{ value }],
|
|
119
|
-
token: { contract: lpTokenAddress, decimals, name, symbol }
|
|
120
|
-
}
|
|
96
|
+
token: { contract: lpTokenAddress, decimals, name, symbol }
|
|
97
|
+
}
|
|
121
98
|
];
|
|
122
99
|
}
|
|
123
100
|
default:
|
|
124
101
|
return;
|
|
125
102
|
}
|
|
126
|
-
});
|
|
103
|
+
})();
|
|
104
|
+
// no supported function detected
|
|
105
|
+
if (!transfers)
|
|
106
|
+
return;
|
|
107
|
+
return {
|
|
108
|
+
transfers,
|
|
109
|
+
data: {
|
|
110
|
+
parser: types_2.TxParser.UniV2,
|
|
111
|
+
method: decoded.name
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
static pairFor(tokenA, tokenB) {
|
|
116
|
+
const [token0, token1] = tokenA < tokenB ? [tokenA, tokenB] : [tokenB, tokenA];
|
|
117
|
+
const factoryContract = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
|
|
118
|
+
const salt = ethers_1.ethers.utils.solidityKeccak256(['address', 'address'], [token0, token1]);
|
|
119
|
+
const initCodeHash = '0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'; // https://github.com/Uniswap/v2-periphery/blob/dda62473e2da448bc9cb8f4514dadda4aeede5f4/contracts/libraries/UniswapV2Library.sol#L24
|
|
120
|
+
return ethers_1.ethers.utils.getCreate2Address(factoryContract, salt, initCodeHash);
|
|
127
121
|
}
|
|
128
122
|
}
|
|
129
123
|
exports.Parser = Parser;
|
|
130
|
-
//# sourceMappingURL=uniV2.js.map
|
|
@@ -6,4 +6,3 @@ export declare const getSigHash: (inputData: string | undefined) => string | und
|
|
|
6
6
|
export declare const txInteractsWithContract: (tx: BlockbookTx, contract: string) => boolean;
|
|
7
7
|
export declare const SENDMULTISIG_SIG_HASH: string;
|
|
8
8
|
export declare const getInternalMultisigAddress: (inputData: string) => string | undefined;
|
|
9
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getInternalMultisigAddress = exports.SENDMULTISIG_SIG_HASH = exports.txInteractsWithContract = exports.getSigHash = exports.toNetworkType = void 0;
|
|
7
|
-
const ethers_1 = require("ethers");
|
|
8
7
|
const types_1 = require("@shapeshiftoss/types");
|
|
8
|
+
const ethers_1 = require("ethers");
|
|
9
9
|
const multiSig_1 = __importDefault(require("./abi/multiSig"));
|
|
10
10
|
const toNetworkType = (network) => {
|
|
11
11
|
switch (network) {
|
|
@@ -38,10 +38,9 @@ exports.SENDMULTISIG_SIG_HASH = (() => {
|
|
|
38
38
|
// detect address associated with sendMultiSig internal transaction
|
|
39
39
|
const getInternalMultisigAddress = (inputData) => {
|
|
40
40
|
const abiInterface = new ethers_1.ethers.utils.Interface(multiSig_1.default);
|
|
41
|
-
if (exports.getSigHash(inputData) !== exports.SENDMULTISIG_SIG_HASH)
|
|
41
|
+
if ((0, exports.getSigHash)(inputData) !== exports.SENDMULTISIG_SIG_HASH)
|
|
42
42
|
return;
|
|
43
43
|
const result = abiInterface.decodeFunctionData(exports.SENDMULTISIG_SIG_HASH, inputData);
|
|
44
44
|
return result.toAddress;
|
|
45
45
|
};
|
|
46
46
|
exports.getInternalMultisigAddress = getInternalMultisigAddress;
|
|
47
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -6,13 +6,14 @@ export interface ParserArgs {
|
|
|
6
6
|
provider: ethers.providers.JsonRpcProvider;
|
|
7
7
|
}
|
|
8
8
|
export declare class Parser implements SubParser {
|
|
9
|
-
abiInterface: ethers.utils.Interface;
|
|
10
|
-
network: Network;
|
|
11
9
|
provider: ethers.providers.JsonRpcProvider;
|
|
12
|
-
readonly
|
|
13
|
-
readonly withdrawalSigHash: string;
|
|
10
|
+
readonly network: Network;
|
|
14
11
|
readonly wethContract: string;
|
|
12
|
+
readonly abiInterface: ethers.utils.Interface;
|
|
13
|
+
readonly supportedFunctions: {
|
|
14
|
+
depositSigHash: string;
|
|
15
|
+
withdrawalSigHash: string;
|
|
16
|
+
};
|
|
15
17
|
constructor(args: ParserArgs);
|
|
16
18
|
parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
|
|
17
19
|
}
|
|
18
|
-
//# sourceMappingURL=weth.d.ts.map
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -17,109 +8,95 @@ const caip_1 = require("@shapeshiftoss/caip");
|
|
|
17
8
|
const types_1 = require("@shapeshiftoss/types");
|
|
18
9
|
const ethers_1 = require("ethers");
|
|
19
10
|
const types_2 = require("../../types");
|
|
11
|
+
const erc20_1 = __importDefault(require("./abi/erc20"));
|
|
20
12
|
const weth_1 = __importDefault(require("./abi/weth"));
|
|
21
|
-
const utils_1 = require("./utils");
|
|
22
13
|
const constants_1 = require("./constants");
|
|
23
|
-
const
|
|
14
|
+
const utils_1 = require("./utils");
|
|
24
15
|
class Parser {
|
|
25
16
|
constructor(args) {
|
|
26
17
|
this.abiInterface = new ethers_1.ethers.utils.Interface(weth_1.default);
|
|
18
|
+
this.supportedFunctions = {
|
|
19
|
+
depositSigHash: this.abiInterface.getSighash('deposit'),
|
|
20
|
+
withdrawalSigHash: this.abiInterface.getSighash('withdraw')
|
|
21
|
+
};
|
|
27
22
|
this.network = args.network;
|
|
28
23
|
this.provider = args.provider;
|
|
29
|
-
this.depositSigHash = this.abiInterface.getSighash('deposit');
|
|
30
|
-
this.withdrawalSigHash = this.abiInterface.getSighash('withdraw');
|
|
31
24
|
this.wethContract = {
|
|
32
25
|
mainnet: constants_1.WETH_CONTRACT_MAINNET,
|
|
33
|
-
ropsten: constants_1.WETH_CONTRACT_ROPSTEN
|
|
26
|
+
ropsten: constants_1.WETH_CONTRACT_ROPSTEN
|
|
34
27
|
}[this.network];
|
|
35
28
|
}
|
|
36
|
-
parse(tx) {
|
|
37
|
-
var _a, _b, _c
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
case this.withdrawalSigHash: {
|
|
80
|
-
if (receiveAddress !== this.wethContract)
|
|
81
|
-
return undefined;
|
|
82
|
-
const result = this.abiInterface.decodeFunctionData(this.withdrawalSigHash, txData);
|
|
83
|
-
const value = result.wad.toString();
|
|
84
|
-
return [
|
|
85
|
-
{
|
|
86
|
-
type: types_2.TransferType.Send,
|
|
87
|
-
from: sendAddress,
|
|
88
|
-
to: this.wethContract,
|
|
89
|
-
caip19: caip_1.caip19.toCAIP19({
|
|
90
|
-
chain: types_1.ChainTypes.Ethereum,
|
|
91
|
-
network: utils_1.toNetworkType(this.network),
|
|
92
|
-
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
93
|
-
assetReference: this.wethContract,
|
|
94
|
-
}),
|
|
95
|
-
totalValue: value,
|
|
96
|
-
components: [{ value }],
|
|
97
|
-
token: {
|
|
98
|
-
contract: this.wethContract,
|
|
99
|
-
decimals,
|
|
100
|
-
name,
|
|
101
|
-
symbol,
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
default:
|
|
107
|
-
return undefined;
|
|
29
|
+
async parse(tx) {
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
32
|
+
if (!(0, utils_1.txInteractsWithContract)(tx, this.wethContract))
|
|
33
|
+
return;
|
|
34
|
+
if (!txData)
|
|
35
|
+
return;
|
|
36
|
+
const txSigHash = (0, utils_1.getSigHash)(txData);
|
|
37
|
+
if (!Object.values(this.supportedFunctions).some((hash) => hash === txSigHash))
|
|
38
|
+
return;
|
|
39
|
+
const decoded = this.abiInterface.parseTransaction({ data: txData });
|
|
40
|
+
// failed to decode input data
|
|
41
|
+
if (!decoded)
|
|
42
|
+
return;
|
|
43
|
+
const sendAddress = (_c = (_b = tx.vin[0].addresses) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '';
|
|
44
|
+
const contract = new ethers_1.ethers.Contract(this.wethContract, erc20_1.default, this.provider);
|
|
45
|
+
const assetId = (0, caip_1.toCAIP19)({
|
|
46
|
+
chain: types_1.ChainTypes.Ethereum,
|
|
47
|
+
network: (0, utils_1.toNetworkType)(this.network),
|
|
48
|
+
assetNamespace: caip_1.AssetNamespace.ERC20,
|
|
49
|
+
assetReference: this.wethContract
|
|
50
|
+
});
|
|
51
|
+
const token = {
|
|
52
|
+
contract: this.wethContract,
|
|
53
|
+
decimals: await contract.decimals(),
|
|
54
|
+
name: await contract.name(),
|
|
55
|
+
symbol: await contract.symbol()
|
|
56
|
+
};
|
|
57
|
+
const transfers = (() => {
|
|
58
|
+
switch (txSigHash) {
|
|
59
|
+
case this.supportedFunctions.depositSigHash: {
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
type: types_2.TransferType.Receive,
|
|
63
|
+
from: this.wethContract,
|
|
64
|
+
to: sendAddress,
|
|
65
|
+
caip19: assetId,
|
|
66
|
+
assetId,
|
|
67
|
+
totalValue: tx.value,
|
|
68
|
+
components: [{ value: tx.value }],
|
|
69
|
+
token
|
|
70
|
+
}
|
|
71
|
+
];
|
|
108
72
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
73
|
+
case this.supportedFunctions.withdrawalSigHash:
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
type: types_2.TransferType.Send,
|
|
77
|
+
from: sendAddress,
|
|
78
|
+
to: this.wethContract,
|
|
79
|
+
caip19: assetId,
|
|
80
|
+
assetId,
|
|
81
|
+
totalValue: decoded.args.wad.toString(),
|
|
82
|
+
components: [{ value: decoded.args.wad.toString() }],
|
|
83
|
+
token
|
|
84
|
+
}
|
|
85
|
+
];
|
|
86
|
+
default:
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
})();
|
|
90
|
+
// no supported function detected
|
|
91
|
+
if (!transfers)
|
|
92
|
+
return;
|
|
93
|
+
return {
|
|
94
|
+
transfers,
|
|
95
|
+
data: {
|
|
114
96
|
parser: types_2.TxParser.WETH,
|
|
115
|
-
method: decoded.name
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
transfers,
|
|
119
|
-
data,
|
|
120
|
-
};
|
|
121
|
-
});
|
|
97
|
+
method: decoded.name
|
|
98
|
+
}
|
|
99
|
+
};
|
|
122
100
|
}
|
|
123
101
|
}
|
|
124
102
|
exports.Parser = Parser;
|
|
125
|
-
//# sourceMappingURL=weth.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChainId, Yearn } from '@yfi/sdk';
|
|
2
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
+
import { ChainId, Yearn } from '@yfi/sdk';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
import { Network, SubParser, TxSpecific } from '../types';
|
|
5
5
|
interface ParserArgs {
|
|
@@ -10,21 +10,20 @@ export declare class Parser implements SubParser {
|
|
|
10
10
|
provider: ethers.providers.JsonRpcProvider;
|
|
11
11
|
yearnSdk: Yearn<ChainId> | undefined;
|
|
12
12
|
yearnTokenVaultAddresses: string[] | undefined;
|
|
13
|
-
shapeShiftInterface: ethers.utils.Interface;
|
|
14
|
-
yearnInterface: ethers.utils.Interface;
|
|
15
|
-
supportedYearnFunctions: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
readonly shapeShiftInterface: ethers.utils.Interface;
|
|
14
|
+
readonly yearnInterface: ethers.utils.Interface;
|
|
15
|
+
readonly supportedYearnFunctions: {
|
|
16
|
+
approveSigHash: string;
|
|
17
|
+
depositSigHash: string;
|
|
18
|
+
depositAmountSigHash: string;
|
|
19
|
+
depositAmountAndRecipientSigHash: string;
|
|
20
|
+
withdrawSigHash: string;
|
|
21
21
|
};
|
|
22
|
-
supportedShapeShiftFunctions: {
|
|
23
|
-
|
|
22
|
+
readonly supportedShapeShiftFunctions: {
|
|
23
|
+
depositSigHash: string;
|
|
24
24
|
};
|
|
25
25
|
constructor(args: ParserArgs);
|
|
26
26
|
parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
|
|
27
27
|
getAbiInterface(txSigHash: string | undefined): ethers.utils.Interface | undefined;
|
|
28
28
|
}
|
|
29
29
|
export {};
|
|
30
|
-
//# sourceMappingURL=yearn.d.ts.map
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -15,76 +6,75 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
exports.Parser = void 0;
|
|
16
7
|
const sdk_1 = require("@yfi/sdk");
|
|
17
8
|
const ethers_1 = require("ethers");
|
|
18
|
-
const
|
|
19
|
-
const utils_1 = require("./utils");
|
|
9
|
+
const types_1 = require("../../types");
|
|
20
10
|
const shapeShiftRouter_1 = __importDefault(require("./abi/shapeShiftRouter"));
|
|
21
11
|
const yearnVault_1 = __importDefault(require("./abi/yearnVault"));
|
|
22
|
-
const
|
|
12
|
+
const constants_1 = require("./constants");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
23
14
|
class Parser {
|
|
24
15
|
constructor(args) {
|
|
25
16
|
this.shapeShiftInterface = new ethers_1.ethers.utils.Interface(shapeShiftRouter_1.default);
|
|
26
17
|
this.yearnInterface = new ethers_1.ethers.utils.Interface(yearnVault_1.default);
|
|
27
18
|
this.supportedYearnFunctions = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
approveSigHash: this.yearnInterface.getSighash('approve'),
|
|
20
|
+
depositSigHash: this.yearnInterface.getSighash('deposit()'),
|
|
21
|
+
depositAmountSigHash: this.yearnInterface.getSighash('deposit(uint256)'),
|
|
22
|
+
depositAmountAndRecipientSigHash: this.yearnInterface.getSighash('deposit(uint256,address)'),
|
|
23
|
+
withdrawSigHash: this.yearnInterface.getSighash('withdraw(uint256,address)')
|
|
33
24
|
};
|
|
34
25
|
this.supportedShapeShiftFunctions = {
|
|
35
|
-
|
|
26
|
+
depositSigHash: this.shapeShiftInterface.getSighash('deposit(address,address,uint256,uint256)')
|
|
36
27
|
};
|
|
37
28
|
this.provider = args.provider;
|
|
38
29
|
// The only Yearn-supported chain we currently support is mainnet
|
|
39
|
-
if (args.network
|
|
30
|
+
if (args.network === 'mainnet') {
|
|
40
31
|
// 1 for EthMain (@yfi/sdk/dist/chain.d.ts)
|
|
41
|
-
this.yearnSdk = new sdk_1.Yearn(1, { provider: this.provider
|
|
32
|
+
this.yearnSdk = new sdk_1.Yearn(1, { provider: this.provider });
|
|
42
33
|
}
|
|
43
34
|
}
|
|
44
|
-
parse(tx) {
|
|
35
|
+
async parse(tx) {
|
|
45
36
|
var _a, _b, _c, _d, _e;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return;
|
|
70
|
-
break;
|
|
71
|
-
case yearnWithdrawSigHash:
|
|
72
|
-
case yearnDepositSigHash:
|
|
73
|
-
case yearnDepositWithAmountSigHash:
|
|
74
|
-
case yearnDepositWithAmountAndRecipientSigHash:
|
|
75
|
-
if (receiveAddress && !((_e = this.yearnTokenVaultAddresses) === null || _e === void 0 ? void 0 : _e.includes(receiveAddress)))
|
|
76
|
-
return;
|
|
77
|
-
break;
|
|
78
|
-
default:
|
|
37
|
+
const txData = (_a = tx.ethereumSpecific) === null || _a === void 0 ? void 0 : _a.data;
|
|
38
|
+
if (!txData)
|
|
39
|
+
return;
|
|
40
|
+
const txSigHash = (0, utils_1.getSigHash)(txData);
|
|
41
|
+
const abiInterface = this.getAbiInterface(txSigHash);
|
|
42
|
+
if (!abiInterface)
|
|
43
|
+
return;
|
|
44
|
+
if (!this.yearnTokenVaultAddresses) {
|
|
45
|
+
const vaults = await ((_b = this.yearnSdk) === null || _b === void 0 ? void 0 : _b.vaults.get());
|
|
46
|
+
this.yearnTokenVaultAddresses = vaults === null || vaults === void 0 ? void 0 : vaults.map((vault) => vault.address);
|
|
47
|
+
}
|
|
48
|
+
const decoded = abiInterface.parseTransaction({ data: txData });
|
|
49
|
+
// failed to decode input data
|
|
50
|
+
if (!decoded)
|
|
51
|
+
return;
|
|
52
|
+
const receiveAddress = (_d = (_c = tx.vout) === null || _c === void 0 ? void 0 : _c[0].addresses) === null || _d === void 0 ? void 0 : _d[0];
|
|
53
|
+
switch (txSigHash) {
|
|
54
|
+
case this.supportedYearnFunctions.approveSigHash:
|
|
55
|
+
if ((decoded === null || decoded === void 0 ? void 0 : decoded.args._spender) !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
|
|
56
|
+
return;
|
|
57
|
+
break;
|
|
58
|
+
case this.supportedShapeShiftFunctions.depositSigHash:
|
|
59
|
+
if (receiveAddress !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
|
|
79
60
|
return;
|
|
61
|
+
break;
|
|
62
|
+
case this.supportedYearnFunctions.withdrawSigHash:
|
|
63
|
+
case this.supportedYearnFunctions.depositSigHash:
|
|
64
|
+
case this.supportedYearnFunctions.depositAmountSigHash:
|
|
65
|
+
case this.supportedYearnFunctions.depositAmountAndRecipientSigHash:
|
|
66
|
+
if (receiveAddress && !((_e = this.yearnTokenVaultAddresses) === null || _e === void 0 ? void 0 : _e.includes(receiveAddress)))
|
|
67
|
+
return;
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
data: {
|
|
74
|
+
method: decoded.name,
|
|
75
|
+
parser: types_1.TxParser.Yearn
|
|
80
76
|
}
|
|
81
|
-
|
|
82
|
-
data: {
|
|
83
|
-
method: decoded === null || decoded === void 0 ? void 0 : decoded.name,
|
|
84
|
-
parser: types_1.TxParser.Yearn,
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
});
|
|
77
|
+
};
|
|
88
78
|
}
|
|
89
79
|
getAbiInterface(txSigHash) {
|
|
90
80
|
if (Object.values(this.supportedYearnFunctions).some((abi) => abi === txSigHash))
|
|
@@ -95,4 +85,3 @@ class Parser {
|
|
|
95
85
|
}
|
|
96
86
|
}
|
|
97
87
|
exports.Parser = Parser;
|
|
98
|
-
//# sourceMappingURL=yearn.js.map
|