@aurigami/sdk 0.2.6 → 0.3.0
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 +11 -1
- package/dist/constants.d.ts +3 -3
- package/dist/sdk.cjs.development.js +961 -902
- 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 +961 -902
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/MoneyMarket.ts +55 -18
- package/src/SDK.ts +10 -8
- package/src/constants.ts +27 -35
- package/src/decimals.ts +16 -16
- package/src/helpers.ts +4 -3
- package/src/priceFetcher.ts +4 -2
|
@@ -10,6 +10,7 @@ var ethers$1 = require('ethers');
|
|
|
10
10
|
var AuErc20ABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json'));
|
|
11
11
|
var AuETHABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json'));
|
|
12
12
|
var ComptrollerABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json'));
|
|
13
|
+
var AuriLensABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json'));
|
|
13
14
|
var TokenLockABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/TokenLock.sol/TokenLock.json'));
|
|
14
15
|
var AuriFairLaunchABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json'));
|
|
15
16
|
|
|
@@ -904,70 +905,71 @@ var AURORA_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(
|
|
|
904
905
|
var dummyAddress = "0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE";
|
|
905
906
|
var ETHAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
906
907
|
var dummyPrivateKey = '1111111111111111111111111111111111111111111111111111111111111111';
|
|
907
|
-
var
|
|
908
|
+
var AURORA_DEFAULT_SIGNER = /*#__PURE__*/new ethers.Wallet(dummyPrivateKey, AURORA_DEFAULT_PROVIDER);
|
|
908
909
|
var AURORA_CHAINID = 1313161554;
|
|
909
910
|
var DECIMAL_PRECISION = 6;
|
|
910
911
|
var networkAddresses = {
|
|
911
912
|
auTokens: [{
|
|
912
|
-
address: '
|
|
913
|
-
underlying: '
|
|
913
|
+
address: /*#__PURE__*/'0xA21d86e113f161fa05d3cf767ef19Ccec1BD4889'.toLowerCase(),
|
|
914
|
+
underlying: /*#__PURE__*/'0x9Daf3f62cE9e53B8cd850a1ad392b632eAF7419F'.toLowerCase()
|
|
914
915
|
}, {
|
|
915
|
-
address: '
|
|
916
|
-
underlying: ETHAddress
|
|
916
|
+
address: /*#__PURE__*/'0xFa4A1B4137B66d69E5af8a0f63591D62A8c14446'.toLowerCase(),
|
|
917
|
+
underlying: /*#__PURE__*/ETHAddress.toLowerCase()
|
|
917
918
|
}, {
|
|
918
|
-
address: '
|
|
919
|
-
underlying: '
|
|
919
|
+
address: /*#__PURE__*/'0x1B8A94C4C9A1496E274B153e0756F1836AeaBB30'.toLowerCase(),
|
|
920
|
+
underlying: /*#__PURE__*/'0x68862668FEdd002dA008596A56C5ea29921E94e6'.toLowerCase()
|
|
920
921
|
}, {
|
|
921
|
-
address: '
|
|
922
|
-
underlying: '
|
|
922
|
+
address: /*#__PURE__*/'0x5f8E0b6b049fecabC16AD7d23b5F311c48555fA6'.toLowerCase(),
|
|
923
|
+
underlying: /*#__PURE__*/'0xc0a00D761E569007a707aA84A9A08837cb6A04c1'.toLowerCase()
|
|
923
924
|
}, {
|
|
924
|
-
address: '
|
|
925
|
-
underlying: '
|
|
925
|
+
address: /*#__PURE__*/'0xeee0A0BC4dc3999136f35f82DdaAC3c27Ed05017'.toLowerCase(),
|
|
926
|
+
underlying: /*#__PURE__*/'0x5231CfaF5BD3Aa0C9423703a72706B2D40f0b783'.toLowerCase()
|
|
926
927
|
}, {
|
|
927
|
-
address: '
|
|
928
|
-
underlying: '
|
|
928
|
+
address: /*#__PURE__*/'0x9Fc4f60DC140645978C53703acE6241448cFEaA8'.toLowerCase(),
|
|
929
|
+
underlying: /*#__PURE__*/'0xf7c51293c5eE5c76867d8Cf400627627a4Bd8697'.toLowerCase()
|
|
929
930
|
}, {
|
|
930
|
-
address: '
|
|
931
|
-
underlying: '
|
|
931
|
+
address: /*#__PURE__*/'0x533dBEC840f10f51B868453f86BDF211Fbc52Ba4'.toLowerCase(),
|
|
932
|
+
underlying: /*#__PURE__*/'0xaa847c16359bAA930ba8a5E8b6e41D6b63ABe505'.toLowerCase()
|
|
932
933
|
}, {
|
|
933
|
-
address: '
|
|
934
|
-
underlying: '
|
|
934
|
+
address: /*#__PURE__*/'0xDA748E324F4e05e1D9f517242C928A01C418c910'.toLowerCase(),
|
|
935
|
+
underlying: /*#__PURE__*/'0x206EA0Ae49F80d0376d04932479e33Cf2098211A'.toLowerCase()
|
|
935
936
|
}],
|
|
936
937
|
misc: {
|
|
937
|
-
COMPTROLLER: "
|
|
938
|
-
oracle: "
|
|
939
|
-
AURIFAIRLAUNCH: "
|
|
940
|
-
AURILENS: '
|
|
938
|
+
COMPTROLLER: /*#__PURE__*/"0x77499F2F82cF45F34287816875794363098cD3e1".toLowerCase(),
|
|
939
|
+
oracle: /*#__PURE__*/"0x38d71afF809941Cd67938f44a827E11F322e8859".toLowerCase(),
|
|
940
|
+
AURIFAIRLAUNCH: /*#__PURE__*/"0x7B0a44390d6be7772438767c392868Db493f85e5".toLowerCase(),
|
|
941
|
+
AURILENS: /*#__PURE__*/'0xF48698990DaEA17a5efAca49293e68c589E292D4'.toLowerCase(),
|
|
942
|
+
TOKENLOCK: /*#__PURE__*/'0x5D2Be450734e880776D21942A6297F6492A35cfD'.toLowerCase()
|
|
941
943
|
},
|
|
942
944
|
tokens: {
|
|
943
|
-
AURORA: "
|
|
944
|
-
PLY: "
|
|
945
|
-
AURPLY: dummyAddress
|
|
945
|
+
AURORA: /*#__PURE__*/"0xf7c51293c5eE5c76867d8Cf400627627a4Bd8697".toLowerCase(),
|
|
946
|
+
PLY: /*#__PURE__*/"0x206EA0Ae49F80d0376d04932479e33Cf2098211A".toLowerCase(),
|
|
947
|
+
AURPLY: /*#__PURE__*/dummyAddress.toLowerCase()
|
|
946
948
|
}
|
|
947
949
|
};
|
|
948
950
|
var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(0.95);
|
|
949
|
-
var REWARDCLAIMSTART =
|
|
951
|
+
var REWARDCLAIMSTART = 1640995200;
|
|
950
952
|
var ONE_DAY = 86400;
|
|
951
953
|
var ONE_YEAR = ONE_DAY * 365;
|
|
952
|
-
var AurPlyPid =
|
|
954
|
+
var AurPlyPid = 0;
|
|
953
955
|
|
|
954
956
|
var decimalRecords = {
|
|
955
957
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
|
|
956
|
-
'
|
|
957
|
-
'
|
|
958
|
-
'
|
|
959
|
-
'
|
|
960
|
-
'
|
|
961
|
-
'
|
|
962
|
-
'
|
|
963
|
-
'
|
|
964
|
-
'
|
|
965
|
-
'
|
|
966
|
-
'
|
|
967
|
-
'
|
|
968
|
-
'
|
|
969
|
-
'
|
|
970
|
-
'
|
|
958
|
+
'0x5231cfaf5bd3aa0c9423703a72706b2d40f0b783': 18,
|
|
959
|
+
'0x5f8e0b6b049fecabc16ad7d23b5f311c48555fa6': 8,
|
|
960
|
+
'0xfa4a1b4137b66d69e5af8a0f63591d62a8c14446': 8,
|
|
961
|
+
'0xa21d86e113f161fa05d3cf767ef19ccec1bd4889': 8,
|
|
962
|
+
'0xf7c51293c5ee5c76867d8cf400627627a4bd8697': 18,
|
|
963
|
+
'0xc0a00d761e569007a707aa84a9a08837cb6a04c1': 18,
|
|
964
|
+
'0x206ea0ae49f80d0376d04932479e33cf2098211a': 18,
|
|
965
|
+
'0x9fc4f60dc140645978c53703ace6241448cfeaa8': 8,
|
|
966
|
+
'0xeee0a0bc4dc3999136f35f82ddaac3c27ed05017': 8,
|
|
967
|
+
'0x1b8a94c4c9a1496e274b153e0756f1836aeabb30': 8,
|
|
968
|
+
'0x533dbec840f10f51b868453f86bdf211fbc52ba4': 8,
|
|
969
|
+
'0xaa847c16359baa930ba8a5e8b6e41d6b63abe505': 18,
|
|
970
|
+
'0x9daf3f62ce9e53b8cd850a1ad392b632eaf7419f': 18,
|
|
971
|
+
'0x68862668fedd002da008596a56c5ea29921e94e6': 18,
|
|
972
|
+
'0xda748e324f4e05e1d9f517242c928a01c418c910': 8
|
|
971
973
|
};
|
|
972
974
|
|
|
973
975
|
function formatObject(object) {
|
|
@@ -981,24 +983,13 @@ var isSameAddress = function isSameAddress(address1, address2) {
|
|
|
981
983
|
};
|
|
982
984
|
var getCurrentTimestamp = /*#__PURE__*/function () {
|
|
983
985
|
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(provider) {
|
|
984
|
-
var latestBlockNumber, currentTime;
|
|
985
986
|
return runtime_1.wrap(function _callee$(_context) {
|
|
986
987
|
while (1) {
|
|
987
988
|
switch (_context.prev = _context.next) {
|
|
988
989
|
case 0:
|
|
989
|
-
_context.
|
|
990
|
-
return provider.getBlockNumber();
|
|
991
|
-
|
|
992
|
-
case 2:
|
|
993
|
-
latestBlockNumber = _context.sent;
|
|
994
|
-
_context.next = 5;
|
|
995
|
-
return provider.getBlock(latestBlockNumber);
|
|
996
|
-
|
|
997
|
-
case 5:
|
|
998
|
-
currentTime = _context.sent.timestamp;
|
|
999
|
-
return _context.abrupt("return", currentTime);
|
|
990
|
+
return _context.abrupt("return", Math.trunc(Date.now() / 1000));
|
|
1000
991
|
|
|
1001
|
-
case
|
|
992
|
+
case 1:
|
|
1002
993
|
case "end":
|
|
1003
994
|
return _context.stop();
|
|
1004
995
|
}
|
|
@@ -1068,573 +1059,6 @@ var TokenAmount = /*#__PURE__*/function () {
|
|
|
1068
1059
|
return TokenAmount;
|
|
1069
1060
|
}();
|
|
1070
1061
|
|
|
1071
|
-
var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
1072
|
-
_inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
|
|
1073
|
-
|
|
1074
|
-
function MoneyMarketRead(networkConnection, auToken, underlyingAsset) {
|
|
1075
|
-
var _this;
|
|
1076
|
-
|
|
1077
|
-
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
1078
|
-
|
|
1079
|
-
if (isSameAddress(underlyingAsset, ETHAddress)) {
|
|
1080
|
-
_this.auToken = new ethers$1.Contract(auToken, AuETHABI.abi, networkConnection.provider);
|
|
1081
|
-
} else {
|
|
1082
|
-
_this.auToken = new ethers$1.Contract(auToken, AuErc20ABI.abi, networkConnection.provider);
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
_this.underlying = new Token(underlyingAsset, getDecimal(underlyingAsset));
|
|
1086
|
-
_this._comptroller = new ethers$1.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
|
|
1087
|
-
return _this;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
var _proto = MoneyMarketRead.prototype;
|
|
1091
|
-
|
|
1092
|
-
_proto.getTotalTokenBorrowed = /*#__PURE__*/function () {
|
|
1093
|
-
var _getTotalTokenBorrowed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1094
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1095
|
-
while (1) {
|
|
1096
|
-
switch (_context.prev = _context.next) {
|
|
1097
|
-
case 0:
|
|
1098
|
-
_context.t0 = TokenAmount;
|
|
1099
|
-
_context.t1 = this.underlying;
|
|
1100
|
-
_context.next = 4;
|
|
1101
|
-
return this.auToken.totalBorrows();
|
|
1102
|
-
|
|
1103
|
-
case 4:
|
|
1104
|
-
_context.t2 = _context.sent.toString();
|
|
1105
|
-
return _context.abrupt("return", new _context.t0(_context.t1, _context.t2));
|
|
1106
|
-
|
|
1107
|
-
case 6:
|
|
1108
|
-
case "end":
|
|
1109
|
-
return _context.stop();
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
}, _callee, this);
|
|
1113
|
-
}));
|
|
1114
|
-
|
|
1115
|
-
function getTotalTokenBorrowed() {
|
|
1116
|
-
return _getTotalTokenBorrowed.apply(this, arguments);
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
return getTotalTokenBorrowed;
|
|
1120
|
-
}();
|
|
1121
|
-
|
|
1122
|
-
_proto.getTotalTokenDeposited = /*#__PURE__*/function () {
|
|
1123
|
-
var _getTotalTokenDeposited = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1124
|
-
var _this2 = this;
|
|
1125
|
-
|
|
1126
|
-
var promises, totalBorrow, totalCash;
|
|
1127
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1128
|
-
while (1) {
|
|
1129
|
-
switch (_context2.prev = _context2.next) {
|
|
1130
|
-
case 0:
|
|
1131
|
-
promises = [];
|
|
1132
|
-
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
1133
|
-
totalBorrow = res;
|
|
1134
|
-
}));
|
|
1135
|
-
promises.push(this.auToken.getCash().then(function (res) {
|
|
1136
|
-
totalCash = new TokenAmount(_this2.underlying, res.toString());
|
|
1137
|
-
}));
|
|
1138
|
-
_context2.next = 5;
|
|
1139
|
-
return Promise.all(promises);
|
|
1140
|
-
|
|
1141
|
-
case 5:
|
|
1142
|
-
return _context2.abrupt("return", new TokenAmount(this.underlying, ethers$1.BigNumber.from(totalCash.rawAmount()).add(totalBorrow.rawAmount()).toString()));
|
|
1143
|
-
|
|
1144
|
-
case 6:
|
|
1145
|
-
case "end":
|
|
1146
|
-
return _context2.stop();
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
}, _callee2, this);
|
|
1150
|
-
}));
|
|
1151
|
-
|
|
1152
|
-
function getTotalTokenDeposited() {
|
|
1153
|
-
return _getTotalTokenDeposited.apply(this, arguments);
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
return getTotalTokenDeposited;
|
|
1157
|
-
}();
|
|
1158
|
-
|
|
1159
|
-
_proto.getDepositAPY = /*#__PURE__*/function () {
|
|
1160
|
-
var _getDepositAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1161
|
-
var supplyRatePerTimestamp;
|
|
1162
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1163
|
-
while (1) {
|
|
1164
|
-
switch (_context3.prev = _context3.next) {
|
|
1165
|
-
case 0:
|
|
1166
|
-
_context3.next = 2;
|
|
1167
|
-
return this.auToken.supplyRatePerTimestamp();
|
|
1168
|
-
|
|
1169
|
-
case 2:
|
|
1170
|
-
supplyRatePerTimestamp = _context3.sent;
|
|
1171
|
-
return _context3.abrupt("return", new BigNumber(supplyRatePerTimestamp.toString()).multipliedBy(60 * 60 * 24 * 365).div(decimalFactor(18)));
|
|
1172
|
-
|
|
1173
|
-
case 4:
|
|
1174
|
-
case "end":
|
|
1175
|
-
return _context3.stop();
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
}, _callee3, this);
|
|
1179
|
-
}));
|
|
1180
|
-
|
|
1181
|
-
function getDepositAPY() {
|
|
1182
|
-
return _getDepositAPY.apply(this, arguments);
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
return getDepositAPY;
|
|
1186
|
-
}();
|
|
1187
|
-
|
|
1188
|
-
_proto.getBorrowAPY = /*#__PURE__*/function () {
|
|
1189
|
-
var _getBorrowAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
1190
|
-
var borrowRatePerTimestamp;
|
|
1191
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1192
|
-
while (1) {
|
|
1193
|
-
switch (_context4.prev = _context4.next) {
|
|
1194
|
-
case 0:
|
|
1195
|
-
_context4.next = 2;
|
|
1196
|
-
return this.auToken.borrowRatePerTimestamp();
|
|
1197
|
-
|
|
1198
|
-
case 2:
|
|
1199
|
-
borrowRatePerTimestamp = _context4.sent;
|
|
1200
|
-
return _context4.abrupt("return", new BigNumber(borrowRatePerTimestamp.toString()).multipliedBy(60 * 60 * 24 * 365).div(decimalFactor(18)));
|
|
1201
|
-
|
|
1202
|
-
case 4:
|
|
1203
|
-
case "end":
|
|
1204
|
-
return _context4.stop();
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
}, _callee4, this);
|
|
1208
|
-
}));
|
|
1209
|
-
|
|
1210
|
-
function getBorrowAPY() {
|
|
1211
|
-
return _getBorrowAPY.apply(this, arguments);
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
return getBorrowAPY;
|
|
1215
|
-
}();
|
|
1216
|
-
|
|
1217
|
-
_proto.getCollateralRatio = /*#__PURE__*/function () {
|
|
1218
|
-
var _getCollateralRatio = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
|
|
1219
|
-
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1220
|
-
while (1) {
|
|
1221
|
-
switch (_context5.prev = _context5.next) {
|
|
1222
|
-
case 0:
|
|
1223
|
-
return _context5.abrupt("return", this._comptroller.markets(this.auToken.address).then(function (res) {
|
|
1224
|
-
return new BigNumber(res.collateralFactorMantissa.toString()).div(decimalFactor(18));
|
|
1225
|
-
}));
|
|
1226
|
-
|
|
1227
|
-
case 1:
|
|
1228
|
-
case "end":
|
|
1229
|
-
return _context5.stop();
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
}, _callee5, this);
|
|
1233
|
-
}));
|
|
1234
|
-
|
|
1235
|
-
function getCollateralRatio() {
|
|
1236
|
-
return _getCollateralRatio.apply(this, arguments);
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
return getCollateralRatio;
|
|
1240
|
-
}();
|
|
1241
|
-
|
|
1242
|
-
_proto.getBorrowPlyAPY = /*#__PURE__*/function () {
|
|
1243
|
-
var _getBorrowPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
1244
|
-
var promises, totalBorrowed, rewardSpeed, plyPrice, underlyingPrice;
|
|
1245
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1246
|
-
while (1) {
|
|
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) {
|
|
1330
|
-
case 0:
|
|
1331
|
-
promises = [];
|
|
1332
|
-
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
1333
|
-
totalDeposited = res;
|
|
1334
|
-
}));
|
|
1335
|
-
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
1336
|
-
totalBorrowed = res;
|
|
1337
|
-
}));
|
|
1338
|
-
promises.push(this.getDepositAPY().then(function (res) {
|
|
1339
|
-
depositAPY = res.toNumber();
|
|
1340
|
-
}));
|
|
1341
|
-
promises.push(this.getBorrowAPY().then(function (res) {
|
|
1342
|
-
borrowAPY = res.toNumber();
|
|
1343
|
-
}));
|
|
1344
|
-
promises.push(this.getCollateralRatio().then(function (res) {
|
|
1345
|
-
collateralRatio = res.toNumber();
|
|
1346
|
-
}));
|
|
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;
|
|
1357
|
-
return Promise.all(promises);
|
|
1358
|
-
|
|
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", {
|
|
1363
|
-
auTokenAddress: this.auToken.address,
|
|
1364
|
-
totalTokenDeposited: totalDeposited,
|
|
1365
|
-
totalTokenBorrowed: totalBorrowed,
|
|
1366
|
-
depositApy: depositAPY,
|
|
1367
|
-
depositPlyApy: depositPlyApy.toNumber(),
|
|
1368
|
-
borrowApy: borrowAPY,
|
|
1369
|
-
borrowPlyApy: borrowPlyApy.toNumber(),
|
|
1370
|
-
collateralRatio: collateralRatio
|
|
1371
|
-
});
|
|
1372
|
-
|
|
1373
|
-
case 14:
|
|
1374
|
-
case "end":
|
|
1375
|
-
return _context8.stop();
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
}, _callee8, this);
|
|
1379
|
-
}));
|
|
1380
|
-
|
|
1381
|
-
function getDetails() {
|
|
1382
|
-
return _getDetails.apply(this, arguments);
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
return getDetails;
|
|
1386
|
-
}();
|
|
1387
|
-
|
|
1388
|
-
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
1389
|
-
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(userAddress) {
|
|
1390
|
-
var totalBorrow;
|
|
1391
|
-
return runtime_1.wrap(function _callee9$(_context9) {
|
|
1392
|
-
while (1) {
|
|
1393
|
-
switch (_context9.prev = _context9.next) {
|
|
1394
|
-
case 0:
|
|
1395
|
-
_context9.next = 2;
|
|
1396
|
-
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
1397
|
-
|
|
1398
|
-
case 2:
|
|
1399
|
-
totalBorrow = _context9.sent;
|
|
1400
|
-
return _context9.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
1401
|
-
|
|
1402
|
-
case 4:
|
|
1403
|
-
case "end":
|
|
1404
|
-
return _context9.stop();
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
}, _callee9, this);
|
|
1408
|
-
}));
|
|
1409
|
-
|
|
1410
|
-
function getUserBorrowBalance(_x) {
|
|
1411
|
-
return _getUserBorrowBalance.apply(this, arguments);
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
return getUserBorrowBalance;
|
|
1415
|
-
}();
|
|
1416
|
-
|
|
1417
|
-
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
1418
|
-
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(userAddress) {
|
|
1419
|
-
var totalDeposit;
|
|
1420
|
-
return runtime_1.wrap(function _callee10$(_context10) {
|
|
1421
|
-
while (1) {
|
|
1422
|
-
switch (_context10.prev = _context10.next) {
|
|
1423
|
-
case 0:
|
|
1424
|
-
_context10.next = 2;
|
|
1425
|
-
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
1426
|
-
|
|
1427
|
-
case 2:
|
|
1428
|
-
totalDeposit = _context10.sent;
|
|
1429
|
-
return _context10.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
1430
|
-
|
|
1431
|
-
case 4:
|
|
1432
|
-
case "end":
|
|
1433
|
-
return _context10.stop();
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
}, _callee10, this);
|
|
1437
|
-
}));
|
|
1438
|
-
|
|
1439
|
-
function getUserDepositBalance(_x2) {
|
|
1440
|
-
return _getUserDepositBalance.apply(this, arguments);
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
return getUserDepositBalance;
|
|
1444
|
-
}();
|
|
1445
|
-
|
|
1446
|
-
return MoneyMarketRead;
|
|
1447
|
-
}(BlockchainEntityRead);
|
|
1448
|
-
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
1449
|
-
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
1450
|
-
|
|
1451
|
-
function MoneyMarketReadWrite() {
|
|
1452
|
-
return _MoneyMarketRead.apply(this, arguments) || this;
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
1456
|
-
|
|
1457
|
-
_proto2.deposit = /*#__PURE__*/function () {
|
|
1458
|
-
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(amount) {
|
|
1459
|
-
return runtime_1.wrap(function _callee11$(_context11) {
|
|
1460
|
-
while (1) {
|
|
1461
|
-
switch (_context11.prev = _context11.next) {
|
|
1462
|
-
case 0:
|
|
1463
|
-
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1464
|
-
_context11.next = 4;
|
|
1465
|
-
break;
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
1469
|
-
value: amount.rawAmount()
|
|
1470
|
-
}));
|
|
1471
|
-
|
|
1472
|
-
case 4:
|
|
1473
|
-
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
1474
|
-
|
|
1475
|
-
case 5:
|
|
1476
|
-
case "end":
|
|
1477
|
-
return _context11.stop();
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
}, _callee11, this);
|
|
1481
|
-
}));
|
|
1482
|
-
|
|
1483
|
-
function deposit(_x3) {
|
|
1484
|
-
return _deposit.apply(this, arguments);
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
return deposit;
|
|
1488
|
-
}();
|
|
1489
|
-
|
|
1490
|
-
_proto2.borrow = /*#__PURE__*/function () {
|
|
1491
|
-
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
|
|
1492
|
-
return runtime_1.wrap(function _callee12$(_context12) {
|
|
1493
|
-
while (1) {
|
|
1494
|
-
switch (_context12.prev = _context12.next) {
|
|
1495
|
-
case 0:
|
|
1496
|
-
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
1497
|
-
|
|
1498
|
-
case 1:
|
|
1499
|
-
case "end":
|
|
1500
|
-
return _context12.stop();
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
}, _callee12, this);
|
|
1504
|
-
}));
|
|
1505
|
-
|
|
1506
|
-
function borrow(_x4) {
|
|
1507
|
-
return _borrow.apply(this, arguments);
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
return borrow;
|
|
1511
|
-
}();
|
|
1512
|
-
|
|
1513
|
-
_proto2.withdraw = /*#__PURE__*/function () {
|
|
1514
|
-
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(amount) {
|
|
1515
|
-
return runtime_1.wrap(function _callee13$(_context13) {
|
|
1516
|
-
while (1) {
|
|
1517
|
-
switch (_context13.prev = _context13.next) {
|
|
1518
|
-
case 0:
|
|
1519
|
-
return _context13.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
1520
|
-
|
|
1521
|
-
case 1:
|
|
1522
|
-
case "end":
|
|
1523
|
-
return _context13.stop();
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
}, _callee13, this);
|
|
1527
|
-
}));
|
|
1528
|
-
|
|
1529
|
-
function withdraw(_x5) {
|
|
1530
|
-
return _withdraw.apply(this, arguments);
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
return withdraw;
|
|
1534
|
-
}();
|
|
1535
|
-
|
|
1536
|
-
_proto2.repay = /*#__PURE__*/function () {
|
|
1537
|
-
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
|
|
1538
|
-
return runtime_1.wrap(function _callee14$(_context14) {
|
|
1539
|
-
while (1) {
|
|
1540
|
-
switch (_context14.prev = _context14.next) {
|
|
1541
|
-
case 0:
|
|
1542
|
-
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1543
|
-
_context14.next = 4;
|
|
1544
|
-
break;
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
1548
|
-
value: amount.rawAmount()
|
|
1549
|
-
}));
|
|
1550
|
-
|
|
1551
|
-
case 4:
|
|
1552
|
-
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
1553
|
-
|
|
1554
|
-
case 5:
|
|
1555
|
-
case "end":
|
|
1556
|
-
return _context14.stop();
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
}, _callee14, this);
|
|
1560
|
-
}));
|
|
1561
|
-
|
|
1562
|
-
function repay(_x6) {
|
|
1563
|
-
return _repay.apply(this, arguments);
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
return repay;
|
|
1567
|
-
}();
|
|
1568
|
-
|
|
1569
|
-
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
1570
|
-
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15() {
|
|
1571
|
-
return runtime_1.wrap(function _callee15$(_context15) {
|
|
1572
|
-
while (1) {
|
|
1573
|
-
switch (_context15.prev = _context15.next) {
|
|
1574
|
-
case 0:
|
|
1575
|
-
return _context15.abrupt("return", this._comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
1576
|
-
|
|
1577
|
-
case 1:
|
|
1578
|
-
case "end":
|
|
1579
|
-
return _context15.stop();
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
}, _callee15, this);
|
|
1583
|
-
}));
|
|
1584
|
-
|
|
1585
|
-
function enableCollateral() {
|
|
1586
|
-
return _enableCollateral.apply(this, arguments);
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
return enableCollateral;
|
|
1590
|
-
}();
|
|
1591
|
-
|
|
1592
|
-
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
1593
|
-
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
|
|
1594
|
-
return runtime_1.wrap(function _callee16$(_context16) {
|
|
1595
|
-
while (1) {
|
|
1596
|
-
switch (_context16.prev = _context16.next) {
|
|
1597
|
-
case 0:
|
|
1598
|
-
return _context16.abrupt("return", this._comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
1599
|
-
|
|
1600
|
-
case 1:
|
|
1601
|
-
case "end":
|
|
1602
|
-
return _context16.stop();
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
}, _callee16, this);
|
|
1606
|
-
}));
|
|
1607
|
-
|
|
1608
|
-
function disableCollateral() {
|
|
1609
|
-
return _disableCollateral.apply(this, arguments);
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
return disableCollateral;
|
|
1613
|
-
}();
|
|
1614
|
-
|
|
1615
|
-
return MoneyMarketReadWrite;
|
|
1616
|
-
}(MoneyMarketRead);
|
|
1617
|
-
var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
1618
|
-
_inheritsLoose(MoneyMarket, _BlockchainEntity);
|
|
1619
|
-
|
|
1620
|
-
function MoneyMarket(address, underlying) {
|
|
1621
|
-
var _this3;
|
|
1622
|
-
|
|
1623
|
-
_this3 = _BlockchainEntity.call(this) || this;
|
|
1624
|
-
_this3.address = validateAndParseAddress(address);
|
|
1625
|
-
_this3.underlying = validateAndParseAddress(underlying);
|
|
1626
|
-
return _this3;
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
var _proto3 = MoneyMarket.prototype;
|
|
1630
|
-
|
|
1631
|
-
_proto3.read = function read(networkConnection) {
|
|
1632
|
-
return new MoneyMarketRead(networkConnection, this.address, this.underlying);
|
|
1633
|
-
};
|
|
1634
|
-
|
|
1635
|
-
return MoneyMarket;
|
|
1636
|
-
}(BlockchainEntity);
|
|
1637
|
-
|
|
1638
1062
|
var abi = [
|
|
1639
1063
|
{
|
|
1640
1064
|
inputs: [
|
|
@@ -2584,305 +2008,942 @@ var IUniswapV2PairABI = {
|
|
|
2584
2008
|
deployedLinkReferences: deployedLinkReferences
|
|
2585
2009
|
};
|
|
2586
2010
|
|
|
2587
|
-
var abi$2 = [
|
|
2588
|
-
];
|
|
2589
|
-
var dummyABI = {
|
|
2590
|
-
abi: abi$2
|
|
2591
|
-
};
|
|
2011
|
+
var abi$2 = [
|
|
2012
|
+
];
|
|
2013
|
+
var dummyABI = {
|
|
2014
|
+
abi: abi$2
|
|
2015
|
+
};
|
|
2016
|
+
|
|
2017
|
+
var axios = /*#__PURE__*/require('axios');
|
|
2018
|
+
|
|
2019
|
+
function fetchPriceFromCoingeckoAPI(_x) {
|
|
2020
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
function _fetchPriceFromCoingeckoAPI() {
|
|
2024
|
+
_fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
|
|
2025
|
+
var price;
|
|
2026
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2027
|
+
while (1) {
|
|
2028
|
+
switch (_context.prev = _context.next) {
|
|
2029
|
+
case 0:
|
|
2030
|
+
_context.next = 2;
|
|
2031
|
+
return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=" + id + "&vs_currencies=usd").then(function (res) {
|
|
2032
|
+
return res.data;
|
|
2033
|
+
});
|
|
2034
|
+
|
|
2035
|
+
case 2:
|
|
2036
|
+
price = _context.sent;
|
|
2037
|
+
return _context.abrupt("return", new BigNumber(price[id].usd));
|
|
2038
|
+
|
|
2039
|
+
case 4:
|
|
2040
|
+
case "end":
|
|
2041
|
+
return _context.stop();
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
}, _callee);
|
|
2045
|
+
}));
|
|
2046
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
function fetchPriceFromCoingecko(_x2) {
|
|
2050
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
function _fetchPriceFromCoingecko() {
|
|
2054
|
+
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(address) {
|
|
2055
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2056
|
+
while (1) {
|
|
2057
|
+
switch (_context2.prev = _context2.next) {
|
|
2058
|
+
case 0:
|
|
2059
|
+
if (!isSameAddress(address, networkAddresses.tokens.AURORA)) {
|
|
2060
|
+
_context2.next = 4;
|
|
2061
|
+
break;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
|
|
2065
|
+
|
|
2066
|
+
case 4:
|
|
2067
|
+
throw Error("Unknown token " + address + " in fetchPriceFromCoingecko");
|
|
2068
|
+
|
|
2069
|
+
case 5:
|
|
2070
|
+
case "end":
|
|
2071
|
+
return _context2.stop();
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
}, _callee2);
|
|
2075
|
+
}));
|
|
2076
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
function fetchLPPositions(_x3, _x4) {
|
|
2080
|
+
return _fetchLPPositions.apply(this, arguments);
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
function _fetchLPPositions() {
|
|
2084
|
+
_fetchLPPositions = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(LPAddress, provider) {
|
|
2085
|
+
var promises, LPContract, values;
|
|
2086
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2087
|
+
while (1) {
|
|
2088
|
+
switch (_context3.prev = _context3.next) {
|
|
2089
|
+
case 0:
|
|
2090
|
+
promises = [];
|
|
2091
|
+
LPContract = new ethers$1.Contract(LPAddress, IUniswapV2PairABI.abi, provider);
|
|
2092
|
+
promises.push(LPContract.token0());
|
|
2093
|
+
promises.push(LPContract.toekn1());
|
|
2094
|
+
promises.push(LPContract.getReserves());
|
|
2095
|
+
promises.push(LPContract.totalSupply());
|
|
2096
|
+
_context3.next = 8;
|
|
2097
|
+
return Promise.all(promises);
|
|
2098
|
+
|
|
2099
|
+
case 8:
|
|
2100
|
+
values = _context3.sent;
|
|
2101
|
+
return _context3.abrupt("return", {
|
|
2102
|
+
token0: values[0],
|
|
2103
|
+
token1: values[1],
|
|
2104
|
+
reserve0: values[2].reserve0,
|
|
2105
|
+
reserve1: values[2].reserve1,
|
|
2106
|
+
totalSupply: values[3]
|
|
2107
|
+
});
|
|
2108
|
+
|
|
2109
|
+
case 10:
|
|
2110
|
+
case "end":
|
|
2111
|
+
return _context3.stop();
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
}, _callee3);
|
|
2115
|
+
}));
|
|
2116
|
+
return _fetchLPPositions.apply(this, arguments);
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
function fetchLPPrice(_x5, _x6) {
|
|
2120
|
+
return _fetchLPPrice.apply(this, arguments);
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
function _fetchLPPrice() {
|
|
2124
|
+
_fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(address, provider) {
|
|
2125
|
+
var LPInfo, token0Price, reserveUSD, token1Price, _reserveUSD;
|
|
2126
|
+
|
|
2127
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2128
|
+
while (1) {
|
|
2129
|
+
switch (_context4.prev = _context4.next) {
|
|
2130
|
+
case 0:
|
|
2131
|
+
_context4.next = 2;
|
|
2132
|
+
return fetchLPPositions(address, provider);
|
|
2133
|
+
|
|
2134
|
+
case 2:
|
|
2135
|
+
LPInfo = _context4.sent;
|
|
2136
|
+
_context4.prev = 3;
|
|
2137
|
+
_context4.next = 6;
|
|
2138
|
+
return fetchPrice(LPInfo.token0, provider);
|
|
2139
|
+
|
|
2140
|
+
case 6:
|
|
2141
|
+
token0Price = _context4.sent;
|
|
2142
|
+
reserveUSD = token0Price.multipliedBy(LPInfo.reserve0.toString()).multipliedBy(2);
|
|
2143
|
+
return _context4.abrupt("return", reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
|
|
2144
|
+
|
|
2145
|
+
case 11:
|
|
2146
|
+
_context4.prev = 11;
|
|
2147
|
+
_context4.t0 = _context4["catch"](3);
|
|
2148
|
+
_context4.prev = 13;
|
|
2149
|
+
_context4.next = 16;
|
|
2150
|
+
return fetchPrice(LPInfo.token1, provider);
|
|
2151
|
+
|
|
2152
|
+
case 16:
|
|
2153
|
+
token1Price = _context4.sent;
|
|
2154
|
+
_reserveUSD = token1Price.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(2);
|
|
2155
|
+
return _context4.abrupt("return", _reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
|
|
2156
|
+
|
|
2157
|
+
case 21:
|
|
2158
|
+
_context4.prev = 21;
|
|
2159
|
+
_context4.t1 = _context4["catch"](13);
|
|
2160
|
+
throw Error("Unable to fetch price for both tokens of LP " + address);
|
|
2161
|
+
|
|
2162
|
+
case 24:
|
|
2163
|
+
case "end":
|
|
2164
|
+
return _context4.stop();
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
}, _callee4, null, [[3, 11], [13, 21]]);
|
|
2168
|
+
}));
|
|
2169
|
+
return _fetchLPPrice.apply(this, arguments);
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
function processPriceFromOracle(rawPrice, underlyingDecimal) {
|
|
2173
|
+
return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
function fetchPriceFromOracle(_x7, _x8, _x9) {
|
|
2177
|
+
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
function _fetchPriceFromOracle() {
|
|
2181
|
+
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress, underlyingDecimal, provider) {
|
|
2182
|
+
var oracleContract, rawPrice;
|
|
2183
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2184
|
+
while (1) {
|
|
2185
|
+
switch (_context5.prev = _context5.next) {
|
|
2186
|
+
case 0:
|
|
2187
|
+
oracleContract = new ethers$1.Contract(networkAddresses.misc.oracle, OracleABI.abi, provider);
|
|
2188
|
+
_context5.next = 3;
|
|
2189
|
+
return oracleContract.getUnderlyingPrice(auTokenAddress);
|
|
2190
|
+
|
|
2191
|
+
case 3:
|
|
2192
|
+
rawPrice = _context5.sent;
|
|
2193
|
+
return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
|
|
2194
|
+
|
|
2195
|
+
case 5:
|
|
2196
|
+
case "end":
|
|
2197
|
+
return _context5.stop();
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
}, _callee5);
|
|
2201
|
+
}));
|
|
2202
|
+
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
function fetchUnderlyingTokensPrices(_x10) {
|
|
2206
|
+
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
function _fetchUnderlyingTokensPrices() {
|
|
2210
|
+
_fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
|
|
2211
|
+
var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
|
|
2212
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2213
|
+
while (1) {
|
|
2214
|
+
switch (_context6.prev = _context6.next) {
|
|
2215
|
+
case 0:
|
|
2216
|
+
auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, dummyABI.abi, provider);
|
|
2217
|
+
auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
|
|
2218
|
+
return auToken.address;
|
|
2219
|
+
});
|
|
2220
|
+
underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
|
|
2221
|
+
return getDecimal(auToken.underlying);
|
|
2222
|
+
});
|
|
2223
|
+
_context6.next = 5;
|
|
2224
|
+
return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
|
|
2225
|
+
|
|
2226
|
+
case 5:
|
|
2227
|
+
rawPrices = _context6.sent;
|
|
2228
|
+
return _context6.abrupt("return", rawPrices.map(function (res, ind) {
|
|
2229
|
+
return {
|
|
2230
|
+
auToken: res.auToken,
|
|
2231
|
+
underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
|
|
2232
|
+
};
|
|
2233
|
+
}));
|
|
2234
|
+
|
|
2235
|
+
case 7:
|
|
2236
|
+
case "end":
|
|
2237
|
+
return _context6.stop();
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
}, _callee6);
|
|
2241
|
+
}));
|
|
2242
|
+
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
function fetchPrice(_x11, _x12) {
|
|
2246
|
+
return _fetchPrice.apply(this, arguments);
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
function _fetchPrice() {
|
|
2250
|
+
_fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(address, provider) {
|
|
2251
|
+
var matchingAuToken;
|
|
2252
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2253
|
+
while (1) {
|
|
2254
|
+
switch (_context7.prev = _context7.next) {
|
|
2255
|
+
case 0:
|
|
2256
|
+
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2257
|
+
return isSameAddress(auToken.underlying, address);
|
|
2258
|
+
});
|
|
2259
|
+
|
|
2260
|
+
if (!(matchingAuToken !== undefined)) {
|
|
2261
|
+
_context7.next = 5;
|
|
2262
|
+
break;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
return _context7.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
|
|
2266
|
+
|
|
2267
|
+
case 5:
|
|
2268
|
+
if (!isSameAddress(address, networkAddresses.misc.AUPLYLP)) {
|
|
2269
|
+
_context7.next = 9;
|
|
2270
|
+
break;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
return _context7.abrupt("return", fetchLPPrice(address, provider));
|
|
2274
|
+
|
|
2275
|
+
case 9:
|
|
2276
|
+
return _context7.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2277
|
+
|
|
2278
|
+
case 10:
|
|
2279
|
+
case "end":
|
|
2280
|
+
return _context7.stop();
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}, _callee7);
|
|
2284
|
+
}));
|
|
2285
|
+
return _fetchPrice.apply(this, arguments);
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
function fetchValuation(_x13, _x14, _x15) {
|
|
2289
|
+
return _fetchValuation.apply(this, arguments);
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
function _fetchValuation() {
|
|
2293
|
+
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider, price) {
|
|
2294
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2295
|
+
while (1) {
|
|
2296
|
+
switch (_context8.prev = _context8.next) {
|
|
2297
|
+
case 0:
|
|
2298
|
+
if (!(price === null)) {
|
|
2299
|
+
_context8.next = 4;
|
|
2300
|
+
break;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
_context8.next = 3;
|
|
2304
|
+
return fetchPrice(tokenAmount.token.address, provider);
|
|
2305
|
+
|
|
2306
|
+
case 3:
|
|
2307
|
+
price = _context8.sent;
|
|
2308
|
+
|
|
2309
|
+
case 4:
|
|
2310
|
+
return _context8.abrupt("return", new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price));
|
|
2311
|
+
|
|
2312
|
+
case 5:
|
|
2313
|
+
case "end":
|
|
2314
|
+
return _context8.stop();
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
}, _callee8);
|
|
2318
|
+
}));
|
|
2319
|
+
return _fetchValuation.apply(this, arguments);
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2323
|
+
_inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
|
|
2324
|
+
|
|
2325
|
+
function MoneyMarketRead(networkConnection, auToken, underlyingAsset) {
|
|
2326
|
+
var _this;
|
|
2327
|
+
|
|
2328
|
+
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
2329
|
+
|
|
2330
|
+
if (isSameAddress(underlyingAsset, ETHAddress)) {
|
|
2331
|
+
_this.auToken = new ethers$1.Contract(auToken, AuETHABI.abi, networkConnection.provider);
|
|
2332
|
+
} else {
|
|
2333
|
+
_this.auToken = new ethers$1.Contract(auToken, AuErc20ABI.abi, networkConnection.provider);
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
_this.underlying = new Token(underlyingAsset, getDecimal(underlyingAsset));
|
|
2337
|
+
_this._comptroller = new ethers$1.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
|
|
2338
|
+
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
|
|
2339
|
+
return _this;
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
var _proto = MoneyMarketRead.prototype;
|
|
2343
|
+
|
|
2344
|
+
_proto.getRewardSpeeds = /*#__PURE__*/function () {
|
|
2345
|
+
var _getRewardSpeeds = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2346
|
+
var promises, speeds;
|
|
2347
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2348
|
+
while (1) {
|
|
2349
|
+
switch (_context.prev = _context.next) {
|
|
2350
|
+
case 0:
|
|
2351
|
+
promises = [];
|
|
2352
|
+
speeds = {};
|
|
2353
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address, true).then(function (res) {
|
|
2354
|
+
speeds.plyRewardSupplySpeed = res;
|
|
2355
|
+
}));
|
|
2356
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address, false).then(function (res) {
|
|
2357
|
+
speeds.plyRewardBorrowSpeed = res;
|
|
2358
|
+
}));
|
|
2359
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.AURORA, this.auToken.address, true).then(function (res) {
|
|
2360
|
+
speeds.auroraRewardSupplySpeed = res;
|
|
2361
|
+
}));
|
|
2362
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.AURORA, this.auToken.address, false).then(function (res) {
|
|
2363
|
+
speeds.auroraRewardBorrowSpeed = res;
|
|
2364
|
+
}));
|
|
2365
|
+
_context.next = 8;
|
|
2366
|
+
return Promise.all(promises);
|
|
2367
|
+
|
|
2368
|
+
case 8:
|
|
2369
|
+
return _context.abrupt("return", speeds);
|
|
2370
|
+
|
|
2371
|
+
case 9:
|
|
2372
|
+
case "end":
|
|
2373
|
+
return _context.stop();
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}, _callee, this);
|
|
2377
|
+
}));
|
|
2378
|
+
|
|
2379
|
+
function getRewardSpeeds() {
|
|
2380
|
+
return _getRewardSpeeds.apply(this, arguments);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
return getRewardSpeeds;
|
|
2384
|
+
}();
|
|
2385
|
+
|
|
2386
|
+
_proto.getTotalTokenBorrowed = /*#__PURE__*/function () {
|
|
2387
|
+
var _getTotalTokenBorrowed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
2388
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2389
|
+
while (1) {
|
|
2390
|
+
switch (_context2.prev = _context2.next) {
|
|
2391
|
+
case 0:
|
|
2392
|
+
_context2.t0 = TokenAmount;
|
|
2393
|
+
_context2.t1 = this.underlying;
|
|
2394
|
+
_context2.next = 4;
|
|
2395
|
+
return this.auToken.totalBorrows();
|
|
2396
|
+
|
|
2397
|
+
case 4:
|
|
2398
|
+
_context2.t2 = _context2.sent.toString();
|
|
2399
|
+
return _context2.abrupt("return", new _context2.t0(_context2.t1, _context2.t2));
|
|
2400
|
+
|
|
2401
|
+
case 6:
|
|
2402
|
+
case "end":
|
|
2403
|
+
return _context2.stop();
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
}, _callee2, this);
|
|
2407
|
+
}));
|
|
2408
|
+
|
|
2409
|
+
function getTotalTokenBorrowed() {
|
|
2410
|
+
return _getTotalTokenBorrowed.apply(this, arguments);
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
return getTotalTokenBorrowed;
|
|
2414
|
+
}();
|
|
2415
|
+
|
|
2416
|
+
_proto.getTotalTokenDeposited = /*#__PURE__*/function () {
|
|
2417
|
+
var _getTotalTokenDeposited = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
2418
|
+
var _this2 = this;
|
|
2419
|
+
|
|
2420
|
+
var promises, totalBorrow, totalCash;
|
|
2421
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2422
|
+
while (1) {
|
|
2423
|
+
switch (_context3.prev = _context3.next) {
|
|
2424
|
+
case 0:
|
|
2425
|
+
promises = [];
|
|
2426
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
2427
|
+
totalBorrow = res;
|
|
2428
|
+
}));
|
|
2429
|
+
promises.push(this.auToken.getCash().then(function (res) {
|
|
2430
|
+
totalCash = new TokenAmount(_this2.underlying, res.toString());
|
|
2431
|
+
}));
|
|
2432
|
+
_context3.next = 5;
|
|
2433
|
+
return Promise.all(promises);
|
|
2434
|
+
|
|
2435
|
+
case 5:
|
|
2436
|
+
return _context3.abrupt("return", new TokenAmount(this.underlying, ethers$1.BigNumber.from(totalCash.rawAmount()).add(totalBorrow.rawAmount()).toString()));
|
|
2437
|
+
|
|
2438
|
+
case 6:
|
|
2439
|
+
case "end":
|
|
2440
|
+
return _context3.stop();
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
}, _callee3, this);
|
|
2444
|
+
}));
|
|
2445
|
+
|
|
2446
|
+
function getTotalTokenDeposited() {
|
|
2447
|
+
return _getTotalTokenDeposited.apply(this, arguments);
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
return getTotalTokenDeposited;
|
|
2451
|
+
}();
|
|
2452
|
+
|
|
2453
|
+
_proto.getDepositAPY = /*#__PURE__*/function () {
|
|
2454
|
+
var _getDepositAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2455
|
+
var supplyRatePerTimestamp;
|
|
2456
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2457
|
+
while (1) {
|
|
2458
|
+
switch (_context4.prev = _context4.next) {
|
|
2459
|
+
case 0:
|
|
2460
|
+
_context4.next = 2;
|
|
2461
|
+
return this.auToken.supplyRatePerTimestamp();
|
|
2462
|
+
|
|
2463
|
+
case 2:
|
|
2464
|
+
supplyRatePerTimestamp = _context4.sent;
|
|
2465
|
+
return _context4.abrupt("return", new BigNumber(supplyRatePerTimestamp.toString()).multipliedBy(60 * 60 * 24 * 365).div(decimalFactor(18)));
|
|
2466
|
+
|
|
2467
|
+
case 4:
|
|
2468
|
+
case "end":
|
|
2469
|
+
return _context4.stop();
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
}, _callee4, this);
|
|
2473
|
+
}));
|
|
2474
|
+
|
|
2475
|
+
function getDepositAPY() {
|
|
2476
|
+
return _getDepositAPY.apply(this, arguments);
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
return getDepositAPY;
|
|
2480
|
+
}();
|
|
2481
|
+
|
|
2482
|
+
_proto.getBorrowAPY = /*#__PURE__*/function () {
|
|
2483
|
+
var _getBorrowAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
|
|
2484
|
+
var borrowRatePerTimestamp;
|
|
2485
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2486
|
+
while (1) {
|
|
2487
|
+
switch (_context5.prev = _context5.next) {
|
|
2488
|
+
case 0:
|
|
2489
|
+
_context5.next = 2;
|
|
2490
|
+
return this.auToken.borrowRatePerTimestamp();
|
|
2491
|
+
|
|
2492
|
+
case 2:
|
|
2493
|
+
borrowRatePerTimestamp = _context5.sent;
|
|
2494
|
+
return _context5.abrupt("return", new BigNumber(borrowRatePerTimestamp.toString()).multipliedBy(60 * 60 * 24 * 365).div(decimalFactor(18)));
|
|
2495
|
+
|
|
2496
|
+
case 4:
|
|
2497
|
+
case "end":
|
|
2498
|
+
return _context5.stop();
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
}, _callee5, this);
|
|
2502
|
+
}));
|
|
2503
|
+
|
|
2504
|
+
function getBorrowAPY() {
|
|
2505
|
+
return _getBorrowAPY.apply(this, arguments);
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
return getBorrowAPY;
|
|
2509
|
+
}();
|
|
2510
|
+
|
|
2511
|
+
_proto.getCollateralRatio = /*#__PURE__*/function () {
|
|
2512
|
+
var _getCollateralRatio = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
2513
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2514
|
+
while (1) {
|
|
2515
|
+
switch (_context6.prev = _context6.next) {
|
|
2516
|
+
case 0:
|
|
2517
|
+
return _context6.abrupt("return", this._comptroller.markets(this.auToken.address).then(function (res) {
|
|
2518
|
+
return new BigNumber(res.collateralFactorMantissa.toString()).div(decimalFactor(18));
|
|
2519
|
+
}));
|
|
2520
|
+
|
|
2521
|
+
case 1:
|
|
2522
|
+
case "end":
|
|
2523
|
+
return _context6.stop();
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
}, _callee6, this);
|
|
2527
|
+
}));
|
|
2528
|
+
|
|
2529
|
+
function getCollateralRatio() {
|
|
2530
|
+
return _getCollateralRatio.apply(this, arguments);
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
return getCollateralRatio;
|
|
2534
|
+
}();
|
|
2535
|
+
|
|
2536
|
+
_proto.getBorrowPlyAPY = /*#__PURE__*/function () {
|
|
2537
|
+
var _getBorrowPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
2538
|
+
var promises, totalBorrowed, rewardSpeed, plyPrice, underlyingPrice;
|
|
2539
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2540
|
+
while (1) {
|
|
2541
|
+
switch (_context7.prev = _context7.next) {
|
|
2542
|
+
case 0:
|
|
2543
|
+
promises = [];
|
|
2544
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
2545
|
+
totalBorrowed = res;
|
|
2546
|
+
}));
|
|
2547
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address, false).then(function (res) {
|
|
2548
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
2549
|
+
}));
|
|
2550
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
2551
|
+
plyPrice = res;
|
|
2552
|
+
}));
|
|
2553
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
2554
|
+
underlyingPrice = res;
|
|
2555
|
+
}));
|
|
2556
|
+
_context7.next = 7;
|
|
2557
|
+
return Promise.all(promises);
|
|
2558
|
+
|
|
2559
|
+
case 7:
|
|
2560
|
+
return _context7.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR));
|
|
2561
|
+
|
|
2562
|
+
case 8:
|
|
2563
|
+
case "end":
|
|
2564
|
+
return _context7.stop();
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
}, _callee7, this);
|
|
2568
|
+
}));
|
|
2569
|
+
|
|
2570
|
+
function getBorrowPlyAPY() {
|
|
2571
|
+
return _getBorrowPlyAPY.apply(this, arguments);
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
return getBorrowPlyAPY;
|
|
2575
|
+
}();
|
|
2576
|
+
|
|
2577
|
+
_proto.getDepositPlyAPY = /*#__PURE__*/function () {
|
|
2578
|
+
var _getDepositPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
2579
|
+
var promises, totalDeposited, rewardSpeed, plyPrice, underlyingPrice;
|
|
2580
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2581
|
+
while (1) {
|
|
2582
|
+
switch (_context8.prev = _context8.next) {
|
|
2583
|
+
case 0:
|
|
2584
|
+
promises = [];
|
|
2585
|
+
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
2586
|
+
totalDeposited = res;
|
|
2587
|
+
}));
|
|
2588
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address, true).then(function (res) {
|
|
2589
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
2590
|
+
}));
|
|
2591
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
2592
|
+
plyPrice = res;
|
|
2593
|
+
}));
|
|
2594
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
2595
|
+
underlyingPrice = res;
|
|
2596
|
+
}));
|
|
2597
|
+
_context8.next = 7;
|
|
2598
|
+
return Promise.all(promises);
|
|
2599
|
+
|
|
2600
|
+
case 7:
|
|
2601
|
+
return _context8.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR));
|
|
2592
2602
|
|
|
2593
|
-
|
|
2603
|
+
case 8:
|
|
2604
|
+
case "end":
|
|
2605
|
+
return _context8.stop();
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
}, _callee8, this);
|
|
2609
|
+
}));
|
|
2594
2610
|
|
|
2595
|
-
function
|
|
2596
|
-
|
|
2597
|
-
}
|
|
2611
|
+
function getDepositPlyAPY() {
|
|
2612
|
+
return _getDepositPlyAPY.apply(this, arguments);
|
|
2613
|
+
}
|
|
2598
2614
|
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
var price;
|
|
2602
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2603
|
-
while (1) {
|
|
2604
|
-
switch (_context.prev = _context.next) {
|
|
2605
|
-
case 0:
|
|
2606
|
-
_context.next = 2;
|
|
2607
|
-
return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=" + id + "&vs_currencies=usd").then(function (res) {
|
|
2608
|
-
return res.data;
|
|
2609
|
-
});
|
|
2615
|
+
return getDepositPlyAPY;
|
|
2616
|
+
}();
|
|
2610
2617
|
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2618
|
+
_proto.getDetails = /*#__PURE__*/function () {
|
|
2619
|
+
var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9() {
|
|
2620
|
+
var promises, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, plyPrice, underlyingPrice, rewardSpeeds, borrowPlyApy, depositPlyApy;
|
|
2621
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
2622
|
+
while (1) {
|
|
2623
|
+
switch (_context9.prev = _context9.next) {
|
|
2624
|
+
case 0:
|
|
2625
|
+
promises = [];
|
|
2626
|
+
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
2627
|
+
totalDeposited = res;
|
|
2628
|
+
}));
|
|
2629
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
2630
|
+
totalBorrowed = res;
|
|
2631
|
+
}));
|
|
2632
|
+
promises.push(this.getDepositAPY().then(function (res) {
|
|
2633
|
+
depositAPY = res.toNumber();
|
|
2634
|
+
}));
|
|
2635
|
+
promises.push(this.getBorrowAPY().then(function (res) {
|
|
2636
|
+
borrowAPY = res.toNumber();
|
|
2637
|
+
}));
|
|
2638
|
+
promises.push(this.getCollateralRatio().then(function (res) {
|
|
2639
|
+
collateralRatio = res.toNumber();
|
|
2640
|
+
}));
|
|
2641
|
+
promises.push(this.getRewardSpeeds().then(function (res) {
|
|
2642
|
+
rewardSpeeds = res;
|
|
2643
|
+
}));
|
|
2644
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
2645
|
+
plyPrice = res;
|
|
2646
|
+
}));
|
|
2647
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
2648
|
+
underlyingPrice = res;
|
|
2649
|
+
}));
|
|
2650
|
+
_context9.next = 11;
|
|
2651
|
+
return Promise.all(promises);
|
|
2614
2652
|
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2653
|
+
case 11:
|
|
2654
|
+
_context9.t0 = calcLMRewardApr;
|
|
2655
|
+
_context9.next = 14;
|
|
2656
|
+
return fetchValuation(new TokenAmount(PLYToken, rewardSpeeds.plyRewardBorrowSpeed.toString()), this._networkConnection.provider, plyPrice);
|
|
2657
|
+
|
|
2658
|
+
case 14:
|
|
2659
|
+
_context9.t1 = _context9.sent;
|
|
2660
|
+
_context9.t2 = underlyingPrice.multipliedBy(totalBorrowed.formattedAmount());
|
|
2661
|
+
_context9.t3 = ONE_YEAR;
|
|
2662
|
+
borrowPlyApy = (0, _context9.t0)(_context9.t1, _context9.t2, _context9.t3);
|
|
2663
|
+
_context9.t4 = calcLMRewardApr;
|
|
2664
|
+
_context9.next = 21;
|
|
2665
|
+
return fetchValuation(new TokenAmount(PLYToken, rewardSpeeds.plyRewardSupplySpeed.toString()), this._networkConnection.provider, plyPrice);
|
|
2666
|
+
|
|
2667
|
+
case 21:
|
|
2668
|
+
_context9.t5 = _context9.sent;
|
|
2669
|
+
_context9.t6 = underlyingPrice.multipliedBy(totalDeposited.formattedAmount());
|
|
2670
|
+
_context9.t7 = ONE_YEAR;
|
|
2671
|
+
depositPlyApy = (0, _context9.t4)(_context9.t5, _context9.t6, _context9.t7);
|
|
2672
|
+
return _context9.abrupt("return", {
|
|
2673
|
+
auTokenAddress: this.auToken.address,
|
|
2674
|
+
totalTokenDeposited: totalDeposited,
|
|
2675
|
+
totalTokenBorrowed: totalBorrowed,
|
|
2676
|
+
depositApy: depositAPY,
|
|
2677
|
+
depositPlyApy: depositPlyApy.toNumber(),
|
|
2678
|
+
borrowApy: borrowAPY,
|
|
2679
|
+
borrowPlyApy: borrowPlyApy.toNumber(),
|
|
2680
|
+
collateralRatio: collateralRatio
|
|
2681
|
+
});
|
|
2682
|
+
|
|
2683
|
+
case 26:
|
|
2684
|
+
case "end":
|
|
2685
|
+
return _context9.stop();
|
|
2686
|
+
}
|
|
2618
2687
|
}
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2621
|
-
}));
|
|
2622
|
-
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2623
|
-
}
|
|
2688
|
+
}, _callee9, this);
|
|
2689
|
+
}));
|
|
2624
2690
|
|
|
2625
|
-
function
|
|
2626
|
-
|
|
2627
|
-
}
|
|
2691
|
+
function getDetails() {
|
|
2692
|
+
return _getDetails.apply(this, arguments);
|
|
2693
|
+
}
|
|
2628
2694
|
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2632
|
-
while (1) {
|
|
2633
|
-
switch (_context2.prev = _context2.next) {
|
|
2634
|
-
case 0:
|
|
2635
|
-
if (!isSameAddress(address, networkAddresses.tokens.AURORA)) {
|
|
2636
|
-
_context2.next = 4;
|
|
2637
|
-
break;
|
|
2638
|
-
}
|
|
2695
|
+
return getDetails;
|
|
2696
|
+
}();
|
|
2639
2697
|
|
|
2640
|
-
|
|
2698
|
+
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
2699
|
+
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(userAddress) {
|
|
2700
|
+
var totalBorrow;
|
|
2701
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
2702
|
+
while (1) {
|
|
2703
|
+
switch (_context10.prev = _context10.next) {
|
|
2704
|
+
case 0:
|
|
2705
|
+
_context10.next = 2;
|
|
2706
|
+
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
2641
2707
|
|
|
2642
|
-
|
|
2643
|
-
|
|
2708
|
+
case 2:
|
|
2709
|
+
totalBorrow = _context10.sent;
|
|
2710
|
+
return _context10.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
2644
2711
|
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2712
|
+
case 4:
|
|
2713
|
+
case "end":
|
|
2714
|
+
return _context10.stop();
|
|
2715
|
+
}
|
|
2648
2716
|
}
|
|
2649
|
-
}
|
|
2650
|
-
}
|
|
2651
|
-
}));
|
|
2652
|
-
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2653
|
-
}
|
|
2717
|
+
}, _callee10, this);
|
|
2718
|
+
}));
|
|
2654
2719
|
|
|
2655
|
-
function
|
|
2656
|
-
|
|
2657
|
-
}
|
|
2720
|
+
function getUserBorrowBalance(_x) {
|
|
2721
|
+
return _getUserBorrowBalance.apply(this, arguments);
|
|
2722
|
+
}
|
|
2658
2723
|
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
var promises, LPContract, values;
|
|
2662
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2663
|
-
while (1) {
|
|
2664
|
-
switch (_context3.prev = _context3.next) {
|
|
2665
|
-
case 0:
|
|
2666
|
-
promises = [];
|
|
2667
|
-
LPContract = new ethers$1.Contract(LPAddress, IUniswapV2PairABI.abi, provider);
|
|
2668
|
-
promises.push(LPContract.token0());
|
|
2669
|
-
promises.push(LPContract.toekn1());
|
|
2670
|
-
promises.push(LPContract.getReserves());
|
|
2671
|
-
promises.push(LPContract.totalSupply());
|
|
2672
|
-
_context3.next = 8;
|
|
2673
|
-
return Promise.all(promises);
|
|
2724
|
+
return getUserBorrowBalance;
|
|
2725
|
+
}();
|
|
2674
2726
|
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2727
|
+
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
2728
|
+
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(userAddress) {
|
|
2729
|
+
var totalDeposit;
|
|
2730
|
+
return runtime_1.wrap(function _callee11$(_context11) {
|
|
2731
|
+
while (1) {
|
|
2732
|
+
switch (_context11.prev = _context11.next) {
|
|
2733
|
+
case 0:
|
|
2734
|
+
_context11.next = 2;
|
|
2735
|
+
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
2684
2736
|
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2737
|
+
case 2:
|
|
2738
|
+
totalDeposit = _context11.sent;
|
|
2739
|
+
return _context11.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
2740
|
+
|
|
2741
|
+
case 4:
|
|
2742
|
+
case "end":
|
|
2743
|
+
return _context11.stop();
|
|
2744
|
+
}
|
|
2688
2745
|
}
|
|
2689
|
-
}
|
|
2690
|
-
}
|
|
2691
|
-
}));
|
|
2692
|
-
return _fetchLPPositions.apply(this, arguments);
|
|
2693
|
-
}
|
|
2746
|
+
}, _callee11, this);
|
|
2747
|
+
}));
|
|
2694
2748
|
|
|
2695
|
-
function
|
|
2696
|
-
|
|
2697
|
-
}
|
|
2749
|
+
function getUserDepositBalance(_x2) {
|
|
2750
|
+
return _getUserDepositBalance.apply(this, arguments);
|
|
2751
|
+
}
|
|
2698
2752
|
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
var LPInfo, token0Price, reserveUSD, token1Price, _reserveUSD;
|
|
2753
|
+
return getUserDepositBalance;
|
|
2754
|
+
}();
|
|
2702
2755
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
_context4.next = 2;
|
|
2708
|
-
return fetchLPPositions(address, provider);
|
|
2756
|
+
return MoneyMarketRead;
|
|
2757
|
+
}(BlockchainEntityRead);
|
|
2758
|
+
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
2759
|
+
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
2709
2760
|
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2761
|
+
function MoneyMarketReadWrite() {
|
|
2762
|
+
return _MoneyMarketRead.apply(this, arguments) || this;
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
2766
|
+
|
|
2767
|
+
_proto2.deposit = /*#__PURE__*/function () {
|
|
2768
|
+
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
|
|
2769
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
2770
|
+
while (1) {
|
|
2771
|
+
switch (_context12.prev = _context12.next) {
|
|
2772
|
+
case 0:
|
|
2773
|
+
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
2774
|
+
_context12.next = 4;
|
|
2775
|
+
break;
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
2779
|
+
value: amount.rawAmount()
|
|
2780
|
+
}));
|
|
2781
|
+
|
|
2782
|
+
case 4:
|
|
2783
|
+
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
2784
|
+
|
|
2785
|
+
case 5:
|
|
2786
|
+
case "end":
|
|
2787
|
+
return _context12.stop();
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
}, _callee12, this);
|
|
2791
|
+
}));
|
|
2792
|
+
|
|
2793
|
+
function deposit(_x3) {
|
|
2794
|
+
return _deposit.apply(this, arguments);
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
return deposit;
|
|
2798
|
+
}();
|
|
2799
|
+
|
|
2800
|
+
_proto2.borrow = /*#__PURE__*/function () {
|
|
2801
|
+
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(amount) {
|
|
2802
|
+
return runtime_1.wrap(function _callee13$(_context13) {
|
|
2803
|
+
while (1) {
|
|
2804
|
+
switch (_context13.prev = _context13.next) {
|
|
2805
|
+
case 0:
|
|
2806
|
+
return _context13.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
2715
2807
|
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2808
|
+
case 1:
|
|
2809
|
+
case "end":
|
|
2810
|
+
return _context13.stop();
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
}, _callee13, this);
|
|
2814
|
+
}));
|
|
2720
2815
|
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
_context4.prev = 13;
|
|
2725
|
-
_context4.next = 16;
|
|
2726
|
-
return fetchPrice(LPInfo.token1, provider);
|
|
2816
|
+
function borrow(_x4) {
|
|
2817
|
+
return _borrow.apply(this, arguments);
|
|
2818
|
+
}
|
|
2727
2819
|
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
_reserveUSD = token1Price.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(2);
|
|
2731
|
-
return _context4.abrupt("return", _reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
|
|
2820
|
+
return borrow;
|
|
2821
|
+
}();
|
|
2732
2822
|
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2823
|
+
_proto2.withdraw = /*#__PURE__*/function () {
|
|
2824
|
+
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
|
|
2825
|
+
return runtime_1.wrap(function _callee14$(_context14) {
|
|
2826
|
+
while (1) {
|
|
2827
|
+
switch (_context14.prev = _context14.next) {
|
|
2828
|
+
case 0:
|
|
2829
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
2737
2830
|
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2831
|
+
case 1:
|
|
2832
|
+
case "end":
|
|
2833
|
+
return _context14.stop();
|
|
2834
|
+
}
|
|
2741
2835
|
}
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
}));
|
|
2745
|
-
return _fetchLPPrice.apply(this, arguments);
|
|
2746
|
-
}
|
|
2836
|
+
}, _callee14, this);
|
|
2837
|
+
}));
|
|
2747
2838
|
|
|
2748
|
-
function
|
|
2749
|
-
|
|
2750
|
-
}
|
|
2839
|
+
function withdraw(_x5) {
|
|
2840
|
+
return _withdraw.apply(this, arguments);
|
|
2841
|
+
}
|
|
2751
2842
|
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
}
|
|
2843
|
+
return withdraw;
|
|
2844
|
+
}();
|
|
2755
2845
|
|
|
2756
|
-
function
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
return oracleContract.getUnderlyingPrice(auTokenAddress);
|
|
2846
|
+
_proto2.repay = /*#__PURE__*/function () {
|
|
2847
|
+
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(amount) {
|
|
2848
|
+
return runtime_1.wrap(function _callee15$(_context15) {
|
|
2849
|
+
while (1) {
|
|
2850
|
+
switch (_context15.prev = _context15.next) {
|
|
2851
|
+
case 0:
|
|
2852
|
+
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
2853
|
+
_context15.next = 4;
|
|
2854
|
+
break;
|
|
2855
|
+
}
|
|
2767
2856
|
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2857
|
+
return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
2858
|
+
value: amount.rawAmount()
|
|
2859
|
+
}));
|
|
2771
2860
|
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2861
|
+
case 4:
|
|
2862
|
+
return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
2863
|
+
|
|
2864
|
+
case 5:
|
|
2865
|
+
case "end":
|
|
2866
|
+
return _context15.stop();
|
|
2867
|
+
}
|
|
2775
2868
|
}
|
|
2776
|
-
}
|
|
2777
|
-
}
|
|
2778
|
-
}));
|
|
2779
|
-
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2780
|
-
}
|
|
2869
|
+
}, _callee15, this);
|
|
2870
|
+
}));
|
|
2781
2871
|
|
|
2782
|
-
function
|
|
2783
|
-
|
|
2784
|
-
}
|
|
2872
|
+
function repay(_x6) {
|
|
2873
|
+
return _repay.apply(this, arguments);
|
|
2874
|
+
}
|
|
2785
2875
|
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
|
|
2789
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2790
|
-
while (1) {
|
|
2791
|
-
switch (_context6.prev = _context6.next) {
|
|
2792
|
-
case 0:
|
|
2793
|
-
auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, dummyABI.abi, provider);
|
|
2794
|
-
auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
|
|
2795
|
-
return auToken.address;
|
|
2796
|
-
});
|
|
2797
|
-
underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
|
|
2798
|
-
return getDecimal(auToken.underlying);
|
|
2799
|
-
});
|
|
2800
|
-
_context6.next = 5;
|
|
2801
|
-
return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
|
|
2876
|
+
return repay;
|
|
2877
|
+
}();
|
|
2802
2878
|
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
}));
|
|
2879
|
+
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
2880
|
+
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
|
|
2881
|
+
return runtime_1.wrap(function _callee16$(_context16) {
|
|
2882
|
+
while (1) {
|
|
2883
|
+
switch (_context16.prev = _context16.next) {
|
|
2884
|
+
case 0:
|
|
2885
|
+
return _context16.abrupt("return", this._comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
2811
2886
|
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2887
|
+
case 1:
|
|
2888
|
+
case "end":
|
|
2889
|
+
return _context16.stop();
|
|
2890
|
+
}
|
|
2815
2891
|
}
|
|
2816
|
-
}
|
|
2817
|
-
}
|
|
2818
|
-
}));
|
|
2819
|
-
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2820
|
-
}
|
|
2892
|
+
}, _callee16, this);
|
|
2893
|
+
}));
|
|
2821
2894
|
|
|
2822
|
-
function
|
|
2823
|
-
|
|
2824
|
-
}
|
|
2895
|
+
function enableCollateral() {
|
|
2896
|
+
return _enableCollateral.apply(this, arguments);
|
|
2897
|
+
}
|
|
2825
2898
|
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
var matchingAuToken;
|
|
2829
|
-
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2830
|
-
while (1) {
|
|
2831
|
-
switch (_context7.prev = _context7.next) {
|
|
2832
|
-
case 0:
|
|
2833
|
-
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2834
|
-
return isSameAddress(auToken.underlying, address);
|
|
2835
|
-
});
|
|
2899
|
+
return enableCollateral;
|
|
2900
|
+
}();
|
|
2836
2901
|
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2902
|
+
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
2903
|
+
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17() {
|
|
2904
|
+
return runtime_1.wrap(function _callee17$(_context17) {
|
|
2905
|
+
while (1) {
|
|
2906
|
+
switch (_context17.prev = _context17.next) {
|
|
2907
|
+
case 0:
|
|
2908
|
+
return _context17.abrupt("return", this._comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
2841
2909
|
|
|
2842
|
-
|
|
2910
|
+
case 1:
|
|
2911
|
+
case "end":
|
|
2912
|
+
return _context17.stop();
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
}, _callee17, this);
|
|
2916
|
+
}));
|
|
2843
2917
|
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
break;
|
|
2848
|
-
}
|
|
2918
|
+
function disableCollateral() {
|
|
2919
|
+
return _disableCollateral.apply(this, arguments);
|
|
2920
|
+
}
|
|
2849
2921
|
|
|
2850
|
-
|
|
2922
|
+
return disableCollateral;
|
|
2923
|
+
}();
|
|
2851
2924
|
|
|
2852
|
-
|
|
2853
|
-
|
|
2925
|
+
return MoneyMarketReadWrite;
|
|
2926
|
+
}(MoneyMarketRead);
|
|
2927
|
+
var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
2928
|
+
_inheritsLoose(MoneyMarket, _BlockchainEntity);
|
|
2854
2929
|
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
return _context7.stop();
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2860
|
-
}, _callee7);
|
|
2861
|
-
}));
|
|
2862
|
-
return _fetchPrice.apply(this, arguments);
|
|
2863
|
-
}
|
|
2930
|
+
function MoneyMarket(address, underlying) {
|
|
2931
|
+
var _this3;
|
|
2864
2932
|
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2933
|
+
_this3 = _BlockchainEntity.call(this) || this;
|
|
2934
|
+
_this3.address = validateAndParseAddress(address);
|
|
2935
|
+
_this3.underlying = validateAndParseAddress(underlying);
|
|
2936
|
+
return _this3;
|
|
2937
|
+
}
|
|
2868
2938
|
|
|
2869
|
-
|
|
2870
|
-
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider, price) {
|
|
2871
|
-
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2872
|
-
while (1) {
|
|
2873
|
-
switch (_context8.prev = _context8.next) {
|
|
2874
|
-
case 0:
|
|
2875
|
-
return _context8.abrupt("return", new BigNumber(0));
|
|
2939
|
+
var _proto3 = MoneyMarket.prototype;
|
|
2876
2940
|
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
}));
|
|
2884
|
-
return _fetchValuation.apply(this, arguments);
|
|
2885
|
-
}
|
|
2941
|
+
_proto3.read = function read(networkConnection) {
|
|
2942
|
+
return new MoneyMarketRead(networkConnection, this.address, this.underlying);
|
|
2943
|
+
};
|
|
2944
|
+
|
|
2945
|
+
return MoneyMarket;
|
|
2946
|
+
}(BlockchainEntity);
|
|
2886
2947
|
|
|
2887
2948
|
var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2888
2949
|
_inheritsLoose(SdkRead, _BlockchainEntityRead);
|
|
@@ -2894,7 +2955,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2894
2955
|
_this._comptroller = new ethers$1.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
|
|
2895
2956
|
_this._tokenLock = new ethers$1.Contract(networkAddresses.misc.TOKENLOCK, TokenLockABI.abi, networkConnection.provider);
|
|
2896
2957
|
_this._auriFairLaunch = new ethers$1.Contract(networkAddresses.misc.AURIFAIRLAUNCH, AuriFairLaunchABI.abi, networkConnection.provider);
|
|
2897
|
-
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS,
|
|
2958
|
+
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
|
|
2898
2959
|
return _this;
|
|
2899
2960
|
}
|
|
2900
2961
|
|
|
@@ -2907,10 +2968,11 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2907
2968
|
while (1) {
|
|
2908
2969
|
switch (_context.prev = _context.next) {
|
|
2909
2970
|
case 0:
|
|
2910
|
-
|
|
2971
|
+
console.log(this._networkConnection.provider);
|
|
2972
|
+
_context.next = 3;
|
|
2911
2973
|
return getCurrentTimestamp(this._networkConnection.provider);
|
|
2912
2974
|
|
|
2913
|
-
case
|
|
2975
|
+
case 3:
|
|
2914
2976
|
currentTime = _context.sent;
|
|
2915
2977
|
currentWeek = ethers$1.BigNumber.from(currentTime - REWARDCLAIMSTART).div(7 * ONE_DAY).toNumber();
|
|
2916
2978
|
denominator = 10000;
|
|
@@ -2919,22 +2981,22 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2919
2981
|
promises.push(this._tokenLock.percentageLock(currentWeek + 1)["catch"](function (err) {
|
|
2920
2982
|
return denominator;
|
|
2921
2983
|
}));
|
|
2922
|
-
_context.next =
|
|
2984
|
+
_context.next = 11;
|
|
2923
2985
|
return Promise.all(promises).then(function (res) {
|
|
2924
2986
|
return res.map(function (v) {
|
|
2925
2987
|
return v.toString();
|
|
2926
2988
|
});
|
|
2927
2989
|
});
|
|
2928
2990
|
|
|
2929
|
-
case
|
|
2991
|
+
case 11:
|
|
2930
2992
|
values = _context.sent;
|
|
2931
2993
|
return _context.abrupt("return", {
|
|
2932
2994
|
vestingStart: REWARDCLAIMSTART,
|
|
2933
|
-
currentUnlockPortion: new BigNumber(values[0]).div(denominator).toNumber(),
|
|
2934
|
-
nextUnlockPortion: new BigNumber(values[1]).div(denominator).toNumber()
|
|
2995
|
+
currentUnlockPortion: new BigNumber(denominator).minus(values[0]).div(denominator).toNumber(),
|
|
2996
|
+
nextUnlockPortion: new BigNumber(denominator).minus(values[1]).div(denominator).toNumber()
|
|
2935
2997
|
});
|
|
2936
2998
|
|
|
2937
|
-
case
|
|
2999
|
+
case 13:
|
|
2938
3000
|
case "end":
|
|
2939
3001
|
return _context.stop();
|
|
2940
3002
|
}
|
|
@@ -2961,6 +3023,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2961
3023
|
case 0:
|
|
2962
3024
|
marketCount = networkAddresses.auTokens.length;
|
|
2963
3025
|
userMarketDetails = [];
|
|
3026
|
+
collateralRatio = new Array(marketCount);
|
|
2964
3027
|
promises = [];
|
|
2965
3028
|
totalBorrowLimit = new BigNumber(0);
|
|
2966
3029
|
pricePromises = [];
|
|
@@ -2990,14 +3053,14 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2990
3053
|
promises.push(this._comptroller.getAssetsIn(userAddress).then(function (res) {
|
|
2991
3054
|
assetsIn = res;
|
|
2992
3055
|
}));
|
|
2993
|
-
_context2.next =
|
|
3056
|
+
_context2.next = 11;
|
|
2994
3057
|
return Promise.all(promises);
|
|
2995
3058
|
|
|
2996
|
-
case
|
|
2997
|
-
_context2.next =
|
|
3059
|
+
case 11:
|
|
3060
|
+
_context2.next = 13;
|
|
2998
3061
|
return Promise.all(pricePromises);
|
|
2999
3062
|
|
|
3000
|
-
case
|
|
3063
|
+
case 13:
|
|
3001
3064
|
underlyingPrices = _context2.sent;
|
|
3002
3065
|
depositValuationPromises = [];
|
|
3003
3066
|
|
|
@@ -3017,10 +3080,10 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3017
3080
|
_loop();
|
|
3018
3081
|
}
|
|
3019
3082
|
|
|
3020
|
-
_context2.next =
|
|
3083
|
+
_context2.next = 19;
|
|
3021
3084
|
return Promise.all(depositValuationPromises);
|
|
3022
3085
|
|
|
3023
|
-
case
|
|
3086
|
+
case 19:
|
|
3024
3087
|
depositValues = _context2.sent;
|
|
3025
3088
|
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
3026
3089
|
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(collateralRatio[index]));
|
|
@@ -3028,12 +3091,12 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3028
3091
|
});
|
|
3029
3092
|
promises = [];
|
|
3030
3093
|
promises.push(this._comptroller.getAccountLiquidity(userAddress));
|
|
3031
|
-
promises.push(this._auriLens.getRewardBalancesMetadata(this._comptroller.address, userAddress));
|
|
3094
|
+
promises.push(this._auriLens.callStatic.getRewardBalancesMetadata(this._comptroller.address, this._auriFairLaunch.address, userAddress, [AurPlyPid]));
|
|
3032
3095
|
promises.push(this._tokenLock.lockedAmounts(userAddress));
|
|
3033
|
-
_context2.next =
|
|
3096
|
+
_context2.next = 27;
|
|
3034
3097
|
return Promise.all(promises);
|
|
3035
3098
|
|
|
3036
|
-
case
|
|
3099
|
+
case 27:
|
|
3037
3100
|
values = _context2.sent;
|
|
3038
3101
|
accountLiquidity = values[0];
|
|
3039
3102
|
rewardBalancesMetadata = values[1];
|
|
@@ -3067,7 +3130,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3067
3130
|
}
|
|
3068
3131
|
});
|
|
3069
3132
|
|
|
3070
|
-
case
|
|
3133
|
+
case 36:
|
|
3071
3134
|
case "end":
|
|
3072
3135
|
return _context2.stop();
|
|
3073
3136
|
}
|
|
@@ -3091,6 +3154,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3091
3154
|
case 0:
|
|
3092
3155
|
promises = [];
|
|
3093
3156
|
promises.push(this._auriFairLaunch.getPoolInfo(AurPlyPid).then(function (res) {
|
|
3157
|
+
console.log(res);
|
|
3094
3158
|
stakedLiquidity = res.totalStake;
|
|
3095
3159
|
rewardPerSecond = res.rewardPerSecond;
|
|
3096
3160
|
}));
|
|
@@ -3105,12 +3169,16 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3105
3169
|
promises.push(fetchValuation(new TokenAmount(AURPLYToken, stakedLiquidity.toString()), this._networkConnection.provider).then(function (res) {
|
|
3106
3170
|
return totalStakeValuation = res;
|
|
3107
3171
|
}));
|
|
3172
|
+
_context3.next = 9;
|
|
3173
|
+
return Promise.all(promises);
|
|
3174
|
+
|
|
3175
|
+
case 9:
|
|
3108
3176
|
return _context3.abrupt("return", {
|
|
3109
3177
|
totalStakedLiquidity: new TokenAmount(AURPLYToken, stakedLiquidity.toString()),
|
|
3110
3178
|
apy: calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION)
|
|
3111
3179
|
});
|
|
3112
3180
|
|
|
3113
|
-
case
|
|
3181
|
+
case 10:
|
|
3114
3182
|
case "end":
|
|
3115
3183
|
return _context3.stop();
|
|
3116
3184
|
}
|
|
@@ -3203,18 +3271,9 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
|
|
|
3203
3271
|
while (1) {
|
|
3204
3272
|
switch (_context6.prev = _context6.next) {
|
|
3205
3273
|
case 0:
|
|
3206
|
-
_context6.
|
|
3207
|
-
_context6.t1 = this._comptroller.address;
|
|
3208
|
-
_context6.t2 = this._auriFairLaunch.address;
|
|
3209
|
-
_context6.next = 5;
|
|
3210
|
-
return this._networkConnection.signer.getAddress();
|
|
3274
|
+
return _context6.abrupt("return", this._auriLens.connect(this._networkConnection.signer).claimRewards(this._comptroller.address, this._auriFairLaunch.address, [AurPlyPid]));
|
|
3211
3275
|
|
|
3212
|
-
case
|
|
3213
|
-
_context6.t3 = _context6.sent;
|
|
3214
|
-
_context6.t4 = [AurPlyPid];
|
|
3215
|
-
return _context6.abrupt("return", _context6.t0.claimRewards.call(_context6.t0, _context6.t1, _context6.t2, _context6.t3, _context6.t4));
|
|
3216
|
-
|
|
3217
|
-
case 8:
|
|
3276
|
+
case 1:
|
|
3218
3277
|
case "end":
|
|
3219
3278
|
return _context6.stop();
|
|
3220
3279
|
}
|
|
@@ -3316,10 +3375,10 @@ var dummyUserMarketDetails = {
|
|
|
3316
3375
|
exports.AURORA_CHAINID = AURORA_CHAINID;
|
|
3317
3376
|
exports.AURORA_DEFAULT_PROVIDER = AURORA_DEFAULT_PROVIDER;
|
|
3318
3377
|
exports.AURORA_DEFAULT_PROVIDER_URL = AURORA_DEFAULT_PROVIDER_URL;
|
|
3378
|
+
exports.AURORA_DEFAULT_SIGNER = AURORA_DEFAULT_SIGNER;
|
|
3319
3379
|
exports.AURPLYToken = AURPLYToken;
|
|
3320
3380
|
exports.AVAX_DEFAULT_PROVIDER = AVAX_DEFAULT_PROVIDER;
|
|
3321
3381
|
exports.AVAX_DEFAULT_PROVIDER_URL = AVAX_DEFAULT_PROVIDER_URL;
|
|
3322
|
-
exports.AVAX_DEFAULT_SIGNER = AVAX_DEFAULT_SIGNER;
|
|
3323
3382
|
exports.AurPlyPid = AurPlyPid;
|
|
3324
3383
|
exports.BORROW_LIMIT_BUFFER = BORROW_LIMIT_BUFFER;
|
|
3325
3384
|
exports.BlockchainEntity = BlockchainEntity;
|