@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
|
@@ -167,9 +167,6 @@
|
|
|
167
167
|
var exports = {},
|
|
168
168
|
Op = Object.prototype,
|
|
169
169
|
hasOwn = Op.hasOwnProperty,
|
|
170
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
171
|
-
obj[key] = desc.value;
|
|
172
|
-
},
|
|
173
170
|
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
174
171
|
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
175
172
|
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
@@ -193,9 +190,40 @@
|
|
|
193
190
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
194
191
|
generator = Object.create(protoGenerator.prototype),
|
|
195
192
|
context = new Context(tryLocsList || []);
|
|
196
|
-
return
|
|
197
|
-
|
|
198
|
-
|
|
193
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
194
|
+
var state = "suspendedStart";
|
|
195
|
+
return function (method, arg) {
|
|
196
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
197
|
+
if ("completed" === state) {
|
|
198
|
+
if ("throw" === method) throw arg;
|
|
199
|
+
return doneResult();
|
|
200
|
+
}
|
|
201
|
+
for (context.method = method, context.arg = arg;;) {
|
|
202
|
+
var delegate = context.delegate;
|
|
203
|
+
if (delegate) {
|
|
204
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
205
|
+
if (delegateResult) {
|
|
206
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
207
|
+
return delegateResult;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
211
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
212
|
+
context.dispatchException(context.arg);
|
|
213
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
214
|
+
state = "executing";
|
|
215
|
+
var record = tryCatch(innerFn, self, context);
|
|
216
|
+
if ("normal" === record.type) {
|
|
217
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
218
|
+
return {
|
|
219
|
+
value: record.arg,
|
|
220
|
+
done: context.done
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}(innerFn, self, context), generator;
|
|
199
227
|
}
|
|
200
228
|
function tryCatch(fn, obj, arg) {
|
|
201
229
|
try {
|
|
@@ -249,49 +277,13 @@
|
|
|
249
277
|
reject(record.arg);
|
|
250
278
|
}
|
|
251
279
|
var previousPromise;
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
function
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
264
|
-
var state = "suspendedStart";
|
|
265
|
-
return function (method, arg) {
|
|
266
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
267
|
-
if ("completed" === state) {
|
|
268
|
-
if ("throw" === method) throw arg;
|
|
269
|
-
return doneResult();
|
|
270
|
-
}
|
|
271
|
-
for (context.method = method, context.arg = arg;;) {
|
|
272
|
-
var delegate = context.delegate;
|
|
273
|
-
if (delegate) {
|
|
274
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
275
|
-
if (delegateResult) {
|
|
276
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
277
|
-
return delegateResult;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
281
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
282
|
-
context.dispatchException(context.arg);
|
|
283
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
284
|
-
state = "executing";
|
|
285
|
-
var record = tryCatch(innerFn, self, context);
|
|
286
|
-
if ("normal" === record.type) {
|
|
287
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
288
|
-
return {
|
|
289
|
-
value: record.arg,
|
|
290
|
-
done: context.done
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
280
|
+
this._invoke = function (method, arg) {
|
|
281
|
+
function callInvokeWithMethodAndArg() {
|
|
282
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
283
|
+
invoke(method, arg, resolve, reject);
|
|
284
|
+
});
|
|
294
285
|
}
|
|
286
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
295
287
|
};
|
|
296
288
|
}
|
|
297
289
|
function maybeInvokeDelegate(delegate, context) {
|
|
@@ -347,13 +339,7 @@
|
|
|
347
339
|
done: !0
|
|
348
340
|
};
|
|
349
341
|
}
|
|
350
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype,
|
|
351
|
-
value: GeneratorFunctionPrototype,
|
|
352
|
-
configurable: !0
|
|
353
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
354
|
-
value: GeneratorFunction,
|
|
355
|
-
configurable: !0
|
|
356
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
342
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
357
343
|
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
358
344
|
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
359
345
|
}, exports.mark = function (genFun) {
|
|
@@ -374,9 +360,8 @@
|
|
|
374
360
|
return this;
|
|
375
361
|
}), define(Gp, "toString", function () {
|
|
376
362
|
return "[object Generator]";
|
|
377
|
-
}), exports.keys = function (
|
|
378
|
-
var
|
|
379
|
-
keys = [];
|
|
363
|
+
}), exports.keys = function (object) {
|
|
364
|
+
var keys = [];
|
|
380
365
|
for (var key in object) keys.push(key);
|
|
381
366
|
return keys.reverse(), function next() {
|
|
382
367
|
for (; keys.length;) {
|
|
@@ -865,7 +850,7 @@
|
|
|
865
850
|
return newAllocations;
|
|
866
851
|
}
|
|
867
852
|
|
|
868
|
-
var
|
|
853
|
+
var _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
|
|
869
854
|
Big.RM = 0;
|
|
870
855
|
Big.DP = 40;
|
|
871
856
|
Big.NE = -40;
|
|
@@ -1287,8 +1272,8 @@
|
|
|
1287
1272
|
return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
|
|
1288
1273
|
}
|
|
1289
1274
|
function _getBestOptimalAllocationsAndOutputs() {
|
|
1290
|
-
_getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1291
|
-
return _regeneratorRuntime().wrap(function
|
|
1275
|
+
_getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
|
|
1276
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context7) {
|
|
1292
1277
|
while (1) {
|
|
1293
1278
|
switch (_context7.prev = _context7.next) {
|
|
1294
1279
|
case 0:
|
|
@@ -1299,9 +1284,9 @@
|
|
|
1299
1284
|
threshold = 0.001;
|
|
1300
1285
|
}
|
|
1301
1286
|
return _context7.abrupt("return", function () {
|
|
1302
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1287
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(totalInput) {
|
|
1303
1288
|
var paths, poolChains, routes, nodeRoutes, inputOutput, allocations, outputs;
|
|
1304
|
-
return _regeneratorRuntime().wrap(function
|
|
1289
|
+
return _regeneratorRuntime().wrap(function _callee$(_context6) {
|
|
1305
1290
|
while (1) {
|
|
1306
1291
|
switch (_context6.prev = _context6.next) {
|
|
1307
1292
|
case 0:
|
|
@@ -1350,7 +1335,7 @@
|
|
|
1350
1335
|
return _context6.stop();
|
|
1351
1336
|
}
|
|
1352
1337
|
}
|
|
1353
|
-
},
|
|
1338
|
+
}, _callee);
|
|
1354
1339
|
}));
|
|
1355
1340
|
return function (_x33) {
|
|
1356
1341
|
return _ref.apply(this, arguments);
|
|
@@ -1361,7 +1346,7 @@
|
|
|
1361
1346
|
return _context7.stop();
|
|
1362
1347
|
}
|
|
1363
1348
|
}
|
|
1364
|
-
},
|
|
1349
|
+
}, _callee2);
|
|
1365
1350
|
}));
|
|
1366
1351
|
return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
|
|
1367
1352
|
}
|
|
@@ -1471,8 +1456,8 @@
|
|
|
1471
1456
|
return _getSmartRouteSwapActions.apply(this, arguments);
|
|
1472
1457
|
}
|
|
1473
1458
|
function _getSmartRouteSwapActions() {
|
|
1474
|
-
_getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1475
|
-
return _regeneratorRuntime().wrap(function
|
|
1459
|
+
_getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(pools, inputToken, outputToken, totalInput, allTokens, maxPathLength, threshold, numberOfRoutesLimit, MAX_NUMBER_PARALLEL_POOLS, decimalsCulledPoolIds) {
|
|
1460
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context10) {
|
|
1476
1461
|
while (1) {
|
|
1477
1462
|
switch (_context10.prev = _context10.next) {
|
|
1478
1463
|
case 0:
|
|
@@ -1492,9 +1477,9 @@
|
|
|
1492
1477
|
decimalsCulledPoolIds = [];
|
|
1493
1478
|
}
|
|
1494
1479
|
return _context10.abrupt("return", function () {
|
|
1495
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1480
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(totalInput) {
|
|
1496
1481
|
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;
|
|
1497
|
-
return _regeneratorRuntime().wrap(function
|
|
1482
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context9) {
|
|
1498
1483
|
while (1) {
|
|
1499
1484
|
switch (_context9.prev = _context9.next) {
|
|
1500
1485
|
case 0:
|
|
@@ -1889,8 +1874,8 @@
|
|
|
1889
1874
|
}
|
|
1890
1875
|
_context9.next = 143;
|
|
1891
1876
|
return Promise.all(hops[i].nodeRoute.map( /*#__PURE__*/function () {
|
|
1892
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1893
|
-
return _regeneratorRuntime().wrap(function
|
|
1877
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(t) {
|
|
1878
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context8) {
|
|
1894
1879
|
while (1) {
|
|
1895
1880
|
switch (_context8.prev = _context8.next) {
|
|
1896
1881
|
case 0:
|
|
@@ -1913,7 +1898,7 @@
|
|
|
1913
1898
|
return _context8.stop();
|
|
1914
1899
|
}
|
|
1915
1900
|
}
|
|
1916
|
-
},
|
|
1901
|
+
}, _callee3);
|
|
1917
1902
|
}));
|
|
1918
1903
|
return function (_x35) {
|
|
1919
1904
|
return _ref3.apply(this, arguments);
|
|
@@ -1974,7 +1959,7 @@
|
|
|
1974
1959
|
return _context9.stop();
|
|
1975
1960
|
}
|
|
1976
1961
|
}
|
|
1977
|
-
},
|
|
1962
|
+
}, _callee4);
|
|
1978
1963
|
}));
|
|
1979
1964
|
return function (_x34) {
|
|
1980
1965
|
return _ref2.apply(this, arguments);
|
|
@@ -1985,7 +1970,7 @@
|
|
|
1985
1970
|
return _context10.stop();
|
|
1986
1971
|
}
|
|
1987
1972
|
}
|
|
1988
|
-
},
|
|
1973
|
+
}, _callee5);
|
|
1989
1974
|
}));
|
|
1990
1975
|
return _getSmartRouteSwapActions.apply(this, arguments);
|
|
1991
1976
|
}
|
|
@@ -1993,9 +1978,9 @@
|
|
|
1993
1978
|
return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
|
|
1994
1979
|
}
|
|
1995
1980
|
function _calculateSmartRouteV2PriceImpact() {
|
|
1996
|
-
_calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1981
|
+
_calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(actions, allTokens) {
|
|
1997
1982
|
var deltaY, inputTokenMeta, deltaX, R, P, routes, nodeRoutes, allocations, totalAllocations, weights, i, route, nodeRoute, tokens, weight, num, denom, routeMarketPrice, num1, denom1, num2, denom2, priceImpact;
|
|
1998
|
-
return _regeneratorRuntime().wrap(function
|
|
1983
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context12) {
|
|
1999
1984
|
while (1) {
|
|
2000
1985
|
switch (_context12.prev = _context12.next) {
|
|
2001
1986
|
case 0:
|
|
@@ -2041,8 +2026,8 @@
|
|
|
2041
2026
|
nodeRoute = nodeRoutes[i];
|
|
2042
2027
|
_context12.next = 17;
|
|
2043
2028
|
return Promise.all(nodeRoute.map( /*#__PURE__*/function () {
|
|
2044
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2045
|
-
return _regeneratorRuntime().wrap(function
|
|
2029
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(t) {
|
|
2030
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context11) {
|
|
2046
2031
|
while (1) {
|
|
2047
2032
|
switch (_context11.prev = _context11.next) {
|
|
2048
2033
|
case 0:
|
|
@@ -2065,7 +2050,7 @@
|
|
|
2065
2050
|
return _context11.stop();
|
|
2066
2051
|
}
|
|
2067
2052
|
}
|
|
2068
|
-
},
|
|
2053
|
+
}, _callee6);
|
|
2069
2054
|
}));
|
|
2070
2055
|
return function (_x36) {
|
|
2071
2056
|
return _ref4.apply(this, arguments);
|
|
@@ -2096,7 +2081,7 @@
|
|
|
2096
2081
|
return _context12.stop();
|
|
2097
2082
|
}
|
|
2098
2083
|
}
|
|
2099
|
-
},
|
|
2084
|
+
}, _callee7);
|
|
2100
2085
|
}));
|
|
2101
2086
|
return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
|
|
2102
2087
|
}
|
|
@@ -2431,7 +2416,7 @@
|
|
|
2431
2416
|
return _context5.stop();
|
|
2432
2417
|
}
|
|
2433
2418
|
}
|
|
2434
|
-
},
|
|
2419
|
+
}, _marked5, null, [[6, 14]]);
|
|
2435
2420
|
}
|
|
2436
2421
|
function getKShortestPaths(g, source, target, k, maxPathLength) {
|
|
2437
2422
|
if (maxPathLength === void 0) {
|
|
@@ -2468,9 +2453,9 @@
|
|
|
2468
2453
|
return _getPathsFromPools.apply(this, arguments);
|
|
2469
2454
|
}
|
|
2470
2455
|
function _getPathsFromPools() {
|
|
2471
|
-
_getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2456
|
+
_getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(pools, inputToken, outputToken, maxPathLength) {
|
|
2472
2457
|
var graph;
|
|
2473
|
-
return _regeneratorRuntime().wrap(function
|
|
2458
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context13) {
|
|
2474
2459
|
while (1) {
|
|
2475
2460
|
switch (_context13.prev = _context13.next) {
|
|
2476
2461
|
case 0:
|
|
@@ -2484,7 +2469,7 @@
|
|
|
2484
2469
|
return _context13.stop();
|
|
2485
2470
|
}
|
|
2486
2471
|
}
|
|
2487
|
-
},
|
|
2472
|
+
}, _callee8);
|
|
2488
2473
|
}));
|
|
2489
2474
|
return _getPathsFromPools.apply(this, arguments);
|
|
2490
2475
|
}
|
|
@@ -2519,9 +2504,9 @@
|
|
|
2519
2504
|
return _stableSmart.apply(this, arguments);
|
|
2520
2505
|
}
|
|
2521
2506
|
function _stableSmart() {
|
|
2522
|
-
_stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2507
|
+
_stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, totalInput, allTokens) {
|
|
2523
2508
|
var smartRouteActions;
|
|
2524
|
-
return _regeneratorRuntime().wrap(function
|
|
2509
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context15) {
|
|
2525
2510
|
while (1) {
|
|
2526
2511
|
switch (_context15.prev = _context15.next) {
|
|
2527
2512
|
case 0:
|
|
@@ -2535,7 +2520,7 @@
|
|
|
2535
2520
|
return _context15.stop();
|
|
2536
2521
|
}
|
|
2537
2522
|
}
|
|
2538
|
-
},
|
|
2523
|
+
}, _callee10);
|
|
2539
2524
|
}));
|
|
2540
2525
|
return _stableSmart.apply(this, arguments);
|
|
2541
2526
|
}
|
|
@@ -3880,7 +3865,11 @@
|
|
|
3880
3865
|
return near.account(exports.REF_FI_CONTRACT_ID);
|
|
3881
3866
|
case 3:
|
|
3882
3867
|
nearConnection = _context.sent;
|
|
3883
|
-
return _context.abrupt("return", nearConnection.viewFunction(
|
|
3868
|
+
return _context.abrupt("return", nearConnection.viewFunction({
|
|
3869
|
+
contractId: exports.REF_FI_CONTRACT_ID,
|
|
3870
|
+
methodName: methodName,
|
|
3871
|
+
args: args
|
|
3872
|
+
}));
|
|
3884
3873
|
case 5:
|
|
3885
3874
|
case "end":
|
|
3886
3875
|
return _context.stop();
|
|
@@ -3904,7 +3893,11 @@
|
|
|
3904
3893
|
return near.account(exports.REF_FI_CONTRACT_ID);
|
|
3905
3894
|
case 3:
|
|
3906
3895
|
nearConnection = _context2.sent;
|
|
3907
|
-
return _context2.abrupt("return", nearConnection.viewFunction(
|
|
3896
|
+
return _context2.abrupt("return", nearConnection.viewFunction({
|
|
3897
|
+
contractId: tokenId,
|
|
3898
|
+
methodName: methodName,
|
|
3899
|
+
args: args
|
|
3900
|
+
}));
|
|
3908
3901
|
case 5:
|
|
3909
3902
|
case "end":
|
|
3910
3903
|
return _context2.stop();
|
|
@@ -4196,7 +4189,11 @@
|
|
|
4196
4189
|
}
|
|
4197
4190
|
throw DCLInValid;
|
|
4198
4191
|
case 6:
|
|
4199
|
-
return _context10.abrupt("return", nearConnection.viewFunction(
|
|
4192
|
+
return _context10.abrupt("return", nearConnection.viewFunction({
|
|
4193
|
+
contractId: exports.config.REF_DCL_SWAP_CONTRACT_ID,
|
|
4194
|
+
methodName: methodName,
|
|
4195
|
+
args: args
|
|
4196
|
+
}));
|
|
4200
4197
|
case 7:
|
|
4201
4198
|
case "end":
|
|
4202
4199
|
return _context10.stop();
|
|
@@ -7521,12 +7518,12 @@
|
|
|
7521
7518
|
var DCL_POOL_SPLITER = '|';
|
|
7522
7519
|
var DCLSwap = /*#__PURE__*/function () {
|
|
7523
7520
|
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
7524
|
-
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;
|
|
7521
|
+
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;
|
|
7525
7522
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
7526
7523
|
while (1) {
|
|
7527
7524
|
switch (_context.prev = _context.next) {
|
|
7528
7525
|
case 0:
|
|
7529
|
-
Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
|
|
7526
|
+
Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, SwapByStopPoint = _ref.SwapByStopPoint, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
|
|
7530
7527
|
transactions = [];
|
|
7531
7528
|
tokenA = swapInfo.tokenA, tokenB = swapInfo.tokenB, amountA = swapInfo.amountA;
|
|
7532
7529
|
if (!Swap) {
|
|
@@ -7569,7 +7566,7 @@
|
|
|
7569
7566
|
amount: ONE_YOCTO_NEAR
|
|
7570
7567
|
}]
|
|
7571
7568
|
});
|
|
7572
|
-
_context.next =
|
|
7569
|
+
_context.next = 52;
|
|
7573
7570
|
break;
|
|
7574
7571
|
case 15:
|
|
7575
7572
|
if (!SwapByOutput) {
|
|
@@ -7612,11 +7609,11 @@
|
|
|
7612
7609
|
amount: ONE_YOCTO_NEAR
|
|
7613
7610
|
}]
|
|
7614
7611
|
});
|
|
7615
|
-
_context.next =
|
|
7612
|
+
_context.next = 52;
|
|
7616
7613
|
break;
|
|
7617
7614
|
case 27:
|
|
7618
7615
|
if (!LimitOrderWithSwap) {
|
|
7619
|
-
_context.next =
|
|
7616
|
+
_context.next = 45;
|
|
7620
7617
|
break;
|
|
7621
7618
|
}
|
|
7622
7619
|
pool_id = LimitOrderWithSwap.pool_id;
|
|
@@ -7683,14 +7680,49 @@
|
|
|
7683
7680
|
amount: ONE_YOCTO_NEAR
|
|
7684
7681
|
}]
|
|
7685
7682
|
});
|
|
7686
|
-
|
|
7683
|
+
_context.next = 52;
|
|
7684
|
+
break;
|
|
7685
|
+
case 45:
|
|
7686
|
+
if (!SwapByStopPoint) {
|
|
7687
|
+
_context.next = 52;
|
|
7688
|
+
break;
|
|
7689
|
+
}
|
|
7690
|
+
_context.next = 48;
|
|
7691
|
+
return ftGetStorageBalance(tokenB.id, AccountId)["catch"](function () {
|
|
7692
|
+
throw new Error(tokenB.id + " doesn't exist.");
|
|
7693
|
+
});
|
|
7694
|
+
case 48:
|
|
7695
|
+
_tokenRegistered3 = _context.sent;
|
|
7696
|
+
if (_tokenRegistered3 === null) {
|
|
7697
|
+
transactions.push({
|
|
7698
|
+
receiverId: tokenB.id,
|
|
7699
|
+
functionCalls: [registerAccountOnToken(AccountId)]
|
|
7700
|
+
});
|
|
7701
|
+
}
|
|
7702
|
+
_msg3 = JSON.stringify({
|
|
7703
|
+
SwapByStopPoint: SwapByStopPoint
|
|
7704
|
+
});
|
|
7705
|
+
transactions.push({
|
|
7706
|
+
receiverId: tokenA.id,
|
|
7707
|
+
functionCalls: [{
|
|
7708
|
+
methodName: 'ft_transfer_call',
|
|
7709
|
+
args: {
|
|
7710
|
+
receiver_id: exports.config.REF_DCL_SWAP_CONTRACT_ID,
|
|
7711
|
+
amount: toNonDivisibleNumber(tokenA.decimals, amountA),
|
|
7712
|
+
msg: _msg3
|
|
7713
|
+
},
|
|
7714
|
+
gas: '180000000000000',
|
|
7715
|
+
amount: ONE_YOCTO_NEAR
|
|
7716
|
+
}]
|
|
7717
|
+
});
|
|
7718
|
+
case 52:
|
|
7687
7719
|
if (!(tokenA.id === exports.WRAP_NEAR_CONTRACT_ID)) {
|
|
7688
|
-
_context.next =
|
|
7720
|
+
_context.next = 57;
|
|
7689
7721
|
break;
|
|
7690
7722
|
}
|
|
7691
|
-
_context.next =
|
|
7723
|
+
_context.next = 55;
|
|
7692
7724
|
return ftGetStorageBalance(exports.WRAP_NEAR_CONTRACT_ID, AccountId);
|
|
7693
|
-
case
|
|
7725
|
+
case 55:
|
|
7694
7726
|
registered = _context.sent;
|
|
7695
7727
|
if (registered === null) {
|
|
7696
7728
|
transactions.unshift({
|
|
@@ -7698,9 +7730,9 @@
|
|
|
7698
7730
|
functionCalls: [registerAccountOnToken(AccountId)]
|
|
7699
7731
|
});
|
|
7700
7732
|
}
|
|
7701
|
-
case
|
|
7733
|
+
case 57:
|
|
7702
7734
|
return _context.abrupt("return", transactions);
|
|
7703
|
-
case
|
|
7735
|
+
case 58:
|
|
7704
7736
|
case "end":
|
|
7705
7737
|
return _context.stop();
|
|
7706
7738
|
}
|