@aurigami/sdk 0.2.5 → 0.3.2
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 +952 -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 +950 -901
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/MoneyMarket.ts +53 -20
- package/src/SDK.ts +9 -8
- package/src/constants.ts +32 -35
- package/src/decimals.ts +16 -15
- package/src/helpers.ts +4 -3
- package/src/priceFetcher.ts +4 -1
|
@@ -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,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);
|
|
903
|
+
var AURORA_DEFAULT_PROVIDER_URL = "https://mainnet.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__*/'0x2dEf6eb801757655AD227110d65C80DB595bBc60'.toLowerCase(),
|
|
914
|
+
underlying: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase()
|
|
912
915
|
}, {
|
|
913
|
-
address: '
|
|
914
|
-
underlying: ETHAddress
|
|
916
|
+
address: /*#__PURE__*/'0x7b47690b04494A628151Dbb86B4cC95CF2629B14'.toLowerCase(),
|
|
917
|
+
underlying: /*#__PURE__*/ETHAddress.toLowerCase()
|
|
915
918
|
}, {
|
|
916
|
-
address: '
|
|
917
|
-
underlying: '
|
|
919
|
+
address: /*#__PURE__*/'0xFB0e4680B8b1c7B69fb6a3988029c74fea871DD9'.toLowerCase(),
|
|
920
|
+
underlying: /*#__PURE__*/'0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase()
|
|
918
921
|
}, {
|
|
919
|
-
address: '
|
|
920
|
-
underlying: '
|
|
922
|
+
address: /*#__PURE__*/'0x6bB82009b316A9098C23E3962b4371E879c8D23D'.toLowerCase(),
|
|
923
|
+
underlying: /*#__PURE__*/'0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase()
|
|
921
924
|
}, {
|
|
922
|
-
address: '
|
|
923
|
-
underlying: '
|
|
925
|
+
address: /*#__PURE__*/'0xBf43057c634868251e65e39b4f27662f644454b4'.toLowerCase(),
|
|
926
|
+
underlying: /*#__PURE__*/'0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase()
|
|
924
927
|
}, {
|
|
925
|
-
address: '
|
|
926
|
-
underlying: '
|
|
928
|
+
address: /*#__PURE__*/'0x83Ae17f197C1F1260543d4D5A710772761535066'.toLowerCase(),
|
|
929
|
+
underlying: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase()
|
|
927
930
|
}, {
|
|
928
|
-
address: '
|
|
929
|
-
underlying: '
|
|
931
|
+
address: /*#__PURE__*/'0xcC5CA0156317C1FF2A96E0f45659625081352071'.toLowerCase(),
|
|
932
|
+
underlying: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase()
|
|
930
933
|
}, {
|
|
931
|
-
address: '
|
|
932
|
-
underlying: '
|
|
934
|
+
address: /*#__PURE__*/'0x173Bf18675D52B4887C5d40E935C3ab1192aFb4C'.toLowerCase(),
|
|
935
|
+
underlying: /*#__PURE__*/'0xb9b8d9e5557381BF025f1A59B602ad3F19A4e4Be'.toLowerCase()
|
|
933
936
|
}],
|
|
934
937
|
misc: {
|
|
935
|
-
COMPTROLLER: "
|
|
936
|
-
oracle: "
|
|
937
|
-
AURIFAIRLAUNCH: "
|
|
938
|
-
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()
|
|
939
943
|
},
|
|
940
944
|
tokens: {
|
|
941
|
-
AURORA: "
|
|
942
|
-
PLY: "
|
|
943
|
-
AURPLY:
|
|
945
|
+
AURORA: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
|
|
946
|
+
PLY: /*#__PURE__*/"0xb9b8d9e5557381BF025f1A59B602ad3F19A4e4Be".toLowerCase(),
|
|
947
|
+
AURPLY: /*#__PURE__*/"0x822E871518C22E8570cFbEa43FddbBFF963d4bdE".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
|
+
'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
|
|
969
974
|
};
|
|
970
975
|
|
|
971
976
|
function formatObject(object) {
|
|
@@ -979,24 +984,13 @@ var isSameAddress = function isSameAddress(address1, address2) {
|
|
|
979
984
|
};
|
|
980
985
|
var getCurrentTimestamp = /*#__PURE__*/function () {
|
|
981
986
|
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(provider) {
|
|
982
|
-
var latestBlockNumber, currentTime;
|
|
983
987
|
return runtime_1.wrap(function _callee$(_context) {
|
|
984
988
|
while (1) {
|
|
985
989
|
switch (_context.prev = _context.next) {
|
|
986
990
|
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);
|
|
991
|
+
return _context.abrupt("return", Math.trunc(Date.now() / 1000));
|
|
998
992
|
|
|
999
|
-
case
|
|
993
|
+
case 1:
|
|
1000
994
|
case "end":
|
|
1001
995
|
return _context.stop();
|
|
1002
996
|
}
|
|
@@ -1066,573 +1060,6 @@ var TokenAmount = /*#__PURE__*/function () {
|
|
|
1066
1060
|
return TokenAmount;
|
|
1067
1061
|
}();
|
|
1068
1062
|
|
|
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
1063
|
var abi = [
|
|
1637
1064
|
{
|
|
1638
1065
|
inputs: [
|
|
@@ -2582,304 +2009,929 @@ var IUniswapV2PairABI = {
|
|
|
2582
2009
|
deployedLinkReferences: deployedLinkReferences
|
|
2583
2010
|
};
|
|
2584
2011
|
|
|
2585
|
-
var abi$2 = [
|
|
2586
|
-
];
|
|
2587
|
-
var dummyABI = {
|
|
2588
|
-
abi: abi$2
|
|
2589
|
-
};
|
|
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));
|
|
2590
2590
|
|
|
2591
|
-
|
|
2591
|
+
case 8:
|
|
2592
|
+
case "end":
|
|
2593
|
+
return _context8.stop();
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
}, _callee8, this);
|
|
2597
|
+
}));
|
|
2592
2598
|
|
|
2593
|
-
function
|
|
2594
|
-
|
|
2595
|
-
}
|
|
2599
|
+
function getDepositPlyAPY() {
|
|
2600
|
+
return _getDepositPlyAPY.apply(this, arguments);
|
|
2601
|
+
}
|
|
2596
2602
|
|
|
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
|
-
});
|
|
2603
|
+
return getDepositPlyAPY;
|
|
2604
|
+
}();
|
|
2608
2605
|
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
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);
|
|
2612
2640
|
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
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
|
+
}
|
|
2616
2675
|
}
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
}));
|
|
2620
|
-
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
2621
|
-
}
|
|
2676
|
+
}, _callee9, this);
|
|
2677
|
+
}));
|
|
2622
2678
|
|
|
2623
|
-
function
|
|
2624
|
-
|
|
2625
|
-
}
|
|
2679
|
+
function getDetails() {
|
|
2680
|
+
return _getDetails.apply(this, arguments);
|
|
2681
|
+
}
|
|
2626
2682
|
|
|
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
|
-
}
|
|
2683
|
+
return getDetails;
|
|
2684
|
+
}();
|
|
2637
2685
|
|
|
2638
|
-
|
|
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);
|
|
2639
2695
|
|
|
2640
|
-
|
|
2641
|
-
|
|
2696
|
+
case 2:
|
|
2697
|
+
totalBorrow = _context10.sent;
|
|
2698
|
+
return _context10.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
2642
2699
|
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2700
|
+
case 4:
|
|
2701
|
+
case "end":
|
|
2702
|
+
return _context10.stop();
|
|
2703
|
+
}
|
|
2646
2704
|
}
|
|
2647
|
-
}
|
|
2648
|
-
}
|
|
2649
|
-
}));
|
|
2650
|
-
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
2651
|
-
}
|
|
2705
|
+
}, _callee10, this);
|
|
2706
|
+
}));
|
|
2652
2707
|
|
|
2653
|
-
function
|
|
2654
|
-
|
|
2655
|
-
}
|
|
2708
|
+
function getUserBorrowBalance(_x) {
|
|
2709
|
+
return _getUserBorrowBalance.apply(this, arguments);
|
|
2710
|
+
}
|
|
2656
2711
|
|
|
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);
|
|
2712
|
+
return getUserBorrowBalance;
|
|
2713
|
+
}();
|
|
2672
2714
|
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
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);
|
|
2682
2724
|
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
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
|
+
}
|
|
2686
2733
|
}
|
|
2687
|
-
}
|
|
2688
|
-
}
|
|
2689
|
-
}));
|
|
2690
|
-
return _fetchLPPositions.apply(this, arguments);
|
|
2691
|
-
}
|
|
2734
|
+
}, _callee11, this);
|
|
2735
|
+
}));
|
|
2692
2736
|
|
|
2693
|
-
function
|
|
2694
|
-
|
|
2695
|
-
}
|
|
2737
|
+
function getUserDepositBalance(_x2) {
|
|
2738
|
+
return _getUserDepositBalance.apply(this, arguments);
|
|
2739
|
+
}
|
|
2696
2740
|
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
var LPInfo, token0Price, reserveUSD, token1Price, _reserveUSD;
|
|
2741
|
+
return getUserDepositBalance;
|
|
2742
|
+
}();
|
|
2700
2743
|
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
_context4.next = 2;
|
|
2706
|
-
return fetchLPPositions(address, provider);
|
|
2744
|
+
return MoneyMarketRead;
|
|
2745
|
+
}(BlockchainEntityRead);
|
|
2746
|
+
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
2747
|
+
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
2707
2748
|
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
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()));
|
|
2713
2795
|
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2796
|
+
case 1:
|
|
2797
|
+
case "end":
|
|
2798
|
+
return _context13.stop();
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
}, _callee13, this);
|
|
2802
|
+
}));
|
|
2718
2803
|
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
_context4.prev = 13;
|
|
2723
|
-
_context4.next = 16;
|
|
2724
|
-
return fetchPrice(LPInfo.token1, provider);
|
|
2804
|
+
function borrow(_x4) {
|
|
2805
|
+
return _borrow.apply(this, arguments);
|
|
2806
|
+
}
|
|
2725
2807
|
|
|
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())));
|
|
2808
|
+
return borrow;
|
|
2809
|
+
}();
|
|
2730
2810
|
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
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()));
|
|
2735
2818
|
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2819
|
+
case 1:
|
|
2820
|
+
case "end":
|
|
2821
|
+
return _context14.stop();
|
|
2822
|
+
}
|
|
2739
2823
|
}
|
|
2740
|
-
}
|
|
2741
|
-
}
|
|
2742
|
-
}));
|
|
2743
|
-
return _fetchLPPrice.apply(this, arguments);
|
|
2744
|
-
}
|
|
2824
|
+
}, _callee14, this);
|
|
2825
|
+
}));
|
|
2745
2826
|
|
|
2746
|
-
function
|
|
2747
|
-
|
|
2748
|
-
}
|
|
2827
|
+
function withdraw(_x5) {
|
|
2828
|
+
return _withdraw.apply(this, arguments);
|
|
2829
|
+
}
|
|
2749
2830
|
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
}
|
|
2831
|
+
return withdraw;
|
|
2832
|
+
}();
|
|
2753
2833
|
|
|
2754
|
-
function
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
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
|
+
}
|
|
2764
2844
|
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2845
|
+
return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow({
|
|
2846
|
+
value: amount.rawAmount()
|
|
2847
|
+
}));
|
|
2768
2848
|
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
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
|
+
}
|
|
2772
2856
|
}
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
}));
|
|
2776
|
-
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2777
|
-
}
|
|
2857
|
+
}, _callee15, this);
|
|
2858
|
+
}));
|
|
2778
2859
|
|
|
2779
|
-
function
|
|
2780
|
-
|
|
2781
|
-
}
|
|
2860
|
+
function repay(_x6) {
|
|
2861
|
+
return _repay.apply(this, arguments);
|
|
2862
|
+
}
|
|
2782
2863
|
|
|
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);
|
|
2864
|
+
return repay;
|
|
2865
|
+
}();
|
|
2799
2866
|
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
}));
|
|
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]));
|
|
2808
2874
|
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2875
|
+
case 1:
|
|
2876
|
+
case "end":
|
|
2877
|
+
return _context16.stop();
|
|
2878
|
+
}
|
|
2812
2879
|
}
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
}));
|
|
2816
|
-
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2817
|
-
}
|
|
2880
|
+
}, _callee16, this);
|
|
2881
|
+
}));
|
|
2818
2882
|
|
|
2819
|
-
function
|
|
2820
|
-
|
|
2821
|
-
}
|
|
2883
|
+
function enableCollateral() {
|
|
2884
|
+
return _enableCollateral.apply(this, arguments);
|
|
2885
|
+
}
|
|
2822
2886
|
|
|
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
|
-
});
|
|
2887
|
+
return enableCollateral;
|
|
2888
|
+
}();
|
|
2833
2889
|
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
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));
|
|
2838
2897
|
|
|
2839
|
-
|
|
2898
|
+
case 1:
|
|
2899
|
+
case "end":
|
|
2900
|
+
return _context17.stop();
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
}, _callee17, this);
|
|
2904
|
+
}));
|
|
2840
2905
|
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
break;
|
|
2845
|
-
}
|
|
2906
|
+
function disableCollateral() {
|
|
2907
|
+
return _disableCollateral.apply(this, arguments);
|
|
2908
|
+
}
|
|
2846
2909
|
|
|
2847
|
-
|
|
2910
|
+
return disableCollateral;
|
|
2911
|
+
}();
|
|
2848
2912
|
|
|
2849
|
-
|
|
2850
|
-
|
|
2913
|
+
return MoneyMarketReadWrite;
|
|
2914
|
+
}(MoneyMarketRead);
|
|
2915
|
+
var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
2916
|
+
_inheritsLoose(MoneyMarket, _BlockchainEntity);
|
|
2851
2917
|
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
return _context7.stop();
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
}, _callee7);
|
|
2858
|
-
}));
|
|
2859
|
-
return _fetchPrice.apply(this, arguments);
|
|
2860
|
-
}
|
|
2918
|
+
function MoneyMarket(address, underlying) {
|
|
2919
|
+
var _this3;
|
|
2861
2920
|
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2921
|
+
_this3 = _BlockchainEntity.call(this) || this;
|
|
2922
|
+
_this3.address = validateAndParseAddress(address);
|
|
2923
|
+
_this3.underlying = validateAndParseAddress(underlying);
|
|
2924
|
+
return _this3;
|
|
2925
|
+
}
|
|
2865
2926
|
|
|
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));
|
|
2927
|
+
var _proto3 = MoneyMarket.prototype;
|
|
2873
2928
|
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
}));
|
|
2881
|
-
return _fetchValuation.apply(this, arguments);
|
|
2882
|
-
}
|
|
2929
|
+
_proto3.read = function read(networkConnection) {
|
|
2930
|
+
return new MoneyMarketRead(networkConnection, this.address, this.underlying);
|
|
2931
|
+
};
|
|
2932
|
+
|
|
2933
|
+
return MoneyMarket;
|
|
2934
|
+
}(BlockchainEntity);
|
|
2883
2935
|
|
|
2884
2936
|
var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2885
2937
|
_inheritsLoose(SdkRead, _BlockchainEntityRead);
|
|
@@ -2891,7 +2943,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2891
2943
|
_this._comptroller = new ethers$1.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
|
|
2892
2944
|
_this._tokenLock = new ethers$1.Contract(networkAddresses.misc.TOKENLOCK, TokenLockABI.abi, networkConnection.provider);
|
|
2893
2945
|
_this._auriFairLaunch = new ethers$1.Contract(networkAddresses.misc.AURIFAIRLAUNCH, AuriFairLaunchABI.abi, networkConnection.provider);
|
|
2894
|
-
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS,
|
|
2946
|
+
_this._auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
|
|
2895
2947
|
return _this;
|
|
2896
2948
|
}
|
|
2897
2949
|
|
|
@@ -2904,10 +2956,11 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2904
2956
|
while (1) {
|
|
2905
2957
|
switch (_context.prev = _context.next) {
|
|
2906
2958
|
case 0:
|
|
2907
|
-
|
|
2959
|
+
console.log(this._networkConnection.provider);
|
|
2960
|
+
_context.next = 3;
|
|
2908
2961
|
return getCurrentTimestamp(this._networkConnection.provider);
|
|
2909
2962
|
|
|
2910
|
-
case
|
|
2963
|
+
case 3:
|
|
2911
2964
|
currentTime = _context.sent;
|
|
2912
2965
|
currentWeek = ethers$1.BigNumber.from(currentTime - REWARDCLAIMSTART).div(7 * ONE_DAY).toNumber();
|
|
2913
2966
|
denominator = 10000;
|
|
@@ -2916,22 +2969,22 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2916
2969
|
promises.push(this._tokenLock.percentageLock(currentWeek + 1)["catch"](function (err) {
|
|
2917
2970
|
return denominator;
|
|
2918
2971
|
}));
|
|
2919
|
-
_context.next =
|
|
2972
|
+
_context.next = 11;
|
|
2920
2973
|
return Promise.all(promises).then(function (res) {
|
|
2921
2974
|
return res.map(function (v) {
|
|
2922
2975
|
return v.toString();
|
|
2923
2976
|
});
|
|
2924
2977
|
});
|
|
2925
2978
|
|
|
2926
|
-
case
|
|
2979
|
+
case 11:
|
|
2927
2980
|
values = _context.sent;
|
|
2928
2981
|
return _context.abrupt("return", {
|
|
2929
2982
|
vestingStart: REWARDCLAIMSTART,
|
|
2930
|
-
currentUnlockPortion: new BigNumber(values[0]).div(denominator).toNumber(),
|
|
2931
|
-
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()
|
|
2932
2985
|
});
|
|
2933
2986
|
|
|
2934
|
-
case
|
|
2987
|
+
case 13:
|
|
2935
2988
|
case "end":
|
|
2936
2989
|
return _context.stop();
|
|
2937
2990
|
}
|
|
@@ -2958,6 +3011,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2958
3011
|
case 0:
|
|
2959
3012
|
marketCount = networkAddresses.auTokens.length;
|
|
2960
3013
|
userMarketDetails = [];
|
|
3014
|
+
collateralRatio = new Array(marketCount);
|
|
2961
3015
|
promises = [];
|
|
2962
3016
|
totalBorrowLimit = new BigNumber(0);
|
|
2963
3017
|
pricePromises = [];
|
|
@@ -2987,14 +3041,14 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2987
3041
|
promises.push(this._comptroller.getAssetsIn(userAddress).then(function (res) {
|
|
2988
3042
|
assetsIn = res;
|
|
2989
3043
|
}));
|
|
2990
|
-
_context2.next =
|
|
3044
|
+
_context2.next = 11;
|
|
2991
3045
|
return Promise.all(promises);
|
|
2992
3046
|
|
|
2993
|
-
case
|
|
2994
|
-
_context2.next =
|
|
3047
|
+
case 11:
|
|
3048
|
+
_context2.next = 13;
|
|
2995
3049
|
return Promise.all(pricePromises);
|
|
2996
3050
|
|
|
2997
|
-
case
|
|
3051
|
+
case 13:
|
|
2998
3052
|
underlyingPrices = _context2.sent;
|
|
2999
3053
|
depositValuationPromises = [];
|
|
3000
3054
|
|
|
@@ -3014,10 +3068,10 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3014
3068
|
_loop();
|
|
3015
3069
|
}
|
|
3016
3070
|
|
|
3017
|
-
_context2.next =
|
|
3071
|
+
_context2.next = 19;
|
|
3018
3072
|
return Promise.all(depositValuationPromises);
|
|
3019
3073
|
|
|
3020
|
-
case
|
|
3074
|
+
case 19:
|
|
3021
3075
|
depositValues = _context2.sent;
|
|
3022
3076
|
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
3023
3077
|
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(collateralRatio[index]));
|
|
@@ -3025,12 +3079,12 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3025
3079
|
});
|
|
3026
3080
|
promises = [];
|
|
3027
3081
|
promises.push(this._comptroller.getAccountLiquidity(userAddress));
|
|
3028
|
-
promises.push(this._auriLens.getRewardBalancesMetadata(this._comptroller.address, userAddress));
|
|
3082
|
+
promises.push(this._auriLens.callStatic.getRewardBalancesMetadata(this._comptroller.address, this._auriFairLaunch.address, userAddress, [AurPlyPid]));
|
|
3029
3083
|
promises.push(this._tokenLock.lockedAmounts(userAddress));
|
|
3030
|
-
_context2.next =
|
|
3084
|
+
_context2.next = 27;
|
|
3031
3085
|
return Promise.all(promises);
|
|
3032
3086
|
|
|
3033
|
-
case
|
|
3087
|
+
case 27:
|
|
3034
3088
|
values = _context2.sent;
|
|
3035
3089
|
accountLiquidity = values[0];
|
|
3036
3090
|
rewardBalancesMetadata = values[1];
|
|
@@ -3064,7 +3118,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3064
3118
|
}
|
|
3065
3119
|
});
|
|
3066
3120
|
|
|
3067
|
-
case
|
|
3121
|
+
case 36:
|
|
3068
3122
|
case "end":
|
|
3069
3123
|
return _context2.stop();
|
|
3070
3124
|
}
|
|
@@ -3102,12 +3156,16 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3102
3156
|
promises.push(fetchValuation(new TokenAmount(AURPLYToken, stakedLiquidity.toString()), this._networkConnection.provider).then(function (res) {
|
|
3103
3157
|
return totalStakeValuation = res;
|
|
3104
3158
|
}));
|
|
3159
|
+
_context3.next = 9;
|
|
3160
|
+
return Promise.all(promises);
|
|
3161
|
+
|
|
3162
|
+
case 9:
|
|
3105
3163
|
return _context3.abrupt("return", {
|
|
3106
3164
|
totalStakedLiquidity: new TokenAmount(AURPLYToken, stakedLiquidity.toString()),
|
|
3107
3165
|
apy: calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION)
|
|
3108
3166
|
});
|
|
3109
3167
|
|
|
3110
|
-
case
|
|
3168
|
+
case 10:
|
|
3111
3169
|
case "end":
|
|
3112
3170
|
return _context3.stop();
|
|
3113
3171
|
}
|
|
@@ -3200,18 +3258,9 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
|
|
|
3200
3258
|
while (1) {
|
|
3201
3259
|
switch (_context6.prev = _context6.next) {
|
|
3202
3260
|
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();
|
|
3261
|
+
return _context6.abrupt("return", this._auriLens.connect(this._networkConnection.signer).claimRewards(this._comptroller.address, this._auriFairLaunch.address, [AurPlyPid]));
|
|
3208
3262
|
|
|
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:
|
|
3263
|
+
case 1:
|
|
3215
3264
|
case "end":
|
|
3216
3265
|
return _context6.stop();
|
|
3217
3266
|
}
|
|
@@ -3311,10 +3360,12 @@ var dummyUserMarketDetails = {
|
|
|
3311
3360
|
};
|
|
3312
3361
|
|
|
3313
3362
|
exports.AURORA_CHAINID = AURORA_CHAINID;
|
|
3363
|
+
exports.AURORA_DEFAULT_PROVIDER = AURORA_DEFAULT_PROVIDER;
|
|
3364
|
+
exports.AURORA_DEFAULT_PROVIDER_URL = AURORA_DEFAULT_PROVIDER_URL;
|
|
3365
|
+
exports.AURORA_DEFAULT_SIGNER = AURORA_DEFAULT_SIGNER;
|
|
3314
3366
|
exports.AURPLYToken = AURPLYToken;
|
|
3315
3367
|
exports.AVAX_DEFAULT_PROVIDER = AVAX_DEFAULT_PROVIDER;
|
|
3316
3368
|
exports.AVAX_DEFAULT_PROVIDER_URL = AVAX_DEFAULT_PROVIDER_URL;
|
|
3317
|
-
exports.AVAX_DEFAULT_SIGNER = AVAX_DEFAULT_SIGNER;
|
|
3318
3369
|
exports.AurPlyPid = AurPlyPid;
|
|
3319
3370
|
exports.BORROW_LIMIT_BUFFER = BORROW_LIMIT_BUFFER;
|
|
3320
3371
|
exports.BlockchainEntity = BlockchainEntity;
|