@shapeshiftoss/unchained-client 9.8.1 → 9.9.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/dist/cosmos/parser/index.js +7 -7
- package/dist/cosmos/parser/utils.d.ts +2 -1
- package/dist/cosmos/parser/utils.js +48 -21
- package/dist/cosmos/types.d.ts +2 -2
- package/dist/evm/ethereum/parser/abi/foxyStaking.js +161 -161
- package/dist/evm/ethereum/parser/abi/shapeShiftRouter.js +119 -119
- package/dist/evm/ethereum/parser/abi/thor.js +28 -28
- package/dist/evm/ethereum/parser/abi/uniV2.js +55 -55
- package/dist/evm/ethereum/parser/abi/uniV2StakingRewards.js +95 -95
- package/dist/evm/ethereum/parser/abi/weth.js +66 -66
- package/dist/evm/ethereum/parser/abi/yearnVault.js +95 -95
- package/dist/evm/ethereum/parser/cowswap.d.ts +4 -0
- package/dist/evm/ethereum/parser/cowswap.js +3 -3
- package/dist/evm/ethereum/parser/foxy.d.ts +4 -0
- package/dist/evm/ethereum/parser/foxy.js +3 -3
- package/dist/evm/ethereum/parser/index.js +1 -1
- package/dist/evm/ethereum/parser/thor.d.ts +4 -0
- package/dist/evm/ethereum/parser/thor.js +2 -2
- package/dist/evm/ethereum/parser/uniV2.d.ts +4 -0
- package/dist/evm/ethereum/parser/uniV2.js +12 -12
- package/dist/evm/ethereum/parser/weth.d.ts +4 -0
- package/dist/evm/ethereum/parser/weth.js +9 -9
- package/dist/evm/ethereum/parser/yearn.d.ts +7 -0
- package/dist/evm/ethereum/parser/yearn.js +32 -16
- package/dist/evm/parser/abi/erc20.js +69 -69
- package/dist/evm/parser/erc20.d.ts +6 -0
- package/dist/evm/parser/erc20.js +15 -12
- package/dist/evm/parser/index.js +4 -4
- package/dist/evm/parser/types.d.ts +10 -9
- package/dist/evm/parser/types.js +0 -5
- package/dist/evm/parser/zrx.d.ts +4 -0
- package/dist/evm/parser/zrx.js +3 -3
- package/dist/types.d.ts +0 -13
- package/dist/types.js +1 -12
- package/dist/utils.js +2 -2
- package/dist/utxo/parser/index.js +1 -1
- package/dist/websocket.js +4 -4
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Tx } from '../../../generated/ethereum';
|
|
2
|
+
import { BaseTxMetadata } from '../../../types';
|
|
2
3
|
import { SubParser, TxSpecific } from '../../parser';
|
|
4
|
+
export interface TxMetadata extends BaseTxMetadata {
|
|
5
|
+
parser: 'cowswap';
|
|
6
|
+
}
|
|
3
7
|
export declare class Parser implements SubParser<Tx> {
|
|
4
8
|
parse(tx: Tx): Promise<TxSpecific | undefined>;
|
|
5
9
|
}
|
|
@@ -13,12 +13,12 @@ class Parser {
|
|
|
13
13
|
return {
|
|
14
14
|
trade: {
|
|
15
15
|
dexName: types_1.Dex.CowSwap,
|
|
16
|
-
type: types_1.TradeType.Trade
|
|
16
|
+
type: types_1.TradeType.Trade,
|
|
17
17
|
},
|
|
18
18
|
data: {
|
|
19
19
|
method: undefined,
|
|
20
|
-
parser: 'cowswap'
|
|
21
|
-
}
|
|
20
|
+
parser: 'cowswap',
|
|
21
|
+
},
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { Tx } from '../../../generated/ethereum';
|
|
3
|
+
import { BaseTxMetadata } from '../../../types';
|
|
3
4
|
import { SubParser, TxSpecific } from '../../parser';
|
|
5
|
+
export interface TxMetadata extends BaseTxMetadata {
|
|
6
|
+
parser: 'foxy';
|
|
7
|
+
}
|
|
4
8
|
export declare class Parser implements SubParser<Tx> {
|
|
5
9
|
readonly abiInterface: ethers.utils.Interface;
|
|
6
10
|
readonly supportedFunctions: {
|
|
@@ -15,7 +15,7 @@ class Parser {
|
|
|
15
15
|
stakeSigHash: this.abiInterface.getSighash('stake(uint256,address)'),
|
|
16
16
|
unstakeSigHash: this.abiInterface.getSighash('unstake'),
|
|
17
17
|
instantUnstakeSigHash: this.abiInterface.getSighash('instantUnstake'),
|
|
18
|
-
claimWithdrawSigHash: this.abiInterface.getSighash('claimWithdraw')
|
|
18
|
+
claimWithdrawSigHash: this.abiInterface.getSighash('claimWithdraw'),
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
async parse(tx) {
|
|
@@ -33,8 +33,8 @@ class Parser {
|
|
|
33
33
|
return {
|
|
34
34
|
data: {
|
|
35
35
|
method: decoded.name,
|
|
36
|
-
parser: 'foxy'
|
|
37
|
-
}
|
|
36
|
+
parser: 'foxy',
|
|
37
|
+
},
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -46,7 +46,7 @@ class TransactionParser extends parser_1.BaseTransactionParser {
|
|
|
46
46
|
new uniV2.Parser({ chainId: this.chainId, provider: this.provider }),
|
|
47
47
|
new thor.Parser({ chainId: this.chainId, rpcUrl: args.rpcUrl }),
|
|
48
48
|
new zrx.Parser(),
|
|
49
|
-
new cowswap.Parser()
|
|
49
|
+
new cowswap.Parser(),
|
|
50
50
|
]);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
import { Tx } from '../../../generated/ethereum';
|
|
4
|
+
import { BaseTxMetadata } from '../../../types';
|
|
4
5
|
import { SubParser, TxSpecific } from '../../parser';
|
|
6
|
+
export interface TxMetadata extends BaseTxMetadata {
|
|
7
|
+
parser: 'thor';
|
|
8
|
+
}
|
|
5
9
|
export interface ParserArgs {
|
|
6
10
|
chainId: ChainId;
|
|
7
11
|
rpcUrl: string;
|
|
@@ -15,7 +15,7 @@ class Parser {
|
|
|
15
15
|
this.abiInterface = new ethers_1.ethers.utils.Interface(thor_1.default);
|
|
16
16
|
this.supportedFunctions = {
|
|
17
17
|
depositSigHash: this.abiInterface.getSighash('deposit'),
|
|
18
|
-
transferOutSigHash: this.abiInterface.getSighash('transferOut')
|
|
18
|
+
transferOutSigHash: this.abiInterface.getSighash('transferOut'),
|
|
19
19
|
};
|
|
20
20
|
// TODO: Router contract can change, use /inbound_addresses endpoint to determine current router contract.
|
|
21
21
|
// We will also need to know all past router contract addresses if we intend on using receive address as the means for detection
|
|
@@ -44,7 +44,7 @@ class Parser {
|
|
|
44
44
|
return;
|
|
45
45
|
const data = {
|
|
46
46
|
method: decoded.name,
|
|
47
|
-
parser: 'thor'
|
|
47
|
+
parser: 'thor',
|
|
48
48
|
};
|
|
49
49
|
const [type] = decoded.args.memo.split(':');
|
|
50
50
|
if (SWAP_TYPES.includes(type) || type === 'OUT') {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
import { Tx } from '../../../generated/ethereum';
|
|
4
|
+
import { BaseTxMetadata } from '../../../types';
|
|
4
5
|
import { SubParser, TxSpecific } from '../../parser';
|
|
6
|
+
export interface TxMetadata extends BaseTxMetadata {
|
|
7
|
+
parser: 'uniV2';
|
|
8
|
+
}
|
|
5
9
|
export interface ParserArgs {
|
|
6
10
|
chainId: ChainId;
|
|
7
11
|
provider: ethers.providers.JsonRpcProvider;
|
|
@@ -18,11 +18,11 @@ class Parser {
|
|
|
18
18
|
this.stakingRewardsInterface = new ethers_1.ethers.utils.Interface(uniV2StakingRewards_1.default);
|
|
19
19
|
this.supportedFunctions = {
|
|
20
20
|
addLiquidityEthSigHash: this.abiInterface.getSighash('addLiquidityETH'),
|
|
21
|
-
removeLiquidityEthSigHash: this.abiInterface.getSighash('removeLiquidityETH')
|
|
21
|
+
removeLiquidityEthSigHash: this.abiInterface.getSighash('removeLiquidityETH'),
|
|
22
22
|
};
|
|
23
23
|
this.supportedStakingRewardsFunctions = {
|
|
24
24
|
stakeSigHash: this.stakingRewardsInterface.getSighash('stake'),
|
|
25
|
-
exitSigHash: this.stakingRewardsInterface.getSighash('exit')
|
|
25
|
+
exitSigHash: this.stakingRewardsInterface.getSighash('exit'),
|
|
26
26
|
};
|
|
27
27
|
this.chainId = args.chainId;
|
|
28
28
|
this.provider = args.provider;
|
|
@@ -62,7 +62,7 @@ class Parser {
|
|
|
62
62
|
const assetId = (0, caip_1.toAssetId)({
|
|
63
63
|
...(0, caip_1.fromChainId)(this.chainId),
|
|
64
64
|
assetNamespace: 'erc20',
|
|
65
|
-
assetReference: tokenAddress
|
|
65
|
+
assetReference: tokenAddress,
|
|
66
66
|
});
|
|
67
67
|
return [
|
|
68
68
|
{
|
|
@@ -72,8 +72,8 @@ class Parser {
|
|
|
72
72
|
assetId,
|
|
73
73
|
totalValue: value,
|
|
74
74
|
components: [{ value }],
|
|
75
|
-
token: { contract: tokenAddress, decimals, name, symbol }
|
|
76
|
-
}
|
|
75
|
+
token: { contract: tokenAddress, decimals, name, symbol },
|
|
76
|
+
},
|
|
77
77
|
];
|
|
78
78
|
}
|
|
79
79
|
case this.supportedFunctions.removeLiquidityEthSigHash: {
|
|
@@ -85,7 +85,7 @@ class Parser {
|
|
|
85
85
|
const assetId = (0, caip_1.toAssetId)({
|
|
86
86
|
...(0, caip_1.fromChainId)(this.chainId),
|
|
87
87
|
assetNamespace: 'erc20',
|
|
88
|
-
assetReference: lpTokenAddress
|
|
88
|
+
assetReference: lpTokenAddress,
|
|
89
89
|
});
|
|
90
90
|
return [
|
|
91
91
|
{
|
|
@@ -95,8 +95,8 @@ class Parser {
|
|
|
95
95
|
assetId,
|
|
96
96
|
totalValue: value,
|
|
97
97
|
components: [{ value }],
|
|
98
|
-
token: { contract: lpTokenAddress, decimals, name, symbol }
|
|
99
|
-
}
|
|
98
|
+
token: { contract: lpTokenAddress, decimals, name, symbol },
|
|
99
|
+
},
|
|
100
100
|
];
|
|
101
101
|
}
|
|
102
102
|
default:
|
|
@@ -110,8 +110,8 @@ class Parser {
|
|
|
110
110
|
transfers,
|
|
111
111
|
data: {
|
|
112
112
|
parser: 'uniV2',
|
|
113
|
-
method: decoded.name
|
|
114
|
-
}
|
|
113
|
+
method: decoded.name,
|
|
114
|
+
},
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
async parseStakingRewards(tx) {
|
|
@@ -127,8 +127,8 @@ class Parser {
|
|
|
127
127
|
return {
|
|
128
128
|
data: {
|
|
129
129
|
parser: 'uniV2',
|
|
130
|
-
method: decoded.name
|
|
131
|
-
}
|
|
130
|
+
method: decoded.name,
|
|
131
|
+
},
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
async parse(tx) {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ChainId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
import { Tx } from '../../../generated/ethereum';
|
|
4
|
+
import { BaseTxMetadata } from '../../../types';
|
|
4
5
|
import { SubParser, TxSpecific } from '../../parser';
|
|
6
|
+
export interface TxMetadata extends BaseTxMetadata {
|
|
7
|
+
parser: 'weth';
|
|
8
|
+
}
|
|
5
9
|
export interface ParserArgs {
|
|
6
10
|
chainId: ChainId;
|
|
7
11
|
provider: ethers.providers.JsonRpcProvider;
|
|
@@ -15,7 +15,7 @@ class Parser {
|
|
|
15
15
|
this.abiInterface = new ethers_1.ethers.utils.Interface(weth_1.default);
|
|
16
16
|
this.supportedFunctions = {
|
|
17
17
|
depositSigHash: this.abiInterface.getSighash('deposit'),
|
|
18
|
-
withdrawalSigHash: this.abiInterface.getSighash('withdraw')
|
|
18
|
+
withdrawalSigHash: this.abiInterface.getSighash('withdraw'),
|
|
19
19
|
};
|
|
20
20
|
this.chainId = args.chainId;
|
|
21
21
|
this.provider = args.provider;
|
|
@@ -45,13 +45,13 @@ class Parser {
|
|
|
45
45
|
const assetId = (0, caip_1.toAssetId)({
|
|
46
46
|
...(0, caip_1.fromChainId)(this.chainId),
|
|
47
47
|
assetNamespace: 'erc20',
|
|
48
|
-
assetReference: this.wethContract
|
|
48
|
+
assetReference: this.wethContract,
|
|
49
49
|
});
|
|
50
50
|
const token = {
|
|
51
51
|
contract: this.wethContract,
|
|
52
52
|
decimals: 18,
|
|
53
53
|
name: 'Wrapped Ether',
|
|
54
|
-
symbol: 'WETH'
|
|
54
|
+
symbol: 'WETH',
|
|
55
55
|
};
|
|
56
56
|
const transfers = (() => {
|
|
57
57
|
switch (txSigHash) {
|
|
@@ -64,8 +64,8 @@ class Parser {
|
|
|
64
64
|
assetId,
|
|
65
65
|
totalValue: tx.value,
|
|
66
66
|
components: [{ value: tx.value }],
|
|
67
|
-
token
|
|
68
|
-
}
|
|
67
|
+
token,
|
|
68
|
+
},
|
|
69
69
|
];
|
|
70
70
|
}
|
|
71
71
|
case this.supportedFunctions.withdrawalSigHash:
|
|
@@ -77,8 +77,8 @@ class Parser {
|
|
|
77
77
|
assetId,
|
|
78
78
|
totalValue: decoded.args.wad.toString(),
|
|
79
79
|
components: [{ value: decoded.args.wad.toString() }],
|
|
80
|
-
token
|
|
81
|
-
}
|
|
80
|
+
token,
|
|
81
|
+
},
|
|
82
82
|
];
|
|
83
83
|
default:
|
|
84
84
|
return;
|
|
@@ -91,8 +91,8 @@ class Parser {
|
|
|
91
91
|
transfers,
|
|
92
92
|
data: {
|
|
93
93
|
parser: 'weth',
|
|
94
|
-
method: decoded.name
|
|
95
|
-
}
|
|
94
|
+
method: decoded.name,
|
|
95
|
+
},
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -2,7 +2,13 @@ import { ChainId } from '@shapeshiftoss/caip';
|
|
|
2
2
|
import { ChainId as YearnChainId, Yearn } from '@yfi/sdk';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
import { Tx } from '../../../generated/ethereum';
|
|
5
|
+
import { BaseTxMetadata } from '../../../types';
|
|
5
6
|
import { SubParser, TxSpecific } from '../../parser';
|
|
7
|
+
export interface TxMetadata extends BaseTxMetadata {
|
|
8
|
+
parser: 'yearn';
|
|
9
|
+
assetId?: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
}
|
|
6
12
|
interface ParserArgs {
|
|
7
13
|
chainId: ChainId;
|
|
8
14
|
provider: ethers.providers.JsonRpcProvider;
|
|
@@ -11,6 +17,7 @@ export declare class Parser implements SubParser<Tx> {
|
|
|
11
17
|
provider: ethers.providers.JsonRpcProvider;
|
|
12
18
|
yearnSdk: Yearn<YearnChainId> | undefined;
|
|
13
19
|
yearnTokenVaultAddresses: string[] | undefined;
|
|
20
|
+
readonly chainId: ChainId;
|
|
14
21
|
readonly shapeShiftInterface: ethers.utils.Interface;
|
|
15
22
|
readonly yearnInterface: ethers.utils.Interface;
|
|
16
23
|
readonly supportedYearnFunctions: {
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Parser = void 0;
|
|
7
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
7
8
|
const sdk_1 = require("@yfi/sdk");
|
|
8
9
|
const ethers_1 = require("ethers");
|
|
9
10
|
const parser_1 = require("../../parser");
|
|
@@ -19,12 +20,13 @@ class Parser {
|
|
|
19
20
|
depositSigHash: this.yearnInterface.getSighash('deposit()'),
|
|
20
21
|
depositAmountSigHash: this.yearnInterface.getSighash('deposit(uint256)'),
|
|
21
22
|
depositAmountAndRecipientSigHash: this.yearnInterface.getSighash('deposit(uint256,address)'),
|
|
22
|
-
withdrawSigHash: this.yearnInterface.getSighash('withdraw(uint256,address)')
|
|
23
|
+
withdrawSigHash: this.yearnInterface.getSighash('withdraw(uint256,address)'),
|
|
23
24
|
};
|
|
24
25
|
this.supportedShapeShiftFunctions = {
|
|
25
|
-
depositSigHash: this.shapeShiftInterface.getSighash('deposit(address,address,uint256,uint256)')
|
|
26
|
+
depositSigHash: this.shapeShiftInterface.getSighash('deposit(address,address,uint256,uint256)'),
|
|
26
27
|
};
|
|
27
28
|
this.provider = args.provider;
|
|
29
|
+
this.chainId = args.chainId;
|
|
28
30
|
// The only Yearn-supported chain we currently support is mainnet
|
|
29
31
|
if (args.chainId === 'eip155:1') {
|
|
30
32
|
// 1 for EthMain (@yfi/sdk/dist/chain.d.ts)
|
|
@@ -36,6 +38,12 @@ class Parser {
|
|
|
36
38
|
if (!tx.inputData)
|
|
37
39
|
return;
|
|
38
40
|
const txSigHash = (0, parser_1.getSigHash)(tx.inputData);
|
|
41
|
+
const supportedSigHashes = [
|
|
42
|
+
...Object.values(this.supportedShapeShiftFunctions),
|
|
43
|
+
...Object.values(this.supportedYearnFunctions),
|
|
44
|
+
];
|
|
45
|
+
if (!supportedSigHashes.some((hash) => hash === txSigHash))
|
|
46
|
+
return;
|
|
39
47
|
const abiInterface = this.getAbiInterface(txSigHash);
|
|
40
48
|
if (!abiInterface)
|
|
41
49
|
return;
|
|
@@ -47,31 +55,39 @@ class Parser {
|
|
|
47
55
|
// failed to decode input data
|
|
48
56
|
if (!decoded)
|
|
49
57
|
return;
|
|
58
|
+
const data = {
|
|
59
|
+
method: decoded.name,
|
|
60
|
+
parser: 'yearn',
|
|
61
|
+
};
|
|
50
62
|
switch (txSigHash) {
|
|
51
63
|
case this.supportedYearnFunctions.approveSigHash:
|
|
52
|
-
if (
|
|
64
|
+
if (decoded.args._spender !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
|
|
53
65
|
return;
|
|
54
|
-
|
|
66
|
+
return {
|
|
67
|
+
data: {
|
|
68
|
+
...data,
|
|
69
|
+
assetId: (0, caip_1.toAssetId)({
|
|
70
|
+
chainId: this.chainId,
|
|
71
|
+
assetNamespace: 'erc20',
|
|
72
|
+
assetReference: tx.to,
|
|
73
|
+
}),
|
|
74
|
+
value: decoded.args._value.toString(),
|
|
75
|
+
},
|
|
76
|
+
};
|
|
55
77
|
case this.supportedShapeShiftFunctions.depositSigHash:
|
|
56
78
|
if (tx.to !== constants_1.SHAPE_SHIFT_ROUTER_CONTRACT)
|
|
57
79
|
return;
|
|
58
|
-
|
|
59
|
-
case this.supportedYearnFunctions.withdrawSigHash:
|
|
60
|
-
case this.supportedYearnFunctions.depositSigHash:
|
|
61
|
-
case this.supportedYearnFunctions.depositAmountSigHash:
|
|
80
|
+
return { data };
|
|
62
81
|
case this.supportedYearnFunctions.depositAmountAndRecipientSigHash:
|
|
63
82
|
if (tx.to && !((_b = this.yearnTokenVaultAddresses) === null || _b === void 0 ? void 0 : _b.includes(tx.to)))
|
|
64
83
|
return;
|
|
65
|
-
|
|
84
|
+
return { data };
|
|
85
|
+
case this.supportedYearnFunctions.withdrawSigHash:
|
|
86
|
+
case this.supportedYearnFunctions.depositSigHash:
|
|
87
|
+
case this.supportedYearnFunctions.depositAmountSigHash:
|
|
66
88
|
default:
|
|
67
|
-
return;
|
|
89
|
+
return { data };
|
|
68
90
|
}
|
|
69
|
-
return {
|
|
70
|
-
data: {
|
|
71
|
-
method: decoded.name,
|
|
72
|
-
parser: 'yearn'
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
91
|
}
|
|
76
92
|
getAbiInterface(txSigHash) {
|
|
77
93
|
if (Object.values(this.supportedYearnFunctions).some((abi) => abi === txSigHash))
|