@aurigami/sdk 0.2.1 → 0.2.5
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/MoneyMarket.d.ts +2 -0
- package/dist/constants.d.ts +1 -0
- package/dist/priceFetcher.d.ts +4 -3
- package/dist/sdk.cjs.development.js +254 -109
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +254 -109
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/package.json +4 -4
- package/src/MoneyMarket.ts +55 -5
- package/src/constants.ts +12 -1
- package/src/priceFetcher.ts +28 -9
- package/src/types.ts +4 -0
|
@@ -935,7 +935,7 @@ var networkAddresses = {
|
|
|
935
935
|
COMPTROLLER: "0xb51028d4f3fc69e3f9e3118ce067a4562c595aad",
|
|
936
936
|
oracle: "0xf1ebfaa2af93f4d82215fd7817c1835853c62fb8",
|
|
937
937
|
AURIFAIRLAUNCH: "0x7942874a9ef8059c5de259625a883dc61f03320d",
|
|
938
|
-
AURILENS:
|
|
938
|
+
AURILENS: '0xa2635a23a7688cd3acdd07713c4943b2f0f9082c'
|
|
939
939
|
},
|
|
940
940
|
tokens: {
|
|
941
941
|
AURORA: "0x7a80df8230c5aa711e2702a275ab31aeb32754bf",
|
|
@@ -946,6 +946,7 @@ var networkAddresses = {
|
|
|
946
946
|
var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(0.95);
|
|
947
947
|
var REWARDCLAIMSTART = 1673280000;
|
|
948
948
|
var ONE_DAY = 86400;
|
|
949
|
+
var ONE_YEAR = ONE_DAY * 365;
|
|
949
950
|
var AurPlyPid = 1;
|
|
950
951
|
|
|
951
952
|
var decimalRecords = {
|
|
@@ -1025,6 +1026,11 @@ function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
|
|
|
1025
1026
|
return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
|
|
1026
1027
|
}
|
|
1027
1028
|
|
|
1029
|
+
(function (ComptrollerRewardType) {
|
|
1030
|
+
ComptrollerRewardType[ComptrollerRewardType["PLY"] = 0] = "PLY";
|
|
1031
|
+
ComptrollerRewardType[ComptrollerRewardType["AURORA"] = 1] = "AURORA";
|
|
1032
|
+
})(exports.ComptrollerRewardType || (exports.ComptrollerRewardType = {}));
|
|
1033
|
+
|
|
1028
1034
|
var Token = function Token(address, decimals) {
|
|
1029
1035
|
this.address = address.toLowerCase();
|
|
1030
1036
|
this.decimals = decimals;
|
|
@@ -1231,12 +1237,94 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1231
1237
|
return getCollateralRatio;
|
|
1232
1238
|
}();
|
|
1233
1239
|
|
|
1234
|
-
_proto.
|
|
1235
|
-
var
|
|
1236
|
-
var promises,
|
|
1240
|
+
_proto.getBorrowPlyAPY = /*#__PURE__*/function () {
|
|
1241
|
+
var _getBorrowPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
1242
|
+
var promises, totalBorrowed, rewardSpeed, plyPrice, underlyingPrice;
|
|
1237
1243
|
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1238
1244
|
while (1) {
|
|
1239
1245
|
switch (_context6.prev = _context6.next) {
|
|
1246
|
+
case 0:
|
|
1247
|
+
promises = [];
|
|
1248
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
1249
|
+
totalBorrowed = res;
|
|
1250
|
+
}));
|
|
1251
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1252
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1253
|
+
}));
|
|
1254
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1255
|
+
plyPrice = res;
|
|
1256
|
+
}));
|
|
1257
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1258
|
+
underlyingPrice = res;
|
|
1259
|
+
}));
|
|
1260
|
+
_context6.next = 7;
|
|
1261
|
+
return Promise.all(promises);
|
|
1262
|
+
|
|
1263
|
+
case 7:
|
|
1264
|
+
return _context6.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR));
|
|
1265
|
+
|
|
1266
|
+
case 8:
|
|
1267
|
+
case "end":
|
|
1268
|
+
return _context6.stop();
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}, _callee6, this);
|
|
1272
|
+
}));
|
|
1273
|
+
|
|
1274
|
+
function getBorrowPlyAPY() {
|
|
1275
|
+
return _getBorrowPlyAPY.apply(this, arguments);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
return getBorrowPlyAPY;
|
|
1279
|
+
}();
|
|
1280
|
+
|
|
1281
|
+
_proto.getDepositPlyAPY = /*#__PURE__*/function () {
|
|
1282
|
+
var _getDepositPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
1283
|
+
var promises, totalDeposited, rewardSpeed, plyPrice, underlyingPrice;
|
|
1284
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
1285
|
+
while (1) {
|
|
1286
|
+
switch (_context7.prev = _context7.next) {
|
|
1287
|
+
case 0:
|
|
1288
|
+
promises = [];
|
|
1289
|
+
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
1290
|
+
totalDeposited = res;
|
|
1291
|
+
}));
|
|
1292
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1293
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1294
|
+
}));
|
|
1295
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1296
|
+
plyPrice = res;
|
|
1297
|
+
}));
|
|
1298
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1299
|
+
underlyingPrice = res;
|
|
1300
|
+
}));
|
|
1301
|
+
_context7.next = 7;
|
|
1302
|
+
return Promise.all(promises);
|
|
1303
|
+
|
|
1304
|
+
case 7:
|
|
1305
|
+
return _context7.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR));
|
|
1306
|
+
|
|
1307
|
+
case 8:
|
|
1308
|
+
case "end":
|
|
1309
|
+
return _context7.stop();
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
}, _callee7, this);
|
|
1313
|
+
}));
|
|
1314
|
+
|
|
1315
|
+
function getDepositPlyAPY() {
|
|
1316
|
+
return _getDepositPlyAPY.apply(this, arguments);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
return getDepositPlyAPY;
|
|
1320
|
+
}();
|
|
1321
|
+
|
|
1322
|
+
_proto.getDetails = /*#__PURE__*/function () {
|
|
1323
|
+
var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
1324
|
+
var promises, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeed, plyPrice, underlyingPrice, borrowPlyApy, depositPlyApy;
|
|
1325
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
1326
|
+
while (1) {
|
|
1327
|
+
switch (_context8.prev = _context8.next) {
|
|
1240
1328
|
case 0:
|
|
1241
1329
|
promises = [];
|
|
1242
1330
|
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
@@ -1254,27 +1342,38 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1254
1342
|
promises.push(this.getCollateralRatio().then(function (res) {
|
|
1255
1343
|
collateralRatio = res.toNumber();
|
|
1256
1344
|
}));
|
|
1257
|
-
|
|
1345
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1346
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1347
|
+
}));
|
|
1348
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1349
|
+
plyPrice = res;
|
|
1350
|
+
}));
|
|
1351
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1352
|
+
underlyingPrice = res;
|
|
1353
|
+
}));
|
|
1354
|
+
_context8.next = 11;
|
|
1258
1355
|
return Promise.all(promises);
|
|
1259
1356
|
|
|
1260
|
-
case
|
|
1261
|
-
|
|
1357
|
+
case 11:
|
|
1358
|
+
borrowPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR);
|
|
1359
|
+
depositPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR);
|
|
1360
|
+
return _context8.abrupt("return", {
|
|
1262
1361
|
auTokenAddress: this.auToken.address,
|
|
1263
1362
|
totalTokenDeposited: totalDeposited,
|
|
1264
1363
|
totalTokenBorrowed: totalBorrowed,
|
|
1265
1364
|
depositApy: depositAPY,
|
|
1266
|
-
depositPlyApy:
|
|
1365
|
+
depositPlyApy: depositPlyApy.toNumber(),
|
|
1267
1366
|
borrowApy: borrowAPY,
|
|
1268
|
-
borrowPlyApy:
|
|
1367
|
+
borrowPlyApy: borrowPlyApy.toNumber(),
|
|
1269
1368
|
collateralRatio: collateralRatio
|
|
1270
1369
|
});
|
|
1271
1370
|
|
|
1272
|
-
case
|
|
1371
|
+
case 14:
|
|
1273
1372
|
case "end":
|
|
1274
|
-
return
|
|
1373
|
+
return _context8.stop();
|
|
1275
1374
|
}
|
|
1276
1375
|
}
|
|
1277
|
-
},
|
|
1376
|
+
}, _callee8, this);
|
|
1278
1377
|
}));
|
|
1279
1378
|
|
|
1280
1379
|
function getDetails() {
|
|
@@ -1285,25 +1384,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1285
1384
|
}();
|
|
1286
1385
|
|
|
1287
1386
|
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
1288
|
-
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1387
|
+
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(userAddress) {
|
|
1289
1388
|
var totalBorrow;
|
|
1290
|
-
return runtime_1.wrap(function
|
|
1389
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
1291
1390
|
while (1) {
|
|
1292
|
-
switch (
|
|
1391
|
+
switch (_context9.prev = _context9.next) {
|
|
1293
1392
|
case 0:
|
|
1294
|
-
|
|
1393
|
+
_context9.next = 2;
|
|
1295
1394
|
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
1296
1395
|
|
|
1297
1396
|
case 2:
|
|
1298
|
-
totalBorrow =
|
|
1299
|
-
return
|
|
1397
|
+
totalBorrow = _context9.sent;
|
|
1398
|
+
return _context9.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
1300
1399
|
|
|
1301
1400
|
case 4:
|
|
1302
1401
|
case "end":
|
|
1303
|
-
return
|
|
1402
|
+
return _context9.stop();
|
|
1304
1403
|
}
|
|
1305
1404
|
}
|
|
1306
|
-
},
|
|
1405
|
+
}, _callee9, this);
|
|
1307
1406
|
}));
|
|
1308
1407
|
|
|
1309
1408
|
function getUserBorrowBalance(_x) {
|
|
@@ -1314,25 +1413,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1314
1413
|
}();
|
|
1315
1414
|
|
|
1316
1415
|
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
1317
|
-
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1416
|
+
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(userAddress) {
|
|
1318
1417
|
var totalDeposit;
|
|
1319
|
-
return runtime_1.wrap(function
|
|
1418
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
1320
1419
|
while (1) {
|
|
1321
|
-
switch (
|
|
1420
|
+
switch (_context10.prev = _context10.next) {
|
|
1322
1421
|
case 0:
|
|
1323
|
-
|
|
1422
|
+
_context10.next = 2;
|
|
1324
1423
|
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
1325
1424
|
|
|
1326
1425
|
case 2:
|
|
1327
|
-
totalDeposit =
|
|
1328
|
-
return
|
|
1426
|
+
totalDeposit = _context10.sent;
|
|
1427
|
+
return _context10.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
1329
1428
|
|
|
1330
1429
|
case 4:
|
|
1331
1430
|
case "end":
|
|
1332
|
-
return
|
|
1431
|
+
return _context10.stop();
|
|
1333
1432
|
}
|
|
1334
1433
|
}
|
|
1335
|
-
},
|
|
1434
|
+
}, _callee10, this);
|
|
1336
1435
|
}));
|
|
1337
1436
|
|
|
1338
1437
|
function getUserDepositBalance(_x2) {
|
|
@@ -1354,29 +1453,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1354
1453
|
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
1355
1454
|
|
|
1356
1455
|
_proto2.deposit = /*#__PURE__*/function () {
|
|
1357
|
-
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1358
|
-
return runtime_1.wrap(function
|
|
1456
|
+
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(amount) {
|
|
1457
|
+
return runtime_1.wrap(function _callee11$(_context11) {
|
|
1359
1458
|
while (1) {
|
|
1360
|
-
switch (
|
|
1459
|
+
switch (_context11.prev = _context11.next) {
|
|
1361
1460
|
case 0:
|
|
1362
1461
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1363
|
-
|
|
1462
|
+
_context11.next = 4;
|
|
1364
1463
|
break;
|
|
1365
1464
|
}
|
|
1366
1465
|
|
|
1367
|
-
return
|
|
1466
|
+
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
1368
1467
|
value: amount.rawAmount()
|
|
1369
1468
|
}));
|
|
1370
1469
|
|
|
1371
1470
|
case 4:
|
|
1372
|
-
return
|
|
1471
|
+
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
1373
1472
|
|
|
1374
1473
|
case 5:
|
|
1375
1474
|
case "end":
|
|
1376
|
-
return
|
|
1475
|
+
return _context11.stop();
|
|
1377
1476
|
}
|
|
1378
1477
|
}
|
|
1379
|
-
},
|
|
1478
|
+
}, _callee11, this);
|
|
1380
1479
|
}));
|
|
1381
1480
|
|
|
1382
1481
|
function deposit(_x3) {
|
|
@@ -1387,19 +1486,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1387
1486
|
}();
|
|
1388
1487
|
|
|
1389
1488
|
_proto2.borrow = /*#__PURE__*/function () {
|
|
1390
|
-
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1391
|
-
return runtime_1.wrap(function
|
|
1489
|
+
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
|
|
1490
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
1392
1491
|
while (1) {
|
|
1393
|
-
switch (
|
|
1492
|
+
switch (_context12.prev = _context12.next) {
|
|
1394
1493
|
case 0:
|
|
1395
|
-
return
|
|
1494
|
+
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
1396
1495
|
|
|
1397
1496
|
case 1:
|
|
1398
1497
|
case "end":
|
|
1399
|
-
return
|
|
1498
|
+
return _context12.stop();
|
|
1400
1499
|
}
|
|
1401
1500
|
}
|
|
1402
|
-
},
|
|
1501
|
+
}, _callee12, this);
|
|
1403
1502
|
}));
|
|
1404
1503
|
|
|
1405
1504
|
function borrow(_x4) {
|
|
@@ -1410,19 +1509,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1410
1509
|
}();
|
|
1411
1510
|
|
|
1412
1511
|
_proto2.withdraw = /*#__PURE__*/function () {
|
|
1413
|
-
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1414
|
-
return runtime_1.wrap(function
|
|
1512
|
+
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(amount) {
|
|
1513
|
+
return runtime_1.wrap(function _callee13$(_context13) {
|
|
1415
1514
|
while (1) {
|
|
1416
|
-
switch (
|
|
1515
|
+
switch (_context13.prev = _context13.next) {
|
|
1417
1516
|
case 0:
|
|
1418
|
-
return
|
|
1517
|
+
return _context13.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
1419
1518
|
|
|
1420
1519
|
case 1:
|
|
1421
1520
|
case "end":
|
|
1422
|
-
return
|
|
1521
|
+
return _context13.stop();
|
|
1423
1522
|
}
|
|
1424
1523
|
}
|
|
1425
|
-
},
|
|
1524
|
+
}, _callee13, this);
|
|
1426
1525
|
}));
|
|
1427
1526
|
|
|
1428
1527
|
function withdraw(_x5) {
|
|
@@ -1433,29 +1532,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1433
1532
|
}();
|
|
1434
1533
|
|
|
1435
1534
|
_proto2.repay = /*#__PURE__*/function () {
|
|
1436
|
-
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1437
|
-
return runtime_1.wrap(function
|
|
1535
|
+
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
|
|
1536
|
+
return runtime_1.wrap(function _callee14$(_context14) {
|
|
1438
1537
|
while (1) {
|
|
1439
|
-
switch (
|
|
1538
|
+
switch (_context14.prev = _context14.next) {
|
|
1440
1539
|
case 0:
|
|
1441
1540
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1442
|
-
|
|
1541
|
+
_context14.next = 4;
|
|
1443
1542
|
break;
|
|
1444
1543
|
}
|
|
1445
1544
|
|
|
1446
|
-
return
|
|
1545
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
1447
1546
|
value: amount.rawAmount()
|
|
1448
1547
|
}));
|
|
1449
1548
|
|
|
1450
1549
|
case 4:
|
|
1451
|
-
return
|
|
1550
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
1452
1551
|
|
|
1453
1552
|
case 5:
|
|
1454
1553
|
case "end":
|
|
1455
|
-
return
|
|
1554
|
+
return _context14.stop();
|
|
1456
1555
|
}
|
|
1457
1556
|
}
|
|
1458
|
-
},
|
|
1557
|
+
}, _callee14, this);
|
|
1459
1558
|
}));
|
|
1460
1559
|
|
|
1461
1560
|
function repay(_x6) {
|
|
@@ -1466,19 +1565,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1466
1565
|
}();
|
|
1467
1566
|
|
|
1468
1567
|
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
1469
|
-
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1470
|
-
return runtime_1.wrap(function
|
|
1568
|
+
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15() {
|
|
1569
|
+
return runtime_1.wrap(function _callee15$(_context15) {
|
|
1471
1570
|
while (1) {
|
|
1472
|
-
switch (
|
|
1571
|
+
switch (_context15.prev = _context15.next) {
|
|
1473
1572
|
case 0:
|
|
1474
|
-
return
|
|
1573
|
+
return _context15.abrupt("return", this._comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
1475
1574
|
|
|
1476
1575
|
case 1:
|
|
1477
1576
|
case "end":
|
|
1478
|
-
return
|
|
1577
|
+
return _context15.stop();
|
|
1479
1578
|
}
|
|
1480
1579
|
}
|
|
1481
|
-
},
|
|
1580
|
+
}, _callee15, this);
|
|
1482
1581
|
}));
|
|
1483
1582
|
|
|
1484
1583
|
function enableCollateral() {
|
|
@@ -1489,19 +1588,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1489
1588
|
}();
|
|
1490
1589
|
|
|
1491
1590
|
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
1492
|
-
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1493
|
-
return runtime_1.wrap(function
|
|
1591
|
+
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
|
|
1592
|
+
return runtime_1.wrap(function _callee16$(_context16) {
|
|
1494
1593
|
while (1) {
|
|
1495
|
-
switch (
|
|
1594
|
+
switch (_context16.prev = _context16.next) {
|
|
1496
1595
|
case 0:
|
|
1497
|
-
return
|
|
1596
|
+
return _context16.abrupt("return", this._comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
1498
1597
|
|
|
1499
1598
|
case 1:
|
|
1500
1599
|
case "end":
|
|
1501
|
-
return
|
|
1600
|
+
return _context16.stop();
|
|
1502
1601
|
}
|
|
1503
1602
|
}
|
|
1504
|
-
},
|
|
1603
|
+
}, _callee16, this);
|
|
1505
1604
|
}));
|
|
1506
1605
|
|
|
1507
1606
|
function disableCollateral() {
|
|
@@ -2483,14 +2582,20 @@ var IUniswapV2PairABI = {
|
|
|
2483
2582
|
deployedLinkReferences: deployedLinkReferences
|
|
2484
2583
|
};
|
|
2485
2584
|
|
|
2585
|
+
var abi$2 = [
|
|
2586
|
+
];
|
|
2587
|
+
var dummyABI = {
|
|
2588
|
+
abi: abi$2
|
|
2589
|
+
};
|
|
2590
|
+
|
|
2486
2591
|
var axios = /*#__PURE__*/require('axios');
|
|
2487
2592
|
|
|
2488
|
-
function
|
|
2489
|
-
return
|
|
2593
|
+
function fetchPriceFromCoingeckoAPI(_x) {
|
|
2594
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2490
2595
|
}
|
|
2491
2596
|
|
|
2492
|
-
function
|
|
2493
|
-
|
|
2597
|
+
function _fetchPriceFromCoingeckoAPI() {
|
|
2598
|
+
_fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
|
|
2494
2599
|
var price;
|
|
2495
2600
|
return runtime_1.wrap(function _callee$(_context) {
|
|
2496
2601
|
while (1) {
|
|
@@ -2512,15 +2617,15 @@ function _fetchPriceFromCoingecko() {
|
|
|
2512
2617
|
}
|
|
2513
2618
|
}, _callee);
|
|
2514
2619
|
}));
|
|
2515
|
-
return
|
|
2620
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2516
2621
|
}
|
|
2517
2622
|
|
|
2518
|
-
function
|
|
2519
|
-
return
|
|
2623
|
+
function fetchPriceFromCoingecko(_x2) {
|
|
2624
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2520
2625
|
}
|
|
2521
2626
|
|
|
2522
|
-
function
|
|
2523
|
-
|
|
2627
|
+
function _fetchPriceFromCoingecko() {
|
|
2628
|
+
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(address) {
|
|
2524
2629
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2525
2630
|
while (1) {
|
|
2526
2631
|
switch (_context2.prev = _context2.next) {
|
|
@@ -2530,10 +2635,10 @@ function _fetchBasicTokenPrice() {
|
|
|
2530
2635
|
break;
|
|
2531
2636
|
}
|
|
2532
2637
|
|
|
2533
|
-
return _context2.abrupt("return",
|
|
2638
|
+
return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
|
|
2534
2639
|
|
|
2535
2640
|
case 4:
|
|
2536
|
-
throw Error("Unknown token " + address + " in
|
|
2641
|
+
throw Error("Unknown token " + address + " in fetchPriceFromCoingecko");
|
|
2537
2642
|
|
|
2538
2643
|
case 5:
|
|
2539
2644
|
case "end":
|
|
@@ -2542,7 +2647,7 @@ function _fetchBasicTokenPrice() {
|
|
|
2542
2647
|
}
|
|
2543
2648
|
}, _callee2);
|
|
2544
2649
|
}));
|
|
2545
|
-
return
|
|
2650
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2546
2651
|
}
|
|
2547
2652
|
|
|
2548
2653
|
function fetchLPPositions(_x3, _x4) {
|
|
@@ -2570,8 +2675,8 @@ function _fetchLPPositions() {
|
|
|
2570
2675
|
return _context3.abrupt("return", {
|
|
2571
2676
|
token0: values[0],
|
|
2572
2677
|
token1: values[1],
|
|
2573
|
-
reserve0: values[2].
|
|
2574
|
-
reserve1: values[2].
|
|
2678
|
+
reserve0: values[2].reserve0,
|
|
2679
|
+
reserve1: values[2].reserve1,
|
|
2575
2680
|
totalSupply: values[3]
|
|
2576
2681
|
});
|
|
2577
2682
|
|
|
@@ -2638,12 +2743,16 @@ function _fetchLPPrice() {
|
|
|
2638
2743
|
return _fetchLPPrice.apply(this, arguments);
|
|
2639
2744
|
}
|
|
2640
2745
|
|
|
2746
|
+
function processPriceFromOracle(rawPrice, underlyingDecimal) {
|
|
2747
|
+
return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2641
2750
|
function fetchPriceFromOracle(_x7, _x8, _x9) {
|
|
2642
2751
|
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2643
2752
|
}
|
|
2644
2753
|
|
|
2645
2754
|
function _fetchPriceFromOracle() {
|
|
2646
|
-
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress,
|
|
2755
|
+
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress, underlyingDecimal, provider) {
|
|
2647
2756
|
var oracleContract, rawPrice;
|
|
2648
2757
|
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2649
2758
|
while (1) {
|
|
@@ -2655,7 +2764,7 @@ function _fetchPriceFromOracle() {
|
|
|
2655
2764
|
|
|
2656
2765
|
case 3:
|
|
2657
2766
|
rawPrice = _context5.sent;
|
|
2658
|
-
return _context5.abrupt("return",
|
|
2767
|
+
return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
|
|
2659
2768
|
|
|
2660
2769
|
case 5:
|
|
2661
2770
|
case "end":
|
|
@@ -2667,77 +2776,111 @@ function _fetchPriceFromOracle() {
|
|
|
2667
2776
|
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2668
2777
|
}
|
|
2669
2778
|
|
|
2670
|
-
function
|
|
2779
|
+
function fetchUnderlyingTokensPrices(_x10) {
|
|
2780
|
+
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
function _fetchUnderlyingTokensPrices() {
|
|
2784
|
+
_fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
|
|
2785
|
+
var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
|
|
2786
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2787
|
+
while (1) {
|
|
2788
|
+
switch (_context6.prev = _context6.next) {
|
|
2789
|
+
case 0:
|
|
2790
|
+
auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, dummyABI.abi, provider);
|
|
2791
|
+
auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
|
|
2792
|
+
return auToken.address;
|
|
2793
|
+
});
|
|
2794
|
+
underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
|
|
2795
|
+
return getDecimal(auToken.underlying);
|
|
2796
|
+
});
|
|
2797
|
+
_context6.next = 5;
|
|
2798
|
+
return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
|
|
2799
|
+
|
|
2800
|
+
case 5:
|
|
2801
|
+
rawPrices = _context6.sent;
|
|
2802
|
+
return _context6.abrupt("return", rawPrices.map(function (res, ind) {
|
|
2803
|
+
return {
|
|
2804
|
+
auToken: res.auToken,
|
|
2805
|
+
underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
|
|
2806
|
+
};
|
|
2807
|
+
}));
|
|
2808
|
+
|
|
2809
|
+
case 7:
|
|
2810
|
+
case "end":
|
|
2811
|
+
return _context6.stop();
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
}, _callee6);
|
|
2815
|
+
}));
|
|
2816
|
+
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
function fetchPrice(_x11, _x12) {
|
|
2671
2820
|
return _fetchPrice.apply(this, arguments);
|
|
2672
2821
|
}
|
|
2673
2822
|
|
|
2674
2823
|
function _fetchPrice() {
|
|
2675
|
-
_fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2824
|
+
_fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(address, provider) {
|
|
2676
2825
|
var matchingAuToken;
|
|
2677
|
-
return runtime_1.wrap(function
|
|
2826
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2678
2827
|
while (1) {
|
|
2679
|
-
switch (
|
|
2828
|
+
switch (_context7.prev = _context7.next) {
|
|
2680
2829
|
case 0:
|
|
2681
2830
|
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2682
2831
|
return isSameAddress(auToken.underlying, address);
|
|
2683
2832
|
});
|
|
2684
2833
|
|
|
2685
2834
|
if (!(matchingAuToken !== undefined)) {
|
|
2686
|
-
|
|
2835
|
+
_context7.next = 5;
|
|
2687
2836
|
break;
|
|
2688
2837
|
}
|
|
2689
2838
|
|
|
2690
|
-
return
|
|
2839
|
+
return _context7.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
|
|
2691
2840
|
|
|
2692
2841
|
case 5:
|
|
2693
2842
|
if (!isSameAddress(address, networkAddresses.misc.AUPLYLP)) {
|
|
2694
|
-
|
|
2843
|
+
_context7.next = 9;
|
|
2695
2844
|
break;
|
|
2696
2845
|
}
|
|
2697
2846
|
|
|
2698
|
-
return
|
|
2847
|
+
return _context7.abrupt("return", fetchLPPrice(address, provider));
|
|
2699
2848
|
|
|
2700
2849
|
case 9:
|
|
2701
|
-
return
|
|
2850
|
+
return _context7.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2702
2851
|
|
|
2703
2852
|
case 10:
|
|
2704
2853
|
case "end":
|
|
2705
|
-
return
|
|
2854
|
+
return _context7.stop();
|
|
2706
2855
|
}
|
|
2707
2856
|
}
|
|
2708
|
-
},
|
|
2857
|
+
}, _callee7);
|
|
2709
2858
|
}));
|
|
2710
2859
|
return _fetchPrice.apply(this, arguments);
|
|
2711
2860
|
}
|
|
2712
2861
|
|
|
2713
|
-
function fetchValuation(
|
|
2862
|
+
function fetchValuation(_x13, _x14, _x15) {
|
|
2714
2863
|
return _fetchValuation.apply(this, arguments);
|
|
2715
2864
|
}
|
|
2716
2865
|
|
|
2717
2866
|
function _fetchValuation() {
|
|
2718
|
-
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2719
|
-
return runtime_1.wrap(function
|
|
2867
|
+
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider, price) {
|
|
2868
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2720
2869
|
while (1) {
|
|
2721
|
-
switch (
|
|
2870
|
+
switch (_context8.prev = _context8.next) {
|
|
2722
2871
|
case 0:
|
|
2723
|
-
return
|
|
2872
|
+
return _context8.abrupt("return", new BigNumber(0));
|
|
2724
2873
|
|
|
2725
2874
|
case 1:
|
|
2726
2875
|
case "end":
|
|
2727
|
-
return
|
|
2876
|
+
return _context8.stop();
|
|
2728
2877
|
}
|
|
2729
2878
|
}
|
|
2730
|
-
},
|
|
2879
|
+
}, _callee8);
|
|
2731
2880
|
}));
|
|
2732
2881
|
return _fetchValuation.apply(this, arguments);
|
|
2733
2882
|
}
|
|
2734
2883
|
|
|
2735
|
-
var abi$2 = [
|
|
2736
|
-
];
|
|
2737
|
-
var dummyABI = {
|
|
2738
|
-
abi: abi$2
|
|
2739
|
-
};
|
|
2740
|
-
|
|
2741
2884
|
var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2742
2885
|
_inheritsLoose(SdkRead, _BlockchainEntityRead);
|
|
2743
2886
|
|
|
@@ -3183,6 +3326,7 @@ exports.MoneyMarket = MoneyMarket;
|
|
|
3183
3326
|
exports.MoneyMarketRead = MoneyMarketRead;
|
|
3184
3327
|
exports.MoneyMarketReadWrite = MoneyMarketReadWrite;
|
|
3185
3328
|
exports.ONE_DAY = ONE_DAY;
|
|
3329
|
+
exports.ONE_YEAR = ONE_YEAR;
|
|
3186
3330
|
exports.PLYToken = PLYToken;
|
|
3187
3331
|
exports.REWARDCLAIMSTART = REWARDCLAIMSTART;
|
|
3188
3332
|
exports.SDK = SDK;
|
|
@@ -3202,12 +3346,13 @@ exports.dummyTokenAmount2 = dummyTokenAmount2;
|
|
|
3202
3346
|
exports.dummyTokenAmount3 = dummyTokenAmount3;
|
|
3203
3347
|
exports.dummyUserMarketDetails = dummyUserMarketDetails;
|
|
3204
3348
|
exports.dummyZeroTokenAmount = dummyZeroTokenAmount;
|
|
3205
|
-
exports.fetchBasicTokenPrice = fetchBasicTokenPrice;
|
|
3206
3349
|
exports.fetchLPPositions = fetchLPPositions;
|
|
3207
3350
|
exports.fetchLPPrice = fetchLPPrice;
|
|
3208
3351
|
exports.fetchPrice = fetchPrice;
|
|
3209
3352
|
exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
|
|
3353
|
+
exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
|
|
3210
3354
|
exports.fetchPriceFromOracle = fetchPriceFromOracle;
|
|
3355
|
+
exports.fetchUnderlyingTokensPrices = fetchUnderlyingTokensPrices;
|
|
3211
3356
|
exports.fetchValuation = fetchValuation;
|
|
3212
3357
|
exports.formatObject = formatObject;
|
|
3213
3358
|
exports.getCurrentTimestamp = getCurrentTimestamp;
|