@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
package/dist/sdk.esm.js
CHANGED
|
@@ -929,7 +929,7 @@ var networkAddresses = {
|
|
|
929
929
|
COMPTROLLER: "0xb51028d4f3fc69e3f9e3118ce067a4562c595aad",
|
|
930
930
|
oracle: "0xf1ebfaa2af93f4d82215fd7817c1835853c62fb8",
|
|
931
931
|
AURIFAIRLAUNCH: "0x7942874a9ef8059c5de259625a883dc61f03320d",
|
|
932
|
-
AURILENS:
|
|
932
|
+
AURILENS: '0xa2635a23a7688cd3acdd07713c4943b2f0f9082c'
|
|
933
933
|
},
|
|
934
934
|
tokens: {
|
|
935
935
|
AURORA: "0x7a80df8230c5aa711e2702a275ab31aeb32754bf",
|
|
@@ -940,6 +940,7 @@ var networkAddresses = {
|
|
|
940
940
|
var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(0.95);
|
|
941
941
|
var REWARDCLAIMSTART = 1673280000;
|
|
942
942
|
var ONE_DAY = 86400;
|
|
943
|
+
var ONE_YEAR = ONE_DAY * 365;
|
|
943
944
|
var AurPlyPid = 1;
|
|
944
945
|
|
|
945
946
|
var decimalRecords = {
|
|
@@ -1019,6 +1020,13 @@ function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
|
|
|
1019
1020
|
return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
|
|
1020
1021
|
}
|
|
1021
1022
|
|
|
1023
|
+
var ComptrollerRewardType;
|
|
1024
|
+
|
|
1025
|
+
(function (ComptrollerRewardType) {
|
|
1026
|
+
ComptrollerRewardType[ComptrollerRewardType["PLY"] = 0] = "PLY";
|
|
1027
|
+
ComptrollerRewardType[ComptrollerRewardType["AURORA"] = 1] = "AURORA";
|
|
1028
|
+
})(ComptrollerRewardType || (ComptrollerRewardType = {}));
|
|
1029
|
+
|
|
1022
1030
|
var Token = function Token(address, decimals) {
|
|
1023
1031
|
this.address = address.toLowerCase();
|
|
1024
1032
|
this.decimals = decimals;
|
|
@@ -1225,12 +1233,94 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1225
1233
|
return getCollateralRatio;
|
|
1226
1234
|
}();
|
|
1227
1235
|
|
|
1228
|
-
_proto.
|
|
1229
|
-
var
|
|
1230
|
-
var promises,
|
|
1236
|
+
_proto.getBorrowPlyAPY = /*#__PURE__*/function () {
|
|
1237
|
+
var _getBorrowPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
1238
|
+
var promises, totalBorrowed, rewardSpeed, plyPrice, underlyingPrice;
|
|
1231
1239
|
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1232
1240
|
while (1) {
|
|
1233
1241
|
switch (_context6.prev = _context6.next) {
|
|
1242
|
+
case 0:
|
|
1243
|
+
promises = [];
|
|
1244
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
1245
|
+
totalBorrowed = res;
|
|
1246
|
+
}));
|
|
1247
|
+
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1248
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1249
|
+
}));
|
|
1250
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1251
|
+
plyPrice = res;
|
|
1252
|
+
}));
|
|
1253
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1254
|
+
underlyingPrice = res;
|
|
1255
|
+
}));
|
|
1256
|
+
_context6.next = 7;
|
|
1257
|
+
return Promise.all(promises);
|
|
1258
|
+
|
|
1259
|
+
case 7:
|
|
1260
|
+
return _context6.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR));
|
|
1261
|
+
|
|
1262
|
+
case 8:
|
|
1263
|
+
case "end":
|
|
1264
|
+
return _context6.stop();
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}, _callee6, this);
|
|
1268
|
+
}));
|
|
1269
|
+
|
|
1270
|
+
function getBorrowPlyAPY() {
|
|
1271
|
+
return _getBorrowPlyAPY.apply(this, arguments);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
return getBorrowPlyAPY;
|
|
1275
|
+
}();
|
|
1276
|
+
|
|
1277
|
+
_proto.getDepositPlyAPY = /*#__PURE__*/function () {
|
|
1278
|
+
var _getDepositPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
1279
|
+
var promises, totalDeposited, rewardSpeed, plyPrice, underlyingPrice;
|
|
1280
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
1281
|
+
while (1) {
|
|
1282
|
+
switch (_context7.prev = _context7.next) {
|
|
1283
|
+
case 0:
|
|
1284
|
+
promises = [];
|
|
1285
|
+
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
1286
|
+
totalDeposited = res;
|
|
1287
|
+
}));
|
|
1288
|
+
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1289
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1290
|
+
}));
|
|
1291
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1292
|
+
plyPrice = res;
|
|
1293
|
+
}));
|
|
1294
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1295
|
+
underlyingPrice = res;
|
|
1296
|
+
}));
|
|
1297
|
+
_context7.next = 7;
|
|
1298
|
+
return Promise.all(promises);
|
|
1299
|
+
|
|
1300
|
+
case 7:
|
|
1301
|
+
return _context7.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR));
|
|
1302
|
+
|
|
1303
|
+
case 8:
|
|
1304
|
+
case "end":
|
|
1305
|
+
return _context7.stop();
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}, _callee7, this);
|
|
1309
|
+
}));
|
|
1310
|
+
|
|
1311
|
+
function getDepositPlyAPY() {
|
|
1312
|
+
return _getDepositPlyAPY.apply(this, arguments);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
return getDepositPlyAPY;
|
|
1316
|
+
}();
|
|
1317
|
+
|
|
1318
|
+
_proto.getDetails = /*#__PURE__*/function () {
|
|
1319
|
+
var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
1320
|
+
var promises, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeed, plyPrice, underlyingPrice, borrowPlyApy, depositPlyApy;
|
|
1321
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
1322
|
+
while (1) {
|
|
1323
|
+
switch (_context8.prev = _context8.next) {
|
|
1234
1324
|
case 0:
|
|
1235
1325
|
promises = [];
|
|
1236
1326
|
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
@@ -1248,27 +1338,38 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1248
1338
|
promises.push(this.getCollateralRatio().then(function (res) {
|
|
1249
1339
|
collateralRatio = res.toNumber();
|
|
1250
1340
|
}));
|
|
1251
|
-
|
|
1341
|
+
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1342
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1343
|
+
}));
|
|
1344
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1345
|
+
plyPrice = res;
|
|
1346
|
+
}));
|
|
1347
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1348
|
+
underlyingPrice = res;
|
|
1349
|
+
}));
|
|
1350
|
+
_context8.next = 11;
|
|
1252
1351
|
return Promise.all(promises);
|
|
1253
1352
|
|
|
1254
|
-
case
|
|
1255
|
-
|
|
1353
|
+
case 11:
|
|
1354
|
+
borrowPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR);
|
|
1355
|
+
depositPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR);
|
|
1356
|
+
return _context8.abrupt("return", {
|
|
1256
1357
|
auTokenAddress: this.auToken.address,
|
|
1257
1358
|
totalTokenDeposited: totalDeposited,
|
|
1258
1359
|
totalTokenBorrowed: totalBorrowed,
|
|
1259
1360
|
depositApy: depositAPY,
|
|
1260
|
-
depositPlyApy:
|
|
1361
|
+
depositPlyApy: depositPlyApy.toNumber(),
|
|
1261
1362
|
borrowApy: borrowAPY,
|
|
1262
|
-
borrowPlyApy:
|
|
1363
|
+
borrowPlyApy: borrowPlyApy.toNumber(),
|
|
1263
1364
|
collateralRatio: collateralRatio
|
|
1264
1365
|
});
|
|
1265
1366
|
|
|
1266
|
-
case
|
|
1367
|
+
case 14:
|
|
1267
1368
|
case "end":
|
|
1268
|
-
return
|
|
1369
|
+
return _context8.stop();
|
|
1269
1370
|
}
|
|
1270
1371
|
}
|
|
1271
|
-
},
|
|
1372
|
+
}, _callee8, this);
|
|
1272
1373
|
}));
|
|
1273
1374
|
|
|
1274
1375
|
function getDetails() {
|
|
@@ -1279,25 +1380,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1279
1380
|
}();
|
|
1280
1381
|
|
|
1281
1382
|
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
1282
|
-
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1383
|
+
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(userAddress) {
|
|
1283
1384
|
var totalBorrow;
|
|
1284
|
-
return runtime_1.wrap(function
|
|
1385
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
1285
1386
|
while (1) {
|
|
1286
|
-
switch (
|
|
1387
|
+
switch (_context9.prev = _context9.next) {
|
|
1287
1388
|
case 0:
|
|
1288
|
-
|
|
1389
|
+
_context9.next = 2;
|
|
1289
1390
|
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
1290
1391
|
|
|
1291
1392
|
case 2:
|
|
1292
|
-
totalBorrow =
|
|
1293
|
-
return
|
|
1393
|
+
totalBorrow = _context9.sent;
|
|
1394
|
+
return _context9.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
1294
1395
|
|
|
1295
1396
|
case 4:
|
|
1296
1397
|
case "end":
|
|
1297
|
-
return
|
|
1398
|
+
return _context9.stop();
|
|
1298
1399
|
}
|
|
1299
1400
|
}
|
|
1300
|
-
},
|
|
1401
|
+
}, _callee9, this);
|
|
1301
1402
|
}));
|
|
1302
1403
|
|
|
1303
1404
|
function getUserBorrowBalance(_x) {
|
|
@@ -1308,25 +1409,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1308
1409
|
}();
|
|
1309
1410
|
|
|
1310
1411
|
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
1311
|
-
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1412
|
+
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(userAddress) {
|
|
1312
1413
|
var totalDeposit;
|
|
1313
|
-
return runtime_1.wrap(function
|
|
1414
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
1314
1415
|
while (1) {
|
|
1315
|
-
switch (
|
|
1416
|
+
switch (_context10.prev = _context10.next) {
|
|
1316
1417
|
case 0:
|
|
1317
|
-
|
|
1418
|
+
_context10.next = 2;
|
|
1318
1419
|
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
1319
1420
|
|
|
1320
1421
|
case 2:
|
|
1321
|
-
totalDeposit =
|
|
1322
|
-
return
|
|
1422
|
+
totalDeposit = _context10.sent;
|
|
1423
|
+
return _context10.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
1323
1424
|
|
|
1324
1425
|
case 4:
|
|
1325
1426
|
case "end":
|
|
1326
|
-
return
|
|
1427
|
+
return _context10.stop();
|
|
1327
1428
|
}
|
|
1328
1429
|
}
|
|
1329
|
-
},
|
|
1430
|
+
}, _callee10, this);
|
|
1330
1431
|
}));
|
|
1331
1432
|
|
|
1332
1433
|
function getUserDepositBalance(_x2) {
|
|
@@ -1348,29 +1449,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1348
1449
|
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
1349
1450
|
|
|
1350
1451
|
_proto2.deposit = /*#__PURE__*/function () {
|
|
1351
|
-
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1352
|
-
return runtime_1.wrap(function
|
|
1452
|
+
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(amount) {
|
|
1453
|
+
return runtime_1.wrap(function _callee11$(_context11) {
|
|
1353
1454
|
while (1) {
|
|
1354
|
-
switch (
|
|
1455
|
+
switch (_context11.prev = _context11.next) {
|
|
1355
1456
|
case 0:
|
|
1356
1457
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1357
|
-
|
|
1458
|
+
_context11.next = 4;
|
|
1358
1459
|
break;
|
|
1359
1460
|
}
|
|
1360
1461
|
|
|
1361
|
-
return
|
|
1462
|
+
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
1362
1463
|
value: amount.rawAmount()
|
|
1363
1464
|
}));
|
|
1364
1465
|
|
|
1365
1466
|
case 4:
|
|
1366
|
-
return
|
|
1467
|
+
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
1367
1468
|
|
|
1368
1469
|
case 5:
|
|
1369
1470
|
case "end":
|
|
1370
|
-
return
|
|
1471
|
+
return _context11.stop();
|
|
1371
1472
|
}
|
|
1372
1473
|
}
|
|
1373
|
-
},
|
|
1474
|
+
}, _callee11, this);
|
|
1374
1475
|
}));
|
|
1375
1476
|
|
|
1376
1477
|
function deposit(_x3) {
|
|
@@ -1381,19 +1482,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1381
1482
|
}();
|
|
1382
1483
|
|
|
1383
1484
|
_proto2.borrow = /*#__PURE__*/function () {
|
|
1384
|
-
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1385
|
-
return runtime_1.wrap(function
|
|
1485
|
+
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
|
|
1486
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
1386
1487
|
while (1) {
|
|
1387
|
-
switch (
|
|
1488
|
+
switch (_context12.prev = _context12.next) {
|
|
1388
1489
|
case 0:
|
|
1389
|
-
return
|
|
1490
|
+
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
1390
1491
|
|
|
1391
1492
|
case 1:
|
|
1392
1493
|
case "end":
|
|
1393
|
-
return
|
|
1494
|
+
return _context12.stop();
|
|
1394
1495
|
}
|
|
1395
1496
|
}
|
|
1396
|
-
},
|
|
1497
|
+
}, _callee12, this);
|
|
1397
1498
|
}));
|
|
1398
1499
|
|
|
1399
1500
|
function borrow(_x4) {
|
|
@@ -1404,19 +1505,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1404
1505
|
}();
|
|
1405
1506
|
|
|
1406
1507
|
_proto2.withdraw = /*#__PURE__*/function () {
|
|
1407
|
-
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1408
|
-
return runtime_1.wrap(function
|
|
1508
|
+
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(amount) {
|
|
1509
|
+
return runtime_1.wrap(function _callee13$(_context13) {
|
|
1409
1510
|
while (1) {
|
|
1410
|
-
switch (
|
|
1511
|
+
switch (_context13.prev = _context13.next) {
|
|
1411
1512
|
case 0:
|
|
1412
|
-
return
|
|
1513
|
+
return _context13.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
1413
1514
|
|
|
1414
1515
|
case 1:
|
|
1415
1516
|
case "end":
|
|
1416
|
-
return
|
|
1517
|
+
return _context13.stop();
|
|
1417
1518
|
}
|
|
1418
1519
|
}
|
|
1419
|
-
},
|
|
1520
|
+
}, _callee13, this);
|
|
1420
1521
|
}));
|
|
1421
1522
|
|
|
1422
1523
|
function withdraw(_x5) {
|
|
@@ -1427,29 +1528,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1427
1528
|
}();
|
|
1428
1529
|
|
|
1429
1530
|
_proto2.repay = /*#__PURE__*/function () {
|
|
1430
|
-
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1431
|
-
return runtime_1.wrap(function
|
|
1531
|
+
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
|
|
1532
|
+
return runtime_1.wrap(function _callee14$(_context14) {
|
|
1432
1533
|
while (1) {
|
|
1433
|
-
switch (
|
|
1534
|
+
switch (_context14.prev = _context14.next) {
|
|
1434
1535
|
case 0:
|
|
1435
1536
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1436
|
-
|
|
1537
|
+
_context14.next = 4;
|
|
1437
1538
|
break;
|
|
1438
1539
|
}
|
|
1439
1540
|
|
|
1440
|
-
return
|
|
1541
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
1441
1542
|
value: amount.rawAmount()
|
|
1442
1543
|
}));
|
|
1443
1544
|
|
|
1444
1545
|
case 4:
|
|
1445
|
-
return
|
|
1546
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
1446
1547
|
|
|
1447
1548
|
case 5:
|
|
1448
1549
|
case "end":
|
|
1449
|
-
return
|
|
1550
|
+
return _context14.stop();
|
|
1450
1551
|
}
|
|
1451
1552
|
}
|
|
1452
|
-
},
|
|
1553
|
+
}, _callee14, this);
|
|
1453
1554
|
}));
|
|
1454
1555
|
|
|
1455
1556
|
function repay(_x6) {
|
|
@@ -1460,19 +1561,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1460
1561
|
}();
|
|
1461
1562
|
|
|
1462
1563
|
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
1463
|
-
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1464
|
-
return runtime_1.wrap(function
|
|
1564
|
+
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15() {
|
|
1565
|
+
return runtime_1.wrap(function _callee15$(_context15) {
|
|
1465
1566
|
while (1) {
|
|
1466
|
-
switch (
|
|
1567
|
+
switch (_context15.prev = _context15.next) {
|
|
1467
1568
|
case 0:
|
|
1468
|
-
return
|
|
1569
|
+
return _context15.abrupt("return", this._comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
1469
1570
|
|
|
1470
1571
|
case 1:
|
|
1471
1572
|
case "end":
|
|
1472
|
-
return
|
|
1573
|
+
return _context15.stop();
|
|
1473
1574
|
}
|
|
1474
1575
|
}
|
|
1475
|
-
},
|
|
1576
|
+
}, _callee15, this);
|
|
1476
1577
|
}));
|
|
1477
1578
|
|
|
1478
1579
|
function enableCollateral() {
|
|
@@ -1483,19 +1584,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1483
1584
|
}();
|
|
1484
1585
|
|
|
1485
1586
|
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
1486
|
-
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1487
|
-
return runtime_1.wrap(function
|
|
1587
|
+
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
|
|
1588
|
+
return runtime_1.wrap(function _callee16$(_context16) {
|
|
1488
1589
|
while (1) {
|
|
1489
|
-
switch (
|
|
1590
|
+
switch (_context16.prev = _context16.next) {
|
|
1490
1591
|
case 0:
|
|
1491
|
-
return
|
|
1592
|
+
return _context16.abrupt("return", this._comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
1492
1593
|
|
|
1493
1594
|
case 1:
|
|
1494
1595
|
case "end":
|
|
1495
|
-
return
|
|
1596
|
+
return _context16.stop();
|
|
1496
1597
|
}
|
|
1497
1598
|
}
|
|
1498
|
-
},
|
|
1599
|
+
}, _callee16, this);
|
|
1499
1600
|
}));
|
|
1500
1601
|
|
|
1501
1602
|
function disableCollateral() {
|
|
@@ -2477,14 +2578,20 @@ var IUniswapV2PairABI = {
|
|
|
2477
2578
|
deployedLinkReferences: deployedLinkReferences
|
|
2478
2579
|
};
|
|
2479
2580
|
|
|
2581
|
+
var abi$2 = [
|
|
2582
|
+
];
|
|
2583
|
+
var dummyABI = {
|
|
2584
|
+
abi: abi$2
|
|
2585
|
+
};
|
|
2586
|
+
|
|
2480
2587
|
var axios = /*#__PURE__*/require('axios');
|
|
2481
2588
|
|
|
2482
|
-
function
|
|
2483
|
-
return
|
|
2589
|
+
function fetchPriceFromCoingeckoAPI(_x) {
|
|
2590
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2484
2591
|
}
|
|
2485
2592
|
|
|
2486
|
-
function
|
|
2487
|
-
|
|
2593
|
+
function _fetchPriceFromCoingeckoAPI() {
|
|
2594
|
+
_fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
|
|
2488
2595
|
var price;
|
|
2489
2596
|
return runtime_1.wrap(function _callee$(_context) {
|
|
2490
2597
|
while (1) {
|
|
@@ -2506,15 +2613,15 @@ function _fetchPriceFromCoingecko() {
|
|
|
2506
2613
|
}
|
|
2507
2614
|
}, _callee);
|
|
2508
2615
|
}));
|
|
2509
|
-
return
|
|
2616
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2510
2617
|
}
|
|
2511
2618
|
|
|
2512
|
-
function
|
|
2513
|
-
return
|
|
2619
|
+
function fetchPriceFromCoingecko(_x2) {
|
|
2620
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2514
2621
|
}
|
|
2515
2622
|
|
|
2516
|
-
function
|
|
2517
|
-
|
|
2623
|
+
function _fetchPriceFromCoingecko() {
|
|
2624
|
+
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(address) {
|
|
2518
2625
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2519
2626
|
while (1) {
|
|
2520
2627
|
switch (_context2.prev = _context2.next) {
|
|
@@ -2524,10 +2631,10 @@ function _fetchBasicTokenPrice() {
|
|
|
2524
2631
|
break;
|
|
2525
2632
|
}
|
|
2526
2633
|
|
|
2527
|
-
return _context2.abrupt("return",
|
|
2634
|
+
return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
|
|
2528
2635
|
|
|
2529
2636
|
case 4:
|
|
2530
|
-
throw Error("Unknown token " + address + " in
|
|
2637
|
+
throw Error("Unknown token " + address + " in fetchPriceFromCoingecko");
|
|
2531
2638
|
|
|
2532
2639
|
case 5:
|
|
2533
2640
|
case "end":
|
|
@@ -2536,7 +2643,7 @@ function _fetchBasicTokenPrice() {
|
|
|
2536
2643
|
}
|
|
2537
2644
|
}, _callee2);
|
|
2538
2645
|
}));
|
|
2539
|
-
return
|
|
2646
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2540
2647
|
}
|
|
2541
2648
|
|
|
2542
2649
|
function fetchLPPositions(_x3, _x4) {
|
|
@@ -2564,8 +2671,8 @@ function _fetchLPPositions() {
|
|
|
2564
2671
|
return _context3.abrupt("return", {
|
|
2565
2672
|
token0: values[0],
|
|
2566
2673
|
token1: values[1],
|
|
2567
|
-
reserve0: values[2].
|
|
2568
|
-
reserve1: values[2].
|
|
2674
|
+
reserve0: values[2].reserve0,
|
|
2675
|
+
reserve1: values[2].reserve1,
|
|
2569
2676
|
totalSupply: values[3]
|
|
2570
2677
|
});
|
|
2571
2678
|
|
|
@@ -2632,12 +2739,16 @@ function _fetchLPPrice() {
|
|
|
2632
2739
|
return _fetchLPPrice.apply(this, arguments);
|
|
2633
2740
|
}
|
|
2634
2741
|
|
|
2742
|
+
function processPriceFromOracle(rawPrice, underlyingDecimal) {
|
|
2743
|
+
return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2635
2746
|
function fetchPriceFromOracle(_x7, _x8, _x9) {
|
|
2636
2747
|
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2637
2748
|
}
|
|
2638
2749
|
|
|
2639
2750
|
function _fetchPriceFromOracle() {
|
|
2640
|
-
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress,
|
|
2751
|
+
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress, underlyingDecimal, provider) {
|
|
2641
2752
|
var oracleContract, rawPrice;
|
|
2642
2753
|
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2643
2754
|
while (1) {
|
|
@@ -2649,7 +2760,7 @@ function _fetchPriceFromOracle() {
|
|
|
2649
2760
|
|
|
2650
2761
|
case 3:
|
|
2651
2762
|
rawPrice = _context5.sent;
|
|
2652
|
-
return _context5.abrupt("return",
|
|
2763
|
+
return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
|
|
2653
2764
|
|
|
2654
2765
|
case 5:
|
|
2655
2766
|
case "end":
|
|
@@ -2661,77 +2772,111 @@ function _fetchPriceFromOracle() {
|
|
|
2661
2772
|
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2662
2773
|
}
|
|
2663
2774
|
|
|
2664
|
-
function
|
|
2775
|
+
function fetchUnderlyingTokensPrices(_x10) {
|
|
2776
|
+
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
function _fetchUnderlyingTokensPrices() {
|
|
2780
|
+
_fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
|
|
2781
|
+
var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
|
|
2782
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2783
|
+
while (1) {
|
|
2784
|
+
switch (_context6.prev = _context6.next) {
|
|
2785
|
+
case 0:
|
|
2786
|
+
auriLens = new Contract(networkAddresses.misc.AURILENS, dummyABI.abi, provider);
|
|
2787
|
+
auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
|
|
2788
|
+
return auToken.address;
|
|
2789
|
+
});
|
|
2790
|
+
underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
|
|
2791
|
+
return getDecimal(auToken.underlying);
|
|
2792
|
+
});
|
|
2793
|
+
_context6.next = 5;
|
|
2794
|
+
return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
|
|
2795
|
+
|
|
2796
|
+
case 5:
|
|
2797
|
+
rawPrices = _context6.sent;
|
|
2798
|
+
return _context6.abrupt("return", rawPrices.map(function (res, ind) {
|
|
2799
|
+
return {
|
|
2800
|
+
auToken: res.auToken,
|
|
2801
|
+
underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
|
|
2802
|
+
};
|
|
2803
|
+
}));
|
|
2804
|
+
|
|
2805
|
+
case 7:
|
|
2806
|
+
case "end":
|
|
2807
|
+
return _context6.stop();
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
}, _callee6);
|
|
2811
|
+
}));
|
|
2812
|
+
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
function fetchPrice(_x11, _x12) {
|
|
2665
2816
|
return _fetchPrice.apply(this, arguments);
|
|
2666
2817
|
}
|
|
2667
2818
|
|
|
2668
2819
|
function _fetchPrice() {
|
|
2669
|
-
_fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2820
|
+
_fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(address, provider) {
|
|
2670
2821
|
var matchingAuToken;
|
|
2671
|
-
return runtime_1.wrap(function
|
|
2822
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2672
2823
|
while (1) {
|
|
2673
|
-
switch (
|
|
2824
|
+
switch (_context7.prev = _context7.next) {
|
|
2674
2825
|
case 0:
|
|
2675
2826
|
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2676
2827
|
return isSameAddress(auToken.underlying, address);
|
|
2677
2828
|
});
|
|
2678
2829
|
|
|
2679
2830
|
if (!(matchingAuToken !== undefined)) {
|
|
2680
|
-
|
|
2831
|
+
_context7.next = 5;
|
|
2681
2832
|
break;
|
|
2682
2833
|
}
|
|
2683
2834
|
|
|
2684
|
-
return
|
|
2835
|
+
return _context7.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
|
|
2685
2836
|
|
|
2686
2837
|
case 5:
|
|
2687
2838
|
if (!isSameAddress(address, networkAddresses.misc.AUPLYLP)) {
|
|
2688
|
-
|
|
2839
|
+
_context7.next = 9;
|
|
2689
2840
|
break;
|
|
2690
2841
|
}
|
|
2691
2842
|
|
|
2692
|
-
return
|
|
2843
|
+
return _context7.abrupt("return", fetchLPPrice(address, provider));
|
|
2693
2844
|
|
|
2694
2845
|
case 9:
|
|
2695
|
-
return
|
|
2846
|
+
return _context7.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2696
2847
|
|
|
2697
2848
|
case 10:
|
|
2698
2849
|
case "end":
|
|
2699
|
-
return
|
|
2850
|
+
return _context7.stop();
|
|
2700
2851
|
}
|
|
2701
2852
|
}
|
|
2702
|
-
},
|
|
2853
|
+
}, _callee7);
|
|
2703
2854
|
}));
|
|
2704
2855
|
return _fetchPrice.apply(this, arguments);
|
|
2705
2856
|
}
|
|
2706
2857
|
|
|
2707
|
-
function fetchValuation(
|
|
2858
|
+
function fetchValuation(_x13, _x14, _x15) {
|
|
2708
2859
|
return _fetchValuation.apply(this, arguments);
|
|
2709
2860
|
}
|
|
2710
2861
|
|
|
2711
2862
|
function _fetchValuation() {
|
|
2712
|
-
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2713
|
-
return runtime_1.wrap(function
|
|
2863
|
+
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider, price) {
|
|
2864
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2714
2865
|
while (1) {
|
|
2715
|
-
switch (
|
|
2866
|
+
switch (_context8.prev = _context8.next) {
|
|
2716
2867
|
case 0:
|
|
2717
|
-
return
|
|
2868
|
+
return _context8.abrupt("return", new BigNumber(0));
|
|
2718
2869
|
|
|
2719
2870
|
case 1:
|
|
2720
2871
|
case "end":
|
|
2721
|
-
return
|
|
2872
|
+
return _context8.stop();
|
|
2722
2873
|
}
|
|
2723
2874
|
}
|
|
2724
|
-
},
|
|
2875
|
+
}, _callee8);
|
|
2725
2876
|
}));
|
|
2726
2877
|
return _fetchValuation.apply(this, arguments);
|
|
2727
2878
|
}
|
|
2728
2879
|
|
|
2729
|
-
var abi$2 = [
|
|
2730
|
-
];
|
|
2731
|
-
var dummyABI = {
|
|
2732
|
-
abi: abi$2
|
|
2733
|
-
};
|
|
2734
|
-
|
|
2735
2880
|
var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2736
2881
|
_inheritsLoose(SdkRead, _BlockchainEntityRead);
|
|
2737
2882
|
|
|
@@ -3161,5 +3306,5 @@ var dummyUserMarketDetails = {
|
|
|
3161
3306
|
maxWithdrawableAmount: dummyTokenAmount
|
|
3162
3307
|
};
|
|
3163
3308
|
|
|
3164
|
-
export { AURORA_CHAINID, AURPLYToken, AVAX_DEFAULT_PROVIDER, AVAX_DEFAULT_PROVIDER_URL, AVAX_DEFAULT_SIGNER, AurPlyPid, BORROW_LIMIT_BUFFER, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, DECIMAL_PRECISION, ETHAddress, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, PLYToken, REWARDCLAIMSTART, SDK, SdkRead, SdkReadWrite, Token, TokenAmount, calcLMRewardApr, decimalFactor, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount,
|
|
3309
|
+
export { AURORA_CHAINID, AURPLYToken, AVAX_DEFAULT_PROVIDER, AVAX_DEFAULT_PROVIDER_URL, AVAX_DEFAULT_SIGNER, AurPlyPid, BORROW_LIMIT_BUFFER, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, ETHAddress, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_YEAR, PLYToken, REWARDCLAIMSTART, SDK, SdkRead, SdkReadWrite, Token, TokenAmount, calcLMRewardApr, decimalFactor, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getCurrentTimestamp, getDecimal, isSameAddress, networkAddresses, validateAndParseAddress };
|
|
3165
3310
|
//# sourceMappingURL=sdk.esm.js.map
|