@pioneer-platform/uniswap-client 0.0.28 → 0.1.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/CHANGELOG.md +16 -0
- package/lib/constants/chainInfo.d.ts +2 -2
- package/lib/constants/chainInfo.js +40 -43
- package/lib/constants/chains.d.ts +20 -20
- package/lib/constants/chains.js +25 -26
- package/lib/constants/governance.js +13 -14
- package/lib/constants/lists.js +20 -28
- package/lib/constants/misc.d.ts +4 -5
- package/lib/constants/misc.js +2 -2
- package/lib/constants/networks.js +45 -46
- package/lib/constants/proposals/uniswap_grants_proposal_description.js +106 -1
- package/lib/constants/providers.d.ts +16 -15
- package/lib/constants/providers.js +23 -24
- package/lib/constants/routing.js +44 -61
- package/lib/constants/tokens.d.ts +49 -49
- package/lib/constants/tokens.js +133 -170
- package/lib/index.js +556 -877
- package/lib/routing/clientSideSmartOrderRouter.js +72 -121
- package/lib/routing/gas.js +63 -150
- package/lib/routing/types.d.ts +7 -7
- package/lib/routing/types.js +160 -264
- package/lib/routing/utils.js +141 -196
- package/lib/rpc/AppJsonRpcProvider.js +40 -131
- package/lib/rpc/ConfiguredJsonRpcProvider.d.ts +1 -1
- package/lib/rpc/ConfiguredJsonRpcProvider.js +8 -27
- package/lib/utils/contracts/getContract.js +6 -7
- package/lib/utils/transformSwapRouteToGetQuoteResult.js +24 -27
- package/lib/utils/uniswapData.d.ts +6 -6
- package/lib/utils/uniswapData.js +64 -142
- package/package.json +19 -19
- package/tsconfig.json +27 -8
- package/lib/constants/chains.test.d.ts +0 -1
- package/lib/constants/chains.test.js +0 -26
- package/lib/constants/localCurrencies.d.ts +0 -6
- package/lib/constants/localCurrencies.js +0 -94
- package/lib/constants/localCurrencyIcons.d.ts +0 -18
- package/lib/constants/localCurrencyIcons.js +0 -298
- package/lib/constants/routing.test.d.ts +0 -1
- package/lib/constants/routing.test.js +0 -32
- package/lib/constants/tokenLists/broken.tokenlist.json +0 -22
- package/lib/constants/tokenLogoLookup.d.ts +0 -8
- package/lib/constants/tokenLogoLookup.js +0 -48
- package/lib/constants/tokenSafety.js +0 -129
- package/lib/constants/tokenSafetyLookup.d.ts +0 -18
- package/lib/constants/tokenSafetyLookup.js +0 -66
- package/lib/constants/tokenSaftey.test.d.ts +0 -1
- package/lib/constants/tokenSaftey.test.js +0 -31
|
@@ -1,113 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
54
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
-
if (ar || !(i in from)) {
|
|
56
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
-
ar[i] = from[i];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
-
};
|
|
62
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
63
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
64
4
|
};
|
|
65
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
-
|
|
67
|
-
|
|
6
|
+
const chainInfo_1 = require("../constants/chainInfo");
|
|
7
|
+
const ConfiguredJsonRpcProvider_1 = __importDefault(require("./ConfiguredJsonRpcProvider"));
|
|
68
8
|
/**
|
|
69
9
|
* A controller which marks itself disabled on an error, and re-enables itself using exponential backoff.
|
|
70
10
|
* After each retry, it will wait twice as long to retry again. After a success, it will reset the backoff.
|
|
71
11
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
12
|
+
class Controller {
|
|
13
|
+
constructor(minimumBackoffTime) {
|
|
74
14
|
this.minimumBackoffTime = minimumBackoffTime;
|
|
75
15
|
this.isEnabled = true;
|
|
76
16
|
this.exponentialBackoffFactor = 1;
|
|
77
17
|
}
|
|
78
|
-
|
|
18
|
+
reset() {
|
|
79
19
|
this.isEnabled = true;
|
|
80
20
|
// @ts-ignore
|
|
81
21
|
clearTimeout(this.timeout);
|
|
82
22
|
this.timeout = undefined;
|
|
83
|
-
}
|
|
84
|
-
|
|
23
|
+
}
|
|
24
|
+
onSuccess() {
|
|
85
25
|
this.reset();
|
|
86
26
|
this.exponentialBackoffFactor = 1;
|
|
87
|
-
}
|
|
27
|
+
}
|
|
88
28
|
/**
|
|
89
29
|
* Called onError.
|
|
90
30
|
* Idempotent - calling this multiple times will *not* reset the exponential backoff timer.
|
|
91
31
|
*/
|
|
92
|
-
|
|
93
|
-
var _this = this;
|
|
32
|
+
onError() {
|
|
94
33
|
this.isEnabled = false;
|
|
95
34
|
if (!this.timeout) {
|
|
96
|
-
this.timeout = setTimeout(
|
|
97
|
-
|
|
98
|
-
|
|
35
|
+
this.timeout = setTimeout(() => {
|
|
36
|
+
this.reset();
|
|
37
|
+
this.exponentialBackoffFactor *= 2;
|
|
99
38
|
}, this.minimumBackoffTime * this.exponentialBackoffFactor);
|
|
100
39
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
enumerable: false,
|
|
107
|
-
configurable: true
|
|
108
|
-
});
|
|
109
|
-
return Controller;
|
|
110
|
-
}());
|
|
40
|
+
}
|
|
41
|
+
get enabled() {
|
|
42
|
+
return this.isEnabled;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
111
45
|
/**
|
|
112
46
|
* An application-specific JSON-RPC provider.
|
|
113
47
|
*
|
|
@@ -115,58 +49,34 @@ var Controller = /** @class */ (function () {
|
|
|
115
49
|
* It will use the first (primary) JSON-RPC URL unless there is issue, at which point it will fallback to the next, &c.,
|
|
116
50
|
* retrying the former using exponential backoff. This prevents secondary URLs from permanently overtaking primary URLs.
|
|
117
51
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
function AppJsonRpcProvider(providers, _a) {
|
|
121
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.minimumBackoffTime, minimumBackoffTime = _c === void 0 ? chainInfo_1.AVERAGE_L1_BLOCK_TIME : _c;
|
|
122
|
-
var _this = this;
|
|
52
|
+
class AppJsonRpcProvider extends ConfiguredJsonRpcProvider_1.default {
|
|
53
|
+
constructor(providers, { minimumBackoffTime = chainInfo_1.AVERAGE_L1_BLOCK_TIME } = {}) {
|
|
123
54
|
if (providers.length === 0)
|
|
124
55
|
throw new Error('Missing providers for AppJsonRpcProvider');
|
|
125
|
-
|
|
56
|
+
super(undefined, providers[0].network);
|
|
126
57
|
// AppJsonRpcProvider configures its own pollingInterval, so the encapsulated providers do not need to poll.
|
|
127
58
|
// providers.forEach((provider) => (provider.pollingInterval = Infinity))
|
|
128
|
-
|
|
129
|
-
return _this;
|
|
59
|
+
this.providers = providers.map((provider) => ({ provider, controller: new Controller(minimumBackoffTime) }));
|
|
130
60
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
case 3:
|
|
148
|
-
result = _b.sent();
|
|
149
|
-
controller.onSuccess();
|
|
150
|
-
return [2 /*return*/, result];
|
|
151
|
-
case 4:
|
|
152
|
-
error_1 = _b.sent();
|
|
153
|
-
console.warn('rpc action failed', error_1);
|
|
154
|
-
controller.onError();
|
|
155
|
-
return [3 /*break*/, 5];
|
|
156
|
-
case 5:
|
|
157
|
-
_i++;
|
|
158
|
-
return [3 /*break*/, 1];
|
|
159
|
-
case 6: throw new Error("All providers failed to perform the operation: ".concat(method));
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
AppJsonRpcProvider.sortProviders = function (providers) {
|
|
61
|
+
async perform(method, params) {
|
|
62
|
+
const sortedProviders = AppJsonRpcProvider.sortProviders(this.providers);
|
|
63
|
+
for (const { provider, controller } of sortedProviders) {
|
|
64
|
+
try {
|
|
65
|
+
const result = await provider.perform(method, params);
|
|
66
|
+
controller.onSuccess();
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.warn('rpc action failed', error);
|
|
71
|
+
controller.onError();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
throw new Error(`All providers failed to perform the operation: ${method}`);
|
|
75
|
+
}
|
|
76
|
+
static sortProviders(providers) {
|
|
165
77
|
// Try enabled providers before resorting to disabled providers.
|
|
166
78
|
// Note that we do not filtered out disabled providers.
|
|
167
|
-
return
|
|
168
|
-
var a = _a.controller.enabled;
|
|
169
|
-
var b = _b.controller.enabled;
|
|
79
|
+
return [...providers].sort(({ controller: { enabled: a } }, { controller: { enabled: b } }) => {
|
|
170
80
|
if (a && !b) {
|
|
171
81
|
return -1;
|
|
172
82
|
}
|
|
@@ -177,7 +87,6 @@ var AppJsonRpcProvider = /** @class */ (function (_super) {
|
|
|
177
87
|
return 0; // sort is stable
|
|
178
88
|
}
|
|
179
89
|
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
}(ConfiguredJsonRpcProvider_1.default));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
183
92
|
exports.default = AppJsonRpcProvider;
|
|
@@ -4,5 +4,5 @@ import { SupportedInterfaceChain } from '../constants/chains';
|
|
|
4
4
|
export default class ConfiguredJsonRpcProvider extends StaticJsonRpcProvider {
|
|
5
5
|
constructor(url: string | undefined, networkish: Networkish & {
|
|
6
6
|
chainId: SupportedInterfaceChain;
|
|
7
|
-
}, pollingInterval?:
|
|
7
|
+
}, pollingInterval?: any);
|
|
8
8
|
}
|
|
@@ -1,35 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function ConfiguredJsonRpcProvider(url,
|
|
3
|
+
const providers_1 = require("@ethersproject/providers");
|
|
4
|
+
const chainInfo_1 = require("../constants/chainInfo");
|
|
5
|
+
class ConfiguredJsonRpcProvider extends providers_1.StaticJsonRpcProvider {
|
|
6
|
+
constructor(url,
|
|
23
7
|
// Including networkish allows ethers to skip the initial detectNetwork call.
|
|
24
|
-
networkish, pollingInterval) {
|
|
25
|
-
|
|
26
|
-
var _this = _super.call(this, url, networkish) || this;
|
|
8
|
+
networkish, pollingInterval = chainInfo_1.AVERAGE_L1_BLOCK_TIME) {
|
|
9
|
+
super(url, networkish);
|
|
27
10
|
// NB: Third-party providers (eg MetaMask) will have their own polling intervals,
|
|
28
11
|
// which should be left as-is to allow operations (eg transaction confirmation) to resolve faster.
|
|
29
12
|
// Network providers need to update less frequently to be considered responsive.
|
|
30
|
-
|
|
31
|
-
return _this;
|
|
13
|
+
this.pollingInterval = pollingInterval;
|
|
32
14
|
}
|
|
33
|
-
|
|
34
|
-
}(providers_1.StaticJsonRpcProvider));
|
|
15
|
+
}
|
|
35
16
|
exports.default = ConfiguredJsonRpcProvider;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getContract =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.getContract = getContract;
|
|
4
|
+
const constants_1 = require("@ethersproject/constants");
|
|
5
|
+
const contracts_1 = require("@ethersproject/contracts");
|
|
6
|
+
const address_1 = require("@ethersproject/address");
|
|
7
7
|
function isAddress(value) {
|
|
8
8
|
if (!value) {
|
|
9
9
|
return false;
|
|
@@ -13,17 +13,16 @@ function isAddress(value) {
|
|
|
13
13
|
// See documentation here: https://docs.ethers.io/v5/api/utils/address/
|
|
14
14
|
return (0, address_1.getAddress)(value.toLowerCase());
|
|
15
15
|
}
|
|
16
|
-
catch
|
|
16
|
+
catch {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function getContract(address, ABI, provider, account) {
|
|
21
21
|
if (!isAddress(address) || address === constants_1.AddressZero) {
|
|
22
|
-
throw Error(
|
|
22
|
+
throw Error(`Invalid 'address' parameter '${address}'.`);
|
|
23
23
|
}
|
|
24
24
|
return new contracts_1.Contract(address, ABI, getProviderOrSigner(provider, account));
|
|
25
25
|
}
|
|
26
|
-
exports.getContract = getContract;
|
|
27
26
|
function getProviderOrSigner(provider, account) {
|
|
28
27
|
return account ? provider.getSigner(account).connectUnchecked() : provider;
|
|
29
28
|
}
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformSwapRouteToGetQuoteResult =
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.transformSwapRouteToGetQuoteResult = transformSwapRouteToGetQuoteResult;
|
|
4
|
+
const router_sdk_1 = require("@uniswap/router-sdk");
|
|
5
|
+
const sdk_core_1 = require("@uniswap/sdk-core");
|
|
6
6
|
// This file is lazy-loaded, so the import of smart-order-router is intentional.
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const smart_order_router_1 = require("@uniswap/smart-order-router");
|
|
9
|
+
const v3_sdk_1 = require("@uniswap/v3-sdk");
|
|
10
|
+
const types_1 = require("../routing/types");
|
|
11
11
|
// from routing-api (https://github.com/Uniswap/routing-api/blob/main/lib/handlers/quote/quote.ts#L243-L311)
|
|
12
|
-
function transformSwapRouteToGetQuoteResult(tradeType, amount,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var tokenOut = tokenPath[i + 1];
|
|
24
|
-
var edgeAmountIn = undefined;
|
|
12
|
+
function transformSwapRouteToGetQuoteResult(tradeType, amount, { quote, quoteGasAdjusted, route, estimatedGasUsed, estimatedGasUsedQuoteToken, estimatedGasUsedUSD, gasPriceWei, methodParameters, blockNumber, }) {
|
|
13
|
+
const routeResponse = [];
|
|
14
|
+
for (const subRoute of route) {
|
|
15
|
+
const { amount, quote, tokenPath } = subRoute;
|
|
16
|
+
const pools = subRoute.protocol === router_sdk_1.Protocol.V2 ? subRoute.route.pairs : subRoute.route.pools;
|
|
17
|
+
const curRoute = [];
|
|
18
|
+
for (let i = 0; i < pools.length; i++) {
|
|
19
|
+
const nextPool = pools[i];
|
|
20
|
+
const tokenIn = tokenPath[i];
|
|
21
|
+
const tokenOut = tokenPath[i + 1];
|
|
22
|
+
let edgeAmountIn = undefined;
|
|
25
23
|
if (i === 0) {
|
|
26
|
-
edgeAmountIn = tradeType === sdk_core_1.TradeType.EXACT_INPUT ?
|
|
24
|
+
edgeAmountIn = tradeType === sdk_core_1.TradeType.EXACT_INPUT ? amount.quotient.toString() : quote.quotient.toString();
|
|
27
25
|
}
|
|
28
|
-
|
|
26
|
+
let edgeAmountOut = undefined;
|
|
29
27
|
if (i === pools.length - 1) {
|
|
30
|
-
edgeAmountOut = tradeType === sdk_core_1.TradeType.EXACT_INPUT ?
|
|
28
|
+
edgeAmountOut = tradeType === sdk_core_1.TradeType.EXACT_INPUT ? quote.quotient.toString() : amount.quotient.toString();
|
|
31
29
|
}
|
|
32
30
|
if (nextPool instanceof v3_sdk_1.Pool) {
|
|
33
31
|
curRoute.push({
|
|
@@ -53,8 +51,8 @@ function transformSwapRouteToGetQuoteResult(tradeType, amount, _a) {
|
|
|
53
51
|
});
|
|
54
52
|
}
|
|
55
53
|
else {
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const reserve0 = nextPool.reserve0;
|
|
55
|
+
const reserve1 = nextPool.reserve1;
|
|
58
56
|
curRoute.push({
|
|
59
57
|
type: 'v2-pool',
|
|
60
58
|
tokenIn: {
|
|
@@ -94,8 +92,8 @@ function transformSwapRouteToGetQuoteResult(tradeType, amount, _a) {
|
|
|
94
92
|
}
|
|
95
93
|
routeResponse.push(curRoute);
|
|
96
94
|
}
|
|
97
|
-
|
|
98
|
-
methodParameters
|
|
95
|
+
const result = {
|
|
96
|
+
methodParameters,
|
|
99
97
|
blockNumber: blockNumber.toString(),
|
|
100
98
|
amount: amount.quotient.toString(),
|
|
101
99
|
amountDecimals: amount.toExact(),
|
|
@@ -113,4 +111,3 @@ function transformSwapRouteToGetQuoteResult(tradeType, amount, _a) {
|
|
|
113
111
|
};
|
|
114
112
|
return { state: types_1.QuoteState.SUCCESS, data: { routing: types_1.URAQuoteType.CLASSIC, quote: result, allQuotes: [] } };
|
|
115
113
|
}
|
|
116
|
-
exports.transformSwapRouteToGetQuoteResult = transformSwapRouteToGetQuoteResult;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { MixedRouteTrade, Trade as RouterTrade } from '@uniswap/router-sdk';
|
|
2
2
|
import { Trade as V2Trade, Pair } from '@uniswap/v2-sdk';
|
|
3
3
|
import { Trade as V3Trade, Pool, FeeAmount } from '@uniswap/v3-sdk';
|
|
4
|
-
import { TradeType,
|
|
5
|
-
export declare const ETHER:
|
|
6
|
-
export declare const WETH:
|
|
7
|
-
export declare const DAI:
|
|
8
|
-
export declare const USDC:
|
|
9
|
-
export declare const FEE_AMOUNT
|
|
4
|
+
import { TradeType, Token, Currency } from '@uniswap/sdk-core';
|
|
5
|
+
export declare const ETHER: any;
|
|
6
|
+
export declare const WETH: any;
|
|
7
|
+
export declare const DAI: any;
|
|
8
|
+
export declare const USDC: any;
|
|
9
|
+
export declare const FEE_AMOUNT: any;
|
|
10
10
|
type UniswapPools = {
|
|
11
11
|
WETH_USDC_V2: Pair;
|
|
12
12
|
USDC_DAI_V2: Pair;
|