@aurigami/sdk 1.20.2 → 1.20.4
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/sdk.cjs.development.js +42 -75
- 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 +42 -75
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/priceFetcher.ts +1 -3
|
@@ -1548,9 +1548,7 @@ function _fetchPriceFromDefiLlamaAPI() {
|
|
|
1548
1548
|
while (1) switch (_context4.prev = _context4.next) {
|
|
1549
1549
|
case 0:
|
|
1550
1550
|
_context4.next = 2;
|
|
1551
|
-
return axios.
|
|
1552
|
-
coins: [id]
|
|
1553
|
-
}).then(function (res) {
|
|
1551
|
+
return axios.get("https://coins.llama.fi/prices/current/" + id).then(function (res) {
|
|
1554
1552
|
return res.data.coins[id].price;
|
|
1555
1553
|
})["catch"](function (err) {
|
|
1556
1554
|
console.log("unable to fetch price from DefiLlama API: " + err);
|
|
@@ -2964,46 +2962,15 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2964
2962
|
}();
|
|
2965
2963
|
_proto.getDepositStaderAPY = /*#__PURE__*/function () {
|
|
2966
2964
|
var _getDepositStaderAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
2967
|
-
var rewardStartTime, currentTime, _yield$Promise$all7, totalDeposited, underlyingPrice, depositStaderApy;
|
|
2968
2965
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
2969
2966
|
while (1) switch (_context14.prev = _context14.next) {
|
|
2970
2967
|
case 0:
|
|
2971
|
-
rewardStartTime = 1675346400;
|
|
2972
|
-
currentTime = getCurrentTimestamp();
|
|
2973
|
-
if (!(currentTime < rewardStartTime)) {
|
|
2974
|
-
_context14.next = 4;
|
|
2975
|
-
break;
|
|
2976
|
-
}
|
|
2977
2968
|
return _context14.abrupt("return", new BigNumber(0));
|
|
2978
|
-
case
|
|
2979
|
-
_context14.next = 6;
|
|
2980
|
-
return Promise.all([this.getTotalTokenDeposited(), fetchPrice(this.underlying.address, this._networkConnection.provider)]);
|
|
2981
|
-
case 6:
|
|
2982
|
-
_yield$Promise$all7 = _context14.sent;
|
|
2983
|
-
totalDeposited = _yield$Promise$all7[0];
|
|
2984
|
-
underlyingPrice = _yield$Promise$all7[1];
|
|
2985
|
-
if (!isSameAddress(this.underlying.address, networkAddresses.tokens.NEARX)) {
|
|
2986
|
-
_context14.next = 18;
|
|
2987
|
-
break;
|
|
2988
|
-
}
|
|
2989
|
-
_context14.t0 = helpers;
|
|
2990
|
-
_context14.next = 13;
|
|
2991
|
-
return fetchValuation(TokenAmount.fromAddressAndAmount(networkAddresses.tokens.STADER, '40', false), this._networkConnection.provider);
|
|
2992
|
-
case 13:
|
|
2993
|
-
_context14.t1 = _context14.sent;
|
|
2994
|
-
_context14.t2 = underlyingPrice.multipliedBy(totalDeposited.formattedAmount());
|
|
2995
|
-
depositStaderApy = _context14.t0.calcLMRewardApr.call(_context14.t0, _context14.t1, _context14.t2, 365);
|
|
2996
|
-
_context14.next = 19;
|
|
2997
|
-
break;
|
|
2998
|
-
case 18:
|
|
2999
|
-
depositStaderApy = new BigNumber(0);
|
|
3000
|
-
case 19:
|
|
3001
|
-
return _context14.abrupt("return", depositStaderApy);
|
|
3002
|
-
case 20:
|
|
2969
|
+
case 1:
|
|
3003
2970
|
case "end":
|
|
3004
2971
|
return _context14.stop();
|
|
3005
2972
|
}
|
|
3006
|
-
}, _callee14
|
|
2973
|
+
}, _callee14);
|
|
3007
2974
|
}));
|
|
3008
2975
|
function getDepositStaderAPY() {
|
|
3009
2976
|
return _getDepositStaderAPY.apply(this, arguments);
|
|
@@ -3012,30 +2979,30 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3012
2979
|
}();
|
|
3013
2980
|
_proto.getDetails = /*#__PURE__*/function () {
|
|
3014
2981
|
var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
3015
|
-
var _yield$Promise$
|
|
2982
|
+
var _yield$Promise$all7, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeeds, _yield$Promise$all8, depositPlyAPY, borrowPlyAPY, depositNearAPY, borrowNearAPY, depositMetaAPY, staderDepositApy;
|
|
3016
2983
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
3017
2984
|
while (1) switch (_context15.prev = _context15.next) {
|
|
3018
2985
|
case 0:
|
|
3019
2986
|
_context15.next = 2;
|
|
3020
2987
|
return Promise.all([this.getTotalTokenDeposited(), this.getTotalTokenBorrowed(), this.getDepositAPY(), this.getBorrowAPY(), this.getCollateralRatio(), this.getRewardSpeeds()]);
|
|
3021
2988
|
case 2:
|
|
3022
|
-
_yield$Promise$
|
|
3023
|
-
totalDeposited = _yield$Promise$
|
|
3024
|
-
totalBorrowed = _yield$Promise$
|
|
3025
|
-
depositAPY = _yield$Promise$
|
|
3026
|
-
borrowAPY = _yield$Promise$
|
|
3027
|
-
collateralRatio = _yield$Promise$
|
|
3028
|
-
rewardSpeeds = _yield$Promise$
|
|
2989
|
+
_yield$Promise$all7 = _context15.sent;
|
|
2990
|
+
totalDeposited = _yield$Promise$all7[0];
|
|
2991
|
+
totalBorrowed = _yield$Promise$all7[1];
|
|
2992
|
+
depositAPY = _yield$Promise$all7[2];
|
|
2993
|
+
borrowAPY = _yield$Promise$all7[3];
|
|
2994
|
+
collateralRatio = _yield$Promise$all7[4];
|
|
2995
|
+
rewardSpeeds = _yield$Promise$all7[5];
|
|
3029
2996
|
_context15.next = 11;
|
|
3030
2997
|
return Promise.all([this.getDepositPlyAPY(), this.getBorrowPlyAPY(), this.getDepositNearAPY(), this.getBorrowNearAPY(), this.getDepositMetaAPY(), this.getDepositStaderAPY()]);
|
|
3031
2998
|
case 11:
|
|
3032
|
-
_yield$Promise$
|
|
3033
|
-
depositPlyAPY = _yield$Promise$
|
|
3034
|
-
borrowPlyAPY = _yield$Promise$
|
|
3035
|
-
depositNearAPY = _yield$Promise$
|
|
3036
|
-
borrowNearAPY = _yield$Promise$
|
|
3037
|
-
depositMetaAPY = _yield$Promise$
|
|
3038
|
-
staderDepositApy = _yield$Promise$
|
|
2999
|
+
_yield$Promise$all8 = _context15.sent;
|
|
3000
|
+
depositPlyAPY = _yield$Promise$all8[0];
|
|
3001
|
+
borrowPlyAPY = _yield$Promise$all8[1];
|
|
3002
|
+
depositNearAPY = _yield$Promise$all8[2];
|
|
3003
|
+
borrowNearAPY = _yield$Promise$all8[3];
|
|
3004
|
+
depositMetaAPY = _yield$Promise$all8[4];
|
|
3005
|
+
staderDepositApy = _yield$Promise$all8[5];
|
|
3039
3006
|
return _context15.abrupt("return", {
|
|
3040
3007
|
auTokenAddress: this.auToken.address,
|
|
3041
3008
|
totalTokenDeposited: totalDeposited,
|
|
@@ -3181,17 +3148,17 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3181
3148
|
}();
|
|
3182
3149
|
_proto.getDepositBorrowValue = /*#__PURE__*/function () {
|
|
3183
3150
|
var _getDepositBorrowValue = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(userAddress) {
|
|
3184
|
-
var _yield$Promise$
|
|
3151
|
+
var _yield$Promise$all9, price, depositBalance, borrowBalance, suppliedValue, borrowedValue;
|
|
3185
3152
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
3186
3153
|
while (1) switch (_context20.prev = _context20.next) {
|
|
3187
3154
|
case 0:
|
|
3188
3155
|
_context20.next = 2;
|
|
3189
3156
|
return Promise.all([this.getUnderlyingPrice(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress)]);
|
|
3190
3157
|
case 2:
|
|
3191
|
-
_yield$Promise$
|
|
3192
|
-
price = _yield$Promise$
|
|
3193
|
-
depositBalance = _yield$Promise$
|
|
3194
|
-
borrowBalance = _yield$Promise$
|
|
3158
|
+
_yield$Promise$all9 = _context20.sent;
|
|
3159
|
+
price = _yield$Promise$all9[0];
|
|
3160
|
+
depositBalance = _yield$Promise$all9[1];
|
|
3161
|
+
borrowBalance = _yield$Promise$all9[2];
|
|
3195
3162
|
suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
|
|
3196
3163
|
borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
|
|
3197
3164
|
return _context20.abrupt("return", {
|
|
@@ -3211,19 +3178,19 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3211
3178
|
}();
|
|
3212
3179
|
_proto.getApyWithoutIncentive = /*#__PURE__*/function () {
|
|
3213
3180
|
var _getApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(userAddress) {
|
|
3214
|
-
var _yield$Promise$
|
|
3181
|
+
var _yield$Promise$all10, price, depositApy, borrowApy, depositBalance, borrowBalance, suppliedValue, borrowedValue, sum;
|
|
3215
3182
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
3216
3183
|
while (1) switch (_context21.prev = _context21.next) {
|
|
3217
3184
|
case 0:
|
|
3218
3185
|
_context21.next = 2;
|
|
3219
3186
|
return Promise.all([this.getUnderlyingPrice(), this.getDepositAPY(), this.getBorrowAPY(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress)]);
|
|
3220
3187
|
case 2:
|
|
3221
|
-
_yield$Promise$
|
|
3222
|
-
price = _yield$Promise$
|
|
3223
|
-
depositApy = _yield$Promise$
|
|
3224
|
-
borrowApy = _yield$Promise$
|
|
3225
|
-
depositBalance = _yield$Promise$
|
|
3226
|
-
borrowBalance = _yield$Promise$
|
|
3188
|
+
_yield$Promise$all10 = _context21.sent;
|
|
3189
|
+
price = _yield$Promise$all10[0];
|
|
3190
|
+
depositApy = _yield$Promise$all10[1];
|
|
3191
|
+
borrowApy = _yield$Promise$all10[2];
|
|
3192
|
+
depositBalance = _yield$Promise$all10[3];
|
|
3193
|
+
borrowBalance = _yield$Promise$all10[4];
|
|
3227
3194
|
suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
|
|
3228
3195
|
borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
|
|
3229
3196
|
sum = calcNetApy(suppliedValue, depositApy, borrowedValue, borrowApy);
|
|
@@ -3245,24 +3212,24 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3245
3212
|
}();
|
|
3246
3213
|
_proto.getApyWithIncentive = /*#__PURE__*/function () {
|
|
3247
3214
|
var _getApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(userAddress) {
|
|
3248
|
-
var _yield$Promise$
|
|
3215
|
+
var _yield$Promise$all11, price, depositApy, borrowApy, depositBalance, borrowBalance, nearDepositApy, plyDepositApy, metaDepositApy, nearBorrowApy, plyBorrowApy, staderDepositApy, suppliedValue, borrowedValue, totalDepositApy, totalBorrowApy, sum;
|
|
3249
3216
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
3250
3217
|
while (1) switch (_context22.prev = _context22.next) {
|
|
3251
3218
|
case 0:
|
|
3252
3219
|
_context22.next = 2;
|
|
3253
3220
|
return Promise.all([this.getUnderlyingPrice(), this.getDepositAPY(), this.getBorrowAPY(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress), this.getDepositNearAPY(), this.getDepositPlyAPY(), this.getDepositMetaAPY(), this.getBorrowNearAPY(), this.getBorrowPlyAPY()]);
|
|
3254
3221
|
case 2:
|
|
3255
|
-
_yield$Promise$
|
|
3256
|
-
price = _yield$Promise$
|
|
3257
|
-
depositApy = _yield$Promise$
|
|
3258
|
-
borrowApy = _yield$Promise$
|
|
3259
|
-
depositBalance = _yield$Promise$
|
|
3260
|
-
borrowBalance = _yield$Promise$
|
|
3261
|
-
nearDepositApy = _yield$Promise$
|
|
3262
|
-
plyDepositApy = _yield$Promise$
|
|
3263
|
-
metaDepositApy = _yield$Promise$
|
|
3264
|
-
nearBorrowApy = _yield$Promise$
|
|
3265
|
-
plyBorrowApy = _yield$Promise$
|
|
3222
|
+
_yield$Promise$all11 = _context22.sent;
|
|
3223
|
+
price = _yield$Promise$all11[0];
|
|
3224
|
+
depositApy = _yield$Promise$all11[1];
|
|
3225
|
+
borrowApy = _yield$Promise$all11[2];
|
|
3226
|
+
depositBalance = _yield$Promise$all11[3];
|
|
3227
|
+
borrowBalance = _yield$Promise$all11[4];
|
|
3228
|
+
nearDepositApy = _yield$Promise$all11[5];
|
|
3229
|
+
plyDepositApy = _yield$Promise$all11[6];
|
|
3230
|
+
metaDepositApy = _yield$Promise$all11[7];
|
|
3231
|
+
nearBorrowApy = _yield$Promise$all11[8];
|
|
3232
|
+
plyBorrowApy = _yield$Promise$all11[9];
|
|
3266
3233
|
_context22.next = 15;
|
|
3267
3234
|
return this.getDepositStaderAPY();
|
|
3268
3235
|
case 15:
|