@aurigami/sdk 0.2.2 → 0.2.6
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 +3 -0
- package/dist/priceFetcher.d.ts +2 -2
- package/dist/sdk.cjs.development.js +192 -87
- 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 +191 -87
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/package.json +4 -4
- package/src/MoneyMarket.ts +59 -7
- package/src/constants.ts +16 -0
- package/src/priceFetcher.ts +8 -7
- package/src/types.ts +4 -0
package/dist/sdk.esm.js
CHANGED
|
@@ -893,6 +893,8 @@ var ethers = /*#__PURE__*/require('ethers');
|
|
|
893
893
|
|
|
894
894
|
var AVAX_DEFAULT_PROVIDER_URL = 'https://api.avax.network/ext/bc/C/rpc';
|
|
895
895
|
var AVAX_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AVAX_DEFAULT_PROVIDER_URL);
|
|
896
|
+
var AURORA_DEFAULT_PROVIDER_URL = "https://testnet.aurora.dev";
|
|
897
|
+
var AURORA_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AURORA_DEFAULT_PROVIDER_URL);
|
|
896
898
|
var dummyAddress = "0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE";
|
|
897
899
|
var ETHAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
898
900
|
var dummyPrivateKey = '1111111111111111111111111111111111111111111111111111111111111111';
|
|
@@ -940,6 +942,7 @@ var networkAddresses = {
|
|
|
940
942
|
var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(0.95);
|
|
941
943
|
var REWARDCLAIMSTART = 1673280000;
|
|
942
944
|
var ONE_DAY = 86400;
|
|
945
|
+
var ONE_YEAR = ONE_DAY * 365;
|
|
943
946
|
var AurPlyPid = 1;
|
|
944
947
|
|
|
945
948
|
var decimalRecords = {
|
|
@@ -1019,6 +1022,13 @@ function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
|
|
|
1019
1022
|
return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
|
|
1020
1023
|
}
|
|
1021
1024
|
|
|
1025
|
+
var ComptrollerRewardType;
|
|
1026
|
+
|
|
1027
|
+
(function (ComptrollerRewardType) {
|
|
1028
|
+
ComptrollerRewardType[ComptrollerRewardType["PLY"] = 0] = "PLY";
|
|
1029
|
+
ComptrollerRewardType[ComptrollerRewardType["AURORA"] = 1] = "AURORA";
|
|
1030
|
+
})(ComptrollerRewardType || (ComptrollerRewardType = {}));
|
|
1031
|
+
|
|
1022
1032
|
var Token = function Token(address, decimals) {
|
|
1023
1033
|
this.address = address.toLowerCase();
|
|
1024
1034
|
this.decimals = decimals;
|
|
@@ -1125,7 +1135,7 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1125
1135
|
return Promise.all(promises);
|
|
1126
1136
|
|
|
1127
1137
|
case 5:
|
|
1128
|
-
return _context2.abrupt("return", new TokenAmount(this.underlying, BigNumber$1.from(totalCash.rawAmount).add(totalBorrow.rawAmount()).toString()));
|
|
1138
|
+
return _context2.abrupt("return", new TokenAmount(this.underlying, BigNumber$1.from(totalCash.rawAmount()).add(totalBorrow.rawAmount()).toString()));
|
|
1129
1139
|
|
|
1130
1140
|
case 6:
|
|
1131
1141
|
case "end":
|
|
@@ -1225,12 +1235,94 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1225
1235
|
return getCollateralRatio;
|
|
1226
1236
|
}();
|
|
1227
1237
|
|
|
1228
|
-
_proto.
|
|
1229
|
-
var
|
|
1230
|
-
var promises,
|
|
1238
|
+
_proto.getBorrowPlyAPY = /*#__PURE__*/function () {
|
|
1239
|
+
var _getBorrowPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
1240
|
+
var promises, totalBorrowed, rewardSpeed, plyPrice, underlyingPrice;
|
|
1231
1241
|
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1232
1242
|
while (1) {
|
|
1233
1243
|
switch (_context6.prev = _context6.next) {
|
|
1244
|
+
case 0:
|
|
1245
|
+
promises = [];
|
|
1246
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
1247
|
+
totalBorrowed = res;
|
|
1248
|
+
}));
|
|
1249
|
+
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1250
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1251
|
+
}));
|
|
1252
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1253
|
+
plyPrice = res;
|
|
1254
|
+
}));
|
|
1255
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1256
|
+
underlyingPrice = res;
|
|
1257
|
+
}));
|
|
1258
|
+
_context6.next = 7;
|
|
1259
|
+
return Promise.all(promises);
|
|
1260
|
+
|
|
1261
|
+
case 7:
|
|
1262
|
+
return _context6.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR));
|
|
1263
|
+
|
|
1264
|
+
case 8:
|
|
1265
|
+
case "end":
|
|
1266
|
+
return _context6.stop();
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}, _callee6, this);
|
|
1270
|
+
}));
|
|
1271
|
+
|
|
1272
|
+
function getBorrowPlyAPY() {
|
|
1273
|
+
return _getBorrowPlyAPY.apply(this, arguments);
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
return getBorrowPlyAPY;
|
|
1277
|
+
}();
|
|
1278
|
+
|
|
1279
|
+
_proto.getDepositPlyAPY = /*#__PURE__*/function () {
|
|
1280
|
+
var _getDepositPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
1281
|
+
var promises, totalDeposited, rewardSpeed, plyPrice, underlyingPrice;
|
|
1282
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
1283
|
+
while (1) {
|
|
1284
|
+
switch (_context7.prev = _context7.next) {
|
|
1285
|
+
case 0:
|
|
1286
|
+
promises = [];
|
|
1287
|
+
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
1288
|
+
totalDeposited = res;
|
|
1289
|
+
}));
|
|
1290
|
+
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1291
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1292
|
+
}));
|
|
1293
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1294
|
+
plyPrice = res;
|
|
1295
|
+
}));
|
|
1296
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1297
|
+
underlyingPrice = res;
|
|
1298
|
+
}));
|
|
1299
|
+
_context7.next = 7;
|
|
1300
|
+
return Promise.all(promises);
|
|
1301
|
+
|
|
1302
|
+
case 7:
|
|
1303
|
+
return _context7.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR));
|
|
1304
|
+
|
|
1305
|
+
case 8:
|
|
1306
|
+
case "end":
|
|
1307
|
+
return _context7.stop();
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}, _callee7, this);
|
|
1311
|
+
}));
|
|
1312
|
+
|
|
1313
|
+
function getDepositPlyAPY() {
|
|
1314
|
+
return _getDepositPlyAPY.apply(this, arguments);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
return getDepositPlyAPY;
|
|
1318
|
+
}();
|
|
1319
|
+
|
|
1320
|
+
_proto.getDetails = /*#__PURE__*/function () {
|
|
1321
|
+
var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
1322
|
+
var promises, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeed, plyPrice, underlyingPrice, borrowPlyApy, depositPlyApy;
|
|
1323
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
1324
|
+
while (1) {
|
|
1325
|
+
switch (_context8.prev = _context8.next) {
|
|
1234
1326
|
case 0:
|
|
1235
1327
|
promises = [];
|
|
1236
1328
|
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
@@ -1248,27 +1340,38 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1248
1340
|
promises.push(this.getCollateralRatio().then(function (res) {
|
|
1249
1341
|
collateralRatio = res.toNumber();
|
|
1250
1342
|
}));
|
|
1251
|
-
|
|
1343
|
+
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1344
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1345
|
+
}));
|
|
1346
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1347
|
+
plyPrice = res;
|
|
1348
|
+
}));
|
|
1349
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1350
|
+
underlyingPrice = res;
|
|
1351
|
+
}));
|
|
1352
|
+
_context8.next = 11;
|
|
1252
1353
|
return Promise.all(promises);
|
|
1253
1354
|
|
|
1254
|
-
case
|
|
1255
|
-
|
|
1355
|
+
case 11:
|
|
1356
|
+
borrowPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR);
|
|
1357
|
+
depositPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR);
|
|
1358
|
+
return _context8.abrupt("return", {
|
|
1256
1359
|
auTokenAddress: this.auToken.address,
|
|
1257
1360
|
totalTokenDeposited: totalDeposited,
|
|
1258
1361
|
totalTokenBorrowed: totalBorrowed,
|
|
1259
1362
|
depositApy: depositAPY,
|
|
1260
|
-
depositPlyApy:
|
|
1363
|
+
depositPlyApy: depositPlyApy.toNumber(),
|
|
1261
1364
|
borrowApy: borrowAPY,
|
|
1262
|
-
borrowPlyApy:
|
|
1365
|
+
borrowPlyApy: borrowPlyApy.toNumber(),
|
|
1263
1366
|
collateralRatio: collateralRatio
|
|
1264
1367
|
});
|
|
1265
1368
|
|
|
1266
|
-
case
|
|
1369
|
+
case 14:
|
|
1267
1370
|
case "end":
|
|
1268
|
-
return
|
|
1371
|
+
return _context8.stop();
|
|
1269
1372
|
}
|
|
1270
1373
|
}
|
|
1271
|
-
},
|
|
1374
|
+
}, _callee8, this);
|
|
1272
1375
|
}));
|
|
1273
1376
|
|
|
1274
1377
|
function getDetails() {
|
|
@@ -1279,25 +1382,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1279
1382
|
}();
|
|
1280
1383
|
|
|
1281
1384
|
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
1282
|
-
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1385
|
+
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(userAddress) {
|
|
1283
1386
|
var totalBorrow;
|
|
1284
|
-
return runtime_1.wrap(function
|
|
1387
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
1285
1388
|
while (1) {
|
|
1286
|
-
switch (
|
|
1389
|
+
switch (_context9.prev = _context9.next) {
|
|
1287
1390
|
case 0:
|
|
1288
|
-
|
|
1391
|
+
_context9.next = 2;
|
|
1289
1392
|
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
1290
1393
|
|
|
1291
1394
|
case 2:
|
|
1292
|
-
totalBorrow =
|
|
1293
|
-
return
|
|
1395
|
+
totalBorrow = _context9.sent;
|
|
1396
|
+
return _context9.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
1294
1397
|
|
|
1295
1398
|
case 4:
|
|
1296
1399
|
case "end":
|
|
1297
|
-
return
|
|
1400
|
+
return _context9.stop();
|
|
1298
1401
|
}
|
|
1299
1402
|
}
|
|
1300
|
-
},
|
|
1403
|
+
}, _callee9, this);
|
|
1301
1404
|
}));
|
|
1302
1405
|
|
|
1303
1406
|
function getUserBorrowBalance(_x) {
|
|
@@ -1308,25 +1411,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1308
1411
|
}();
|
|
1309
1412
|
|
|
1310
1413
|
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
1311
|
-
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1414
|
+
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(userAddress) {
|
|
1312
1415
|
var totalDeposit;
|
|
1313
|
-
return runtime_1.wrap(function
|
|
1416
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
1314
1417
|
while (1) {
|
|
1315
|
-
switch (
|
|
1418
|
+
switch (_context10.prev = _context10.next) {
|
|
1316
1419
|
case 0:
|
|
1317
|
-
|
|
1420
|
+
_context10.next = 2;
|
|
1318
1421
|
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
1319
1422
|
|
|
1320
1423
|
case 2:
|
|
1321
|
-
totalDeposit =
|
|
1322
|
-
return
|
|
1424
|
+
totalDeposit = _context10.sent;
|
|
1425
|
+
return _context10.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
1323
1426
|
|
|
1324
1427
|
case 4:
|
|
1325
1428
|
case "end":
|
|
1326
|
-
return
|
|
1429
|
+
return _context10.stop();
|
|
1327
1430
|
}
|
|
1328
1431
|
}
|
|
1329
|
-
},
|
|
1432
|
+
}, _callee10, this);
|
|
1330
1433
|
}));
|
|
1331
1434
|
|
|
1332
1435
|
function getUserDepositBalance(_x2) {
|
|
@@ -1348,29 +1451,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1348
1451
|
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
1349
1452
|
|
|
1350
1453
|
_proto2.deposit = /*#__PURE__*/function () {
|
|
1351
|
-
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1352
|
-
return runtime_1.wrap(function
|
|
1454
|
+
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(amount) {
|
|
1455
|
+
return runtime_1.wrap(function _callee11$(_context11) {
|
|
1353
1456
|
while (1) {
|
|
1354
|
-
switch (
|
|
1457
|
+
switch (_context11.prev = _context11.next) {
|
|
1355
1458
|
case 0:
|
|
1356
1459
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1357
|
-
|
|
1460
|
+
_context11.next = 4;
|
|
1358
1461
|
break;
|
|
1359
1462
|
}
|
|
1360
1463
|
|
|
1361
|
-
return
|
|
1464
|
+
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
1362
1465
|
value: amount.rawAmount()
|
|
1363
1466
|
}));
|
|
1364
1467
|
|
|
1365
1468
|
case 4:
|
|
1366
|
-
return
|
|
1469
|
+
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
1367
1470
|
|
|
1368
1471
|
case 5:
|
|
1369
1472
|
case "end":
|
|
1370
|
-
return
|
|
1473
|
+
return _context11.stop();
|
|
1371
1474
|
}
|
|
1372
1475
|
}
|
|
1373
|
-
},
|
|
1476
|
+
}, _callee11, this);
|
|
1374
1477
|
}));
|
|
1375
1478
|
|
|
1376
1479
|
function deposit(_x3) {
|
|
@@ -1381,19 +1484,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1381
1484
|
}();
|
|
1382
1485
|
|
|
1383
1486
|
_proto2.borrow = /*#__PURE__*/function () {
|
|
1384
|
-
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1385
|
-
return runtime_1.wrap(function
|
|
1487
|
+
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
|
|
1488
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
1386
1489
|
while (1) {
|
|
1387
|
-
switch (
|
|
1490
|
+
switch (_context12.prev = _context12.next) {
|
|
1388
1491
|
case 0:
|
|
1389
|
-
return
|
|
1492
|
+
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
1390
1493
|
|
|
1391
1494
|
case 1:
|
|
1392
1495
|
case "end":
|
|
1393
|
-
return
|
|
1496
|
+
return _context12.stop();
|
|
1394
1497
|
}
|
|
1395
1498
|
}
|
|
1396
|
-
},
|
|
1499
|
+
}, _callee12, this);
|
|
1397
1500
|
}));
|
|
1398
1501
|
|
|
1399
1502
|
function borrow(_x4) {
|
|
@@ -1404,19 +1507,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1404
1507
|
}();
|
|
1405
1508
|
|
|
1406
1509
|
_proto2.withdraw = /*#__PURE__*/function () {
|
|
1407
|
-
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1408
|
-
return runtime_1.wrap(function
|
|
1510
|
+
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(amount) {
|
|
1511
|
+
return runtime_1.wrap(function _callee13$(_context13) {
|
|
1409
1512
|
while (1) {
|
|
1410
|
-
switch (
|
|
1513
|
+
switch (_context13.prev = _context13.next) {
|
|
1411
1514
|
case 0:
|
|
1412
|
-
return
|
|
1515
|
+
return _context13.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
1413
1516
|
|
|
1414
1517
|
case 1:
|
|
1415
1518
|
case "end":
|
|
1416
|
-
return
|
|
1519
|
+
return _context13.stop();
|
|
1417
1520
|
}
|
|
1418
1521
|
}
|
|
1419
|
-
},
|
|
1522
|
+
}, _callee13, this);
|
|
1420
1523
|
}));
|
|
1421
1524
|
|
|
1422
1525
|
function withdraw(_x5) {
|
|
@@ -1427,29 +1530,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1427
1530
|
}();
|
|
1428
1531
|
|
|
1429
1532
|
_proto2.repay = /*#__PURE__*/function () {
|
|
1430
|
-
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1431
|
-
return runtime_1.wrap(function
|
|
1533
|
+
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
|
|
1534
|
+
return runtime_1.wrap(function _callee14$(_context14) {
|
|
1432
1535
|
while (1) {
|
|
1433
|
-
switch (
|
|
1536
|
+
switch (_context14.prev = _context14.next) {
|
|
1434
1537
|
case 0:
|
|
1435
1538
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1436
|
-
|
|
1539
|
+
_context14.next = 4;
|
|
1437
1540
|
break;
|
|
1438
1541
|
}
|
|
1439
1542
|
|
|
1440
|
-
return
|
|
1543
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
1441
1544
|
value: amount.rawAmount()
|
|
1442
1545
|
}));
|
|
1443
1546
|
|
|
1444
1547
|
case 4:
|
|
1445
|
-
return
|
|
1548
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
1446
1549
|
|
|
1447
1550
|
case 5:
|
|
1448
1551
|
case "end":
|
|
1449
|
-
return
|
|
1552
|
+
return _context14.stop();
|
|
1450
1553
|
}
|
|
1451
1554
|
}
|
|
1452
|
-
},
|
|
1555
|
+
}, _callee14, this);
|
|
1453
1556
|
}));
|
|
1454
1557
|
|
|
1455
1558
|
function repay(_x6) {
|
|
@@ -1460,19 +1563,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1460
1563
|
}();
|
|
1461
1564
|
|
|
1462
1565
|
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
1463
|
-
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1464
|
-
return runtime_1.wrap(function
|
|
1566
|
+
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15() {
|
|
1567
|
+
return runtime_1.wrap(function _callee15$(_context15) {
|
|
1465
1568
|
while (1) {
|
|
1466
|
-
switch (
|
|
1569
|
+
switch (_context15.prev = _context15.next) {
|
|
1467
1570
|
case 0:
|
|
1468
|
-
return
|
|
1571
|
+
return _context15.abrupt("return", this._comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
1469
1572
|
|
|
1470
1573
|
case 1:
|
|
1471
1574
|
case "end":
|
|
1472
|
-
return
|
|
1575
|
+
return _context15.stop();
|
|
1473
1576
|
}
|
|
1474
1577
|
}
|
|
1475
|
-
},
|
|
1578
|
+
}, _callee15, this);
|
|
1476
1579
|
}));
|
|
1477
1580
|
|
|
1478
1581
|
function enableCollateral() {
|
|
@@ -1483,19 +1586,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1483
1586
|
}();
|
|
1484
1587
|
|
|
1485
1588
|
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
1486
|
-
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1487
|
-
return runtime_1.wrap(function
|
|
1589
|
+
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
|
|
1590
|
+
return runtime_1.wrap(function _callee16$(_context16) {
|
|
1488
1591
|
while (1) {
|
|
1489
|
-
switch (
|
|
1592
|
+
switch (_context16.prev = _context16.next) {
|
|
1490
1593
|
case 0:
|
|
1491
|
-
return
|
|
1594
|
+
return _context16.abrupt("return", this._comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
1492
1595
|
|
|
1493
1596
|
case 1:
|
|
1494
1597
|
case "end":
|
|
1495
|
-
return
|
|
1598
|
+
return _context16.stop();
|
|
1496
1599
|
}
|
|
1497
1600
|
}
|
|
1498
|
-
},
|
|
1601
|
+
}, _callee16, this);
|
|
1499
1602
|
}));
|
|
1500
1603
|
|
|
1501
1604
|
function disableCollateral() {
|
|
@@ -2485,12 +2588,12 @@ var dummyABI = {
|
|
|
2485
2588
|
|
|
2486
2589
|
var axios = /*#__PURE__*/require('axios');
|
|
2487
2590
|
|
|
2488
|
-
function
|
|
2489
|
-
return
|
|
2591
|
+
function fetchPriceFromCoingeckoAPI(_x) {
|
|
2592
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2490
2593
|
}
|
|
2491
2594
|
|
|
2492
|
-
function
|
|
2493
|
-
|
|
2595
|
+
function _fetchPriceFromCoingeckoAPI() {
|
|
2596
|
+
_fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
|
|
2494
2597
|
var price;
|
|
2495
2598
|
return runtime_1.wrap(function _callee$(_context) {
|
|
2496
2599
|
while (1) {
|
|
@@ -2512,15 +2615,15 @@ function _fetchPriceFromCoingecko() {
|
|
|
2512
2615
|
}
|
|
2513
2616
|
}, _callee);
|
|
2514
2617
|
}));
|
|
2515
|
-
return
|
|
2618
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2516
2619
|
}
|
|
2517
2620
|
|
|
2518
|
-
function
|
|
2519
|
-
return
|
|
2621
|
+
function fetchPriceFromCoingecko(_x2) {
|
|
2622
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2520
2623
|
}
|
|
2521
2624
|
|
|
2522
|
-
function
|
|
2523
|
-
|
|
2625
|
+
function _fetchPriceFromCoingecko() {
|
|
2626
|
+
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(address) {
|
|
2524
2627
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2525
2628
|
while (1) {
|
|
2526
2629
|
switch (_context2.prev = _context2.next) {
|
|
@@ -2530,10 +2633,10 @@ function _fetchBasicTokenPrice() {
|
|
|
2530
2633
|
break;
|
|
2531
2634
|
}
|
|
2532
2635
|
|
|
2533
|
-
return _context2.abrupt("return",
|
|
2636
|
+
return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
|
|
2534
2637
|
|
|
2535
2638
|
case 4:
|
|
2536
|
-
throw Error("Unknown token " + address + " in
|
|
2639
|
+
throw Error("Unknown token " + address + " in fetchPriceFromCoingecko");
|
|
2537
2640
|
|
|
2538
2641
|
case 5:
|
|
2539
2642
|
case "end":
|
|
@@ -2542,7 +2645,7 @@ function _fetchBasicTokenPrice() {
|
|
|
2542
2645
|
}
|
|
2543
2646
|
}, _callee2);
|
|
2544
2647
|
}));
|
|
2545
|
-
return
|
|
2648
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2546
2649
|
}
|
|
2547
2650
|
|
|
2548
2651
|
function fetchLPPositions(_x3, _x4) {
|
|
@@ -2570,8 +2673,8 @@ function _fetchLPPositions() {
|
|
|
2570
2673
|
return _context3.abrupt("return", {
|
|
2571
2674
|
token0: values[0],
|
|
2572
2675
|
token1: values[1],
|
|
2573
|
-
reserve0: values[2].
|
|
2574
|
-
reserve1: values[2].
|
|
2676
|
+
reserve0: values[2].reserve0,
|
|
2677
|
+
reserve1: values[2].reserve1,
|
|
2575
2678
|
totalSupply: values[3]
|
|
2576
2679
|
});
|
|
2577
2680
|
|
|
@@ -2654,14 +2757,15 @@ function _fetchPriceFromOracle() {
|
|
|
2654
2757
|
switch (_context5.prev = _context5.next) {
|
|
2655
2758
|
case 0:
|
|
2656
2759
|
oracleContract = new Contract(networkAddresses.misc.oracle, OracleABI.abi, provider);
|
|
2657
|
-
|
|
2760
|
+
console.log(oracleContract.address, auTokenAddress);
|
|
2761
|
+
_context5.next = 4;
|
|
2658
2762
|
return oracleContract.getUnderlyingPrice(auTokenAddress);
|
|
2659
2763
|
|
|
2660
|
-
case
|
|
2764
|
+
case 4:
|
|
2661
2765
|
rawPrice = _context5.sent;
|
|
2662
2766
|
return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
|
|
2663
2767
|
|
|
2664
|
-
case
|
|
2768
|
+
case 6:
|
|
2665
2769
|
case "end":
|
|
2666
2770
|
return _context5.stop();
|
|
2667
2771
|
}
|
|
@@ -2742,7 +2846,7 @@ function _fetchPrice() {
|
|
|
2742
2846
|
return _context7.abrupt("return", fetchLPPrice(address, provider));
|
|
2743
2847
|
|
|
2744
2848
|
case 9:
|
|
2745
|
-
return _context7.abrupt("return",
|
|
2849
|
+
return _context7.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2746
2850
|
|
|
2747
2851
|
case 10:
|
|
2748
2852
|
case "end":
|
|
@@ -3205,5 +3309,5 @@ var dummyUserMarketDetails = {
|
|
|
3205
3309
|
maxWithdrawableAmount: dummyTokenAmount
|
|
3206
3310
|
};
|
|
3207
3311
|
|
|
3208
|
-
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,
|
|
3312
|
+
export { AURORA_CHAINID, AURORA_DEFAULT_PROVIDER, AURORA_DEFAULT_PROVIDER_URL, 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 };
|
|
3209
3313
|
//# sourceMappingURL=sdk.esm.js.map
|