@ref-finance/ref-sdk 1.2.3 → 1.3.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 +6 -4
- package/dist/dcl-swap/swap.d.ts +6 -1
- package/dist/ref-sdk.cjs.development.js +133 -101
- package/dist/ref-sdk.cjs.development.js.map +1 -1
- package/dist/ref-sdk.cjs.production.min.js +1 -1
- package/dist/ref-sdk.cjs.production.min.js.map +1 -1
- package/dist/ref-sdk.esm.js +133 -101
- package/dist/ref-sdk.esm.js.map +1 -1
- package/dist/ref-sdk.umd.development.js +133 -101
- package/dist/ref-sdk.umd.development.js.map +1 -1
- package/dist/ref-sdk.umd.production.min.js +1 -1
- package/dist/ref-sdk.umd.production.min.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -21,9 +21,11 @@ Ref SDK identifies env variable NEAR_ENV or REACT_APP_REF_SDK_ENV to get global
|
|
|
21
21
|
|
|
22
22
|
```plain
|
|
23
23
|
export function getConfig(
|
|
24
|
-
env: string | undefined =
|
|
24
|
+
env: string | undefined = ENV ||
|
|
25
|
+
process.env.NEAR_ENV ||
|
|
25
26
|
process.env.REACT_APP_REF_SDK_ENV
|
|
26
27
|
) {
|
|
28
|
+
ENV = env;
|
|
27
29
|
switch (env) {
|
|
28
30
|
case 'mainnet':
|
|
29
31
|
return {
|
|
@@ -35,7 +37,7 @@ export function getConfig(
|
|
|
35
37
|
REF_TOKEN_ID: 'token.v2.ref-finance.near',
|
|
36
38
|
indexerUrl: 'https://indexer.ref.finance',
|
|
37
39
|
explorerUrl: 'https://testnet.nearblocks.io',
|
|
38
|
-
REF_DCL_SWAP_CONTRACT_ID: '',
|
|
40
|
+
REF_DCL_SWAP_CONTRACT_ID: 'dclv2.ref-labs.near',
|
|
39
41
|
};
|
|
40
42
|
case 'testnet':
|
|
41
43
|
return {
|
|
@@ -47,7 +49,7 @@ export function getConfig(
|
|
|
47
49
|
REF_FI_CONTRACT_ID: 'ref-finance-101.testnet',
|
|
48
50
|
REF_TOKEN_ID: 'ref.fakes.testnet',
|
|
49
51
|
explorerUrl: 'https://testnet.nearblocks.io',
|
|
50
|
-
REF_DCL_SWAP_CONTRACT_ID: '
|
|
52
|
+
REF_DCL_SWAP_CONTRACT_ID: 'dclv2.ref-dev.testnet',
|
|
51
53
|
};
|
|
52
54
|
default:
|
|
53
55
|
return {
|
|
@@ -59,7 +61,7 @@ export function getConfig(
|
|
|
59
61
|
REF_TOKEN_ID: 'token.v2.ref-finance.near',
|
|
60
62
|
indexerUrl: 'https://indexer.ref.finance',
|
|
61
63
|
explorerUrl: 'https://nearblocks.io',
|
|
62
|
-
REF_DCL_SWAP_CONTRACT_ID: '',
|
|
64
|
+
REF_DCL_SWAP_CONTRACT_ID: 'dclv2.ref-labs.near',
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
67
|
}
|
package/dist/dcl-swap/swap.d.ts
CHANGED
|
@@ -18,10 +18,15 @@ interface DCLSwapProps {
|
|
|
18
18
|
pool_id: string;
|
|
19
19
|
output_amount: string;
|
|
20
20
|
};
|
|
21
|
+
SwapByStopPoint?: {
|
|
22
|
+
pool_id: string;
|
|
23
|
+
stop_point: number;
|
|
24
|
+
skip_unwrap_near: boolean;
|
|
25
|
+
};
|
|
21
26
|
AccountId: string;
|
|
22
27
|
}
|
|
23
28
|
export declare const DCL_POOL_SPLITER = "|";
|
|
24
|
-
export declare const DCLSwap: ({ Swap, SwapByOutput, LimitOrderWithSwap, AccountId, swapInfo, }: DCLSwapProps) => Promise<Transaction[]>;
|
|
29
|
+
export declare const DCLSwap: ({ Swap, SwapByOutput, LimitOrderWithSwap, SwapByStopPoint, AccountId, swapInfo, }: DCLSwapProps) => Promise<Transaction[]>;
|
|
25
30
|
export declare const quote: ({ pool_ids, input_amount, input_token, output_token, tag, }: {
|
|
26
31
|
pool_ids: string[];
|
|
27
32
|
input_token: TokenMetadata;
|
|
@@ -186,9 +186,6 @@ function _regeneratorRuntime() {
|
|
|
186
186
|
var exports = {},
|
|
187
187
|
Op = Object.prototype,
|
|
188
188
|
hasOwn = Op.hasOwnProperty,
|
|
189
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
190
|
-
obj[key] = desc.value;
|
|
191
|
-
},
|
|
192
189
|
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
193
190
|
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
194
191
|
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
@@ -212,9 +209,40 @@ function _regeneratorRuntime() {
|
|
|
212
209
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
213
210
|
generator = Object.create(protoGenerator.prototype),
|
|
214
211
|
context = new Context(tryLocsList || []);
|
|
215
|
-
return
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
213
|
+
var state = "suspendedStart";
|
|
214
|
+
return function (method, arg) {
|
|
215
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
216
|
+
if ("completed" === state) {
|
|
217
|
+
if ("throw" === method) throw arg;
|
|
218
|
+
return doneResult();
|
|
219
|
+
}
|
|
220
|
+
for (context.method = method, context.arg = arg;;) {
|
|
221
|
+
var delegate = context.delegate;
|
|
222
|
+
if (delegate) {
|
|
223
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
224
|
+
if (delegateResult) {
|
|
225
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
226
|
+
return delegateResult;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
230
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
231
|
+
context.dispatchException(context.arg);
|
|
232
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
233
|
+
state = "executing";
|
|
234
|
+
var record = tryCatch(innerFn, self, context);
|
|
235
|
+
if ("normal" === record.type) {
|
|
236
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
237
|
+
return {
|
|
238
|
+
value: record.arg,
|
|
239
|
+
done: context.done
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
}(innerFn, self, context), generator;
|
|
218
246
|
}
|
|
219
247
|
function tryCatch(fn, obj, arg) {
|
|
220
248
|
try {
|
|
@@ -268,49 +296,13 @@ function _regeneratorRuntime() {
|
|
|
268
296
|
reject(record.arg);
|
|
269
297
|
}
|
|
270
298
|
var previousPromise;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
function
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
283
|
-
var state = "suspendedStart";
|
|
284
|
-
return function (method, arg) {
|
|
285
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
286
|
-
if ("completed" === state) {
|
|
287
|
-
if ("throw" === method) throw arg;
|
|
288
|
-
return doneResult();
|
|
289
|
-
}
|
|
290
|
-
for (context.method = method, context.arg = arg;;) {
|
|
291
|
-
var delegate = context.delegate;
|
|
292
|
-
if (delegate) {
|
|
293
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
294
|
-
if (delegateResult) {
|
|
295
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
296
|
-
return delegateResult;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
300
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
301
|
-
context.dispatchException(context.arg);
|
|
302
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
303
|
-
state = "executing";
|
|
304
|
-
var record = tryCatch(innerFn, self, context);
|
|
305
|
-
if ("normal" === record.type) {
|
|
306
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
307
|
-
return {
|
|
308
|
-
value: record.arg,
|
|
309
|
-
done: context.done
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
299
|
+
this._invoke = function (method, arg) {
|
|
300
|
+
function callInvokeWithMethodAndArg() {
|
|
301
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
302
|
+
invoke(method, arg, resolve, reject);
|
|
303
|
+
});
|
|
313
304
|
}
|
|
305
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
314
306
|
};
|
|
315
307
|
}
|
|
316
308
|
function maybeInvokeDelegate(delegate, context) {
|
|
@@ -366,13 +358,7 @@ function _regeneratorRuntime() {
|
|
|
366
358
|
done: !0
|
|
367
359
|
};
|
|
368
360
|
}
|
|
369
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype,
|
|
370
|
-
value: GeneratorFunctionPrototype,
|
|
371
|
-
configurable: !0
|
|
372
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
373
|
-
value: GeneratorFunction,
|
|
374
|
-
configurable: !0
|
|
375
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
361
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
376
362
|
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
377
363
|
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
378
364
|
}, exports.mark = function (genFun) {
|
|
@@ -393,9 +379,8 @@ function _regeneratorRuntime() {
|
|
|
393
379
|
return this;
|
|
394
380
|
}), define(Gp, "toString", function () {
|
|
395
381
|
return "[object Generator]";
|
|
396
|
-
}), exports.keys = function (
|
|
397
|
-
var
|
|
398
|
-
keys = [];
|
|
382
|
+
}), exports.keys = function (object) {
|
|
383
|
+
var keys = [];
|
|
399
384
|
for (var key in object) keys.push(key);
|
|
400
385
|
return keys.reverse(), function next() {
|
|
401
386
|
for (; keys.length;) {
|
|
@@ -884,7 +869,7 @@ function checkIntegerSumOfAllocations(allocations, totalInput) {
|
|
|
884
869
|
return newAllocations;
|
|
885
870
|
}
|
|
886
871
|
|
|
887
|
-
var
|
|
872
|
+
var _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
|
|
888
873
|
Big.RM = 0;
|
|
889
874
|
Big.DP = 40;
|
|
890
875
|
Big.NE = -40;
|
|
@@ -1306,8 +1291,8 @@ function getBestOptimalAllocationsAndOutputs(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
|
1306
1291
|
return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
|
|
1307
1292
|
}
|
|
1308
1293
|
function _getBestOptimalAllocationsAndOutputs() {
|
|
1309
|
-
_getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1310
|
-
return _regeneratorRuntime().wrap(function
|
|
1294
|
+
_getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
|
|
1295
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context7) {
|
|
1311
1296
|
while (1) {
|
|
1312
1297
|
switch (_context7.prev = _context7.next) {
|
|
1313
1298
|
case 0:
|
|
@@ -1318,9 +1303,9 @@ function _getBestOptimalAllocationsAndOutputs() {
|
|
|
1318
1303
|
threshold = 0.001;
|
|
1319
1304
|
}
|
|
1320
1305
|
return _context7.abrupt("return", function () {
|
|
1321
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1306
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(totalInput) {
|
|
1322
1307
|
var paths, poolChains, routes, nodeRoutes, inputOutput, allocations, outputs;
|
|
1323
|
-
return _regeneratorRuntime().wrap(function
|
|
1308
|
+
return _regeneratorRuntime().wrap(function _callee$(_context6) {
|
|
1324
1309
|
while (1) {
|
|
1325
1310
|
switch (_context6.prev = _context6.next) {
|
|
1326
1311
|
case 0:
|
|
@@ -1369,7 +1354,7 @@ function _getBestOptimalAllocationsAndOutputs() {
|
|
|
1369
1354
|
return _context6.stop();
|
|
1370
1355
|
}
|
|
1371
1356
|
}
|
|
1372
|
-
},
|
|
1357
|
+
}, _callee);
|
|
1373
1358
|
}));
|
|
1374
1359
|
return function (_x33) {
|
|
1375
1360
|
return _ref.apply(this, arguments);
|
|
@@ -1380,7 +1365,7 @@ function _getBestOptimalAllocationsAndOutputs() {
|
|
|
1380
1365
|
return _context7.stop();
|
|
1381
1366
|
}
|
|
1382
1367
|
}
|
|
1383
|
-
},
|
|
1368
|
+
}, _callee2);
|
|
1384
1369
|
}));
|
|
1385
1370
|
return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
|
|
1386
1371
|
}
|
|
@@ -1490,8 +1475,8 @@ function getSmartRouteSwapActions(_x7, _x8, _x9, _x10, _x11, _x12, _x13, _x14, _
|
|
|
1490
1475
|
return _getSmartRouteSwapActions.apply(this, arguments);
|
|
1491
1476
|
}
|
|
1492
1477
|
function _getSmartRouteSwapActions() {
|
|
1493
|
-
_getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1494
|
-
return _regeneratorRuntime().wrap(function
|
|
1478
|
+
_getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(pools, inputToken, outputToken, totalInput, allTokens, maxPathLength, threshold, numberOfRoutesLimit, MAX_NUMBER_PARALLEL_POOLS, decimalsCulledPoolIds) {
|
|
1479
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context10) {
|
|
1495
1480
|
while (1) {
|
|
1496
1481
|
switch (_context10.prev = _context10.next) {
|
|
1497
1482
|
case 0:
|
|
@@ -1511,9 +1496,9 @@ function _getSmartRouteSwapActions() {
|
|
|
1511
1496
|
decimalsCulledPoolIds = [];
|
|
1512
1497
|
}
|
|
1513
1498
|
return _context10.abrupt("return", function () {
|
|
1514
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1499
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(totalInput) {
|
|
1515
1500
|
var resDict, allocations, routes, nodeRoutes, sortedIndexValues, topIndices, reducedRoutes, reducedNodeRoutes, _iterator3, _step3, ind, currentBestOutput, bestAllocations, bestNodeRoutes, bestRoutes, parallelNodeRoutes, parallelRoutes, n, currentNodeRoute, bestRoutesAreParallel, _filteredAllocationsAndOutputs, parallellAllocations, parallelOutputs, sortIndices, filteredParallelRoutes, filteredParallelNodeRoutes, i, parallelOutput, canHaveTwoRoutes, j, route1, route2, nodeRoute1, nodeRoute2, _route1PoolIds, route2PoolIds, sharePool, _iterator4, _step4, route1PoolId, currentRoutes, currentNodeRoutes, _filteredAllocationsAndOutputs2, _filteredAllocations, _filteredOutputs, totalOutput, _currentRoutes, _currentNodeRoutes, _filteredAllocationsAndOutputs3, _filteredAllocations2, _filteredOutputs2, _totalOutput, allSortedIndices, sortedIndices, filteredRoutes, filteredNodeRoutes, index, route1PoolIds, _route2PoolIds, sharedRoute, allFilteredRoutes, allFilteredNodeRoutes, firstRoute, firstRoutePoolIds, allFilteredRouteIds, secondRoute, filteredAllocationsAndOutputs, filteredAllocations, hops, actions, _supplies, hopInputTokenMeta, hopOutputTokenMeta, hopOutputTokenDecimals, expectedHopOutput, decimalEstimate, status, tokens, overallPriceImpact, action;
|
|
1516
|
-
return _regeneratorRuntime().wrap(function
|
|
1501
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context9) {
|
|
1517
1502
|
while (1) {
|
|
1518
1503
|
switch (_context9.prev = _context9.next) {
|
|
1519
1504
|
case 0:
|
|
@@ -1908,8 +1893,8 @@ function _getSmartRouteSwapActions() {
|
|
|
1908
1893
|
}
|
|
1909
1894
|
_context9.next = 143;
|
|
1910
1895
|
return Promise.all(hops[i].nodeRoute.map( /*#__PURE__*/function () {
|
|
1911
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1912
|
-
return _regeneratorRuntime().wrap(function
|
|
1896
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(t) {
|
|
1897
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context8) {
|
|
1913
1898
|
while (1) {
|
|
1914
1899
|
switch (_context8.prev = _context8.next) {
|
|
1915
1900
|
case 0:
|
|
@@ -1932,7 +1917,7 @@ function _getSmartRouteSwapActions() {
|
|
|
1932
1917
|
return _context8.stop();
|
|
1933
1918
|
}
|
|
1934
1919
|
}
|
|
1935
|
-
},
|
|
1920
|
+
}, _callee3);
|
|
1936
1921
|
}));
|
|
1937
1922
|
return function (_x35) {
|
|
1938
1923
|
return _ref3.apply(this, arguments);
|
|
@@ -1993,7 +1978,7 @@ function _getSmartRouteSwapActions() {
|
|
|
1993
1978
|
return _context9.stop();
|
|
1994
1979
|
}
|
|
1995
1980
|
}
|
|
1996
|
-
},
|
|
1981
|
+
}, _callee4);
|
|
1997
1982
|
}));
|
|
1998
1983
|
return function (_x34) {
|
|
1999
1984
|
return _ref2.apply(this, arguments);
|
|
@@ -2004,7 +1989,7 @@ function _getSmartRouteSwapActions() {
|
|
|
2004
1989
|
return _context10.stop();
|
|
2005
1990
|
}
|
|
2006
1991
|
}
|
|
2007
|
-
},
|
|
1992
|
+
}, _callee5);
|
|
2008
1993
|
}));
|
|
2009
1994
|
return _getSmartRouteSwapActions.apply(this, arguments);
|
|
2010
1995
|
}
|
|
@@ -2012,9 +1997,9 @@ function calculateSmartRouteV2PriceImpact(_x17, _x18) {
|
|
|
2012
1997
|
return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
|
|
2013
1998
|
}
|
|
2014
1999
|
function _calculateSmartRouteV2PriceImpact() {
|
|
2015
|
-
_calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2000
|
+
_calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(actions, allTokens) {
|
|
2016
2001
|
var deltaY, inputTokenMeta, deltaX, R, P, routes, nodeRoutes, allocations, totalAllocations, weights, i, route, nodeRoute, tokens, weight, num, denom, routeMarketPrice, num1, denom1, num2, denom2, priceImpact;
|
|
2017
|
-
return _regeneratorRuntime().wrap(function
|
|
2002
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context12) {
|
|
2018
2003
|
while (1) {
|
|
2019
2004
|
switch (_context12.prev = _context12.next) {
|
|
2020
2005
|
case 0:
|
|
@@ -2060,8 +2045,8 @@ function _calculateSmartRouteV2PriceImpact() {
|
|
|
2060
2045
|
nodeRoute = nodeRoutes[i];
|
|
2061
2046
|
_context12.next = 17;
|
|
2062
2047
|
return Promise.all(nodeRoute.map( /*#__PURE__*/function () {
|
|
2063
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2064
|
-
return _regeneratorRuntime().wrap(function
|
|
2048
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(t) {
|
|
2049
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context11) {
|
|
2065
2050
|
while (1) {
|
|
2066
2051
|
switch (_context11.prev = _context11.next) {
|
|
2067
2052
|
case 0:
|
|
@@ -2084,7 +2069,7 @@ function _calculateSmartRouteV2PriceImpact() {
|
|
|
2084
2069
|
return _context11.stop();
|
|
2085
2070
|
}
|
|
2086
2071
|
}
|
|
2087
|
-
},
|
|
2072
|
+
}, _callee6);
|
|
2088
2073
|
}));
|
|
2089
2074
|
return function (_x36) {
|
|
2090
2075
|
return _ref4.apply(this, arguments);
|
|
@@ -2115,7 +2100,7 @@ function _calculateSmartRouteV2PriceImpact() {
|
|
|
2115
2100
|
return _context12.stop();
|
|
2116
2101
|
}
|
|
2117
2102
|
}
|
|
2118
|
-
},
|
|
2103
|
+
}, _callee7);
|
|
2119
2104
|
}));
|
|
2120
2105
|
return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
|
|
2121
2106
|
}
|
|
@@ -2450,7 +2435,7 @@ function yenFromPy(g, source, target) {
|
|
|
2450
2435
|
return _context5.stop();
|
|
2451
2436
|
}
|
|
2452
2437
|
}
|
|
2453
|
-
},
|
|
2438
|
+
}, _marked5, null, [[6, 14]]);
|
|
2454
2439
|
}
|
|
2455
2440
|
function getKShortestPaths(g, source, target, k, maxPathLength) {
|
|
2456
2441
|
if (maxPathLength === void 0) {
|
|
@@ -2487,9 +2472,9 @@ function getPathsFromPools(_x19, _x20, _x21, _x22) {
|
|
|
2487
2472
|
return _getPathsFromPools.apply(this, arguments);
|
|
2488
2473
|
}
|
|
2489
2474
|
function _getPathsFromPools() {
|
|
2490
|
-
_getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2475
|
+
_getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(pools, inputToken, outputToken, maxPathLength) {
|
|
2491
2476
|
var graph;
|
|
2492
|
-
return _regeneratorRuntime().wrap(function
|
|
2477
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context13) {
|
|
2493
2478
|
while (1) {
|
|
2494
2479
|
switch (_context13.prev = _context13.next) {
|
|
2495
2480
|
case 0:
|
|
@@ -2503,7 +2488,7 @@ function _getPathsFromPools() {
|
|
|
2503
2488
|
return _context13.stop();
|
|
2504
2489
|
}
|
|
2505
2490
|
}
|
|
2506
|
-
},
|
|
2491
|
+
}, _callee8);
|
|
2507
2492
|
}));
|
|
2508
2493
|
return _getPathsFromPools.apply(this, arguments);
|
|
2509
2494
|
}
|
|
@@ -2538,9 +2523,9 @@ function stableSmart(_x28, _x29, _x30, _x31, _x32) {
|
|
|
2538
2523
|
return _stableSmart.apply(this, arguments);
|
|
2539
2524
|
}
|
|
2540
2525
|
function _stableSmart() {
|
|
2541
|
-
_stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2526
|
+
_stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, totalInput, allTokens) {
|
|
2542
2527
|
var smartRouteActions;
|
|
2543
|
-
return _regeneratorRuntime().wrap(function
|
|
2528
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context15) {
|
|
2544
2529
|
while (1) {
|
|
2545
2530
|
switch (_context15.prev = _context15.next) {
|
|
2546
2531
|
case 0:
|
|
@@ -2554,7 +2539,7 @@ function _stableSmart() {
|
|
|
2554
2539
|
return _context15.stop();
|
|
2555
2540
|
}
|
|
2556
2541
|
}
|
|
2557
|
-
},
|
|
2542
|
+
}, _callee10);
|
|
2558
2543
|
}));
|
|
2559
2544
|
return _stableSmart.apply(this, arguments);
|
|
2560
2545
|
}
|
|
@@ -3899,7 +3884,11 @@ var refFiViewFunction = /*#__PURE__*/function () {
|
|
|
3899
3884
|
return near.account(exports.REF_FI_CONTRACT_ID);
|
|
3900
3885
|
case 3:
|
|
3901
3886
|
nearConnection = _context.sent;
|
|
3902
|
-
return _context.abrupt("return", nearConnection.viewFunction(
|
|
3887
|
+
return _context.abrupt("return", nearConnection.viewFunction({
|
|
3888
|
+
contractId: exports.REF_FI_CONTRACT_ID,
|
|
3889
|
+
methodName: methodName,
|
|
3890
|
+
args: args
|
|
3891
|
+
}));
|
|
3903
3892
|
case 5:
|
|
3904
3893
|
case "end":
|
|
3905
3894
|
return _context.stop();
|
|
@@ -3923,7 +3912,11 @@ var ftViewFunction = /*#__PURE__*/function () {
|
|
|
3923
3912
|
return near.account(exports.REF_FI_CONTRACT_ID);
|
|
3924
3913
|
case 3:
|
|
3925
3914
|
nearConnection = _context2.sent;
|
|
3926
|
-
return _context2.abrupt("return", nearConnection.viewFunction(
|
|
3915
|
+
return _context2.abrupt("return", nearConnection.viewFunction({
|
|
3916
|
+
contractId: tokenId,
|
|
3917
|
+
methodName: methodName,
|
|
3918
|
+
args: args
|
|
3919
|
+
}));
|
|
3927
3920
|
case 5:
|
|
3928
3921
|
case "end":
|
|
3929
3922
|
return _context2.stop();
|
|
@@ -4215,7 +4208,11 @@ var refDCLSwapViewFunction = /*#__PURE__*/function () {
|
|
|
4215
4208
|
}
|
|
4216
4209
|
throw DCLInValid;
|
|
4217
4210
|
case 6:
|
|
4218
|
-
return _context10.abrupt("return", nearConnection.viewFunction(
|
|
4211
|
+
return _context10.abrupt("return", nearConnection.viewFunction({
|
|
4212
|
+
contractId: exports.config.REF_DCL_SWAP_CONTRACT_ID,
|
|
4213
|
+
methodName: methodName,
|
|
4214
|
+
args: args
|
|
4215
|
+
}));
|
|
4219
4216
|
case 7:
|
|
4220
4217
|
case "end":
|
|
4221
4218
|
return _context10.stop();
|
|
@@ -7510,12 +7507,12 @@ function getDefaultTokenList() {
|
|
|
7510
7507
|
var DCL_POOL_SPLITER = '|';
|
|
7511
7508
|
var DCLSwap = /*#__PURE__*/function () {
|
|
7512
7509
|
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
7513
|
-
var Swap, SwapByOutput, LimitOrderWithSwap, AccountId, swapInfo, transactions, tokenA, tokenB, amountA, pool_ids, tokenRegistered, output_token, min_output_amount, msg, _pool_ids, _output_token, output_amount, _msg, _tokenRegistered, pool_id, fee, buy_token, point, _tokenRegistered2, DCLRegistered, new_point, _msg2, registered;
|
|
7510
|
+
var Swap, SwapByOutput, LimitOrderWithSwap, SwapByStopPoint, AccountId, swapInfo, transactions, tokenA, tokenB, amountA, pool_ids, tokenRegistered, output_token, min_output_amount, msg, _pool_ids, _output_token, output_amount, _msg, _tokenRegistered, pool_id, fee, buy_token, point, _tokenRegistered2, DCLRegistered, new_point, _msg2, _tokenRegistered3, _msg3, registered;
|
|
7514
7511
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
7515
7512
|
while (1) {
|
|
7516
7513
|
switch (_context.prev = _context.next) {
|
|
7517
7514
|
case 0:
|
|
7518
|
-
Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
|
|
7515
|
+
Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, SwapByStopPoint = _ref.SwapByStopPoint, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
|
|
7519
7516
|
transactions = [];
|
|
7520
7517
|
tokenA = swapInfo.tokenA, tokenB = swapInfo.tokenB, amountA = swapInfo.amountA;
|
|
7521
7518
|
if (!Swap) {
|
|
@@ -7558,7 +7555,7 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7558
7555
|
amount: ONE_YOCTO_NEAR
|
|
7559
7556
|
}]
|
|
7560
7557
|
});
|
|
7561
|
-
_context.next =
|
|
7558
|
+
_context.next = 52;
|
|
7562
7559
|
break;
|
|
7563
7560
|
case 15:
|
|
7564
7561
|
if (!SwapByOutput) {
|
|
@@ -7601,11 +7598,11 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7601
7598
|
amount: ONE_YOCTO_NEAR
|
|
7602
7599
|
}]
|
|
7603
7600
|
});
|
|
7604
|
-
_context.next =
|
|
7601
|
+
_context.next = 52;
|
|
7605
7602
|
break;
|
|
7606
7603
|
case 27:
|
|
7607
7604
|
if (!LimitOrderWithSwap) {
|
|
7608
|
-
_context.next =
|
|
7605
|
+
_context.next = 45;
|
|
7609
7606
|
break;
|
|
7610
7607
|
}
|
|
7611
7608
|
pool_id = LimitOrderWithSwap.pool_id;
|
|
@@ -7672,14 +7669,49 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7672
7669
|
amount: ONE_YOCTO_NEAR
|
|
7673
7670
|
}]
|
|
7674
7671
|
});
|
|
7675
|
-
|
|
7672
|
+
_context.next = 52;
|
|
7673
|
+
break;
|
|
7674
|
+
case 45:
|
|
7675
|
+
if (!SwapByStopPoint) {
|
|
7676
|
+
_context.next = 52;
|
|
7677
|
+
break;
|
|
7678
|
+
}
|
|
7679
|
+
_context.next = 48;
|
|
7680
|
+
return ftGetStorageBalance(tokenB.id, AccountId)["catch"](function () {
|
|
7681
|
+
throw new Error(tokenB.id + " doesn't exist.");
|
|
7682
|
+
});
|
|
7683
|
+
case 48:
|
|
7684
|
+
_tokenRegistered3 = _context.sent;
|
|
7685
|
+
if (_tokenRegistered3 === null) {
|
|
7686
|
+
transactions.push({
|
|
7687
|
+
receiverId: tokenB.id,
|
|
7688
|
+
functionCalls: [registerAccountOnToken(AccountId)]
|
|
7689
|
+
});
|
|
7690
|
+
}
|
|
7691
|
+
_msg3 = JSON.stringify({
|
|
7692
|
+
SwapByStopPoint: SwapByStopPoint
|
|
7693
|
+
});
|
|
7694
|
+
transactions.push({
|
|
7695
|
+
receiverId: tokenA.id,
|
|
7696
|
+
functionCalls: [{
|
|
7697
|
+
methodName: 'ft_transfer_call',
|
|
7698
|
+
args: {
|
|
7699
|
+
receiver_id: exports.config.REF_DCL_SWAP_CONTRACT_ID,
|
|
7700
|
+
amount: toNonDivisibleNumber(tokenA.decimals, amountA),
|
|
7701
|
+
msg: _msg3
|
|
7702
|
+
},
|
|
7703
|
+
gas: '180000000000000',
|
|
7704
|
+
amount: ONE_YOCTO_NEAR
|
|
7705
|
+
}]
|
|
7706
|
+
});
|
|
7707
|
+
case 52:
|
|
7676
7708
|
if (!(tokenA.id === exports.WRAP_NEAR_CONTRACT_ID)) {
|
|
7677
|
-
_context.next =
|
|
7709
|
+
_context.next = 57;
|
|
7678
7710
|
break;
|
|
7679
7711
|
}
|
|
7680
|
-
_context.next =
|
|
7712
|
+
_context.next = 55;
|
|
7681
7713
|
return ftGetStorageBalance(exports.WRAP_NEAR_CONTRACT_ID, AccountId);
|
|
7682
|
-
case
|
|
7714
|
+
case 55:
|
|
7683
7715
|
registered = _context.sent;
|
|
7684
7716
|
if (registered === null) {
|
|
7685
7717
|
transactions.unshift({
|
|
@@ -7687,9 +7719,9 @@ var DCLSwap = /*#__PURE__*/function () {
|
|
|
7687
7719
|
functionCalls: [registerAccountOnToken(AccountId)]
|
|
7688
7720
|
});
|
|
7689
7721
|
}
|
|
7690
|
-
case
|
|
7722
|
+
case 57:
|
|
7691
7723
|
return _context.abrupt("return", transactions);
|
|
7692
|
-
case
|
|
7724
|
+
case 58:
|
|
7693
7725
|
case "end":
|
|
7694
7726
|
return _context.stop();
|
|
7695
7727
|
}
|