@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/MoneyMarket.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export declare class MoneyMarketRead extends BlockchainEntityRead {
|
|
|
15
15
|
getDepositAPY(): Promise<BigNumber>;
|
|
16
16
|
getBorrowAPY(): Promise<BigNumber>;
|
|
17
17
|
getCollateralRatio(): Promise<BigNumber>;
|
|
18
|
+
getBorrowPlyAPY(): Promise<BigNumber>;
|
|
19
|
+
getDepositPlyAPY(): Promise<BigNumber>;
|
|
18
20
|
getDetails(): Promise<MoneyMarketDetails>;
|
|
19
21
|
getUserBorrowBalance(userAddress: string): Promise<TokenAmount>;
|
|
20
22
|
getUserDepositBalance(userAddress: string): Promise<TokenAmount>;
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import BigNumber from 'bignumber.js';
|
|
|
2
2
|
import { Signer } from 'ethers';
|
|
3
3
|
export declare const AVAX_DEFAULT_PROVIDER_URL = "https://api.avax.network/ext/bc/C/rpc";
|
|
4
4
|
export declare const AVAX_DEFAULT_PROVIDER: any;
|
|
5
|
+
export declare const AURORA_DEFAULT_PROVIDER_URL = "https://testnet.aurora.dev";
|
|
6
|
+
export declare const AURORA_DEFAULT_PROVIDER: any;
|
|
5
7
|
export declare const dummyAddress: string;
|
|
6
8
|
export declare const ETHAddress: string;
|
|
7
9
|
export declare const AVAX_DEFAULT_SIGNER: Signer;
|
|
@@ -19,4 +21,5 @@ export declare const networkAddresses: NetworkAddresses;
|
|
|
19
21
|
export declare const BORROW_LIMIT_BUFFER: BigNumber;
|
|
20
22
|
export declare const REWARDCLAIMSTART = 1673280000;
|
|
21
23
|
export declare const ONE_DAY = 86400;
|
|
24
|
+
export declare const ONE_YEAR: number;
|
|
22
25
|
export declare const AurPlyPid = 1;
|
package/dist/priceFetcher.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import BigNumber from "bignumber.js";
|
|
|
2
2
|
import { providers, BigNumber as BN } from "ethers";
|
|
3
3
|
import { TokenAmount } from "./tokenAmount";
|
|
4
4
|
import { Address } from "./types";
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
5
|
+
export declare function fetchPriceFromCoingeckoAPI(id: string): Promise<BigNumber>;
|
|
6
|
+
export declare function fetchPriceFromCoingecko(address: Address): Promise<BigNumber>;
|
|
7
7
|
export declare function fetchLPPositions(LPAddress: Address, provider: providers.Provider): Promise<{
|
|
8
8
|
token0: Address;
|
|
9
9
|
token1: Address;
|
|
@@ -899,6 +899,8 @@ var ethers = /*#__PURE__*/require('ethers');
|
|
|
899
899
|
|
|
900
900
|
var AVAX_DEFAULT_PROVIDER_URL = 'https://api.avax.network/ext/bc/C/rpc';
|
|
901
901
|
var AVAX_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AVAX_DEFAULT_PROVIDER_URL);
|
|
902
|
+
var AURORA_DEFAULT_PROVIDER_URL = "https://testnet.aurora.dev";
|
|
903
|
+
var AURORA_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AURORA_DEFAULT_PROVIDER_URL);
|
|
902
904
|
var dummyAddress = "0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE";
|
|
903
905
|
var ETHAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
904
906
|
var dummyPrivateKey = '1111111111111111111111111111111111111111111111111111111111111111';
|
|
@@ -946,6 +948,7 @@ var networkAddresses = {
|
|
|
946
948
|
var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(0.95);
|
|
947
949
|
var REWARDCLAIMSTART = 1673280000;
|
|
948
950
|
var ONE_DAY = 86400;
|
|
951
|
+
var ONE_YEAR = ONE_DAY * 365;
|
|
949
952
|
var AurPlyPid = 1;
|
|
950
953
|
|
|
951
954
|
var decimalRecords = {
|
|
@@ -1025,6 +1028,11 @@ function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
|
|
|
1025
1028
|
return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
|
|
1026
1029
|
}
|
|
1027
1030
|
|
|
1031
|
+
(function (ComptrollerRewardType) {
|
|
1032
|
+
ComptrollerRewardType[ComptrollerRewardType["PLY"] = 0] = "PLY";
|
|
1033
|
+
ComptrollerRewardType[ComptrollerRewardType["AURORA"] = 1] = "AURORA";
|
|
1034
|
+
})(exports.ComptrollerRewardType || (exports.ComptrollerRewardType = {}));
|
|
1035
|
+
|
|
1028
1036
|
var Token = function Token(address, decimals) {
|
|
1029
1037
|
this.address = address.toLowerCase();
|
|
1030
1038
|
this.decimals = decimals;
|
|
@@ -1131,7 +1139,7 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1131
1139
|
return Promise.all(promises);
|
|
1132
1140
|
|
|
1133
1141
|
case 5:
|
|
1134
|
-
return _context2.abrupt("return", new TokenAmount(this.underlying, ethers$1.BigNumber.from(totalCash.rawAmount).add(totalBorrow.rawAmount()).toString()));
|
|
1142
|
+
return _context2.abrupt("return", new TokenAmount(this.underlying, ethers$1.BigNumber.from(totalCash.rawAmount()).add(totalBorrow.rawAmount()).toString()));
|
|
1135
1143
|
|
|
1136
1144
|
case 6:
|
|
1137
1145
|
case "end":
|
|
@@ -1231,12 +1239,94 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1231
1239
|
return getCollateralRatio;
|
|
1232
1240
|
}();
|
|
1233
1241
|
|
|
1234
|
-
_proto.
|
|
1235
|
-
var
|
|
1236
|
-
var promises,
|
|
1242
|
+
_proto.getBorrowPlyAPY = /*#__PURE__*/function () {
|
|
1243
|
+
var _getBorrowPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
1244
|
+
var promises, totalBorrowed, rewardSpeed, plyPrice, underlyingPrice;
|
|
1237
1245
|
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1238
1246
|
while (1) {
|
|
1239
1247
|
switch (_context6.prev = _context6.next) {
|
|
1248
|
+
case 0:
|
|
1249
|
+
promises = [];
|
|
1250
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
1251
|
+
totalBorrowed = res;
|
|
1252
|
+
}));
|
|
1253
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1254
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1255
|
+
}));
|
|
1256
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1257
|
+
plyPrice = res;
|
|
1258
|
+
}));
|
|
1259
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1260
|
+
underlyingPrice = res;
|
|
1261
|
+
}));
|
|
1262
|
+
_context6.next = 7;
|
|
1263
|
+
return Promise.all(promises);
|
|
1264
|
+
|
|
1265
|
+
case 7:
|
|
1266
|
+
return _context6.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR));
|
|
1267
|
+
|
|
1268
|
+
case 8:
|
|
1269
|
+
case "end":
|
|
1270
|
+
return _context6.stop();
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}, _callee6, this);
|
|
1274
|
+
}));
|
|
1275
|
+
|
|
1276
|
+
function getBorrowPlyAPY() {
|
|
1277
|
+
return _getBorrowPlyAPY.apply(this, arguments);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
return getBorrowPlyAPY;
|
|
1281
|
+
}();
|
|
1282
|
+
|
|
1283
|
+
_proto.getDepositPlyAPY = /*#__PURE__*/function () {
|
|
1284
|
+
var _getDepositPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
1285
|
+
var promises, totalDeposited, rewardSpeed, plyPrice, underlyingPrice;
|
|
1286
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
1287
|
+
while (1) {
|
|
1288
|
+
switch (_context7.prev = _context7.next) {
|
|
1289
|
+
case 0:
|
|
1290
|
+
promises = [];
|
|
1291
|
+
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
1292
|
+
totalDeposited = res;
|
|
1293
|
+
}));
|
|
1294
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1295
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1296
|
+
}));
|
|
1297
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1298
|
+
plyPrice = res;
|
|
1299
|
+
}));
|
|
1300
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1301
|
+
underlyingPrice = res;
|
|
1302
|
+
}));
|
|
1303
|
+
_context7.next = 7;
|
|
1304
|
+
return Promise.all(promises);
|
|
1305
|
+
|
|
1306
|
+
case 7:
|
|
1307
|
+
return _context7.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR));
|
|
1308
|
+
|
|
1309
|
+
case 8:
|
|
1310
|
+
case "end":
|
|
1311
|
+
return _context7.stop();
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}, _callee7, this);
|
|
1315
|
+
}));
|
|
1316
|
+
|
|
1317
|
+
function getDepositPlyAPY() {
|
|
1318
|
+
return _getDepositPlyAPY.apply(this, arguments);
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
return getDepositPlyAPY;
|
|
1322
|
+
}();
|
|
1323
|
+
|
|
1324
|
+
_proto.getDetails = /*#__PURE__*/function () {
|
|
1325
|
+
var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
1326
|
+
var promises, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeed, plyPrice, underlyingPrice, borrowPlyApy, depositPlyApy;
|
|
1327
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
1328
|
+
while (1) {
|
|
1329
|
+
switch (_context8.prev = _context8.next) {
|
|
1240
1330
|
case 0:
|
|
1241
1331
|
promises = [];
|
|
1242
1332
|
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
@@ -1254,27 +1344,38 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1254
1344
|
promises.push(this.getCollateralRatio().then(function (res) {
|
|
1255
1345
|
collateralRatio = res.toNumber();
|
|
1256
1346
|
}));
|
|
1257
|
-
|
|
1347
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1348
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1349
|
+
}));
|
|
1350
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1351
|
+
plyPrice = res;
|
|
1352
|
+
}));
|
|
1353
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1354
|
+
underlyingPrice = res;
|
|
1355
|
+
}));
|
|
1356
|
+
_context8.next = 11;
|
|
1258
1357
|
return Promise.all(promises);
|
|
1259
1358
|
|
|
1260
|
-
case
|
|
1261
|
-
|
|
1359
|
+
case 11:
|
|
1360
|
+
borrowPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR);
|
|
1361
|
+
depositPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR);
|
|
1362
|
+
return _context8.abrupt("return", {
|
|
1262
1363
|
auTokenAddress: this.auToken.address,
|
|
1263
1364
|
totalTokenDeposited: totalDeposited,
|
|
1264
1365
|
totalTokenBorrowed: totalBorrowed,
|
|
1265
1366
|
depositApy: depositAPY,
|
|
1266
|
-
depositPlyApy:
|
|
1367
|
+
depositPlyApy: depositPlyApy.toNumber(),
|
|
1267
1368
|
borrowApy: borrowAPY,
|
|
1268
|
-
borrowPlyApy:
|
|
1369
|
+
borrowPlyApy: borrowPlyApy.toNumber(),
|
|
1269
1370
|
collateralRatio: collateralRatio
|
|
1270
1371
|
});
|
|
1271
1372
|
|
|
1272
|
-
case
|
|
1373
|
+
case 14:
|
|
1273
1374
|
case "end":
|
|
1274
|
-
return
|
|
1375
|
+
return _context8.stop();
|
|
1275
1376
|
}
|
|
1276
1377
|
}
|
|
1277
|
-
},
|
|
1378
|
+
}, _callee8, this);
|
|
1278
1379
|
}));
|
|
1279
1380
|
|
|
1280
1381
|
function getDetails() {
|
|
@@ -1285,25 +1386,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1285
1386
|
}();
|
|
1286
1387
|
|
|
1287
1388
|
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
1288
|
-
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1389
|
+
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(userAddress) {
|
|
1289
1390
|
var totalBorrow;
|
|
1290
|
-
return runtime_1.wrap(function
|
|
1391
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
1291
1392
|
while (1) {
|
|
1292
|
-
switch (
|
|
1393
|
+
switch (_context9.prev = _context9.next) {
|
|
1293
1394
|
case 0:
|
|
1294
|
-
|
|
1395
|
+
_context9.next = 2;
|
|
1295
1396
|
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
1296
1397
|
|
|
1297
1398
|
case 2:
|
|
1298
|
-
totalBorrow =
|
|
1299
|
-
return
|
|
1399
|
+
totalBorrow = _context9.sent;
|
|
1400
|
+
return _context9.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
1300
1401
|
|
|
1301
1402
|
case 4:
|
|
1302
1403
|
case "end":
|
|
1303
|
-
return
|
|
1404
|
+
return _context9.stop();
|
|
1304
1405
|
}
|
|
1305
1406
|
}
|
|
1306
|
-
},
|
|
1407
|
+
}, _callee9, this);
|
|
1307
1408
|
}));
|
|
1308
1409
|
|
|
1309
1410
|
function getUserBorrowBalance(_x) {
|
|
@@ -1314,25 +1415,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1314
1415
|
}();
|
|
1315
1416
|
|
|
1316
1417
|
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
1317
|
-
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1418
|
+
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(userAddress) {
|
|
1318
1419
|
var totalDeposit;
|
|
1319
|
-
return runtime_1.wrap(function
|
|
1420
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
1320
1421
|
while (1) {
|
|
1321
|
-
switch (
|
|
1422
|
+
switch (_context10.prev = _context10.next) {
|
|
1322
1423
|
case 0:
|
|
1323
|
-
|
|
1424
|
+
_context10.next = 2;
|
|
1324
1425
|
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
1325
1426
|
|
|
1326
1427
|
case 2:
|
|
1327
|
-
totalDeposit =
|
|
1328
|
-
return
|
|
1428
|
+
totalDeposit = _context10.sent;
|
|
1429
|
+
return _context10.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
1329
1430
|
|
|
1330
1431
|
case 4:
|
|
1331
1432
|
case "end":
|
|
1332
|
-
return
|
|
1433
|
+
return _context10.stop();
|
|
1333
1434
|
}
|
|
1334
1435
|
}
|
|
1335
|
-
},
|
|
1436
|
+
}, _callee10, this);
|
|
1336
1437
|
}));
|
|
1337
1438
|
|
|
1338
1439
|
function getUserDepositBalance(_x2) {
|
|
@@ -1354,29 +1455,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1354
1455
|
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
1355
1456
|
|
|
1356
1457
|
_proto2.deposit = /*#__PURE__*/function () {
|
|
1357
|
-
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1358
|
-
return runtime_1.wrap(function
|
|
1458
|
+
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(amount) {
|
|
1459
|
+
return runtime_1.wrap(function _callee11$(_context11) {
|
|
1359
1460
|
while (1) {
|
|
1360
|
-
switch (
|
|
1461
|
+
switch (_context11.prev = _context11.next) {
|
|
1361
1462
|
case 0:
|
|
1362
1463
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1363
|
-
|
|
1464
|
+
_context11.next = 4;
|
|
1364
1465
|
break;
|
|
1365
1466
|
}
|
|
1366
1467
|
|
|
1367
|
-
return
|
|
1468
|
+
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
1368
1469
|
value: amount.rawAmount()
|
|
1369
1470
|
}));
|
|
1370
1471
|
|
|
1371
1472
|
case 4:
|
|
1372
|
-
return
|
|
1473
|
+
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
1373
1474
|
|
|
1374
1475
|
case 5:
|
|
1375
1476
|
case "end":
|
|
1376
|
-
return
|
|
1477
|
+
return _context11.stop();
|
|
1377
1478
|
}
|
|
1378
1479
|
}
|
|
1379
|
-
},
|
|
1480
|
+
}, _callee11, this);
|
|
1380
1481
|
}));
|
|
1381
1482
|
|
|
1382
1483
|
function deposit(_x3) {
|
|
@@ -1387,19 +1488,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1387
1488
|
}();
|
|
1388
1489
|
|
|
1389
1490
|
_proto2.borrow = /*#__PURE__*/function () {
|
|
1390
|
-
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1391
|
-
return runtime_1.wrap(function
|
|
1491
|
+
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
|
|
1492
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
1392
1493
|
while (1) {
|
|
1393
|
-
switch (
|
|
1494
|
+
switch (_context12.prev = _context12.next) {
|
|
1394
1495
|
case 0:
|
|
1395
|
-
return
|
|
1496
|
+
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
1396
1497
|
|
|
1397
1498
|
case 1:
|
|
1398
1499
|
case "end":
|
|
1399
|
-
return
|
|
1500
|
+
return _context12.stop();
|
|
1400
1501
|
}
|
|
1401
1502
|
}
|
|
1402
|
-
},
|
|
1503
|
+
}, _callee12, this);
|
|
1403
1504
|
}));
|
|
1404
1505
|
|
|
1405
1506
|
function borrow(_x4) {
|
|
@@ -1410,19 +1511,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1410
1511
|
}();
|
|
1411
1512
|
|
|
1412
1513
|
_proto2.withdraw = /*#__PURE__*/function () {
|
|
1413
|
-
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1414
|
-
return runtime_1.wrap(function
|
|
1514
|
+
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(amount) {
|
|
1515
|
+
return runtime_1.wrap(function _callee13$(_context13) {
|
|
1415
1516
|
while (1) {
|
|
1416
|
-
switch (
|
|
1517
|
+
switch (_context13.prev = _context13.next) {
|
|
1417
1518
|
case 0:
|
|
1418
|
-
return
|
|
1519
|
+
return _context13.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
1419
1520
|
|
|
1420
1521
|
case 1:
|
|
1421
1522
|
case "end":
|
|
1422
|
-
return
|
|
1523
|
+
return _context13.stop();
|
|
1423
1524
|
}
|
|
1424
1525
|
}
|
|
1425
|
-
},
|
|
1526
|
+
}, _callee13, this);
|
|
1426
1527
|
}));
|
|
1427
1528
|
|
|
1428
1529
|
function withdraw(_x5) {
|
|
@@ -1433,29 +1534,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1433
1534
|
}();
|
|
1434
1535
|
|
|
1435
1536
|
_proto2.repay = /*#__PURE__*/function () {
|
|
1436
|
-
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1437
|
-
return runtime_1.wrap(function
|
|
1537
|
+
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
|
|
1538
|
+
return runtime_1.wrap(function _callee14$(_context14) {
|
|
1438
1539
|
while (1) {
|
|
1439
|
-
switch (
|
|
1540
|
+
switch (_context14.prev = _context14.next) {
|
|
1440
1541
|
case 0:
|
|
1441
1542
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1442
|
-
|
|
1543
|
+
_context14.next = 4;
|
|
1443
1544
|
break;
|
|
1444
1545
|
}
|
|
1445
1546
|
|
|
1446
|
-
return
|
|
1547
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
1447
1548
|
value: amount.rawAmount()
|
|
1448
1549
|
}));
|
|
1449
1550
|
|
|
1450
1551
|
case 4:
|
|
1451
|
-
return
|
|
1552
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
1452
1553
|
|
|
1453
1554
|
case 5:
|
|
1454
1555
|
case "end":
|
|
1455
|
-
return
|
|
1556
|
+
return _context14.stop();
|
|
1456
1557
|
}
|
|
1457
1558
|
}
|
|
1458
|
-
},
|
|
1559
|
+
}, _callee14, this);
|
|
1459
1560
|
}));
|
|
1460
1561
|
|
|
1461
1562
|
function repay(_x6) {
|
|
@@ -1466,19 +1567,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1466
1567
|
}();
|
|
1467
1568
|
|
|
1468
1569
|
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
1469
|
-
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1470
|
-
return runtime_1.wrap(function
|
|
1570
|
+
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15() {
|
|
1571
|
+
return runtime_1.wrap(function _callee15$(_context15) {
|
|
1471
1572
|
while (1) {
|
|
1472
|
-
switch (
|
|
1573
|
+
switch (_context15.prev = _context15.next) {
|
|
1473
1574
|
case 0:
|
|
1474
|
-
return
|
|
1575
|
+
return _context15.abrupt("return", this._comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
1475
1576
|
|
|
1476
1577
|
case 1:
|
|
1477
1578
|
case "end":
|
|
1478
|
-
return
|
|
1579
|
+
return _context15.stop();
|
|
1479
1580
|
}
|
|
1480
1581
|
}
|
|
1481
|
-
},
|
|
1582
|
+
}, _callee15, this);
|
|
1482
1583
|
}));
|
|
1483
1584
|
|
|
1484
1585
|
function enableCollateral() {
|
|
@@ -1489,19 +1590,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
1489
1590
|
}();
|
|
1490
1591
|
|
|
1491
1592
|
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
1492
|
-
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1493
|
-
return runtime_1.wrap(function
|
|
1593
|
+
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
|
|
1594
|
+
return runtime_1.wrap(function _callee16$(_context16) {
|
|
1494
1595
|
while (1) {
|
|
1495
|
-
switch (
|
|
1596
|
+
switch (_context16.prev = _context16.next) {
|
|
1496
1597
|
case 0:
|
|
1497
|
-
return
|
|
1598
|
+
return _context16.abrupt("return", this._comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
1498
1599
|
|
|
1499
1600
|
case 1:
|
|
1500
1601
|
case "end":
|
|
1501
|
-
return
|
|
1602
|
+
return _context16.stop();
|
|
1502
1603
|
}
|
|
1503
1604
|
}
|
|
1504
|
-
},
|
|
1605
|
+
}, _callee16, this);
|
|
1505
1606
|
}));
|
|
1506
1607
|
|
|
1507
1608
|
function disableCollateral() {
|
|
@@ -2491,12 +2592,12 @@ var dummyABI = {
|
|
|
2491
2592
|
|
|
2492
2593
|
var axios = /*#__PURE__*/require('axios');
|
|
2493
2594
|
|
|
2494
|
-
function
|
|
2495
|
-
return
|
|
2595
|
+
function fetchPriceFromCoingeckoAPI(_x) {
|
|
2596
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2496
2597
|
}
|
|
2497
2598
|
|
|
2498
|
-
function
|
|
2499
|
-
|
|
2599
|
+
function _fetchPriceFromCoingeckoAPI() {
|
|
2600
|
+
_fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
|
|
2500
2601
|
var price;
|
|
2501
2602
|
return runtime_1.wrap(function _callee$(_context) {
|
|
2502
2603
|
while (1) {
|
|
@@ -2518,15 +2619,15 @@ function _fetchPriceFromCoingecko() {
|
|
|
2518
2619
|
}
|
|
2519
2620
|
}, _callee);
|
|
2520
2621
|
}));
|
|
2521
|
-
return
|
|
2622
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2522
2623
|
}
|
|
2523
2624
|
|
|
2524
|
-
function
|
|
2525
|
-
return
|
|
2625
|
+
function fetchPriceFromCoingecko(_x2) {
|
|
2626
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2526
2627
|
}
|
|
2527
2628
|
|
|
2528
|
-
function
|
|
2529
|
-
|
|
2629
|
+
function _fetchPriceFromCoingecko() {
|
|
2630
|
+
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(address) {
|
|
2530
2631
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2531
2632
|
while (1) {
|
|
2532
2633
|
switch (_context2.prev = _context2.next) {
|
|
@@ -2536,10 +2637,10 @@ function _fetchBasicTokenPrice() {
|
|
|
2536
2637
|
break;
|
|
2537
2638
|
}
|
|
2538
2639
|
|
|
2539
|
-
return _context2.abrupt("return",
|
|
2640
|
+
return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
|
|
2540
2641
|
|
|
2541
2642
|
case 4:
|
|
2542
|
-
throw Error("Unknown token " + address + " in
|
|
2643
|
+
throw Error("Unknown token " + address + " in fetchPriceFromCoingecko");
|
|
2543
2644
|
|
|
2544
2645
|
case 5:
|
|
2545
2646
|
case "end":
|
|
@@ -2548,7 +2649,7 @@ function _fetchBasicTokenPrice() {
|
|
|
2548
2649
|
}
|
|
2549
2650
|
}, _callee2);
|
|
2550
2651
|
}));
|
|
2551
|
-
return
|
|
2652
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2552
2653
|
}
|
|
2553
2654
|
|
|
2554
2655
|
function fetchLPPositions(_x3, _x4) {
|
|
@@ -2576,8 +2677,8 @@ function _fetchLPPositions() {
|
|
|
2576
2677
|
return _context3.abrupt("return", {
|
|
2577
2678
|
token0: values[0],
|
|
2578
2679
|
token1: values[1],
|
|
2579
|
-
reserve0: values[2].
|
|
2580
|
-
reserve1: values[2].
|
|
2680
|
+
reserve0: values[2].reserve0,
|
|
2681
|
+
reserve1: values[2].reserve1,
|
|
2581
2682
|
totalSupply: values[3]
|
|
2582
2683
|
});
|
|
2583
2684
|
|
|
@@ -2660,14 +2761,15 @@ function _fetchPriceFromOracle() {
|
|
|
2660
2761
|
switch (_context5.prev = _context5.next) {
|
|
2661
2762
|
case 0:
|
|
2662
2763
|
oracleContract = new ethers$1.Contract(networkAddresses.misc.oracle, OracleABI.abi, provider);
|
|
2663
|
-
|
|
2764
|
+
console.log(oracleContract.address, auTokenAddress);
|
|
2765
|
+
_context5.next = 4;
|
|
2664
2766
|
return oracleContract.getUnderlyingPrice(auTokenAddress);
|
|
2665
2767
|
|
|
2666
|
-
case
|
|
2768
|
+
case 4:
|
|
2667
2769
|
rawPrice = _context5.sent;
|
|
2668
2770
|
return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
|
|
2669
2771
|
|
|
2670
|
-
case
|
|
2772
|
+
case 6:
|
|
2671
2773
|
case "end":
|
|
2672
2774
|
return _context5.stop();
|
|
2673
2775
|
}
|
|
@@ -2748,7 +2850,7 @@ function _fetchPrice() {
|
|
|
2748
2850
|
return _context7.abrupt("return", fetchLPPrice(address, provider));
|
|
2749
2851
|
|
|
2750
2852
|
case 9:
|
|
2751
|
-
return _context7.abrupt("return",
|
|
2853
|
+
return _context7.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2752
2854
|
|
|
2753
2855
|
case 10:
|
|
2754
2856
|
case "end":
|
|
@@ -3212,6 +3314,8 @@ var dummyUserMarketDetails = {
|
|
|
3212
3314
|
};
|
|
3213
3315
|
|
|
3214
3316
|
exports.AURORA_CHAINID = AURORA_CHAINID;
|
|
3317
|
+
exports.AURORA_DEFAULT_PROVIDER = AURORA_DEFAULT_PROVIDER;
|
|
3318
|
+
exports.AURORA_DEFAULT_PROVIDER_URL = AURORA_DEFAULT_PROVIDER_URL;
|
|
3215
3319
|
exports.AURPLYToken = AURPLYToken;
|
|
3216
3320
|
exports.AVAX_DEFAULT_PROVIDER = AVAX_DEFAULT_PROVIDER;
|
|
3217
3321
|
exports.AVAX_DEFAULT_PROVIDER_URL = AVAX_DEFAULT_PROVIDER_URL;
|
|
@@ -3227,6 +3331,7 @@ exports.MoneyMarket = MoneyMarket;
|
|
|
3227
3331
|
exports.MoneyMarketRead = MoneyMarketRead;
|
|
3228
3332
|
exports.MoneyMarketReadWrite = MoneyMarketReadWrite;
|
|
3229
3333
|
exports.ONE_DAY = ONE_DAY;
|
|
3334
|
+
exports.ONE_YEAR = ONE_YEAR;
|
|
3230
3335
|
exports.PLYToken = PLYToken;
|
|
3231
3336
|
exports.REWARDCLAIMSTART = REWARDCLAIMSTART;
|
|
3232
3337
|
exports.SDK = SDK;
|
|
@@ -3246,11 +3351,11 @@ exports.dummyTokenAmount2 = dummyTokenAmount2;
|
|
|
3246
3351
|
exports.dummyTokenAmount3 = dummyTokenAmount3;
|
|
3247
3352
|
exports.dummyUserMarketDetails = dummyUserMarketDetails;
|
|
3248
3353
|
exports.dummyZeroTokenAmount = dummyZeroTokenAmount;
|
|
3249
|
-
exports.fetchBasicTokenPrice = fetchBasicTokenPrice;
|
|
3250
3354
|
exports.fetchLPPositions = fetchLPPositions;
|
|
3251
3355
|
exports.fetchLPPrice = fetchLPPrice;
|
|
3252
3356
|
exports.fetchPrice = fetchPrice;
|
|
3253
3357
|
exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
|
|
3358
|
+
exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
|
|
3254
3359
|
exports.fetchPriceFromOracle = fetchPriceFromOracle;
|
|
3255
3360
|
exports.fetchUnderlyingTokensPrices = fetchUnderlyingTokensPrices;
|
|
3256
3361
|
exports.fetchValuation = fetchValuation;
|