@sonarwatch/portfolio-plugins 0.14.14 → 0.14.15
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/CHANGELOG.md +1648 -1644
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/plugins/aftermath/helpers.d.ts +4 -0
- package/src/plugins/aftermath/helpers.js +81 -0
- package/src/plugins/aftermath/helpers.js.map +1 -0
- package/src/plugins/aftermath/poolsJob.js +1 -1
- package/src/plugins/aftermath/poolsJob.js.map +1 -1
- package/src/plugins/aftermath/stakingFetcher.js +42 -9
- package/src/plugins/aftermath/stakingFetcher.js.map +1 -1
- package/src/plugins/aftermath/types.d.ts +12 -0
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/suilend/helpers.d.ts +4 -1
- package/src/plugins/suilend/helpers.js +25 -12
- package/src/plugins/suilend/helpers.js.map +1 -1
- package/src/plugins/suilend/obligationsFetcher.js +24 -5
- package/src/plugins/suilend/obligationsFetcher.js.map +1 -1
- package/src/plugins/suilend/types.d.ts +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/plugins/zeta/airdropFetcher.js +14 -14
- package/src/utils/misc/getLendingMarketAprs.d.ts +18 -0
- package/src/utils/misc/getLendingMarketAprs.js +58 -0
- package/src/utils/misc/getLendingMarketAprs.js.map +1 -0
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
|
@@ -42,20 +42,20 @@ const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/token
|
|
|
42
42
|
const clients_1 = require("../../utils/clients");
|
|
43
43
|
const getMultipleAccountsInfoSafe_1 = require("../../utils/solana/getMultipleAccountsInfoSafe");
|
|
44
44
|
const helpers_1 = require("./helpers");
|
|
45
|
-
const query = (0, graphql_request_1.gql) `
|
|
46
|
-
query GetAirdropFinalFrontend($authority: String!) {
|
|
47
|
-
getAirdropFinalFrontend(authority: $authority) {
|
|
48
|
-
authority
|
|
49
|
-
community_allocation
|
|
50
|
-
eligibility
|
|
51
|
-
main_allocation
|
|
52
|
-
og_allocation
|
|
53
|
-
s1_allocation
|
|
54
|
-
s2_allocation
|
|
55
|
-
total_allocation
|
|
56
|
-
__typename
|
|
57
|
-
}
|
|
58
|
-
}
|
|
45
|
+
const query = (0, graphql_request_1.gql) `
|
|
46
|
+
query GetAirdropFinalFrontend($authority: String!) {
|
|
47
|
+
getAirdropFinalFrontend(authority: $authority) {
|
|
48
|
+
authority
|
|
49
|
+
community_allocation
|
|
50
|
+
eligibility
|
|
51
|
+
main_allocation
|
|
52
|
+
og_allocation
|
|
53
|
+
s1_allocation
|
|
54
|
+
s2_allocation
|
|
55
|
+
total_allocation
|
|
56
|
+
__typename
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
59
|
`;
|
|
60
60
|
const networkId = portfolio_core_1.NetworkId.solana;
|
|
61
61
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get both Lending and Borrowing APRs of a market
|
|
4
|
+
*
|
|
5
|
+
* @param {BigNumber} borrowedAmount Borrow Amount of the market (decimals applied)
|
|
6
|
+
* @param {BigNumber} availableAmount Available Amount of the market (decimals applied)
|
|
7
|
+
* @param {number[]} interestRateAprs The differents raw level of APRs (i.e 2 = 2%, expecting 2 here)
|
|
8
|
+
* @param {number[]} interestRateSteps The steps of each level of APRs (i.e 80 = 80%, expecting 80 here)
|
|
9
|
+
* @param {number} spreadFeeBps The spread fee (fee of the protocol) (i.e 2 = 2%, expecting 2 here)
|
|
10
|
+
*
|
|
11
|
+
* @returns {Aprs} BorrowApr and DepositApr of the market in raw value (i.e 0.02 = 2%)
|
|
12
|
+
*/
|
|
13
|
+
export default function getLendingMarketAprs(borrowedAmount: BigNumber, availableAmount: BigNumber, interestRateAprs: number[], interestRateSteps: number[], spreadFeeBps: number): Aprs;
|
|
14
|
+
type Aprs = {
|
|
15
|
+
borrowApr: number;
|
|
16
|
+
depositApr: number;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
7
|
+
/**
|
|
8
|
+
* Get both Lending and Borrowing APRs of a market
|
|
9
|
+
*
|
|
10
|
+
* @param {BigNumber} borrowedAmount Borrow Amount of the market (decimals applied)
|
|
11
|
+
* @param {BigNumber} availableAmount Available Amount of the market (decimals applied)
|
|
12
|
+
* @param {number[]} interestRateAprs The differents raw level of APRs (i.e 2 = 2%, expecting 2 here)
|
|
13
|
+
* @param {number[]} interestRateSteps The steps of each level of APRs (i.e 80 = 80%, expecting 80 here)
|
|
14
|
+
* @param {number} spreadFeeBps The spread fee (fee of the protocol) (i.e 2 = 2%, expecting 2 here)
|
|
15
|
+
*
|
|
16
|
+
* @returns {Aprs} BorrowApr and DepositApr of the market in raw value (i.e 0.02 = 2%)
|
|
17
|
+
*/
|
|
18
|
+
function getLendingMarketAprs(borrowedAmount, availableAmount, interestRateAprs, interestRateSteps, spreadFeeBps) {
|
|
19
|
+
if (interestRateAprs.length !== interestRateSteps.length)
|
|
20
|
+
throw new Error("Interest Rate Aprs and Steps length don't match");
|
|
21
|
+
const utilization = borrowedAmount.dividedBy(availableAmount.plus(borrowedAmount));
|
|
22
|
+
let borrowApr = 0;
|
|
23
|
+
if (borrowedAmount.isZero())
|
|
24
|
+
borrowApr = (0, bignumber_js_1.default)(interestRateAprs[0]).dividedBy(100).toNumber();
|
|
25
|
+
if (availableAmount.isZero())
|
|
26
|
+
borrowApr = (0, bignumber_js_1.default)(interestRateAprs[interestRateAprs.length])
|
|
27
|
+
.dividedBy(100)
|
|
28
|
+
.toNumber();
|
|
29
|
+
for (let i = 0; i < interestRateSteps.length; i++) {
|
|
30
|
+
const currentUtil = interestRateSteps[i] / 100;
|
|
31
|
+
const nextUtil = interestRateSteps[i + 1] / 100;
|
|
32
|
+
const currentApr = new bignumber_js_1.default(interestRateAprs[i]).dividedBy(100);
|
|
33
|
+
const nextApr = new bignumber_js_1.default(interestRateAprs[i + 1]).dividedBy(100);
|
|
34
|
+
if (utilization.isEqualTo(currentUtil)) {
|
|
35
|
+
borrowApr = currentApr.toNumber();
|
|
36
|
+
}
|
|
37
|
+
if (utilization.isLessThan(nextUtil)) {
|
|
38
|
+
const utilizationDelta = utilization.minus(currentUtil);
|
|
39
|
+
const utilStepsDelta = nextUtil - currentUtil;
|
|
40
|
+
borrowApr = utilizationDelta
|
|
41
|
+
.dividedBy(utilStepsDelta)
|
|
42
|
+
.times(nextApr.minus(currentApr))
|
|
43
|
+
.plus(currentApr)
|
|
44
|
+
.toNumber();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
borrowApr = 0;
|
|
48
|
+
const depositApr = (0, bignumber_js_1.default)(borrowApr)
|
|
49
|
+
.times(1 - Number(spreadFeeBps) / 100)
|
|
50
|
+
.times(utilization)
|
|
51
|
+
.toNumber();
|
|
52
|
+
return {
|
|
53
|
+
borrowApr,
|
|
54
|
+
depositApr,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.default = getLendingMarketAprs;
|
|
58
|
+
//# sourceMappingURL=getLendingMarketAprs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLendingMarketAprs.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getLendingMarketAprs.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AAErC;;;;;;;;;;GAUG;AACH,SAAwB,oBAAoB,CAC1C,cAAyB,EACzB,eAA0B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ACpC,CAAC;QAED,IAAI,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrC,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACxD,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,CAAC;YAC9C,SAAS,GAAG,gBAAgB;iBACzB,SAAS,CAAC,cAAc,CAAC;iBACzB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;iBAChC,IAAI,CAAC,UAAU,CAAC;iBAChB,QAAQ,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IACD,SAAS,GAAG,CAAC,CAAC;IAEd,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,SAAS,CAAC;SACpC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC;SACrC,KAAK,CAAC,WAAW,CAAC;SAClB,QAAQ,EAAE,CAAC;IAEd,OAAO;QACL,SAAS;QACT,UAAU;KACX,CAAC;AACJ,CAAC;AAnDD,uCAmDC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.poolQueryMsg = exports.minterQueryMsg = exports.tokenInfoQueryMsg = exports.infoQueryMsg = void 0;
|
|
4
|
-
exports.infoQueryMsg = JSON.parse(`{
|
|
5
|
-
"info": {}
|
|
4
|
+
exports.infoQueryMsg = JSON.parse(`{
|
|
5
|
+
"info": {}
|
|
6
6
|
}`);
|
|
7
|
-
exports.tokenInfoQueryMsg = JSON.parse(`{
|
|
8
|
-
"token_info": {}
|
|
7
|
+
exports.tokenInfoQueryMsg = JSON.parse(`{
|
|
8
|
+
"token_info": {}
|
|
9
9
|
}`);
|
|
10
|
-
exports.minterQueryMsg = JSON.parse(`{
|
|
11
|
-
"minter": {}
|
|
10
|
+
exports.minterQueryMsg = JSON.parse(`{
|
|
11
|
+
"minter": {}
|
|
12
12
|
}`);
|
|
13
|
-
exports.poolQueryMsg = JSON.parse(`{
|
|
14
|
-
"pool": {}
|
|
13
|
+
exports.poolQueryMsg = JSON.parse(`{
|
|
14
|
+
"pool": {}
|
|
15
15
|
}`);
|
|
16
16
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
function getQueryBalanceByOwner(owner) {
|
|
4
|
-
return JSON.parse(`{
|
|
5
|
-
"balance": {
|
|
6
|
-
"address": "${owner}"
|
|
7
|
-
}
|
|
4
|
+
return JSON.parse(`{
|
|
5
|
+
"balance": {
|
|
6
|
+
"address": "${owner}"
|
|
7
|
+
}
|
|
8
8
|
}`);
|
|
9
9
|
}
|
|
10
10
|
exports.default = getQueryBalanceByOwner;
|