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