@shapeshiftoss/unchained-client 6.11.0 → 6.12.1
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 -55
- 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 +1 -2
- package/dist/cosmos/parser/index.js +56 -64
- package/dist/cosmos/parser/utils.d.ts +2 -3
- package/dist/cosmos/parser/utils.js +21 -22
- package/dist/cosmos/types.d.ts +0 -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 +1 -2
- package/dist/ethereum/parser/foxy.js +22 -34
- package/dist/ethereum/parser/index.d.ts +0 -1
- package/dist/ethereum/parser/index.js +49 -57
- package/dist/ethereum/parser/thor.d.ts +1 -2
- package/dist/ethereum/parser/thor.js +29 -41
- package/dist/ethereum/parser/uniV2.d.ts +0 -1
- package/dist/ethereum/parser/uniV2.js +87 -99
- package/dist/ethereum/parser/utils.d.ts +0 -1
- package/dist/ethereum/parser/utils.js +2 -3
- package/dist/ethereum/parser/weth.d.ts +0 -1
- package/dist/ethereum/parser/weth.js +72 -84
- package/dist/ethereum/parser/yearn.d.ts +1 -2
- package/dist/ethereum/parser/yearn.js +46 -58
- 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 +116 -120
- package/dist/generated/bitcoin/api.js +81 -110
- package/dist/generated/bitcoin/base.d.ts +2 -3
- package/dist/generated/bitcoin/base.js +1 -2
- package/dist/generated/bitcoin/common.d.ts +2 -3
- package/dist/generated/bitcoin/common.js +22 -38
- package/dist/generated/bitcoin/configuration.d.ts +0 -1
- package/dist/generated/bitcoin/configuration.js +0 -1
- package/dist/generated/bitcoin/index.d.ts +0 -1
- package/dist/generated/bitcoin/index.js +5 -2
- 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 +73 -77
- package/dist/generated/ethereum/api.js +73 -100
- package/dist/generated/ethereum/base.d.ts +2 -3
- package/dist/generated/ethereum/base.js +1 -2
- package/dist/generated/ethereum/common.d.ts +2 -3
- package/dist/generated/ethereum/common.js +22 -38
- package/dist/generated/ethereum/configuration.d.ts +0 -1
- package/dist/generated/ethereum/configuration.js +0 -1
- package/dist/generated/ethereum/index.d.ts +0 -1
- package/dist/generated/ethereum/index.js +5 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +5 -2
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -1
- package/dist/utils.d.ts +1 -2
- package/dist/utils.js +18 -21
- package/dist/websocket.d.ts +1 -2
- package/dist/websocket.js +78 -84
- package/package.json +19 -11
- 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 -4986
- 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,111 +8,109 @@ 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);
|
|
27
18
|
this.supportedFunctions = {
|
|
28
19
|
addLiquidityEthSigHash: this.abiInterface.getSighash('addLiquidityETH'),
|
|
29
|
-
removeLiquidityEthSigHash: this.abiInterface.getSighash('removeLiquidityETH')
|
|
20
|
+
removeLiquidityEthSigHash: this.abiInterface.getSighash('removeLiquidityETH')
|
|
30
21
|
};
|
|
31
22
|
this.network = args.network;
|
|
32
23
|
this.provider = args.provider;
|
|
33
24
|
this.wethContract = {
|
|
34
25
|
mainnet: constants_1.WETH_CONTRACT_MAINNET,
|
|
35
|
-
ropsten: constants_1.WETH_CONTRACT_ROPSTEN
|
|
26
|
+
ropsten: constants_1.WETH_CONTRACT_ROPSTEN
|
|
36
27
|
}[this.network];
|
|
37
28
|
}
|
|
38
|
-
parse(tx) {
|
|
29
|
+
async parse(tx) {
|
|
39
30
|
var _a, _b, _c;
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
];
|
|
109
|
-
}
|
|
110
|
-
default:
|
|
111
|
-
return;
|
|
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: {
|
|
51
|
+
const contract = new ethers_1.ethers.Contract(tokenAddress, erc20_1.default, this.provider);
|
|
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
|
+
});
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
type: types_2.TransferType.Send,
|
|
65
|
+
from: sendAddress,
|
|
66
|
+
to: lpTokenAddress,
|
|
67
|
+
caip19: assetId,
|
|
68
|
+
assetId,
|
|
69
|
+
totalValue: value,
|
|
70
|
+
components: [{ value }],
|
|
71
|
+
token: { contract: tokenAddress, decimals, name, symbol }
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
case this.supportedFunctions.removeLiquidityEthSigHash: {
|
|
76
|
+
const contract = new ethers_1.ethers.Contract(lpTokenAddress, erc20_1.default, this.provider);
|
|
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
|
+
});
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
type: types_2.TransferType.Send,
|
|
90
|
+
from: sendAddress,
|
|
91
|
+
to: lpTokenAddress,
|
|
92
|
+
caip19: assetId,
|
|
93
|
+
assetId,
|
|
94
|
+
totalValue: value,
|
|
95
|
+
components: [{ value }],
|
|
96
|
+
token: { contract: lpTokenAddress, decimals, name, symbol }
|
|
97
|
+
}
|
|
98
|
+
];
|
|
112
99
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
100
|
+
default:
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
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
|
+
};
|
|
125
114
|
}
|
|
126
115
|
static pairFor(tokenA, tokenB) {
|
|
127
116
|
const [token0, token1] = tokenA < tokenB ? [tokenA, tokenB] : [tokenB, tokenA];
|
|
@@ -132,4 +121,3 @@ class Parser {
|
|
|
132
121
|
}
|
|
133
122
|
}
|
|
134
123
|
exports.Parser = Parser;
|
|
135
|
-
//# 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
|
|
@@ -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
|
};
|
|
@@ -19,96 +10,93 @@ const ethers_1 = require("ethers");
|
|
|
19
10
|
const types_2 = require("../../types");
|
|
20
11
|
const erc20_1 = __importDefault(require("./abi/erc20"));
|
|
21
12
|
const weth_1 = __importDefault(require("./abi/weth"));
|
|
22
|
-
const utils_1 = require("./utils");
|
|
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(weth_1.default);
|
|
27
18
|
this.supportedFunctions = {
|
|
28
19
|
depositSigHash: this.abiInterface.getSighash('deposit'),
|
|
29
|
-
withdrawalSigHash: this.abiInterface.getSighash('withdraw')
|
|
20
|
+
withdrawalSigHash: this.abiInterface.getSighash('withdraw')
|
|
30
21
|
};
|
|
31
22
|
this.network = args.network;
|
|
32
23
|
this.provider = args.provider;
|
|
33
24
|
this.wethContract = {
|
|
34
25
|
mainnet: constants_1.WETH_CONTRACT_MAINNET,
|
|
35
|
-
ropsten: constants_1.WETH_CONTRACT_ROPSTEN
|
|
26
|
+
ropsten: constants_1.WETH_CONTRACT_ROPSTEN
|
|
36
27
|
}[this.network];
|
|
37
28
|
}
|
|
38
|
-
parse(tx) {
|
|
29
|
+
async parse(tx) {
|
|
39
30
|
var _a, _b, _c;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
assetReference: this.wethContract,
|
|
60
|
-
});
|
|
61
|
-
const token = {
|
|
62
|
-
contract: this.wethContract,
|
|
63
|
-
decimals: yield contract.decimals(),
|
|
64
|
-
name: yield contract.name(),
|
|
65
|
-
symbol: yield contract.symbol(),
|
|
66
|
-
};
|
|
67
|
-
const transfers = (() => {
|
|
68
|
-
switch (txSigHash) {
|
|
69
|
-
case this.supportedFunctions.depositSigHash: {
|
|
70
|
-
return [
|
|
71
|
-
{
|
|
72
|
-
type: types_2.TransferType.Receive,
|
|
73
|
-
from: this.wethContract,
|
|
74
|
-
to: sendAddress,
|
|
75
|
-
caip19: assetId,
|
|
76
|
-
assetId: assetId,
|
|
77
|
-
totalValue: tx.value,
|
|
78
|
-
components: [{ value: tx.value }],
|
|
79
|
-
token: token,
|
|
80
|
-
},
|
|
81
|
-
];
|
|
82
|
-
}
|
|
83
|
-
case this.supportedFunctions.withdrawalSigHash:
|
|
84
|
-
return [
|
|
85
|
-
{
|
|
86
|
-
type: types_2.TransferType.Send,
|
|
87
|
-
from: sendAddress,
|
|
88
|
-
to: this.wethContract,
|
|
89
|
-
caip19: assetId,
|
|
90
|
-
assetId: assetId,
|
|
91
|
-
totalValue: decoded.args.wad.toString(),
|
|
92
|
-
components: [{ value: decoded.args.wad.toString() }],
|
|
93
|
-
token: token,
|
|
94
|
-
},
|
|
95
|
-
];
|
|
96
|
-
default:
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
})();
|
|
100
|
-
// no supported function detected
|
|
101
|
-
if (!transfers)
|
|
102
|
-
return;
|
|
103
|
-
return {
|
|
104
|
-
transfers,
|
|
105
|
-
data: {
|
|
106
|
-
parser: types_2.TxParser.WETH,
|
|
107
|
-
method: decoded.name,
|
|
108
|
-
},
|
|
109
|
-
};
|
|
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
|
|
110
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
|
+
];
|
|
72
|
+
}
|
|
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: {
|
|
96
|
+
parser: types_2.TxParser.WETH,
|
|
97
|
+
method: decoded.name
|
|
98
|
+
}
|
|
99
|
+
};
|
|
111
100
|
}
|
|
112
101
|
}
|
|
113
102
|
exports.Parser = Parser;
|
|
114
|
-
//# 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 {
|
|
@@ -27,4 +27,3 @@ export declare class Parser implements SubParser {
|
|
|
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,11 +6,11 @@ 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);
|
|
@@ -29,63 +20,61 @@ class Parser {
|
|
|
29
20
|
depositSigHash: this.yearnInterface.getSighash('deposit()'),
|
|
30
21
|
depositAmountSigHash: this.yearnInterface.getSighash('deposit(uint256)'),
|
|
31
22
|
depositAmountAndRecipientSigHash: this.yearnInterface.getSighash('deposit(uint256,address)'),
|
|
32
|
-
withdrawSigHash: this.yearnInterface.getSighash('withdraw(uint256,address)')
|
|
23
|
+
withdrawSigHash: this.yearnInterface.getSighash('withdraw(uint256,address)')
|
|
33
24
|
};
|
|
34
25
|
this.supportedShapeShiftFunctions = {
|
|
35
|
-
depositSigHash: this.shapeShiftInterface.getSighash('deposit(address,address,uint256,uint256)')
|
|
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
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
|
-
if (receiveAddress !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
|
|
70
|
-
return;
|
|
71
|
-
break;
|
|
72
|
-
case this.supportedYearnFunctions.withdrawSigHash:
|
|
73
|
-
case this.supportedYearnFunctions.depositSigHash:
|
|
74
|
-
case this.supportedYearnFunctions.depositAmountSigHash:
|
|
75
|
-
case this.supportedYearnFunctions.depositAmountAndRecipientSigHash:
|
|
76
|
-
if (receiveAddress && !((_e = this.yearnTokenVaultAddresses) === null || _e === void 0 ? void 0 : _e.includes(receiveAddress)))
|
|
77
|
-
return;
|
|
78
|
-
break;
|
|
79
|
-
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)
|
|
80
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
|
|
81
76
|
}
|
|
82
|
-
|
|
83
|
-
data: {
|
|
84
|
-
method: decoded.name,
|
|
85
|
-
parser: types_1.TxParser.Yearn,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
});
|
|
77
|
+
};
|
|
89
78
|
}
|
|
90
79
|
getAbiInterface(txSigHash) {
|
|
91
80
|
if (Object.values(this.supportedYearnFunctions).some((abi) => abi === txSigHash))
|
|
@@ -96,4 +85,3 @@ class Parser {
|
|
|
96
85
|
}
|
|
97
86
|
}
|
|
98
87
|
exports.Parser = Parser;
|
|
99
|
-
//# sourceMappingURL=yearn.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Tx as BlockbookTx } from '@shapeshiftoss/blockbook';
|
|
2
|
-
import {
|
|
2
|
+
import { SubParser, TxSpecific } from '../types';
|
|
3
3
|
export declare class Parser implements SubParser {
|
|
4
4
|
parse(tx: BlockbookTx): Promise<TxSpecific | undefined>;
|
|
5
5
|
}
|
|
6
|
-
//# sourceMappingURL=zrx.d.ts.map
|