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