@aurigami/sdk 0.2.3 → 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 +5 -3
- package/dist/sdk.cjs.development.js +965 -901
- 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 +963 -901
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +4 -4
- package/src/MoneyMarket.ts +59 -20
- package/src/SDK.ts +10 -8
- package/src/constants.ts +32 -26
- package/src/decimals.ts +16 -16
- package/src/helpers.ts +4 -3
- package/src/priceFetcher.ts +6 -3
|
@@ -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
|
|
|
@@ -899,73 +900,76 @@ var ethers = /*#__PURE__*/require('ethers');
|
|
|
899
900
|
|
|
900
901
|
var AVAX_DEFAULT_PROVIDER_URL = 'https://api.avax.network/ext/bc/C/rpc';
|
|
901
902
|
var AVAX_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AVAX_DEFAULT_PROVIDER_URL);
|
|
903
|
+
var AURORA_DEFAULT_PROVIDER_URL = "https://testnet.aurora.dev";
|
|
904
|
+
var AURORA_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AURORA_DEFAULT_PROVIDER_URL);
|
|
902
905
|
var dummyAddress = "0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE";
|
|
903
906
|
var ETHAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
904
907
|
var dummyPrivateKey = '1111111111111111111111111111111111111111111111111111111111111111';
|
|
905
|
-
var
|
|
908
|
+
var AURORA_DEFAULT_SIGNER = /*#__PURE__*/new ethers.Wallet(dummyPrivateKey, AURORA_DEFAULT_PROVIDER);
|
|
906
909
|
var AURORA_CHAINID = 1313161554;
|
|
907
910
|
var DECIMAL_PRECISION = 6;
|
|
908
911
|
var networkAddresses = {
|
|
909
912
|
auTokens: [{
|
|
910
|
-
address: '
|
|
911
|
-
underlying: '
|
|
913
|
+
address: /*#__PURE__*/'0xA21d86e113f161fa05d3cf767ef19Ccec1BD4889'.toLowerCase(),
|
|
914
|
+
underlying: /*#__PURE__*/'0x9Daf3f62cE9e53B8cd850a1ad392b632eAF7419F'.toLowerCase()
|
|
912
915
|
}, {
|
|
913
|
-
address: '
|
|
914
|
-
underlying: ETHAddress
|
|
916
|
+
address: /*#__PURE__*/'0xFa4A1B4137B66d69E5af8a0f63591D62A8c14446'.toLowerCase(),
|
|
917
|
+
underlying: /*#__PURE__*/ETHAddress.toLowerCase()
|
|
915
918
|
}, {
|
|
916
|
-
address: '
|
|
917
|
-
underlying: '
|
|
919
|
+
address: /*#__PURE__*/'0x1B8A94C4C9A1496E274B153e0756F1836AeaBB30'.toLowerCase(),
|
|
920
|
+
underlying: /*#__PURE__*/'0x68862668FEdd002dA008596A56C5ea29921E94e6'.toLowerCase()
|
|
918
921
|
}, {
|
|
919
|
-
address: '
|
|
920
|
-
underlying: '
|
|
922
|
+
address: /*#__PURE__*/'0x5f8E0b6b049fecabC16AD7d23b5F311c48555fA6'.toLowerCase(),
|
|
923
|
+
underlying: /*#__PURE__*/'0xc0a00D761E569007a707aA84A9A08837cb6A04c1'.toLowerCase()
|
|
921
924
|
}, {
|
|
922
|
-
address: '
|
|
923
|
-
underlying: '
|
|
925
|
+
address: /*#__PURE__*/'0xeee0A0BC4dc3999136f35f82DdaAC3c27Ed05017'.toLowerCase(),
|
|
926
|
+
underlying: /*#__PURE__*/'0x5231CfaF5BD3Aa0C9423703a72706B2D40f0b783'.toLowerCase()
|
|
924
927
|
}, {
|
|
925
|
-
address: '
|
|
926
|
-
underlying: '
|
|
928
|
+
address: /*#__PURE__*/'0x9Fc4f60DC140645978C53703acE6241448cFEaA8'.toLowerCase(),
|
|
929
|
+
underlying: /*#__PURE__*/'0xf7c51293c5eE5c76867d8Cf400627627a4Bd8697'.toLowerCase()
|
|
927
930
|
}, {
|
|
928
|
-
address: '
|
|
929
|
-
underlying: '
|
|
931
|
+
address: /*#__PURE__*/'0x533dBEC840f10f51B868453f86BDF211Fbc52Ba4'.toLowerCase(),
|
|
932
|
+
underlying: /*#__PURE__*/'0xaa847c16359bAA930ba8a5E8b6e41D6b63ABe505'.toLowerCase()
|
|
930
933
|
}, {
|
|
931
|
-
address: '
|
|
932
|
-
underlying: '
|
|
934
|
+
address: /*#__PURE__*/'0xDA748E324F4e05e1D9f517242C928A01C418c910'.toLowerCase(),
|
|
935
|
+
underlying: /*#__PURE__*/'0x206EA0Ae49F80d0376d04932479e33Cf2098211A'.toLowerCase()
|
|
933
936
|
}],
|
|
934
937
|
misc: {
|
|
935
|
-
COMPTROLLER: "
|
|
936
|
-
oracle: "
|
|
937
|
-
AURIFAIRLAUNCH: "
|
|
938
|
-
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()
|
|
939
943
|
},
|
|
940
944
|
tokens: {
|
|
941
|
-
AURORA: "
|
|
942
|
-
PLY: "
|
|
943
|
-
AURPLY: dummyAddress
|
|
945
|
+
AURORA: /*#__PURE__*/"0xf7c51293c5eE5c76867d8Cf400627627a4Bd8697".toLowerCase(),
|
|
946
|
+
PLY: /*#__PURE__*/"0x206EA0Ae49F80d0376d04932479e33Cf2098211A".toLowerCase(),
|
|
947
|
+
AURPLY: /*#__PURE__*/dummyAddress.toLowerCase()
|
|
944
948
|
}
|
|
945
949
|
};
|
|
946
950
|
var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(0.95);
|
|
947
|
-
var REWARDCLAIMSTART =
|
|
951
|
+
var REWARDCLAIMSTART = 1640995200;
|
|
948
952
|
var ONE_DAY = 86400;
|
|
949
953
|
var ONE_YEAR = ONE_DAY * 365;
|
|
950
|
-
var AurPlyPid =
|
|
954
|
+
var AurPlyPid = 0;
|
|
951
955
|
|
|
952
956
|
var decimalRecords = {
|
|
953
957
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
|
|
954
|
-
'
|
|
955
|
-
'
|
|
956
|
-
'
|
|
957
|
-
'
|
|
958
|
-
'
|
|
959
|
-
'
|
|
960
|
-
'
|
|
961
|
-
'
|
|
962
|
-
'
|
|
963
|
-
'
|
|
964
|
-
'
|
|
965
|
-
'
|
|
966
|
-
'
|
|
967
|
-
'
|
|
968
|
-
'
|
|
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
|
|
969
973
|
};
|
|
970
974
|
|
|
971
975
|
function formatObject(object) {
|
|
@@ -979,24 +983,13 @@ var isSameAddress = function isSameAddress(address1, address2) {
|
|
|
979
983
|
};
|
|
980
984
|
var getCurrentTimestamp = /*#__PURE__*/function () {
|
|
981
985
|
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(provider) {
|
|
982
|
-
var latestBlockNumber, currentTime;
|
|
983
986
|
return runtime_1.wrap(function _callee$(_context) {
|
|
984
987
|
while (1) {
|
|
985
988
|
switch (_context.prev = _context.next) {
|
|
986
989
|
case 0:
|
|
987
|
-
_context.
|
|
988
|
-
return provider.getBlockNumber();
|
|
989
|
-
|
|
990
|
-
case 2:
|
|
991
|
-
latestBlockNumber = _context.sent;
|
|
992
|
-
_context.next = 5;
|
|
993
|
-
return provider.getBlock(latestBlockNumber);
|
|
994
|
-
|
|
995
|
-
case 5:
|
|
996
|
-
currentTime = _context.sent.timestamp;
|
|
997
|
-
return _context.abrupt("return", currentTime);
|
|
990
|
+
return _context.abrupt("return", Math.trunc(Date.now() / 1000));
|
|
998
991
|
|
|
999
|
-
case
|
|
992
|
+
case 1:
|
|
1000
993
|
case "end":
|
|
1001
994
|
return _context.stop();
|
|
1002
995
|
}
|
|
@@ -1066,573 +1059,6 @@ var TokenAmount = /*#__PURE__*/function () {
|
|
|
1066
1059
|
return TokenAmount;
|
|
1067
1060
|
}();
|
|
1068
1061
|
|
|
1069
|
-
var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
1070
|
-
_inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
|
|
1071
|
-
|
|
1072
|
-
function MoneyMarketRead(networkConnection, auToken, underlyingAsset) {
|
|
1073
|
-
var _this;
|
|
1074
|
-
|
|
1075
|
-
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
1076
|
-
|
|
1077
|
-
if (isSameAddress(underlyingAsset, ETHAddress)) {
|
|
1078
|
-
_this.auToken = new ethers$1.Contract(auToken, AuETHABI.abi, networkConnection.provider);
|
|
1079
|
-
} else {
|
|
1080
|
-
_this.auToken = new ethers$1.Contract(auToken, AuErc20ABI.abi, networkConnection.provider);
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
_this.underlying = new Token(underlyingAsset, getDecimal(underlyingAsset));
|
|
1084
|
-
_this._comptroller = new ethers$1.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
|
|
1085
|
-
return _this;
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
var _proto = MoneyMarketRead.prototype;
|
|
1089
|
-
|
|
1090
|
-
_proto.getTotalTokenBorrowed = /*#__PURE__*/function () {
|
|
1091
|
-
var _getTotalTokenBorrowed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1092
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1093
|
-
while (1) {
|
|
1094
|
-
switch (_context.prev = _context.next) {
|
|
1095
|
-
case 0:
|
|
1096
|
-
_context.t0 = TokenAmount;
|
|
1097
|
-
_context.t1 = this.underlying;
|
|
1098
|
-
_context.next = 4;
|
|
1099
|
-
return this.auToken.totalBorrows();
|
|
1100
|
-
|
|
1101
|
-
case 4:
|
|
1102
|
-
_context.t2 = _context.sent.toString();
|
|
1103
|
-
return _context.abrupt("return", new _context.t0(_context.t1, _context.t2));
|
|
1104
|
-
|
|
1105
|
-
case 6:
|
|
1106
|
-
case "end":
|
|
1107
|
-
return _context.stop();
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
}, _callee, this);
|
|
1111
|
-
}));
|
|
1112
|
-
|
|
1113
|
-
function getTotalTokenBorrowed() {
|
|
1114
|
-
return _getTotalTokenBorrowed.apply(this, arguments);
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
return getTotalTokenBorrowed;
|
|
1118
|
-
}();
|
|
1119
|
-
|
|
1120
|
-
_proto.getTotalTokenDeposited = /*#__PURE__*/function () {
|
|
1121
|
-
var _getTotalTokenDeposited = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1122
|
-
var _this2 = this;
|
|
1123
|
-
|
|
1124
|
-
var promises, totalBorrow, totalCash;
|
|
1125
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1126
|
-
while (1) {
|
|
1127
|
-
switch (_context2.prev = _context2.next) {
|
|
1128
|
-
case 0:
|
|
1129
|
-
promises = [];
|
|
1130
|
-
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
1131
|
-
totalBorrow = res;
|
|
1132
|
-
}));
|
|
1133
|
-
promises.push(this.auToken.getCash().then(function (res) {
|
|
1134
|
-
totalCash = new TokenAmount(_this2.underlying, res.toString());
|
|
1135
|
-
}));
|
|
1136
|
-
_context2.next = 5;
|
|
1137
|
-
return Promise.all(promises);
|
|
1138
|
-
|
|
1139
|
-
case 5:
|
|
1140
|
-
return _context2.abrupt("return", new TokenAmount(this.underlying, ethers$1.BigNumber.from(totalCash.rawAmount).add(totalBorrow.rawAmount()).toString()));
|
|
1141
|
-
|
|
1142
|
-
case 6:
|
|
1143
|
-
case "end":
|
|
1144
|
-
return _context2.stop();
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
}, _callee2, this);
|
|
1148
|
-
}));
|
|
1149
|
-
|
|
1150
|
-
function getTotalTokenDeposited() {
|
|
1151
|
-
return _getTotalTokenDeposited.apply(this, arguments);
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
return getTotalTokenDeposited;
|
|
1155
|
-
}();
|
|
1156
|
-
|
|
1157
|
-
_proto.getDepositAPY = /*#__PURE__*/function () {
|
|
1158
|
-
var _getDepositAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1159
|
-
var supplyRatePerTimestamp;
|
|
1160
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1161
|
-
while (1) {
|
|
1162
|
-
switch (_context3.prev = _context3.next) {
|
|
1163
|
-
case 0:
|
|
1164
|
-
_context3.next = 2;
|
|
1165
|
-
return this.auToken.supplyRatePerTimestamp();
|
|
1166
|
-
|
|
1167
|
-
case 2:
|
|
1168
|
-
supplyRatePerTimestamp = _context3.sent;
|
|
1169
|
-
return _context3.abrupt("return", new BigNumber(supplyRatePerTimestamp.toString()).multipliedBy(60 * 60 * 24 * 365).div(decimalFactor(18)));
|
|
1170
|
-
|
|
1171
|
-
case 4:
|
|
1172
|
-
case "end":
|
|
1173
|
-
return _context3.stop();
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}, _callee3, this);
|
|
1177
|
-
}));
|
|
1178
|
-
|
|
1179
|
-
function getDepositAPY() {
|
|
1180
|
-
return _getDepositAPY.apply(this, arguments);
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
return getDepositAPY;
|
|
1184
|
-
}();
|
|
1185
|
-
|
|
1186
|
-
_proto.getBorrowAPY = /*#__PURE__*/function () {
|
|
1187
|
-
var _getBorrowAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
1188
|
-
var borrowRatePerTimestamp;
|
|
1189
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1190
|
-
while (1) {
|
|
1191
|
-
switch (_context4.prev = _context4.next) {
|
|
1192
|
-
case 0:
|
|
1193
|
-
_context4.next = 2;
|
|
1194
|
-
return this.auToken.borrowRatePerTimestamp();
|
|
1195
|
-
|
|
1196
|
-
case 2:
|
|
1197
|
-
borrowRatePerTimestamp = _context4.sent;
|
|
1198
|
-
return _context4.abrupt("return", new BigNumber(borrowRatePerTimestamp.toString()).multipliedBy(60 * 60 * 24 * 365).div(decimalFactor(18)));
|
|
1199
|
-
|
|
1200
|
-
case 4:
|
|
1201
|
-
case "end":
|
|
1202
|
-
return _context4.stop();
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
}, _callee4, this);
|
|
1206
|
-
}));
|
|
1207
|
-
|
|
1208
|
-
function getBorrowAPY() {
|
|
1209
|
-
return _getBorrowAPY.apply(this, arguments);
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
return getBorrowAPY;
|
|
1213
|
-
}();
|
|
1214
|
-
|
|
1215
|
-
_proto.getCollateralRatio = /*#__PURE__*/function () {
|
|
1216
|
-
var _getCollateralRatio = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
|
|
1217
|
-
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1218
|
-
while (1) {
|
|
1219
|
-
switch (_context5.prev = _context5.next) {
|
|
1220
|
-
case 0:
|
|
1221
|
-
return _context5.abrupt("return", this._comptroller.markets(this.auToken.address).then(function (res) {
|
|
1222
|
-
return new BigNumber(res.collateralFactorMantissa.toString()).div(decimalFactor(18));
|
|
1223
|
-
}));
|
|
1224
|
-
|
|
1225
|
-
case 1:
|
|
1226
|
-
case "end":
|
|
1227
|
-
return _context5.stop();
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
}, _callee5, this);
|
|
1231
|
-
}));
|
|
1232
|
-
|
|
1233
|
-
function getCollateralRatio() {
|
|
1234
|
-
return _getCollateralRatio.apply(this, arguments);
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
return getCollateralRatio;
|
|
1238
|
-
}();
|
|
1239
|
-
|
|
1240
|
-
_proto.getBorrowPlyAPY = /*#__PURE__*/function () {
|
|
1241
|
-
var _getBorrowPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
1242
|
-
var promises, totalBorrowed, rewardSpeed, plyPrice, underlyingPrice;
|
|
1243
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1244
|
-
while (1) {
|
|
1245
|
-
switch (_context6.prev = _context6.next) {
|
|
1246
|
-
case 0:
|
|
1247
|
-
promises = [];
|
|
1248
|
-
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
1249
|
-
totalBorrowed = res;
|
|
1250
|
-
}));
|
|
1251
|
-
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1252
|
-
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1253
|
-
}));
|
|
1254
|
-
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1255
|
-
plyPrice = res;
|
|
1256
|
-
}));
|
|
1257
|
-
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1258
|
-
underlyingPrice = res;
|
|
1259
|
-
}));
|
|
1260
|
-
_context6.next = 7;
|
|
1261
|
-
return Promise.all(promises);
|
|
1262
|
-
|
|
1263
|
-
case 7:
|
|
1264
|
-
return _context6.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR));
|
|
1265
|
-
|
|
1266
|
-
case 8:
|
|
1267
|
-
case "end":
|
|
1268
|
-
return _context6.stop();
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}, _callee6, this);
|
|
1272
|
-
}));
|
|
1273
|
-
|
|
1274
|
-
function getBorrowPlyAPY() {
|
|
1275
|
-
return _getBorrowPlyAPY.apply(this, arguments);
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
return getBorrowPlyAPY;
|
|
1279
|
-
}();
|
|
1280
|
-
|
|
1281
|
-
_proto.getDepositPlyAPY = /*#__PURE__*/function () {
|
|
1282
|
-
var _getDepositPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
1283
|
-
var promises, totalDeposited, rewardSpeed, plyPrice, underlyingPrice;
|
|
1284
|
-
return runtime_1.wrap(function _callee7$(_context7) {
|
|
1285
|
-
while (1) {
|
|
1286
|
-
switch (_context7.prev = _context7.next) {
|
|
1287
|
-
case 0:
|
|
1288
|
-
promises = [];
|
|
1289
|
-
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
1290
|
-
totalDeposited = res;
|
|
1291
|
-
}));
|
|
1292
|
-
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1293
|
-
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1294
|
-
}));
|
|
1295
|
-
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1296
|
-
plyPrice = res;
|
|
1297
|
-
}));
|
|
1298
|
-
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1299
|
-
underlyingPrice = res;
|
|
1300
|
-
}));
|
|
1301
|
-
_context7.next = 7;
|
|
1302
|
-
return Promise.all(promises);
|
|
1303
|
-
|
|
1304
|
-
case 7:
|
|
1305
|
-
return _context7.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR));
|
|
1306
|
-
|
|
1307
|
-
case 8:
|
|
1308
|
-
case "end":
|
|
1309
|
-
return _context7.stop();
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
}, _callee7, this);
|
|
1313
|
-
}));
|
|
1314
|
-
|
|
1315
|
-
function getDepositPlyAPY() {
|
|
1316
|
-
return _getDepositPlyAPY.apply(this, arguments);
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
return getDepositPlyAPY;
|
|
1320
|
-
}();
|
|
1321
|
-
|
|
1322
|
-
_proto.getDetails = /*#__PURE__*/function () {
|
|
1323
|
-
var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
1324
|
-
var promises, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeed, plyPrice, underlyingPrice, borrowPlyApy, depositPlyApy;
|
|
1325
|
-
return runtime_1.wrap(function _callee8$(_context8) {
|
|
1326
|
-
while (1) {
|
|
1327
|
-
switch (_context8.prev = _context8.next) {
|
|
1328
|
-
case 0:
|
|
1329
|
-
promises = [];
|
|
1330
|
-
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
1331
|
-
totalDeposited = res;
|
|
1332
|
-
}));
|
|
1333
|
-
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
1334
|
-
totalBorrowed = res;
|
|
1335
|
-
}));
|
|
1336
|
-
promises.push(this.getDepositAPY().then(function (res) {
|
|
1337
|
-
depositAPY = res.toNumber();
|
|
1338
|
-
}));
|
|
1339
|
-
promises.push(this.getBorrowAPY().then(function (res) {
|
|
1340
|
-
borrowAPY = res.toNumber();
|
|
1341
|
-
}));
|
|
1342
|
-
promises.push(this.getCollateralRatio().then(function (res) {
|
|
1343
|
-
collateralRatio = res.toNumber();
|
|
1344
|
-
}));
|
|
1345
|
-
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address).then(function (res) {
|
|
1346
|
-
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
1347
|
-
}));
|
|
1348
|
-
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
1349
|
-
plyPrice = res;
|
|
1350
|
-
}));
|
|
1351
|
-
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
1352
|
-
underlyingPrice = res;
|
|
1353
|
-
}));
|
|
1354
|
-
_context8.next = 11;
|
|
1355
|
-
return Promise.all(promises);
|
|
1356
|
-
|
|
1357
|
-
case 11:
|
|
1358
|
-
borrowPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR);
|
|
1359
|
-
depositPlyApy = calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR);
|
|
1360
|
-
return _context8.abrupt("return", {
|
|
1361
|
-
auTokenAddress: this.auToken.address,
|
|
1362
|
-
totalTokenDeposited: totalDeposited,
|
|
1363
|
-
totalTokenBorrowed: totalBorrowed,
|
|
1364
|
-
depositApy: depositAPY,
|
|
1365
|
-
depositPlyApy: depositPlyApy.toNumber(),
|
|
1366
|
-
borrowApy: borrowAPY,
|
|
1367
|
-
borrowPlyApy: borrowPlyApy.toNumber(),
|
|
1368
|
-
collateralRatio: collateralRatio
|
|
1369
|
-
});
|
|
1370
|
-
|
|
1371
|
-
case 14:
|
|
1372
|
-
case "end":
|
|
1373
|
-
return _context8.stop();
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
}, _callee8, this);
|
|
1377
|
-
}));
|
|
1378
|
-
|
|
1379
|
-
function getDetails() {
|
|
1380
|
-
return _getDetails.apply(this, arguments);
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
return getDetails;
|
|
1384
|
-
}();
|
|
1385
|
-
|
|
1386
|
-
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
1387
|
-
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(userAddress) {
|
|
1388
|
-
var totalBorrow;
|
|
1389
|
-
return runtime_1.wrap(function _callee9$(_context9) {
|
|
1390
|
-
while (1) {
|
|
1391
|
-
switch (_context9.prev = _context9.next) {
|
|
1392
|
-
case 0:
|
|
1393
|
-
_context9.next = 2;
|
|
1394
|
-
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
1395
|
-
|
|
1396
|
-
case 2:
|
|
1397
|
-
totalBorrow = _context9.sent;
|
|
1398
|
-
return _context9.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
1399
|
-
|
|
1400
|
-
case 4:
|
|
1401
|
-
case "end":
|
|
1402
|
-
return _context9.stop();
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
}, _callee9, this);
|
|
1406
|
-
}));
|
|
1407
|
-
|
|
1408
|
-
function getUserBorrowBalance(_x) {
|
|
1409
|
-
return _getUserBorrowBalance.apply(this, arguments);
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
return getUserBorrowBalance;
|
|
1413
|
-
}();
|
|
1414
|
-
|
|
1415
|
-
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
1416
|
-
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(userAddress) {
|
|
1417
|
-
var totalDeposit;
|
|
1418
|
-
return runtime_1.wrap(function _callee10$(_context10) {
|
|
1419
|
-
while (1) {
|
|
1420
|
-
switch (_context10.prev = _context10.next) {
|
|
1421
|
-
case 0:
|
|
1422
|
-
_context10.next = 2;
|
|
1423
|
-
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
1424
|
-
|
|
1425
|
-
case 2:
|
|
1426
|
-
totalDeposit = _context10.sent;
|
|
1427
|
-
return _context10.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
1428
|
-
|
|
1429
|
-
case 4:
|
|
1430
|
-
case "end":
|
|
1431
|
-
return _context10.stop();
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
}, _callee10, this);
|
|
1435
|
-
}));
|
|
1436
|
-
|
|
1437
|
-
function getUserDepositBalance(_x2) {
|
|
1438
|
-
return _getUserDepositBalance.apply(this, arguments);
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
return getUserDepositBalance;
|
|
1442
|
-
}();
|
|
1443
|
-
|
|
1444
|
-
return MoneyMarketRead;
|
|
1445
|
-
}(BlockchainEntityRead);
|
|
1446
|
-
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
1447
|
-
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
1448
|
-
|
|
1449
|
-
function MoneyMarketReadWrite() {
|
|
1450
|
-
return _MoneyMarketRead.apply(this, arguments) || this;
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
1454
|
-
|
|
1455
|
-
_proto2.deposit = /*#__PURE__*/function () {
|
|
1456
|
-
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(amount) {
|
|
1457
|
-
return runtime_1.wrap(function _callee11$(_context11) {
|
|
1458
|
-
while (1) {
|
|
1459
|
-
switch (_context11.prev = _context11.next) {
|
|
1460
|
-
case 0:
|
|
1461
|
-
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1462
|
-
_context11.next = 4;
|
|
1463
|
-
break;
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
1467
|
-
value: amount.rawAmount()
|
|
1468
|
-
}));
|
|
1469
|
-
|
|
1470
|
-
case 4:
|
|
1471
|
-
return _context11.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
1472
|
-
|
|
1473
|
-
case 5:
|
|
1474
|
-
case "end":
|
|
1475
|
-
return _context11.stop();
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
}, _callee11, this);
|
|
1479
|
-
}));
|
|
1480
|
-
|
|
1481
|
-
function deposit(_x3) {
|
|
1482
|
-
return _deposit.apply(this, arguments);
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
return deposit;
|
|
1486
|
-
}();
|
|
1487
|
-
|
|
1488
|
-
_proto2.borrow = /*#__PURE__*/function () {
|
|
1489
|
-
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
|
|
1490
|
-
return runtime_1.wrap(function _callee12$(_context12) {
|
|
1491
|
-
while (1) {
|
|
1492
|
-
switch (_context12.prev = _context12.next) {
|
|
1493
|
-
case 0:
|
|
1494
|
-
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
1495
|
-
|
|
1496
|
-
case 1:
|
|
1497
|
-
case "end":
|
|
1498
|
-
return _context12.stop();
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
}, _callee12, this);
|
|
1502
|
-
}));
|
|
1503
|
-
|
|
1504
|
-
function borrow(_x4) {
|
|
1505
|
-
return _borrow.apply(this, arguments);
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
return borrow;
|
|
1509
|
-
}();
|
|
1510
|
-
|
|
1511
|
-
_proto2.withdraw = /*#__PURE__*/function () {
|
|
1512
|
-
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(amount) {
|
|
1513
|
-
return runtime_1.wrap(function _callee13$(_context13) {
|
|
1514
|
-
while (1) {
|
|
1515
|
-
switch (_context13.prev = _context13.next) {
|
|
1516
|
-
case 0:
|
|
1517
|
-
return _context13.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
1518
|
-
|
|
1519
|
-
case 1:
|
|
1520
|
-
case "end":
|
|
1521
|
-
return _context13.stop();
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
}, _callee13, this);
|
|
1525
|
-
}));
|
|
1526
|
-
|
|
1527
|
-
function withdraw(_x5) {
|
|
1528
|
-
return _withdraw.apply(this, arguments);
|
|
1529
|
-
}
|
|
1530
|
-
|
|
1531
|
-
return withdraw;
|
|
1532
|
-
}();
|
|
1533
|
-
|
|
1534
|
-
_proto2.repay = /*#__PURE__*/function () {
|
|
1535
|
-
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
|
|
1536
|
-
return runtime_1.wrap(function _callee14$(_context14) {
|
|
1537
|
-
while (1) {
|
|
1538
|
-
switch (_context14.prev = _context14.next) {
|
|
1539
|
-
case 0:
|
|
1540
|
-
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
1541
|
-
_context14.next = 4;
|
|
1542
|
-
break;
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
1546
|
-
value: amount.rawAmount()
|
|
1547
|
-
}));
|
|
1548
|
-
|
|
1549
|
-
case 4:
|
|
1550
|
-
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
1551
|
-
|
|
1552
|
-
case 5:
|
|
1553
|
-
case "end":
|
|
1554
|
-
return _context14.stop();
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
}, _callee14, this);
|
|
1558
|
-
}));
|
|
1559
|
-
|
|
1560
|
-
function repay(_x6) {
|
|
1561
|
-
return _repay.apply(this, arguments);
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1564
|
-
return repay;
|
|
1565
|
-
}();
|
|
1566
|
-
|
|
1567
|
-
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
1568
|
-
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15() {
|
|
1569
|
-
return runtime_1.wrap(function _callee15$(_context15) {
|
|
1570
|
-
while (1) {
|
|
1571
|
-
switch (_context15.prev = _context15.next) {
|
|
1572
|
-
case 0:
|
|
1573
|
-
return _context15.abrupt("return", this._comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
1574
|
-
|
|
1575
|
-
case 1:
|
|
1576
|
-
case "end":
|
|
1577
|
-
return _context15.stop();
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
}, _callee15, this);
|
|
1581
|
-
}));
|
|
1582
|
-
|
|
1583
|
-
function enableCollateral() {
|
|
1584
|
-
return _enableCollateral.apply(this, arguments);
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
|
-
return enableCollateral;
|
|
1588
|
-
}();
|
|
1589
|
-
|
|
1590
|
-
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
1591
|
-
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
|
|
1592
|
-
return runtime_1.wrap(function _callee16$(_context16) {
|
|
1593
|
-
while (1) {
|
|
1594
|
-
switch (_context16.prev = _context16.next) {
|
|
1595
|
-
case 0:
|
|
1596
|
-
return _context16.abrupt("return", this._comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
1597
|
-
|
|
1598
|
-
case 1:
|
|
1599
|
-
case "end":
|
|
1600
|
-
return _context16.stop();
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
}, _callee16, this);
|
|
1604
|
-
}));
|
|
1605
|
-
|
|
1606
|
-
function disableCollateral() {
|
|
1607
|
-
return _disableCollateral.apply(this, arguments);
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1610
|
-
return disableCollateral;
|
|
1611
|
-
}();
|
|
1612
|
-
|
|
1613
|
-
return MoneyMarketReadWrite;
|
|
1614
|
-
}(MoneyMarketRead);
|
|
1615
|
-
var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
1616
|
-
_inheritsLoose(MoneyMarket, _BlockchainEntity);
|
|
1617
|
-
|
|
1618
|
-
function MoneyMarket(address, underlying) {
|
|
1619
|
-
var _this3;
|
|
1620
|
-
|
|
1621
|
-
_this3 = _BlockchainEntity.call(this) || this;
|
|
1622
|
-
_this3.address = validateAndParseAddress(address);
|
|
1623
|
-
_this3.underlying = validateAndParseAddress(underlying);
|
|
1624
|
-
return _this3;
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
var _proto3 = MoneyMarket.prototype;
|
|
1628
|
-
|
|
1629
|
-
_proto3.read = function read(networkConnection) {
|
|
1630
|
-
return new MoneyMarketRead(networkConnection, this.address, this.underlying);
|
|
1631
|
-
};
|
|
1632
|
-
|
|
1633
|
-
return MoneyMarket;
|
|
1634
|
-
}(BlockchainEntity);
|
|
1635
|
-
|
|
1636
1062
|
var abi = [
|
|
1637
1063
|
{
|
|
1638
1064
|
inputs: [
|
|
@@ -2582,304 +2008,942 @@ var IUniswapV2PairABI = {
|
|
|
2582
2008
|
deployedLinkReferences: deployedLinkReferences
|
|
2583
2009
|
};
|
|
2584
2010
|
|
|
2585
|
-
var abi$2 = [
|
|
2586
|
-
];
|
|
2587
|
-
var dummyABI = {
|
|
2588
|
-
abi: abi$2
|
|
2589
|
-
};
|
|
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));
|
|
2590
2602
|
|
|
2591
|
-
|
|
2603
|
+
case 8:
|
|
2604
|
+
case "end":
|
|
2605
|
+
return _context8.stop();
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
}, _callee8, this);
|
|
2609
|
+
}));
|
|
2592
2610
|
|
|
2593
|
-
function
|
|
2594
|
-
|
|
2595
|
-
}
|
|
2611
|
+
function getDepositPlyAPY() {
|
|
2612
|
+
return _getDepositPlyAPY.apply(this, arguments);
|
|
2613
|
+
}
|
|
2596
2614
|
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
var price;
|
|
2600
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2601
|
-
while (1) {
|
|
2602
|
-
switch (_context.prev = _context.next) {
|
|
2603
|
-
case 0:
|
|
2604
|
-
_context.next = 2;
|
|
2605
|
-
return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=" + id + "&vs_currencies=usd").then(function (res) {
|
|
2606
|
-
return res.data;
|
|
2607
|
-
});
|
|
2615
|
+
return getDepositPlyAPY;
|
|
2616
|
+
}();
|
|
2608
2617
|
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
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);
|
|
2612
2652
|
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
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
|
+
}
|
|
2616
2687
|
}
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
}));
|
|
2620
|
-
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2621
|
-
}
|
|
2688
|
+
}, _callee9, this);
|
|
2689
|
+
}));
|
|
2622
2690
|
|
|
2623
|
-
function
|
|
2624
|
-
|
|
2625
|
-
}
|
|
2691
|
+
function getDetails() {
|
|
2692
|
+
return _getDetails.apply(this, arguments);
|
|
2693
|
+
}
|
|
2626
2694
|
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2630
|
-
while (1) {
|
|
2631
|
-
switch (_context2.prev = _context2.next) {
|
|
2632
|
-
case 0:
|
|
2633
|
-
if (!isSameAddress(address, networkAddresses.tokens.AURORA)) {
|
|
2634
|
-
_context2.next = 4;
|
|
2635
|
-
break;
|
|
2636
|
-
}
|
|
2695
|
+
return getDetails;
|
|
2696
|
+
}();
|
|
2637
2697
|
|
|
2638
|
-
|
|
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);
|
|
2639
2707
|
|
|
2640
|
-
|
|
2641
|
-
|
|
2708
|
+
case 2:
|
|
2709
|
+
totalBorrow = _context10.sent;
|
|
2710
|
+
return _context10.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
2642
2711
|
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2712
|
+
case 4:
|
|
2713
|
+
case "end":
|
|
2714
|
+
return _context10.stop();
|
|
2715
|
+
}
|
|
2646
2716
|
}
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
}));
|
|
2650
|
-
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2651
|
-
}
|
|
2717
|
+
}, _callee10, this);
|
|
2718
|
+
}));
|
|
2652
2719
|
|
|
2653
|
-
function
|
|
2654
|
-
|
|
2655
|
-
}
|
|
2720
|
+
function getUserBorrowBalance(_x) {
|
|
2721
|
+
return _getUserBorrowBalance.apply(this, arguments);
|
|
2722
|
+
}
|
|
2656
2723
|
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
var promises, LPContract, values;
|
|
2660
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2661
|
-
while (1) {
|
|
2662
|
-
switch (_context3.prev = _context3.next) {
|
|
2663
|
-
case 0:
|
|
2664
|
-
promises = [];
|
|
2665
|
-
LPContract = new ethers$1.Contract(LPAddress, IUniswapV2PairABI.abi, provider);
|
|
2666
|
-
promises.push(LPContract.token0());
|
|
2667
|
-
promises.push(LPContract.toekn1());
|
|
2668
|
-
promises.push(LPContract.getReserves());
|
|
2669
|
-
promises.push(LPContract.totalSupply());
|
|
2670
|
-
_context3.next = 8;
|
|
2671
|
-
return Promise.all(promises);
|
|
2724
|
+
return getUserBorrowBalance;
|
|
2725
|
+
}();
|
|
2672
2726
|
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
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);
|
|
2682
2736
|
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
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
|
+
}
|
|
2686
2745
|
}
|
|
2687
|
-
}
|
|
2688
|
-
}
|
|
2689
|
-
}));
|
|
2690
|
-
return _fetchLPPositions.apply(this, arguments);
|
|
2691
|
-
}
|
|
2746
|
+
}, _callee11, this);
|
|
2747
|
+
}));
|
|
2692
2748
|
|
|
2693
|
-
function
|
|
2694
|
-
|
|
2695
|
-
}
|
|
2749
|
+
function getUserDepositBalance(_x2) {
|
|
2750
|
+
return _getUserDepositBalance.apply(this, arguments);
|
|
2751
|
+
}
|
|
2696
2752
|
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
var LPInfo, token0Price, reserveUSD, token1Price, _reserveUSD;
|
|
2753
|
+
return getUserDepositBalance;
|
|
2754
|
+
}();
|
|
2700
2755
|
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
_context4.next = 2;
|
|
2706
|
-
return fetchLPPositions(address, provider);
|
|
2756
|
+
return MoneyMarketRead;
|
|
2757
|
+
}(BlockchainEntityRead);
|
|
2758
|
+
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
2759
|
+
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
2707
2760
|
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
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()));
|
|
2713
2807
|
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2808
|
+
case 1:
|
|
2809
|
+
case "end":
|
|
2810
|
+
return _context13.stop();
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
}, _callee13, this);
|
|
2814
|
+
}));
|
|
2718
2815
|
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
_context4.prev = 13;
|
|
2723
|
-
_context4.next = 16;
|
|
2724
|
-
return fetchPrice(LPInfo.token1, provider);
|
|
2816
|
+
function borrow(_x4) {
|
|
2817
|
+
return _borrow.apply(this, arguments);
|
|
2818
|
+
}
|
|
2725
2819
|
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
_reserveUSD = token1Price.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(2);
|
|
2729
|
-
return _context4.abrupt("return", _reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
|
|
2820
|
+
return borrow;
|
|
2821
|
+
}();
|
|
2730
2822
|
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
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()));
|
|
2735
2830
|
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2831
|
+
case 1:
|
|
2832
|
+
case "end":
|
|
2833
|
+
return _context14.stop();
|
|
2834
|
+
}
|
|
2739
2835
|
}
|
|
2740
|
-
}
|
|
2741
|
-
}
|
|
2742
|
-
}));
|
|
2743
|
-
return _fetchLPPrice.apply(this, arguments);
|
|
2744
|
-
}
|
|
2836
|
+
}, _callee14, this);
|
|
2837
|
+
}));
|
|
2745
2838
|
|
|
2746
|
-
function
|
|
2747
|
-
|
|
2748
|
-
}
|
|
2839
|
+
function withdraw(_x5) {
|
|
2840
|
+
return _withdraw.apply(this, arguments);
|
|
2841
|
+
}
|
|
2749
2842
|
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
}
|
|
2843
|
+
return withdraw;
|
|
2844
|
+
}();
|
|
2753
2845
|
|
|
2754
|
-
function
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
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
|
+
}
|
|
2764
2856
|
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2857
|
+
return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
2858
|
+
value: amount.rawAmount()
|
|
2859
|
+
}));
|
|
2768
2860
|
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
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
|
+
}
|
|
2772
2868
|
}
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
}));
|
|
2776
|
-
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2777
|
-
}
|
|
2869
|
+
}, _callee15, this);
|
|
2870
|
+
}));
|
|
2778
2871
|
|
|
2779
|
-
function
|
|
2780
|
-
|
|
2781
|
-
}
|
|
2872
|
+
function repay(_x6) {
|
|
2873
|
+
return _repay.apply(this, arguments);
|
|
2874
|
+
}
|
|
2782
2875
|
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
|
|
2786
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2787
|
-
while (1) {
|
|
2788
|
-
switch (_context6.prev = _context6.next) {
|
|
2789
|
-
case 0:
|
|
2790
|
-
auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, dummyABI.abi, provider);
|
|
2791
|
-
auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
|
|
2792
|
-
return auToken.address;
|
|
2793
|
-
});
|
|
2794
|
-
underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
|
|
2795
|
-
return getDecimal(auToken.underlying);
|
|
2796
|
-
});
|
|
2797
|
-
_context6.next = 5;
|
|
2798
|
-
return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
|
|
2876
|
+
return repay;
|
|
2877
|
+
}();
|
|
2799
2878
|
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
}));
|
|
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]));
|
|
2808
2886
|
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2887
|
+
case 1:
|
|
2888
|
+
case "end":
|
|
2889
|
+
return _context16.stop();
|
|
2890
|
+
}
|
|
2812
2891
|
}
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
}));
|
|
2816
|
-
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2817
|
-
}
|
|
2892
|
+
}, _callee16, this);
|
|
2893
|
+
}));
|
|
2818
2894
|
|
|
2819
|
-
function
|
|
2820
|
-
|
|
2821
|
-
}
|
|
2895
|
+
function enableCollateral() {
|
|
2896
|
+
return _enableCollateral.apply(this, arguments);
|
|
2897
|
+
}
|
|
2822
2898
|
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
var matchingAuToken;
|
|
2826
|
-
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2827
|
-
while (1) {
|
|
2828
|
-
switch (_context7.prev = _context7.next) {
|
|
2829
|
-
case 0:
|
|
2830
|
-
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2831
|
-
return isSameAddress(auToken.underlying, address);
|
|
2832
|
-
});
|
|
2899
|
+
return enableCollateral;
|
|
2900
|
+
}();
|
|
2833
2901
|
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
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));
|
|
2838
2909
|
|
|
2839
|
-
|
|
2910
|
+
case 1:
|
|
2911
|
+
case "end":
|
|
2912
|
+
return _context17.stop();
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
}, _callee17, this);
|
|
2916
|
+
}));
|
|
2840
2917
|
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
break;
|
|
2845
|
-
}
|
|
2918
|
+
function disableCollateral() {
|
|
2919
|
+
return _disableCollateral.apply(this, arguments);
|
|
2920
|
+
}
|
|
2846
2921
|
|
|
2847
|
-
|
|
2922
|
+
return disableCollateral;
|
|
2923
|
+
}();
|
|
2848
2924
|
|
|
2849
|
-
|
|
2850
|
-
|
|
2925
|
+
return MoneyMarketReadWrite;
|
|
2926
|
+
}(MoneyMarketRead);
|
|
2927
|
+
var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
2928
|
+
_inheritsLoose(MoneyMarket, _BlockchainEntity);
|
|
2851
2929
|
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
return _context7.stop();
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
}, _callee7);
|
|
2858
|
-
}));
|
|
2859
|
-
return _fetchPrice.apply(this, arguments);
|
|
2860
|
-
}
|
|
2930
|
+
function MoneyMarket(address, underlying) {
|
|
2931
|
+
var _this3;
|
|
2861
2932
|
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2933
|
+
_this3 = _BlockchainEntity.call(this) || this;
|
|
2934
|
+
_this3.address = validateAndParseAddress(address);
|
|
2935
|
+
_this3.underlying = validateAndParseAddress(underlying);
|
|
2936
|
+
return _this3;
|
|
2937
|
+
}
|
|
2865
2938
|
|
|
2866
|
-
|
|
2867
|
-
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider, price) {
|
|
2868
|
-
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2869
|
-
while (1) {
|
|
2870
|
-
switch (_context8.prev = _context8.next) {
|
|
2871
|
-
case 0:
|
|
2872
|
-
return _context8.abrupt("return", new BigNumber(0));
|
|
2939
|
+
var _proto3 = MoneyMarket.prototype;
|
|
2873
2940
|
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
}));
|
|
2881
|
-
return _fetchValuation.apply(this, arguments);
|
|
2882
|
-
}
|
|
2941
|
+
_proto3.read = function read(networkConnection) {
|
|
2942
|
+
return new MoneyMarketRead(networkConnection, this.address, this.underlying);
|
|
2943
|
+
};
|
|
2944
|
+
|
|
2945
|
+
return MoneyMarket;
|
|
2946
|
+
}(BlockchainEntity);
|
|
2883
2947
|
|
|
2884
2948
|
var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2885
2949
|
_inheritsLoose(SdkRead, _BlockchainEntityRead);
|
|
@@ -2891,7 +2955,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2891
2955
|
_this._comptroller = new ethers$1.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
|
|
2892
2956
|
_this._tokenLock = new ethers$1.Contract(networkAddresses.misc.TOKENLOCK, TokenLockABI.abi, networkConnection.provider);
|
|
2893
2957
|
_this._auriFairLaunch = new ethers$1.Contract(networkAddresses.misc.AURIFAIRLAUNCH, AuriFairLaunchABI.abi, networkConnection.provider);
|
|
2894
|
-
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS,
|
|
2958
|
+
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
|
|
2895
2959
|
return _this;
|
|
2896
2960
|
}
|
|
2897
2961
|
|
|
@@ -2904,10 +2968,11 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2904
2968
|
while (1) {
|
|
2905
2969
|
switch (_context.prev = _context.next) {
|
|
2906
2970
|
case 0:
|
|
2907
|
-
|
|
2971
|
+
console.log(this._networkConnection.provider);
|
|
2972
|
+
_context.next = 3;
|
|
2908
2973
|
return getCurrentTimestamp(this._networkConnection.provider);
|
|
2909
2974
|
|
|
2910
|
-
case
|
|
2975
|
+
case 3:
|
|
2911
2976
|
currentTime = _context.sent;
|
|
2912
2977
|
currentWeek = ethers$1.BigNumber.from(currentTime - REWARDCLAIMSTART).div(7 * ONE_DAY).toNumber();
|
|
2913
2978
|
denominator = 10000;
|
|
@@ -2916,22 +2981,22 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2916
2981
|
promises.push(this._tokenLock.percentageLock(currentWeek + 1)["catch"](function (err) {
|
|
2917
2982
|
return denominator;
|
|
2918
2983
|
}));
|
|
2919
|
-
_context.next =
|
|
2984
|
+
_context.next = 11;
|
|
2920
2985
|
return Promise.all(promises).then(function (res) {
|
|
2921
2986
|
return res.map(function (v) {
|
|
2922
2987
|
return v.toString();
|
|
2923
2988
|
});
|
|
2924
2989
|
});
|
|
2925
2990
|
|
|
2926
|
-
case
|
|
2991
|
+
case 11:
|
|
2927
2992
|
values = _context.sent;
|
|
2928
2993
|
return _context.abrupt("return", {
|
|
2929
2994
|
vestingStart: REWARDCLAIMSTART,
|
|
2930
|
-
currentUnlockPortion: new BigNumber(values[0]).div(denominator).toNumber(),
|
|
2931
|
-
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()
|
|
2932
2997
|
});
|
|
2933
2998
|
|
|
2934
|
-
case
|
|
2999
|
+
case 13:
|
|
2935
3000
|
case "end":
|
|
2936
3001
|
return _context.stop();
|
|
2937
3002
|
}
|
|
@@ -2958,6 +3023,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2958
3023
|
case 0:
|
|
2959
3024
|
marketCount = networkAddresses.auTokens.length;
|
|
2960
3025
|
userMarketDetails = [];
|
|
3026
|
+
collateralRatio = new Array(marketCount);
|
|
2961
3027
|
promises = [];
|
|
2962
3028
|
totalBorrowLimit = new BigNumber(0);
|
|
2963
3029
|
pricePromises = [];
|
|
@@ -2987,14 +3053,14 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2987
3053
|
promises.push(this._comptroller.getAssetsIn(userAddress).then(function (res) {
|
|
2988
3054
|
assetsIn = res;
|
|
2989
3055
|
}));
|
|
2990
|
-
_context2.next =
|
|
3056
|
+
_context2.next = 11;
|
|
2991
3057
|
return Promise.all(promises);
|
|
2992
3058
|
|
|
2993
|
-
case
|
|
2994
|
-
_context2.next =
|
|
3059
|
+
case 11:
|
|
3060
|
+
_context2.next = 13;
|
|
2995
3061
|
return Promise.all(pricePromises);
|
|
2996
3062
|
|
|
2997
|
-
case
|
|
3063
|
+
case 13:
|
|
2998
3064
|
underlyingPrices = _context2.sent;
|
|
2999
3065
|
depositValuationPromises = [];
|
|
3000
3066
|
|
|
@@ -3014,10 +3080,10 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3014
3080
|
_loop();
|
|
3015
3081
|
}
|
|
3016
3082
|
|
|
3017
|
-
_context2.next =
|
|
3083
|
+
_context2.next = 19;
|
|
3018
3084
|
return Promise.all(depositValuationPromises);
|
|
3019
3085
|
|
|
3020
|
-
case
|
|
3086
|
+
case 19:
|
|
3021
3087
|
depositValues = _context2.sent;
|
|
3022
3088
|
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
3023
3089
|
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(collateralRatio[index]));
|
|
@@ -3025,12 +3091,12 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3025
3091
|
});
|
|
3026
3092
|
promises = [];
|
|
3027
3093
|
promises.push(this._comptroller.getAccountLiquidity(userAddress));
|
|
3028
|
-
promises.push(this._auriLens.getRewardBalancesMetadata(this._comptroller.address, userAddress));
|
|
3094
|
+
promises.push(this._auriLens.callStatic.getRewardBalancesMetadata(this._comptroller.address, this._auriFairLaunch.address, userAddress, [AurPlyPid]));
|
|
3029
3095
|
promises.push(this._tokenLock.lockedAmounts(userAddress));
|
|
3030
|
-
_context2.next =
|
|
3096
|
+
_context2.next = 27;
|
|
3031
3097
|
return Promise.all(promises);
|
|
3032
3098
|
|
|
3033
|
-
case
|
|
3099
|
+
case 27:
|
|
3034
3100
|
values = _context2.sent;
|
|
3035
3101
|
accountLiquidity = values[0];
|
|
3036
3102
|
rewardBalancesMetadata = values[1];
|
|
@@ -3064,7 +3130,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3064
3130
|
}
|
|
3065
3131
|
});
|
|
3066
3132
|
|
|
3067
|
-
case
|
|
3133
|
+
case 36:
|
|
3068
3134
|
case "end":
|
|
3069
3135
|
return _context2.stop();
|
|
3070
3136
|
}
|
|
@@ -3088,6 +3154,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3088
3154
|
case 0:
|
|
3089
3155
|
promises = [];
|
|
3090
3156
|
promises.push(this._auriFairLaunch.getPoolInfo(AurPlyPid).then(function (res) {
|
|
3157
|
+
console.log(res);
|
|
3091
3158
|
stakedLiquidity = res.totalStake;
|
|
3092
3159
|
rewardPerSecond = res.rewardPerSecond;
|
|
3093
3160
|
}));
|
|
@@ -3102,12 +3169,16 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3102
3169
|
promises.push(fetchValuation(new TokenAmount(AURPLYToken, stakedLiquidity.toString()), this._networkConnection.provider).then(function (res) {
|
|
3103
3170
|
return totalStakeValuation = res;
|
|
3104
3171
|
}));
|
|
3172
|
+
_context3.next = 9;
|
|
3173
|
+
return Promise.all(promises);
|
|
3174
|
+
|
|
3175
|
+
case 9:
|
|
3105
3176
|
return _context3.abrupt("return", {
|
|
3106
3177
|
totalStakedLiquidity: new TokenAmount(AURPLYToken, stakedLiquidity.toString()),
|
|
3107
3178
|
apy: calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION)
|
|
3108
3179
|
});
|
|
3109
3180
|
|
|
3110
|
-
case
|
|
3181
|
+
case 10:
|
|
3111
3182
|
case "end":
|
|
3112
3183
|
return _context3.stop();
|
|
3113
3184
|
}
|
|
@@ -3200,18 +3271,9 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
|
|
|
3200
3271
|
while (1) {
|
|
3201
3272
|
switch (_context6.prev = _context6.next) {
|
|
3202
3273
|
case 0:
|
|
3203
|
-
_context6.
|
|
3204
|
-
_context6.t1 = this._comptroller.address;
|
|
3205
|
-
_context6.t2 = this._auriFairLaunch.address;
|
|
3206
|
-
_context6.next = 5;
|
|
3207
|
-
return this._networkConnection.signer.getAddress();
|
|
3274
|
+
return _context6.abrupt("return", this._auriLens.connect(this._networkConnection.signer).claimRewards(this._comptroller.address, this._auriFairLaunch.address, [AurPlyPid]));
|
|
3208
3275
|
|
|
3209
|
-
case
|
|
3210
|
-
_context6.t3 = _context6.sent;
|
|
3211
|
-
_context6.t4 = [AurPlyPid];
|
|
3212
|
-
return _context6.abrupt("return", _context6.t0.claimRewards.call(_context6.t0, _context6.t1, _context6.t2, _context6.t3, _context6.t4));
|
|
3213
|
-
|
|
3214
|
-
case 8:
|
|
3276
|
+
case 1:
|
|
3215
3277
|
case "end":
|
|
3216
3278
|
return _context6.stop();
|
|
3217
3279
|
}
|
|
@@ -3311,10 +3373,12 @@ var dummyUserMarketDetails = {
|
|
|
3311
3373
|
};
|
|
3312
3374
|
|
|
3313
3375
|
exports.AURORA_CHAINID = AURORA_CHAINID;
|
|
3376
|
+
exports.AURORA_DEFAULT_PROVIDER = AURORA_DEFAULT_PROVIDER;
|
|
3377
|
+
exports.AURORA_DEFAULT_PROVIDER_URL = AURORA_DEFAULT_PROVIDER_URL;
|
|
3378
|
+
exports.AURORA_DEFAULT_SIGNER = AURORA_DEFAULT_SIGNER;
|
|
3314
3379
|
exports.AURPLYToken = AURPLYToken;
|
|
3315
3380
|
exports.AVAX_DEFAULT_PROVIDER = AVAX_DEFAULT_PROVIDER;
|
|
3316
3381
|
exports.AVAX_DEFAULT_PROVIDER_URL = AVAX_DEFAULT_PROVIDER_URL;
|
|
3317
|
-
exports.AVAX_DEFAULT_SIGNER = AVAX_DEFAULT_SIGNER;
|
|
3318
3382
|
exports.AurPlyPid = AurPlyPid;
|
|
3319
3383
|
exports.BORROW_LIMIT_BUFFER = BORROW_LIMIT_BUFFER;
|
|
3320
3384
|
exports.BlockchainEntity = BlockchainEntity;
|