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