@aurigami/sdk 0.2.6 → 0.3.3
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 +4 -4
- package/dist/sdk.cjs.development.js +951 -903
- 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 +951 -903
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/MoneyMarket.ts +49 -18
- package/src/SDK.ts +11 -8
- package/src/constants.ts +28 -36
- package/src/decimals.ts +16 -15
- 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
|
|
|
@@ -899,75 +900,77 @@ 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);
|
|
902
|
-
var AURORA_DEFAULT_PROVIDER_URL = "https://
|
|
903
|
+
var AURORA_DEFAULT_PROVIDER_URL = "https://mainnet.aurora.dev";
|
|
903
904
|
var AURORA_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AURORA_DEFAULT_PROVIDER_URL);
|
|
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__*/'0x2dEf6eb801757655AD227110d65C80DB595bBc60'.toLowerCase(),
|
|
914
|
+
underlying: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase()
|
|
914
915
|
}, {
|
|
915
|
-
address: '
|
|
916
|
-
underlying: ETHAddress
|
|
916
|
+
address: /*#__PURE__*/'0x7b47690b04494A628151Dbb86B4cC95CF2629B14'.toLowerCase(),
|
|
917
|
+
underlying: /*#__PURE__*/ETHAddress.toLowerCase()
|
|
917
918
|
}, {
|
|
918
|
-
address: '
|
|
919
|
-
underlying: '
|
|
919
|
+
address: /*#__PURE__*/'0xFB0e4680B8b1c7B69fb6a3988029c74fea871DD9'.toLowerCase(),
|
|
920
|
+
underlying: /*#__PURE__*/'0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase()
|
|
920
921
|
}, {
|
|
921
|
-
address: '
|
|
922
|
-
underlying: '
|
|
922
|
+
address: /*#__PURE__*/'0x6bB82009b316A9098C23E3962b4371E879c8D23D'.toLowerCase(),
|
|
923
|
+
underlying: /*#__PURE__*/'0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase()
|
|
923
924
|
}, {
|
|
924
|
-
address: '
|
|
925
|
-
underlying: '
|
|
925
|
+
address: /*#__PURE__*/'0xBf43057c634868251e65e39b4f27662f644454b4'.toLowerCase(),
|
|
926
|
+
underlying: /*#__PURE__*/'0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase()
|
|
926
927
|
}, {
|
|
927
|
-
address: '
|
|
928
|
-
underlying: '
|
|
928
|
+
address: /*#__PURE__*/'0x83Ae17f197C1F1260543d4D5A710772761535066'.toLowerCase(),
|
|
929
|
+
underlying: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase()
|
|
929
930
|
}, {
|
|
930
|
-
address: '
|
|
931
|
-
underlying: '
|
|
931
|
+
address: /*#__PURE__*/'0xcC5CA0156317C1FF2A96E0f45659625081352071'.toLowerCase(),
|
|
932
|
+
underlying: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase()
|
|
932
933
|
}, {
|
|
933
|
-
address: '
|
|
934
|
-
underlying: '
|
|
934
|
+
address: /*#__PURE__*/'0x173Bf18675D52B4887C5d40E935C3ab1192aFb4C'.toLowerCase(),
|
|
935
|
+
underlying: /*#__PURE__*/'0xb9b8d9e5557381BF025f1A59B602ad3F19A4e4Be'.toLowerCase()
|
|
935
936
|
}],
|
|
936
937
|
misc: {
|
|
937
|
-
COMPTROLLER: "
|
|
938
|
-
oracle: "
|
|
939
|
-
AURIFAIRLAUNCH: "
|
|
940
|
-
AURILENS: '
|
|
938
|
+
COMPTROLLER: /*#__PURE__*/"0x3b416D37A85F7aD941e36258d4Da660A1898E181".toLowerCase(),
|
|
939
|
+
oracle: /*#__PURE__*/"0x08A74ca75BAE803e92752f8d7A5cD718b1cA6509".toLowerCase(),
|
|
940
|
+
AURIFAIRLAUNCH: /*#__PURE__*/"0xeed0433Cbc81F25061bb739Ff8f1D5736b16d038".toLowerCase(),
|
|
941
|
+
AURILENS: /*#__PURE__*/'0xb11820C3d8ae1f6C31047644C59190280651C9da'.toLowerCase(),
|
|
942
|
+
TOKENLOCK: /*#__PURE__*/'0x537754515509A83Ce2D076c0982292AC5289b408'.toLowerCase()
|
|
941
943
|
},
|
|
942
944
|
tokens: {
|
|
943
|
-
AURORA: "
|
|
944
|
-
PLY: "
|
|
945
|
-
AURPLY:
|
|
945
|
+
AURORA: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
|
|
946
|
+
PLY: /*#__PURE__*/"0xb9b8d9e5557381BF025f1A59B602ad3F19A4e4Be".toLowerCase(),
|
|
947
|
+
AURPLY: /*#__PURE__*/"0x822E871518C22E8570cFbEa43FddbBFF963d4bdE".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
|
+
'0xb9b8d9e5557381bf025f1a59b602ad3f19a4e4be': 18,
|
|
959
|
+
'0x83ae17f197c1f1260543d4d5a710772761535066': 8,
|
|
960
|
+
'0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
|
|
961
|
+
'0x4988a896b1227218e4a686fde5eabdcabd91571f': 6,
|
|
962
|
+
'0xfb0e4680b8b1c7b69fb6a3988029c74fea871dd9': 8,
|
|
963
|
+
'0xb12bfca5a55806aaf64e99521918a4bf0fc40802': 6,
|
|
964
|
+
'0xbf43057c634868251e65e39b4f27662f644454b4': 8,
|
|
965
|
+
'0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': 24,
|
|
966
|
+
'0x7b47690b04494a628151dbb86b4cc95cf2629b14': 8,
|
|
967
|
+
'0x822e871518c22e8570cfbea43fddbbff963d4bde': 18,
|
|
968
|
+
'0x2def6eb801757655ad227110d65c80db595bbc60': 8,
|
|
969
|
+
'0x6bb82009b316a9098c23e3962b4371e879c8d23d': 8,
|
|
970
|
+
'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79': 18,
|
|
971
|
+
'0xcc5ca0156317c1ff2a96e0f45659625081352071': 8,
|
|
972
|
+
'0xe3520349f477a5f6eb06107066048508498a291b': 18,
|
|
973
|
+
'0x173bf18675d52b4887c5d40e935c3ab1192afb4c': 8
|
|
971
974
|
};
|
|
972
975
|
|
|
973
976
|
function formatObject(object) {
|
|
@@ -981,24 +984,13 @@ var isSameAddress = function isSameAddress(address1, address2) {
|
|
|
981
984
|
};
|
|
982
985
|
var getCurrentTimestamp = /*#__PURE__*/function () {
|
|
983
986
|
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(provider) {
|
|
984
|
-
var latestBlockNumber, currentTime;
|
|
985
987
|
return runtime_1.wrap(function _callee$(_context) {
|
|
986
988
|
while (1) {
|
|
987
989
|
switch (_context.prev = _context.next) {
|
|
988
990
|
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);
|
|
991
|
+
return _context.abrupt("return", Math.trunc(Date.now() / 1000));
|
|
1000
992
|
|
|
1001
|
-
case
|
|
993
|
+
case 1:
|
|
1002
994
|
case "end":
|
|
1003
995
|
return _context.stop();
|
|
1004
996
|
}
|
|
@@ -1068,573 +1060,6 @@ var TokenAmount = /*#__PURE__*/function () {
|
|
|
1068
1060
|
return TokenAmount;
|
|
1069
1061
|
}();
|
|
1070
1062
|
|
|
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
1063
|
var abi = [
|
|
1639
1064
|
{
|
|
1640
1065
|
inputs: [
|
|
@@ -2584,305 +2009,929 @@ var IUniswapV2PairABI = {
|
|
|
2584
2009
|
deployedLinkReferences: deployedLinkReferences
|
|
2585
2010
|
};
|
|
2586
2011
|
|
|
2587
|
-
var abi$2 = [
|
|
2588
|
-
];
|
|
2589
|
-
var dummyABI = {
|
|
2590
|
-
abi: abi$2
|
|
2591
|
-
};
|
|
2012
|
+
var abi$2 = [
|
|
2013
|
+
];
|
|
2014
|
+
var dummyABI = {
|
|
2015
|
+
abi: abi$2
|
|
2016
|
+
};
|
|
2017
|
+
|
|
2018
|
+
var axios = /*#__PURE__*/require('axios');
|
|
2019
|
+
|
|
2020
|
+
function fetchPriceFromCoingeckoAPI(_x) {
|
|
2021
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
function _fetchPriceFromCoingeckoAPI() {
|
|
2025
|
+
_fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
|
|
2026
|
+
var price;
|
|
2027
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2028
|
+
while (1) {
|
|
2029
|
+
switch (_context.prev = _context.next) {
|
|
2030
|
+
case 0:
|
|
2031
|
+
_context.next = 2;
|
|
2032
|
+
return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=" + id + "&vs_currencies=usd").then(function (res) {
|
|
2033
|
+
return res.data;
|
|
2034
|
+
});
|
|
2035
|
+
|
|
2036
|
+
case 2:
|
|
2037
|
+
price = _context.sent;
|
|
2038
|
+
return _context.abrupt("return", new BigNumber(price[id].usd));
|
|
2039
|
+
|
|
2040
|
+
case 4:
|
|
2041
|
+
case "end":
|
|
2042
|
+
return _context.stop();
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}, _callee);
|
|
2046
|
+
}));
|
|
2047
|
+
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
function fetchPriceFromCoingecko(_x2) {
|
|
2051
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
function _fetchPriceFromCoingecko() {
|
|
2055
|
+
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(address) {
|
|
2056
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2057
|
+
while (1) {
|
|
2058
|
+
switch (_context2.prev = _context2.next) {
|
|
2059
|
+
case 0:
|
|
2060
|
+
if (!isSameAddress(address, networkAddresses.tokens.AURORA)) {
|
|
2061
|
+
_context2.next = 4;
|
|
2062
|
+
break;
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
|
|
2066
|
+
|
|
2067
|
+
case 4:
|
|
2068
|
+
throw Error("Unknown token " + address + " in fetchPriceFromCoingecko");
|
|
2069
|
+
|
|
2070
|
+
case 5:
|
|
2071
|
+
case "end":
|
|
2072
|
+
return _context2.stop();
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
}, _callee2);
|
|
2076
|
+
}));
|
|
2077
|
+
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
function fetchLPPositions(_x3, _x4) {
|
|
2081
|
+
return _fetchLPPositions.apply(this, arguments);
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
function _fetchLPPositions() {
|
|
2085
|
+
_fetchLPPositions = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(LPAddress, provider) {
|
|
2086
|
+
var promises, LPContract, values;
|
|
2087
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2088
|
+
while (1) {
|
|
2089
|
+
switch (_context3.prev = _context3.next) {
|
|
2090
|
+
case 0:
|
|
2091
|
+
promises = [];
|
|
2092
|
+
LPContract = new ethers$1.Contract(LPAddress, IUniswapV2PairABI.abi, provider);
|
|
2093
|
+
promises.push(LPContract.token0());
|
|
2094
|
+
promises.push(LPContract.toekn1());
|
|
2095
|
+
promises.push(LPContract.getReserves());
|
|
2096
|
+
promises.push(LPContract.totalSupply());
|
|
2097
|
+
_context3.next = 8;
|
|
2098
|
+
return Promise.all(promises);
|
|
2099
|
+
|
|
2100
|
+
case 8:
|
|
2101
|
+
values = _context3.sent;
|
|
2102
|
+
return _context3.abrupt("return", {
|
|
2103
|
+
token0: values[0],
|
|
2104
|
+
token1: values[1],
|
|
2105
|
+
reserve0: values[2].reserve0,
|
|
2106
|
+
reserve1: values[2].reserve1,
|
|
2107
|
+
totalSupply: values[3]
|
|
2108
|
+
});
|
|
2109
|
+
|
|
2110
|
+
case 10:
|
|
2111
|
+
case "end":
|
|
2112
|
+
return _context3.stop();
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
}, _callee3);
|
|
2116
|
+
}));
|
|
2117
|
+
return _fetchLPPositions.apply(this, arguments);
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
function fetchLPPrice(_x5, _x6) {
|
|
2121
|
+
return _fetchLPPrice.apply(this, arguments);
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
function _fetchLPPrice() {
|
|
2125
|
+
_fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(address, provider) {
|
|
2126
|
+
var LPInfo, token0Price, reserveUSD, token1Price, _reserveUSD;
|
|
2127
|
+
|
|
2128
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2129
|
+
while (1) {
|
|
2130
|
+
switch (_context4.prev = _context4.next) {
|
|
2131
|
+
case 0:
|
|
2132
|
+
_context4.next = 2;
|
|
2133
|
+
return fetchLPPositions(address, provider);
|
|
2134
|
+
|
|
2135
|
+
case 2:
|
|
2136
|
+
LPInfo = _context4.sent;
|
|
2137
|
+
_context4.prev = 3;
|
|
2138
|
+
_context4.next = 6;
|
|
2139
|
+
return fetchPrice(LPInfo.token0, provider);
|
|
2140
|
+
|
|
2141
|
+
case 6:
|
|
2142
|
+
token0Price = _context4.sent;
|
|
2143
|
+
reserveUSD = token0Price.multipliedBy(LPInfo.reserve0.toString()).multipliedBy(2);
|
|
2144
|
+
return _context4.abrupt("return", reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
|
|
2145
|
+
|
|
2146
|
+
case 11:
|
|
2147
|
+
_context4.prev = 11;
|
|
2148
|
+
_context4.t0 = _context4["catch"](3);
|
|
2149
|
+
_context4.prev = 13;
|
|
2150
|
+
_context4.next = 16;
|
|
2151
|
+
return fetchPrice(LPInfo.token1, provider);
|
|
2152
|
+
|
|
2153
|
+
case 16:
|
|
2154
|
+
token1Price = _context4.sent;
|
|
2155
|
+
_reserveUSD = token1Price.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(2);
|
|
2156
|
+
return _context4.abrupt("return", _reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
|
|
2157
|
+
|
|
2158
|
+
case 21:
|
|
2159
|
+
_context4.prev = 21;
|
|
2160
|
+
_context4.t1 = _context4["catch"](13);
|
|
2161
|
+
throw Error("Unable to fetch price for both tokens of LP " + address);
|
|
2162
|
+
|
|
2163
|
+
case 24:
|
|
2164
|
+
case "end":
|
|
2165
|
+
return _context4.stop();
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
}, _callee4, null, [[3, 11], [13, 21]]);
|
|
2169
|
+
}));
|
|
2170
|
+
return _fetchLPPrice.apply(this, arguments);
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
function processPriceFromOracle(rawPrice, underlyingDecimal) {
|
|
2174
|
+
return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
function fetchPriceFromOracle(_x7, _x8, _x9) {
|
|
2178
|
+
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
function _fetchPriceFromOracle() {
|
|
2182
|
+
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress, underlyingDecimal, provider) {
|
|
2183
|
+
var oracleContract, rawPrice;
|
|
2184
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2185
|
+
while (1) {
|
|
2186
|
+
switch (_context5.prev = _context5.next) {
|
|
2187
|
+
case 0:
|
|
2188
|
+
oracleContract = new ethers$1.Contract(networkAddresses.misc.oracle, OracleABI.abi, provider);
|
|
2189
|
+
_context5.next = 3;
|
|
2190
|
+
return oracleContract.getUnderlyingPrice(auTokenAddress);
|
|
2191
|
+
|
|
2192
|
+
case 3:
|
|
2193
|
+
rawPrice = _context5.sent;
|
|
2194
|
+
return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
|
|
2195
|
+
|
|
2196
|
+
case 5:
|
|
2197
|
+
case "end":
|
|
2198
|
+
return _context5.stop();
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
}, _callee5);
|
|
2202
|
+
}));
|
|
2203
|
+
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
function fetchUnderlyingTokensPrices(_x10) {
|
|
2207
|
+
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
function _fetchUnderlyingTokensPrices() {
|
|
2211
|
+
_fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
|
|
2212
|
+
var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
|
|
2213
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2214
|
+
while (1) {
|
|
2215
|
+
switch (_context6.prev = _context6.next) {
|
|
2216
|
+
case 0:
|
|
2217
|
+
auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, dummyABI.abi, provider);
|
|
2218
|
+
auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
|
|
2219
|
+
return auToken.address;
|
|
2220
|
+
});
|
|
2221
|
+
underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
|
|
2222
|
+
return getDecimal(auToken.underlying);
|
|
2223
|
+
});
|
|
2224
|
+
_context6.next = 5;
|
|
2225
|
+
return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
|
|
2226
|
+
|
|
2227
|
+
case 5:
|
|
2228
|
+
rawPrices = _context6.sent;
|
|
2229
|
+
return _context6.abrupt("return", rawPrices.map(function (res, ind) {
|
|
2230
|
+
return {
|
|
2231
|
+
auToken: res.auToken,
|
|
2232
|
+
underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
|
|
2233
|
+
};
|
|
2234
|
+
}));
|
|
2235
|
+
|
|
2236
|
+
case 7:
|
|
2237
|
+
case "end":
|
|
2238
|
+
return _context6.stop();
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
}, _callee6);
|
|
2242
|
+
}));
|
|
2243
|
+
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
function fetchPrice(_x11, _x12) {
|
|
2247
|
+
return _fetchPrice.apply(this, arguments);
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
function _fetchPrice() {
|
|
2251
|
+
_fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(address, provider) {
|
|
2252
|
+
var matchingAuToken;
|
|
2253
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2254
|
+
while (1) {
|
|
2255
|
+
switch (_context7.prev = _context7.next) {
|
|
2256
|
+
case 0:
|
|
2257
|
+
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2258
|
+
return isSameAddress(auToken.underlying, address);
|
|
2259
|
+
});
|
|
2260
|
+
|
|
2261
|
+
if (!(matchingAuToken !== undefined)) {
|
|
2262
|
+
_context7.next = 5;
|
|
2263
|
+
break;
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
return _context7.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
|
|
2267
|
+
|
|
2268
|
+
case 5:
|
|
2269
|
+
if (!isSameAddress(address, networkAddresses.misc.AUPLYLP)) {
|
|
2270
|
+
_context7.next = 9;
|
|
2271
|
+
break;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
return _context7.abrupt("return", fetchLPPrice(address, provider));
|
|
2275
|
+
|
|
2276
|
+
case 9:
|
|
2277
|
+
return _context7.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2278
|
+
|
|
2279
|
+
case 10:
|
|
2280
|
+
case "end":
|
|
2281
|
+
return _context7.stop();
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
}, _callee7);
|
|
2285
|
+
}));
|
|
2286
|
+
return _fetchPrice.apply(this, arguments);
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
function fetchValuation(_x13, _x14, _x15) {
|
|
2290
|
+
return _fetchValuation.apply(this, arguments);
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
function _fetchValuation() {
|
|
2294
|
+
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider, price) {
|
|
2295
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2296
|
+
while (1) {
|
|
2297
|
+
switch (_context8.prev = _context8.next) {
|
|
2298
|
+
case 0:
|
|
2299
|
+
if (!(price === null)) {
|
|
2300
|
+
_context8.next = 4;
|
|
2301
|
+
break;
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
_context8.next = 3;
|
|
2305
|
+
return fetchPrice(tokenAmount.token.address, provider);
|
|
2306
|
+
|
|
2307
|
+
case 3:
|
|
2308
|
+
price = _context8.sent;
|
|
2309
|
+
|
|
2310
|
+
case 4:
|
|
2311
|
+
return _context8.abrupt("return", new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price));
|
|
2312
|
+
|
|
2313
|
+
case 5:
|
|
2314
|
+
case "end":
|
|
2315
|
+
return _context8.stop();
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
}, _callee8);
|
|
2319
|
+
}));
|
|
2320
|
+
return _fetchValuation.apply(this, arguments);
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2324
|
+
_inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
|
|
2325
|
+
|
|
2326
|
+
function MoneyMarketRead(networkConnection, auToken, underlyingAsset) {
|
|
2327
|
+
var _this;
|
|
2328
|
+
|
|
2329
|
+
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
2330
|
+
|
|
2331
|
+
if (isSameAddress(underlyingAsset, ETHAddress)) {
|
|
2332
|
+
_this.auToken = new ethers$1.Contract(auToken, AuETHABI.abi, networkConnection.provider);
|
|
2333
|
+
} else {
|
|
2334
|
+
_this.auToken = new ethers$1.Contract(auToken, AuErc20ABI.abi, networkConnection.provider);
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
_this.underlying = new Token(underlyingAsset, getDecimal(underlyingAsset));
|
|
2338
|
+
_this._comptroller = new ethers$1.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
|
|
2339
|
+
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
|
|
2340
|
+
return _this;
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
var _proto = MoneyMarketRead.prototype;
|
|
2344
|
+
|
|
2345
|
+
_proto.getRewardSpeeds = /*#__PURE__*/function () {
|
|
2346
|
+
var _getRewardSpeeds = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2347
|
+
var speeds;
|
|
2348
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2349
|
+
while (1) {
|
|
2350
|
+
switch (_context.prev = _context.next) {
|
|
2351
|
+
case 0:
|
|
2352
|
+
_context.next = 2;
|
|
2353
|
+
return this._auriLens.getRewardSpeeds(this._comptroller.address, this.auToken.address);
|
|
2354
|
+
|
|
2355
|
+
case 2:
|
|
2356
|
+
speeds = _context.sent;
|
|
2357
|
+
return _context.abrupt("return", speeds);
|
|
2358
|
+
|
|
2359
|
+
case 4:
|
|
2360
|
+
case "end":
|
|
2361
|
+
return _context.stop();
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
}, _callee, this);
|
|
2365
|
+
}));
|
|
2366
|
+
|
|
2367
|
+
function getRewardSpeeds() {
|
|
2368
|
+
return _getRewardSpeeds.apply(this, arguments);
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
return getRewardSpeeds;
|
|
2372
|
+
}();
|
|
2373
|
+
|
|
2374
|
+
_proto.getTotalTokenBorrowed = /*#__PURE__*/function () {
|
|
2375
|
+
var _getTotalTokenBorrowed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
2376
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2377
|
+
while (1) {
|
|
2378
|
+
switch (_context2.prev = _context2.next) {
|
|
2379
|
+
case 0:
|
|
2380
|
+
_context2.t0 = TokenAmount;
|
|
2381
|
+
_context2.t1 = this.underlying;
|
|
2382
|
+
_context2.next = 4;
|
|
2383
|
+
return this.auToken.totalBorrows();
|
|
2384
|
+
|
|
2385
|
+
case 4:
|
|
2386
|
+
_context2.t2 = _context2.sent.toString();
|
|
2387
|
+
return _context2.abrupt("return", new _context2.t0(_context2.t1, _context2.t2));
|
|
2388
|
+
|
|
2389
|
+
case 6:
|
|
2390
|
+
case "end":
|
|
2391
|
+
return _context2.stop();
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}, _callee2, this);
|
|
2395
|
+
}));
|
|
2396
|
+
|
|
2397
|
+
function getTotalTokenBorrowed() {
|
|
2398
|
+
return _getTotalTokenBorrowed.apply(this, arguments);
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
return getTotalTokenBorrowed;
|
|
2402
|
+
}();
|
|
2403
|
+
|
|
2404
|
+
_proto.getTotalTokenDeposited = /*#__PURE__*/function () {
|
|
2405
|
+
var _getTotalTokenDeposited = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
2406
|
+
var _this2 = this;
|
|
2407
|
+
|
|
2408
|
+
var promises, totalBorrow, totalCash;
|
|
2409
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2410
|
+
while (1) {
|
|
2411
|
+
switch (_context3.prev = _context3.next) {
|
|
2412
|
+
case 0:
|
|
2413
|
+
promises = [];
|
|
2414
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
2415
|
+
totalBorrow = res;
|
|
2416
|
+
}));
|
|
2417
|
+
promises.push(this.auToken.getCash().then(function (res) {
|
|
2418
|
+
totalCash = new TokenAmount(_this2.underlying, res.toString());
|
|
2419
|
+
}));
|
|
2420
|
+
_context3.next = 5;
|
|
2421
|
+
return Promise.all(promises);
|
|
2422
|
+
|
|
2423
|
+
case 5:
|
|
2424
|
+
return _context3.abrupt("return", new TokenAmount(this.underlying, ethers$1.BigNumber.from(totalCash.rawAmount()).add(totalBorrow.rawAmount()).toString()));
|
|
2425
|
+
|
|
2426
|
+
case 6:
|
|
2427
|
+
case "end":
|
|
2428
|
+
return _context3.stop();
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
}, _callee3, this);
|
|
2432
|
+
}));
|
|
2433
|
+
|
|
2434
|
+
function getTotalTokenDeposited() {
|
|
2435
|
+
return _getTotalTokenDeposited.apply(this, arguments);
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
return getTotalTokenDeposited;
|
|
2439
|
+
}();
|
|
2440
|
+
|
|
2441
|
+
_proto.getDepositAPY = /*#__PURE__*/function () {
|
|
2442
|
+
var _getDepositAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2443
|
+
var supplyRatePerTimestamp;
|
|
2444
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2445
|
+
while (1) {
|
|
2446
|
+
switch (_context4.prev = _context4.next) {
|
|
2447
|
+
case 0:
|
|
2448
|
+
_context4.next = 2;
|
|
2449
|
+
return this.auToken.supplyRatePerTimestamp();
|
|
2450
|
+
|
|
2451
|
+
case 2:
|
|
2452
|
+
supplyRatePerTimestamp = _context4.sent;
|
|
2453
|
+
return _context4.abrupt("return", new BigNumber(supplyRatePerTimestamp.toString()).multipliedBy(60 * 60 * 24 * 365).div(decimalFactor(18)));
|
|
2454
|
+
|
|
2455
|
+
case 4:
|
|
2456
|
+
case "end":
|
|
2457
|
+
return _context4.stop();
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
}, _callee4, this);
|
|
2461
|
+
}));
|
|
2462
|
+
|
|
2463
|
+
function getDepositAPY() {
|
|
2464
|
+
return _getDepositAPY.apply(this, arguments);
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
return getDepositAPY;
|
|
2468
|
+
}();
|
|
2469
|
+
|
|
2470
|
+
_proto.getBorrowAPY = /*#__PURE__*/function () {
|
|
2471
|
+
var _getBorrowAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
|
|
2472
|
+
var borrowRatePerTimestamp;
|
|
2473
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2474
|
+
while (1) {
|
|
2475
|
+
switch (_context5.prev = _context5.next) {
|
|
2476
|
+
case 0:
|
|
2477
|
+
_context5.next = 2;
|
|
2478
|
+
return this.auToken.borrowRatePerTimestamp();
|
|
2479
|
+
|
|
2480
|
+
case 2:
|
|
2481
|
+
borrowRatePerTimestamp = _context5.sent;
|
|
2482
|
+
return _context5.abrupt("return", new BigNumber(borrowRatePerTimestamp.toString()).multipliedBy(60 * 60 * 24 * 365).div(decimalFactor(18)));
|
|
2483
|
+
|
|
2484
|
+
case 4:
|
|
2485
|
+
case "end":
|
|
2486
|
+
return _context5.stop();
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
}, _callee5, this);
|
|
2490
|
+
}));
|
|
2491
|
+
|
|
2492
|
+
function getBorrowAPY() {
|
|
2493
|
+
return _getBorrowAPY.apply(this, arguments);
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
return getBorrowAPY;
|
|
2497
|
+
}();
|
|
2498
|
+
|
|
2499
|
+
_proto.getCollateralRatio = /*#__PURE__*/function () {
|
|
2500
|
+
var _getCollateralRatio = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
2501
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2502
|
+
while (1) {
|
|
2503
|
+
switch (_context6.prev = _context6.next) {
|
|
2504
|
+
case 0:
|
|
2505
|
+
return _context6.abrupt("return", this._comptroller.markets(this.auToken.address).then(function (res) {
|
|
2506
|
+
return new BigNumber(res.collateralFactorMantissa.toString()).div(decimalFactor(18));
|
|
2507
|
+
}));
|
|
2508
|
+
|
|
2509
|
+
case 1:
|
|
2510
|
+
case "end":
|
|
2511
|
+
return _context6.stop();
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
}, _callee6, this);
|
|
2515
|
+
}));
|
|
2516
|
+
|
|
2517
|
+
function getCollateralRatio() {
|
|
2518
|
+
return _getCollateralRatio.apply(this, arguments);
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
return getCollateralRatio;
|
|
2522
|
+
}();
|
|
2523
|
+
|
|
2524
|
+
_proto.getBorrowPlyAPY = /*#__PURE__*/function () {
|
|
2525
|
+
var _getBorrowPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
2526
|
+
var promises, totalBorrowed, rewardSpeed, plyPrice, underlyingPrice;
|
|
2527
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2528
|
+
while (1) {
|
|
2529
|
+
switch (_context7.prev = _context7.next) {
|
|
2530
|
+
case 0:
|
|
2531
|
+
promises = [];
|
|
2532
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
2533
|
+
totalBorrowed = res;
|
|
2534
|
+
}));
|
|
2535
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address, false).then(function (res) {
|
|
2536
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
2537
|
+
}));
|
|
2538
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
2539
|
+
plyPrice = res;
|
|
2540
|
+
}));
|
|
2541
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
2542
|
+
underlyingPrice = res;
|
|
2543
|
+
}));
|
|
2544
|
+
_context7.next = 7;
|
|
2545
|
+
return Promise.all(promises);
|
|
2546
|
+
|
|
2547
|
+
case 7:
|
|
2548
|
+
return _context7.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalBorrowed.formattedAmount()), ONE_YEAR));
|
|
2549
|
+
|
|
2550
|
+
case 8:
|
|
2551
|
+
case "end":
|
|
2552
|
+
return _context7.stop();
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
}, _callee7, this);
|
|
2556
|
+
}));
|
|
2557
|
+
|
|
2558
|
+
function getBorrowPlyAPY() {
|
|
2559
|
+
return _getBorrowPlyAPY.apply(this, arguments);
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
return getBorrowPlyAPY;
|
|
2563
|
+
}();
|
|
2564
|
+
|
|
2565
|
+
_proto.getDepositPlyAPY = /*#__PURE__*/function () {
|
|
2566
|
+
var _getDepositPlyAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
2567
|
+
var promises, totalDeposited, rewardSpeed, plyPrice, underlyingPrice;
|
|
2568
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2569
|
+
while (1) {
|
|
2570
|
+
switch (_context8.prev = _context8.next) {
|
|
2571
|
+
case 0:
|
|
2572
|
+
promises = [];
|
|
2573
|
+
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
2574
|
+
totalDeposited = res;
|
|
2575
|
+
}));
|
|
2576
|
+
promises.push(this._comptroller.rewardSpeeds(exports.ComptrollerRewardType.PLY, this.auToken.address, true).then(function (res) {
|
|
2577
|
+
rewardSpeed = new TokenAmount(PLYToken, res.toString());
|
|
2578
|
+
}));
|
|
2579
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
2580
|
+
plyPrice = res;
|
|
2581
|
+
}));
|
|
2582
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
2583
|
+
underlyingPrice = res;
|
|
2584
|
+
}));
|
|
2585
|
+
_context8.next = 7;
|
|
2586
|
+
return Promise.all(promises);
|
|
2587
|
+
|
|
2588
|
+
case 7:
|
|
2589
|
+
return _context8.abrupt("return", calcLMRewardApr(plyPrice.multipliedBy(rewardSpeed.formattedAmount()), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), ONE_YEAR));
|
|
2592
2590
|
|
|
2593
|
-
|
|
2591
|
+
case 8:
|
|
2592
|
+
case "end":
|
|
2593
|
+
return _context8.stop();
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
}, _callee8, this);
|
|
2597
|
+
}));
|
|
2594
2598
|
|
|
2595
|
-
function
|
|
2596
|
-
|
|
2597
|
-
}
|
|
2599
|
+
function getDepositPlyAPY() {
|
|
2600
|
+
return _getDepositPlyAPY.apply(this, arguments);
|
|
2601
|
+
}
|
|
2598
2602
|
|
|
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
|
-
});
|
|
2603
|
+
return getDepositPlyAPY;
|
|
2604
|
+
}();
|
|
2610
2605
|
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2606
|
+
_proto.getDetails = /*#__PURE__*/function () {
|
|
2607
|
+
var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9() {
|
|
2608
|
+
var promises, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, plyPrice, underlyingPrice, rewardSpeeds, borrowPlyApy, depositPlyApy;
|
|
2609
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
2610
|
+
while (1) {
|
|
2611
|
+
switch (_context9.prev = _context9.next) {
|
|
2612
|
+
case 0:
|
|
2613
|
+
promises = [];
|
|
2614
|
+
promises.push(this.getTotalTokenDeposited().then(function (res) {
|
|
2615
|
+
totalDeposited = res;
|
|
2616
|
+
}));
|
|
2617
|
+
promises.push(this.getTotalTokenBorrowed().then(function (res) {
|
|
2618
|
+
totalBorrowed = res;
|
|
2619
|
+
}));
|
|
2620
|
+
promises.push(this.getDepositAPY().then(function (res) {
|
|
2621
|
+
depositAPY = res.toNumber();
|
|
2622
|
+
}));
|
|
2623
|
+
promises.push(this.getBorrowAPY().then(function (res) {
|
|
2624
|
+
borrowAPY = res.toNumber();
|
|
2625
|
+
}));
|
|
2626
|
+
promises.push(this.getCollateralRatio().then(function (res) {
|
|
2627
|
+
collateralRatio = res.toNumber();
|
|
2628
|
+
}));
|
|
2629
|
+
promises.push(this.getRewardSpeeds().then(function (res) {
|
|
2630
|
+
rewardSpeeds = res;
|
|
2631
|
+
}));
|
|
2632
|
+
promises.push(fetchPrice(networkAddresses.tokens.PLY, this._networkConnection.provider).then(function (res) {
|
|
2633
|
+
plyPrice = res;
|
|
2634
|
+
}));
|
|
2635
|
+
promises.push(fetchPrice(this.underlying.address, this._networkConnection.provider).then(function (res) {
|
|
2636
|
+
underlyingPrice = res;
|
|
2637
|
+
}));
|
|
2638
|
+
_context9.next = 11;
|
|
2639
|
+
return Promise.all(promises);
|
|
2614
2640
|
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2641
|
+
case 11:
|
|
2642
|
+
_context9.t0 = calcLMRewardApr;
|
|
2643
|
+
_context9.next = 14;
|
|
2644
|
+
return fetchValuation(new TokenAmount(PLYToken, rewardSpeeds.plyRewardBorrowSpeed.toString()), this._networkConnection.provider, plyPrice);
|
|
2645
|
+
|
|
2646
|
+
case 14:
|
|
2647
|
+
_context9.t1 = _context9.sent;
|
|
2648
|
+
_context9.t2 = underlyingPrice.multipliedBy(totalBorrowed.formattedAmount());
|
|
2649
|
+
_context9.t3 = ONE_YEAR;
|
|
2650
|
+
borrowPlyApy = (0, _context9.t0)(_context9.t1, _context9.t2, _context9.t3);
|
|
2651
|
+
_context9.t4 = calcLMRewardApr;
|
|
2652
|
+
_context9.next = 21;
|
|
2653
|
+
return fetchValuation(new TokenAmount(PLYToken, rewardSpeeds.plyRewardSupplySpeed.toString()), this._networkConnection.provider, plyPrice);
|
|
2654
|
+
|
|
2655
|
+
case 21:
|
|
2656
|
+
_context9.t5 = _context9.sent;
|
|
2657
|
+
_context9.t6 = underlyingPrice.multipliedBy(totalDeposited.formattedAmount());
|
|
2658
|
+
_context9.t7 = ONE_YEAR;
|
|
2659
|
+
depositPlyApy = (0, _context9.t4)(_context9.t5, _context9.t6, _context9.t7);
|
|
2660
|
+
return _context9.abrupt("return", {
|
|
2661
|
+
auTokenAddress: this.auToken.address,
|
|
2662
|
+
totalTokenDeposited: totalDeposited,
|
|
2663
|
+
totalTokenBorrowed: totalBorrowed,
|
|
2664
|
+
depositApy: depositAPY,
|
|
2665
|
+
depositPlyApy: depositPlyApy.toNumber(),
|
|
2666
|
+
borrowApy: borrowAPY,
|
|
2667
|
+
borrowPlyApy: borrowPlyApy.toNumber(),
|
|
2668
|
+
collateralRatio: collateralRatio
|
|
2669
|
+
});
|
|
2670
|
+
|
|
2671
|
+
case 26:
|
|
2672
|
+
case "end":
|
|
2673
|
+
return _context9.stop();
|
|
2674
|
+
}
|
|
2618
2675
|
}
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2621
|
-
}));
|
|
2622
|
-
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2623
|
-
}
|
|
2676
|
+
}, _callee9, this);
|
|
2677
|
+
}));
|
|
2624
2678
|
|
|
2625
|
-
function
|
|
2626
|
-
|
|
2627
|
-
}
|
|
2679
|
+
function getDetails() {
|
|
2680
|
+
return _getDetails.apply(this, arguments);
|
|
2681
|
+
}
|
|
2628
2682
|
|
|
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
|
-
}
|
|
2683
|
+
return getDetails;
|
|
2684
|
+
}();
|
|
2639
2685
|
|
|
2640
|
-
|
|
2686
|
+
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
2687
|
+
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(userAddress) {
|
|
2688
|
+
var totalBorrow;
|
|
2689
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
2690
|
+
while (1) {
|
|
2691
|
+
switch (_context10.prev = _context10.next) {
|
|
2692
|
+
case 0:
|
|
2693
|
+
_context10.next = 2;
|
|
2694
|
+
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
2641
2695
|
|
|
2642
|
-
|
|
2643
|
-
|
|
2696
|
+
case 2:
|
|
2697
|
+
totalBorrow = _context10.sent;
|
|
2698
|
+
return _context10.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
2644
2699
|
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2700
|
+
case 4:
|
|
2701
|
+
case "end":
|
|
2702
|
+
return _context10.stop();
|
|
2703
|
+
}
|
|
2648
2704
|
}
|
|
2649
|
-
}
|
|
2650
|
-
}
|
|
2651
|
-
}));
|
|
2652
|
-
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2653
|
-
}
|
|
2705
|
+
}, _callee10, this);
|
|
2706
|
+
}));
|
|
2654
2707
|
|
|
2655
|
-
function
|
|
2656
|
-
|
|
2657
|
-
}
|
|
2708
|
+
function getUserBorrowBalance(_x) {
|
|
2709
|
+
return _getUserBorrowBalance.apply(this, arguments);
|
|
2710
|
+
}
|
|
2658
2711
|
|
|
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);
|
|
2712
|
+
return getUserBorrowBalance;
|
|
2713
|
+
}();
|
|
2674
2714
|
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2715
|
+
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
2716
|
+
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(userAddress) {
|
|
2717
|
+
var totalDeposit;
|
|
2718
|
+
return runtime_1.wrap(function _callee11$(_context11) {
|
|
2719
|
+
while (1) {
|
|
2720
|
+
switch (_context11.prev = _context11.next) {
|
|
2721
|
+
case 0:
|
|
2722
|
+
_context11.next = 2;
|
|
2723
|
+
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
2684
2724
|
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2725
|
+
case 2:
|
|
2726
|
+
totalDeposit = _context11.sent;
|
|
2727
|
+
return _context11.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
2728
|
+
|
|
2729
|
+
case 4:
|
|
2730
|
+
case "end":
|
|
2731
|
+
return _context11.stop();
|
|
2732
|
+
}
|
|
2688
2733
|
}
|
|
2689
|
-
}
|
|
2690
|
-
}
|
|
2691
|
-
}));
|
|
2692
|
-
return _fetchLPPositions.apply(this, arguments);
|
|
2693
|
-
}
|
|
2734
|
+
}, _callee11, this);
|
|
2735
|
+
}));
|
|
2694
2736
|
|
|
2695
|
-
function
|
|
2696
|
-
|
|
2697
|
-
}
|
|
2737
|
+
function getUserDepositBalance(_x2) {
|
|
2738
|
+
return _getUserDepositBalance.apply(this, arguments);
|
|
2739
|
+
}
|
|
2698
2740
|
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
var LPInfo, token0Price, reserveUSD, token1Price, _reserveUSD;
|
|
2741
|
+
return getUserDepositBalance;
|
|
2742
|
+
}();
|
|
2702
2743
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
_context4.next = 2;
|
|
2708
|
-
return fetchLPPositions(address, provider);
|
|
2744
|
+
return MoneyMarketRead;
|
|
2745
|
+
}(BlockchainEntityRead);
|
|
2746
|
+
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
2747
|
+
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
2709
2748
|
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2749
|
+
function MoneyMarketReadWrite() {
|
|
2750
|
+
return _MoneyMarketRead.apply(this, arguments) || this;
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
2754
|
+
|
|
2755
|
+
_proto2.deposit = /*#__PURE__*/function () {
|
|
2756
|
+
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
|
|
2757
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
2758
|
+
while (1) {
|
|
2759
|
+
switch (_context12.prev = _context12.next) {
|
|
2760
|
+
case 0:
|
|
2761
|
+
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
2762
|
+
_context12.next = 4;
|
|
2763
|
+
break;
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
2767
|
+
value: amount.rawAmount()
|
|
2768
|
+
}));
|
|
2769
|
+
|
|
2770
|
+
case 4:
|
|
2771
|
+
return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
2772
|
+
|
|
2773
|
+
case 5:
|
|
2774
|
+
case "end":
|
|
2775
|
+
return _context12.stop();
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
}, _callee12, this);
|
|
2779
|
+
}));
|
|
2780
|
+
|
|
2781
|
+
function deposit(_x3) {
|
|
2782
|
+
return _deposit.apply(this, arguments);
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
return deposit;
|
|
2786
|
+
}();
|
|
2787
|
+
|
|
2788
|
+
_proto2.borrow = /*#__PURE__*/function () {
|
|
2789
|
+
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(amount) {
|
|
2790
|
+
return runtime_1.wrap(function _callee13$(_context13) {
|
|
2791
|
+
while (1) {
|
|
2792
|
+
switch (_context13.prev = _context13.next) {
|
|
2793
|
+
case 0:
|
|
2794
|
+
return _context13.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
2715
2795
|
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2796
|
+
case 1:
|
|
2797
|
+
case "end":
|
|
2798
|
+
return _context13.stop();
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
}, _callee13, this);
|
|
2802
|
+
}));
|
|
2720
2803
|
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
_context4.prev = 13;
|
|
2725
|
-
_context4.next = 16;
|
|
2726
|
-
return fetchPrice(LPInfo.token1, provider);
|
|
2804
|
+
function borrow(_x4) {
|
|
2805
|
+
return _borrow.apply(this, arguments);
|
|
2806
|
+
}
|
|
2727
2807
|
|
|
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())));
|
|
2808
|
+
return borrow;
|
|
2809
|
+
}();
|
|
2732
2810
|
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2811
|
+
_proto2.withdraw = /*#__PURE__*/function () {
|
|
2812
|
+
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
|
|
2813
|
+
return runtime_1.wrap(function _callee14$(_context14) {
|
|
2814
|
+
while (1) {
|
|
2815
|
+
switch (_context14.prev = _context14.next) {
|
|
2816
|
+
case 0:
|
|
2817
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
2737
2818
|
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2819
|
+
case 1:
|
|
2820
|
+
case "end":
|
|
2821
|
+
return _context14.stop();
|
|
2822
|
+
}
|
|
2741
2823
|
}
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
}));
|
|
2745
|
-
return _fetchLPPrice.apply(this, arguments);
|
|
2746
|
-
}
|
|
2824
|
+
}, _callee14, this);
|
|
2825
|
+
}));
|
|
2747
2826
|
|
|
2748
|
-
function
|
|
2749
|
-
|
|
2750
|
-
}
|
|
2827
|
+
function withdraw(_x5) {
|
|
2828
|
+
return _withdraw.apply(this, arguments);
|
|
2829
|
+
}
|
|
2751
2830
|
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
}
|
|
2831
|
+
return withdraw;
|
|
2832
|
+
}();
|
|
2755
2833
|
|
|
2756
|
-
function
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
return oracleContract.getUnderlyingPrice(auTokenAddress);
|
|
2834
|
+
_proto2.repay = /*#__PURE__*/function () {
|
|
2835
|
+
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(amount) {
|
|
2836
|
+
return runtime_1.wrap(function _callee15$(_context15) {
|
|
2837
|
+
while (1) {
|
|
2838
|
+
switch (_context15.prev = _context15.next) {
|
|
2839
|
+
case 0:
|
|
2840
|
+
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
2841
|
+
_context15.next = 4;
|
|
2842
|
+
break;
|
|
2843
|
+
}
|
|
2767
2844
|
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2845
|
+
return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
2846
|
+
value: amount.rawAmount()
|
|
2847
|
+
}));
|
|
2771
2848
|
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2849
|
+
case 4:
|
|
2850
|
+
return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
2851
|
+
|
|
2852
|
+
case 5:
|
|
2853
|
+
case "end":
|
|
2854
|
+
return _context15.stop();
|
|
2855
|
+
}
|
|
2775
2856
|
}
|
|
2776
|
-
}
|
|
2777
|
-
}
|
|
2778
|
-
}));
|
|
2779
|
-
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2780
|
-
}
|
|
2857
|
+
}, _callee15, this);
|
|
2858
|
+
}));
|
|
2781
2859
|
|
|
2782
|
-
function
|
|
2783
|
-
|
|
2784
|
-
}
|
|
2860
|
+
function repay(_x6) {
|
|
2861
|
+
return _repay.apply(this, arguments);
|
|
2862
|
+
}
|
|
2785
2863
|
|
|
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);
|
|
2864
|
+
return repay;
|
|
2865
|
+
}();
|
|
2802
2866
|
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
}));
|
|
2867
|
+
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
2868
|
+
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
|
|
2869
|
+
return runtime_1.wrap(function _callee16$(_context16) {
|
|
2870
|
+
while (1) {
|
|
2871
|
+
switch (_context16.prev = _context16.next) {
|
|
2872
|
+
case 0:
|
|
2873
|
+
return _context16.abrupt("return", this._comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
2811
2874
|
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2875
|
+
case 1:
|
|
2876
|
+
case "end":
|
|
2877
|
+
return _context16.stop();
|
|
2878
|
+
}
|
|
2815
2879
|
}
|
|
2816
|
-
}
|
|
2817
|
-
}
|
|
2818
|
-
}));
|
|
2819
|
-
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2820
|
-
}
|
|
2880
|
+
}, _callee16, this);
|
|
2881
|
+
}));
|
|
2821
2882
|
|
|
2822
|
-
function
|
|
2823
|
-
|
|
2824
|
-
}
|
|
2883
|
+
function enableCollateral() {
|
|
2884
|
+
return _enableCollateral.apply(this, arguments);
|
|
2885
|
+
}
|
|
2825
2886
|
|
|
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
|
-
});
|
|
2887
|
+
return enableCollateral;
|
|
2888
|
+
}();
|
|
2836
2889
|
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2890
|
+
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
2891
|
+
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17() {
|
|
2892
|
+
return runtime_1.wrap(function _callee17$(_context17) {
|
|
2893
|
+
while (1) {
|
|
2894
|
+
switch (_context17.prev = _context17.next) {
|
|
2895
|
+
case 0:
|
|
2896
|
+
return _context17.abrupt("return", this._comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
2841
2897
|
|
|
2842
|
-
|
|
2898
|
+
case 1:
|
|
2899
|
+
case "end":
|
|
2900
|
+
return _context17.stop();
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
}, _callee17, this);
|
|
2904
|
+
}));
|
|
2843
2905
|
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
break;
|
|
2848
|
-
}
|
|
2906
|
+
function disableCollateral() {
|
|
2907
|
+
return _disableCollateral.apply(this, arguments);
|
|
2908
|
+
}
|
|
2849
2909
|
|
|
2850
|
-
|
|
2910
|
+
return disableCollateral;
|
|
2911
|
+
}();
|
|
2851
2912
|
|
|
2852
|
-
|
|
2853
|
-
|
|
2913
|
+
return MoneyMarketReadWrite;
|
|
2914
|
+
}(MoneyMarketRead);
|
|
2915
|
+
var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
2916
|
+
_inheritsLoose(MoneyMarket, _BlockchainEntity);
|
|
2854
2917
|
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
return _context7.stop();
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2860
|
-
}, _callee7);
|
|
2861
|
-
}));
|
|
2862
|
-
return _fetchPrice.apply(this, arguments);
|
|
2863
|
-
}
|
|
2918
|
+
function MoneyMarket(address, underlying) {
|
|
2919
|
+
var _this3;
|
|
2864
2920
|
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2921
|
+
_this3 = _BlockchainEntity.call(this) || this;
|
|
2922
|
+
_this3.address = validateAndParseAddress(address);
|
|
2923
|
+
_this3.underlying = validateAndParseAddress(underlying);
|
|
2924
|
+
return _this3;
|
|
2925
|
+
}
|
|
2868
2926
|
|
|
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));
|
|
2927
|
+
var _proto3 = MoneyMarket.prototype;
|
|
2876
2928
|
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
}));
|
|
2884
|
-
return _fetchValuation.apply(this, arguments);
|
|
2885
|
-
}
|
|
2929
|
+
_proto3.read = function read(networkConnection) {
|
|
2930
|
+
return new MoneyMarketRead(networkConnection, this.address, this.underlying);
|
|
2931
|
+
};
|
|
2932
|
+
|
|
2933
|
+
return MoneyMarket;
|
|
2934
|
+
}(BlockchainEntity);
|
|
2886
2935
|
|
|
2887
2936
|
var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2888
2937
|
_inheritsLoose(SdkRead, _BlockchainEntityRead);
|
|
@@ -2894,7 +2943,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2894
2943
|
_this._comptroller = new ethers$1.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
|
|
2895
2944
|
_this._tokenLock = new ethers$1.Contract(networkAddresses.misc.TOKENLOCK, TokenLockABI.abi, networkConnection.provider);
|
|
2896
2945
|
_this._auriFairLaunch = new ethers$1.Contract(networkAddresses.misc.AURIFAIRLAUNCH, AuriFairLaunchABI.abi, networkConnection.provider);
|
|
2897
|
-
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS,
|
|
2946
|
+
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
|
|
2898
2947
|
return _this;
|
|
2899
2948
|
}
|
|
2900
2949
|
|
|
@@ -2907,10 +2956,11 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2907
2956
|
while (1) {
|
|
2908
2957
|
switch (_context.prev = _context.next) {
|
|
2909
2958
|
case 0:
|
|
2910
|
-
|
|
2959
|
+
console.log(this._networkConnection.provider);
|
|
2960
|
+
_context.next = 3;
|
|
2911
2961
|
return getCurrentTimestamp(this._networkConnection.provider);
|
|
2912
2962
|
|
|
2913
|
-
case
|
|
2963
|
+
case 3:
|
|
2914
2964
|
currentTime = _context.sent;
|
|
2915
2965
|
currentWeek = ethers$1.BigNumber.from(currentTime - REWARDCLAIMSTART).div(7 * ONE_DAY).toNumber();
|
|
2916
2966
|
denominator = 10000;
|
|
@@ -2919,22 +2969,22 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2919
2969
|
promises.push(this._tokenLock.percentageLock(currentWeek + 1)["catch"](function (err) {
|
|
2920
2970
|
return denominator;
|
|
2921
2971
|
}));
|
|
2922
|
-
_context.next =
|
|
2972
|
+
_context.next = 11;
|
|
2923
2973
|
return Promise.all(promises).then(function (res) {
|
|
2924
2974
|
return res.map(function (v) {
|
|
2925
2975
|
return v.toString();
|
|
2926
2976
|
});
|
|
2927
2977
|
});
|
|
2928
2978
|
|
|
2929
|
-
case
|
|
2979
|
+
case 11:
|
|
2930
2980
|
values = _context.sent;
|
|
2931
2981
|
return _context.abrupt("return", {
|
|
2932
2982
|
vestingStart: REWARDCLAIMSTART,
|
|
2933
|
-
currentUnlockPortion: new BigNumber(values[0]).div(denominator).toNumber(),
|
|
2934
|
-
nextUnlockPortion: new BigNumber(values[1]).div(denominator).toNumber()
|
|
2983
|
+
currentUnlockPortion: new BigNumber(denominator).minus(values[0]).div(denominator).toNumber(),
|
|
2984
|
+
nextUnlockPortion: new BigNumber(denominator).minus(values[1]).div(denominator).toNumber()
|
|
2935
2985
|
});
|
|
2936
2986
|
|
|
2937
|
-
case
|
|
2987
|
+
case 13:
|
|
2938
2988
|
case "end":
|
|
2939
2989
|
return _context.stop();
|
|
2940
2990
|
}
|
|
@@ -2961,6 +3011,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2961
3011
|
case 0:
|
|
2962
3012
|
marketCount = networkAddresses.auTokens.length;
|
|
2963
3013
|
userMarketDetails = [];
|
|
3014
|
+
collateralRatio = new Array(marketCount);
|
|
2964
3015
|
promises = [];
|
|
2965
3016
|
totalBorrowLimit = new BigNumber(0);
|
|
2966
3017
|
pricePromises = [];
|
|
@@ -2990,14 +3041,14 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2990
3041
|
promises.push(this._comptroller.getAssetsIn(userAddress).then(function (res) {
|
|
2991
3042
|
assetsIn = res;
|
|
2992
3043
|
}));
|
|
2993
|
-
_context2.next =
|
|
3044
|
+
_context2.next = 11;
|
|
2994
3045
|
return Promise.all(promises);
|
|
2995
3046
|
|
|
2996
|
-
case
|
|
2997
|
-
_context2.next =
|
|
3047
|
+
case 11:
|
|
3048
|
+
_context2.next = 13;
|
|
2998
3049
|
return Promise.all(pricePromises);
|
|
2999
3050
|
|
|
3000
|
-
case
|
|
3051
|
+
case 13:
|
|
3001
3052
|
underlyingPrices = _context2.sent;
|
|
3002
3053
|
depositValuationPromises = [];
|
|
3003
3054
|
|
|
@@ -3008,6 +3059,8 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3008
3059
|
isSameAddress(auToken.address, auAddress);
|
|
3009
3060
|
}).length > 0) {
|
|
3010
3061
|
userMarketDetails[i].isCollateral = true;
|
|
3062
|
+
} else {
|
|
3063
|
+
userMarketDetails[i].isCollateral = false;
|
|
3011
3064
|
}
|
|
3012
3065
|
|
|
3013
3066
|
depositValuationPromises.push(fetchValuation(userMarketDetails[i].depositBalance, _this2._networkConnection.provider, underlyingPrices[i]));
|
|
@@ -3017,10 +3070,10 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3017
3070
|
_loop();
|
|
3018
3071
|
}
|
|
3019
3072
|
|
|
3020
|
-
_context2.next =
|
|
3073
|
+
_context2.next = 19;
|
|
3021
3074
|
return Promise.all(depositValuationPromises);
|
|
3022
3075
|
|
|
3023
|
-
case
|
|
3076
|
+
case 19:
|
|
3024
3077
|
depositValues = _context2.sent;
|
|
3025
3078
|
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
3026
3079
|
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(collateralRatio[index]));
|
|
@@ -3028,12 +3081,12 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3028
3081
|
});
|
|
3029
3082
|
promises = [];
|
|
3030
3083
|
promises.push(this._comptroller.getAccountLiquidity(userAddress));
|
|
3031
|
-
promises.push(this._auriLens.getRewardBalancesMetadata(this._comptroller.address, userAddress));
|
|
3084
|
+
promises.push(this._auriLens.callStatic.getRewardBalancesMetadata(this._comptroller.address, this._auriFairLaunch.address, userAddress, [AurPlyPid]));
|
|
3032
3085
|
promises.push(this._tokenLock.lockedAmounts(userAddress));
|
|
3033
|
-
_context2.next =
|
|
3086
|
+
_context2.next = 27;
|
|
3034
3087
|
return Promise.all(promises);
|
|
3035
3088
|
|
|
3036
|
-
case
|
|
3089
|
+
case 27:
|
|
3037
3090
|
values = _context2.sent;
|
|
3038
3091
|
accountLiquidity = values[0];
|
|
3039
3092
|
rewardBalancesMetadata = values[1];
|
|
@@ -3067,7 +3120,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3067
3120
|
}
|
|
3068
3121
|
});
|
|
3069
3122
|
|
|
3070
|
-
case
|
|
3123
|
+
case 36:
|
|
3071
3124
|
case "end":
|
|
3072
3125
|
return _context2.stop();
|
|
3073
3126
|
}
|
|
@@ -3105,12 +3158,16 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3105
3158
|
promises.push(fetchValuation(new TokenAmount(AURPLYToken, stakedLiquidity.toString()), this._networkConnection.provider).then(function (res) {
|
|
3106
3159
|
return totalStakeValuation = res;
|
|
3107
3160
|
}));
|
|
3161
|
+
_context3.next = 9;
|
|
3162
|
+
return Promise.all(promises);
|
|
3163
|
+
|
|
3164
|
+
case 9:
|
|
3108
3165
|
return _context3.abrupt("return", {
|
|
3109
3166
|
totalStakedLiquidity: new TokenAmount(AURPLYToken, stakedLiquidity.toString()),
|
|
3110
3167
|
apy: calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION)
|
|
3111
3168
|
});
|
|
3112
3169
|
|
|
3113
|
-
case
|
|
3170
|
+
case 10:
|
|
3114
3171
|
case "end":
|
|
3115
3172
|
return _context3.stop();
|
|
3116
3173
|
}
|
|
@@ -3203,18 +3260,9 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
|
|
|
3203
3260
|
while (1) {
|
|
3204
3261
|
switch (_context6.prev = _context6.next) {
|
|
3205
3262
|
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();
|
|
3263
|
+
return _context6.abrupt("return", this._auriLens.connect(this._networkConnection.signer).claimRewards(this._comptroller.address, this._auriFairLaunch.address, [AurPlyPid]));
|
|
3211
3264
|
|
|
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:
|
|
3265
|
+
case 1:
|
|
3218
3266
|
case "end":
|
|
3219
3267
|
return _context6.stop();
|
|
3220
3268
|
}
|
|
@@ -3316,10 +3364,10 @@ var dummyUserMarketDetails = {
|
|
|
3316
3364
|
exports.AURORA_CHAINID = AURORA_CHAINID;
|
|
3317
3365
|
exports.AURORA_DEFAULT_PROVIDER = AURORA_DEFAULT_PROVIDER;
|
|
3318
3366
|
exports.AURORA_DEFAULT_PROVIDER_URL = AURORA_DEFAULT_PROVIDER_URL;
|
|
3367
|
+
exports.AURORA_DEFAULT_SIGNER = AURORA_DEFAULT_SIGNER;
|
|
3319
3368
|
exports.AURPLYToken = AURPLYToken;
|
|
3320
3369
|
exports.AVAX_DEFAULT_PROVIDER = AVAX_DEFAULT_PROVIDER;
|
|
3321
3370
|
exports.AVAX_DEFAULT_PROVIDER_URL = AVAX_DEFAULT_PROVIDER_URL;
|
|
3322
|
-
exports.AVAX_DEFAULT_SIGNER = AVAX_DEFAULT_SIGNER;
|
|
3323
3371
|
exports.AurPlyPid = AurPlyPid;
|
|
3324
3372
|
exports.BORROW_LIMIT_BUFFER = BORROW_LIMIT_BUFFER;
|
|
3325
3373
|
exports.BlockchainEntity = BlockchainEntity;
|