@uniswap/universal-router-sdk 4.3.1 → 4.4.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/index.d.ts +2 -2
- package/dist/universal-router-sdk.cjs.development.js +61 -44
- package/dist/universal-router-sdk.cjs.development.js.map +1 -1
- package/dist/universal-router-sdk.cjs.production.min.js +1 -1
- package/dist/universal-router-sdk.cjs.production.min.js.map +1 -1
- package/dist/universal-router-sdk.esm.js +30 -12
- package/dist/universal-router-sdk.esm.js.map +1 -1
- package/dist/utils/commandParser.d.ts +9 -1
- package/package.json +1 -1
|
@@ -554,11 +554,11 @@ var CHAIN_CONFIGS = (_CHAIN_CONFIGS = {}, _CHAIN_CONFIGS[1] = {
|
|
|
554
554
|
}, _CHAIN_CONFIGS[1301] = {
|
|
555
555
|
weth: '0x4200000000000000000000000000000000000006',
|
|
556
556
|
routerConfigs: (_routerConfigs20 = {}, _routerConfigs20[UniversalRouterVersion.V1_2] = {
|
|
557
|
-
address: '
|
|
558
|
-
creationBlock:
|
|
557
|
+
address: '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6',
|
|
558
|
+
creationBlock: 1241811
|
|
559
559
|
}, _routerConfigs20[UniversalRouterVersion.V2_0] = {
|
|
560
|
-
address: '
|
|
561
|
-
creationBlock:
|
|
560
|
+
address: '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6',
|
|
561
|
+
creationBlock: 1241811
|
|
562
562
|
}, _routerConfigs20)
|
|
563
563
|
}, _CHAIN_CONFIGS);
|
|
564
564
|
var UNIVERSAL_ROUTER_ADDRESS = function UNIVERSAL_ROUTER_ADDRESS(version, chainId) {
|
|
@@ -1093,20 +1093,34 @@ RouterTradeAdapter.toPair = function (_ref2) {
|
|
|
1093
1093
|
return new Pair(CurrencyAmount.fromRawAmount(RouterTradeAdapter.toToken(reserve0.token), reserve0.quotient), CurrencyAmount.fromRawAmount(RouterTradeAdapter.toToken(reserve1.token), reserve1.quotient));
|
|
1094
1094
|
};
|
|
1095
1095
|
|
|
1096
|
-
// Parses UniversalRouter commands
|
|
1096
|
+
// Parses UniversalRouter V2 commands
|
|
1097
1097
|
var CommandParser = /*#__PURE__*/function () {
|
|
1098
1098
|
function CommandParser() {}
|
|
1099
1099
|
CommandParser.parseCalldata = function parseCalldata(calldata) {
|
|
1100
|
+
var genericParser = new GenericCommandParser(COMMAND_DEFINITION);
|
|
1100
1101
|
var txDescription = CommandParser.INTERFACE.parseTransaction({
|
|
1101
1102
|
data: calldata
|
|
1102
1103
|
});
|
|
1103
1104
|
var _txDescription$args = txDescription.args,
|
|
1104
1105
|
commands = _txDescription$args.commands,
|
|
1105
1106
|
inputs = _txDescription$args.inputs;
|
|
1106
|
-
|
|
1107
|
+
return genericParser.parse(commands, inputs);
|
|
1108
|
+
};
|
|
1109
|
+
return CommandParser;
|
|
1110
|
+
}();
|
|
1111
|
+
CommandParser.INTERFACE = /*#__PURE__*/new Interface(abi);
|
|
1112
|
+
// Parses commands based on given command definition
|
|
1113
|
+
var GenericCommandParser = /*#__PURE__*/function () {
|
|
1114
|
+
function GenericCommandParser(commandDefinition) {
|
|
1115
|
+
this.commandDefinition = commandDefinition;
|
|
1116
|
+
}
|
|
1117
|
+
var _proto = GenericCommandParser.prototype;
|
|
1118
|
+
_proto.parse = function parse(commands, inputs) {
|
|
1119
|
+
var _this = this;
|
|
1120
|
+
var commandTypes = GenericCommandParser.getCommands(commands);
|
|
1107
1121
|
return {
|
|
1108
1122
|
commands: commandTypes.map(function (commandType, i) {
|
|
1109
|
-
var commandDef =
|
|
1123
|
+
var commandDef = _this.commandDefinition[commandType];
|
|
1110
1124
|
if (commandDef.parser === Parser.V4Actions) {
|
|
1111
1125
|
var _V4BaseActionsParser$ = V4BaseActionsParser.parseCalldata(inputs[i]),
|
|
1112
1126
|
actions = _V4BaseActionsParser$.actions;
|
|
@@ -1149,7 +1163,12 @@ var CommandParser = /*#__PURE__*/function () {
|
|
|
1149
1163
|
return {
|
|
1150
1164
|
commandName: CommandType[commandType],
|
|
1151
1165
|
commandType: commandType,
|
|
1152
|
-
params: inputs
|
|
1166
|
+
params: inputs.map(function (input) {
|
|
1167
|
+
return {
|
|
1168
|
+
name: 'command',
|
|
1169
|
+
value: input
|
|
1170
|
+
};
|
|
1171
|
+
})
|
|
1153
1172
|
};
|
|
1154
1173
|
} else {
|
|
1155
1174
|
throw new Error("Unsupported parser: " + commandDef);
|
|
@@ -1159,7 +1178,7 @@ var CommandParser = /*#__PURE__*/function () {
|
|
|
1159
1178
|
}
|
|
1160
1179
|
// parse command types from bytes string
|
|
1161
1180
|
;
|
|
1162
|
-
|
|
1181
|
+
GenericCommandParser.getCommands = function getCommands(commands) {
|
|
1163
1182
|
var commandTypes = [];
|
|
1164
1183
|
for (var i = 2; i < commands.length; i += 2) {
|
|
1165
1184
|
var _byte = commands.substring(i, i + 2);
|
|
@@ -1167,9 +1186,8 @@ var CommandParser = /*#__PURE__*/function () {
|
|
|
1167
1186
|
}
|
|
1168
1187
|
return commandTypes;
|
|
1169
1188
|
};
|
|
1170
|
-
return
|
|
1189
|
+
return GenericCommandParser;
|
|
1171
1190
|
}();
|
|
1172
|
-
CommandParser.INTERFACE = /*#__PURE__*/new Interface(abi);
|
|
1173
1191
|
function parseV3PathExactIn(path) {
|
|
1174
1192
|
var strippedPath = path.replace('0x', '');
|
|
1175
1193
|
var tokenIn = ethers.utils.getAddress(strippedPath.substring(0, 40));
|
|
@@ -1222,5 +1240,5 @@ function v4RouterCallToParams(actions) {
|
|
|
1222
1240
|
});
|
|
1223
1241
|
}
|
|
1224
1242
|
|
|
1225
|
-
export { CommandParser, CommandType, PoolType, ROUTER_AS_RECIPIENT, RoutePlanner, RouterActionType, RouterTradeAdapter, SwapRouter, UNIVERSAL_ROUTER_ADDRESS, UNIVERSAL_ROUTER_CREATION_BLOCK, UniswapTrade, UniversalRouterVersion, UnwrapWETH, WETH_ADDRESS, isNativeCurrency };
|
|
1243
|
+
export { COMMAND_DEFINITION, CommandParser, CommandType, Parser, PoolType, ROUTER_AS_RECIPIENT, RoutePlanner, RouterActionType, RouterTradeAdapter, Subparser, SwapRouter, UNIVERSAL_ROUTER_ADDRESS, UNIVERSAL_ROUTER_CREATION_BLOCK, UniswapTrade, UniversalRouterVersion, UnwrapWETH, WETH_ADDRESS, isNativeCurrency };
|
|
1226
1244
|
//# sourceMappingURL=universal-router-sdk.esm.js.map
|