@sonarwatch/portfolio-plugins 0.14.143 → 0.14.144

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +1 -1
  3. package/src/plugins/banx/constants.d.ts +14 -8
  4. package/src/plugins/banx/constants.js +25 -13
  5. package/src/plugins/banx/constants.js.map +1 -1
  6. package/src/plugins/banx/index.js +12 -2
  7. package/src/plugins/banx/index.js.map +1 -1
  8. package/src/plugins/banx/loansFetcher.js +108 -123
  9. package/src/plugins/banx/loansFetcher.js.map +1 -1
  10. package/src/plugins/banx/marketsJob.js +40 -0
  11. package/src/plugins/banx/marketsJob.js.map +1 -0
  12. package/src/plugins/banx/offersFetcher.js +61 -70
  13. package/src/plugins/banx/offersFetcher.js.map +1 -1
  14. package/src/plugins/banx/stakingFetcher.js +6 -3
  15. package/src/plugins/banx/stakingFetcher.js.map +1 -1
  16. package/src/plugins/banx/structs.d.ts +222 -2
  17. package/src/plugins/banx/structs.js +216 -2
  18. package/src/plugins/banx/structs.js.map +1 -1
  19. package/src/plugins/banx/types.d.ts +50 -258
  20. package/src/plugins/banx/vaultsFetcher.d.ts +3 -0
  21. package/src/plugins/banx/vaultsFetcher.js +74 -0
  22. package/src/plugins/banx/vaultsFetcher.js.map +1 -0
  23. package/src/plugins/banx/vaultsJob.d.ts +3 -0
  24. package/src/plugins/banx/{collectionsJob.js → vaultsJob.js} +5 -16
  25. package/src/plugins/banx/vaultsJob.js.map +1 -0
  26. package/src/plugins/banx/collectionsJob.js.map +0 -1
  27. package/src/plugins/banx/filters.d.ts +0 -6
  28. package/src/plugins/banx/filters.js +0 -39
  29. package/src/plugins/banx/filters.js.map +0 -1
  30. package/src/plugins/banx/helpers.d.ts +0 -5
  31. package/src/plugins/banx/helpers.js +0 -64
  32. package/src/plugins/banx/helpers.js.map +0 -1
  33. package/src/plugins/banx/idl.d.ts +0 -123
  34. package/src/plugins/banx/idl.js +0 -2187
  35. package/src/plugins/banx/idl.js.map +0 -1
  36. /package/src/plugins/banx/{collectionsJob.d.ts → marketsJob.d.ts} +0 -0
@@ -15,30 +15,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
16
  const axios_1 = __importDefault(require("axios"));
17
17
  const constants_1 = require("./constants");
18
- /**
19
- * @deprecated
20
- * this job has been deprecated following protocol changes
21
- */
22
18
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
23
- const res = yield axios_1.default
24
- .get(constants_1.banxApiCollectionsUrl, {
25
- timeout: 5000,
26
- })
27
- .catch((err) => {
28
- throw Error(`BANX_API ERR: ${err}`);
19
+ const resSpl = yield axios_1.default.get(constants_1.banxApiVaultsUrl, {
20
+ timeout: 3000,
29
21
  });
30
- if (!res) {
31
- throw Error(`BANX_API NO RESPONSE`);
32
- }
33
- yield cache.setItem(constants_1.collectionsCacheKey, res.data.data, {
22
+ yield cache.setItem(constants_1.vaultsCacheKey, resSpl.data.data, {
34
23
  prefix: constants_1.cachePrefix,
35
24
  networkId: portfolio_core_1.NetworkId.solana,
36
25
  });
37
26
  });
38
27
  const job = {
39
- id: `${constants_1.platformId}-collections`,
28
+ id: `${constants_1.platformId}-vaults`,
40
29
  executor,
41
30
  labels: ['normal'],
42
31
  };
43
32
  exports.default = job;
44
- //# sourceMappingURL=collectionsJob.js.map
33
+ //# sourceMappingURL=vaultsJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vaultsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/vaultsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,kDAA0B;AAG1B,2CAKqB;AAGrB,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,MAAM,eAAK,CAAC,GAAG,CAAoB,4BAAgB,EAAE;QAClE,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;IAEH,MAAM,KAAK,CAAC,OAAO,CAAC,0BAAc,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;QACpD,MAAM,EAAE,uBAAW;QACnB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,SAAS;IAC1B,QAAQ;IACR,MAAM,EAAE,CAAC,QAAQ,CAAC;CACnB,CAAC;AAEF,kBAAe,GAAG,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"collectionsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/collectionsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,kDAA0B;AAG1B,2CAKqB;AAGrB;;;GAGG;AACH,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,GAAG,GAAG,MAAM,eAAK;SACpB,GAAG,CAAyB,iCAAqB,EAAE;QAClD,OAAO,EAAE,IAAI;KACd,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,MAAM,KAAK,CAAC,iBAAiB,GAAG,EAAE,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEL,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,CAAC,OAAO,CAAC,+BAAmB,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE;QACtD,MAAM,EAAE,uBAAW;QACnB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,cAAc;IAC/B,QAAQ;IACR,MAAM,EAAE,CAAC,QAAQ,CAAC;CACnB,CAAC;AAEF,kBAAe,GAAG,CAAC"}
@@ -1,6 +0,0 @@
1
- /// <reference types="@drift-labs/sdk/node_modules/@solana/web3.js" />
2
- /// <reference types="jito-ts/node_modules/@solana/web3.js" />
3
- import { GetProgramAccountsFilter } from '@solana/web3.js';
4
- export declare const stakeFilters: (owner: string) => GetProgramAccountsFilter[];
5
- export declare const loanFiltersA: (owner: string) => GetProgramAccountsFilter[];
6
- export declare const loanFiltersB: (owner: string) => GetProgramAccountsFilter[];
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loanFiltersB = exports.loanFiltersA = exports.stakeFilters = void 0;
4
- const constants_1 = require("./constants");
5
- const stakeFilters = (owner) => [
6
- {
7
- memcmp: {
8
- offset: 9,
9
- bytes: owner,
10
- },
11
- },
12
- { dataSize: 160 },
13
- ];
14
- exports.stakeFilters = stakeFilters;
15
- const loanFiltersA = (owner) => [
16
- {
17
- dataSize: constants_1.bondTradeTransactionV3DataSize,
18
- },
19
- {
20
- memcmp: {
21
- bytes: owner,
22
- offset: 41,
23
- },
24
- },
25
- ];
26
- exports.loanFiltersA = loanFiltersA;
27
- const loanFiltersB = (owner) => [
28
- {
29
- dataSize: constants_1.bondTradeTransactionV3DataSize,
30
- },
31
- {
32
- memcmp: {
33
- bytes: owner,
34
- offset: 147,
35
- },
36
- },
37
- ];
38
- exports.loanFiltersB = loanFiltersB;
39
- //# sourceMappingURL=filters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/banx/filters.ts"],"names":[],"mappings":";;;AACA,2CAA6D;AAEtD,MAAM,YAAY,GAAG,CAAC,KAAa,EAA8B,EAAE,CAAC;IACzE;QACE,MAAM,EAAE;YACN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,KAAK;SACb;KACF;IACD,EAAE,QAAQ,EAAE,GAAG,EAAE;CAClB,CAAC;AARW,QAAA,YAAY,gBAQvB;AAEK,MAAM,YAAY,GAAG,CAAC,KAAa,EAA8B,EAAE,CAAC;IACzE;QACE,QAAQ,EAAE,0CAA8B;KACzC;IACD;QACE,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,EAAE;SACX;KACF;CACF,CAAC;AAVW,QAAA,YAAY,gBAUvB;AAEK,MAAM,YAAY,GAAG,CAAC,KAAa,EAA8B,EAAE,CAAC;IACzE;QACE,QAAQ,EAAE,0CAA8B;KACzC;IACD;QACE,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,GAAG;SACZ;KACF;CACF,CAAC;AAVW,QAAA,YAAY,gBAUvB"}
@@ -1,5 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- import { ParsedAccount } from '../../utils/solana';
3
- import { BondTradeTransactionV3 } from './types';
4
- export declare const calculateLoanRepayValue: (acc: ParsedAccount<BondTradeTransactionV3>) => BigNumber;
5
- export declare const calculateDebtValue: (acc: ParsedAccount<BondTradeTransactionV3>) => BigNumber;
@@ -1,64 +0,0 @@
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
- exports.calculateDebtValue = exports.calculateLoanRepayValue = void 0;
7
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
- const BONDS = {
9
- PROGRAM_PUBKEY: '4tdmkuY6EStxbS6Y8s5ueznL3VPMSugrvQuDeAHGZhSt',
10
- ADMIN_PUBKEY: 'revJ8QJgQ3xCcZ6CMykjsmGMYdg8Pj9WnqgJZBHBwSK',
11
- PROTOCOL_FEE_PERCENT: 100, // ? Base points
12
- PROTOCOL_REPAY_FEE: 620, // ? Base points
13
- };
14
- const SOL_WAD = 1e9;
15
- const SECONDS_IN_YEAR = 31536000;
16
- const BASE_POINTS = 10000;
17
- const wadMul = (x, y) => Math.floor((x * y) / SOL_WAD);
18
- const wadDiv = (x, y) => Math.floor((x * SOL_WAD) / y);
19
- const basePointsToWads = (basePoints) => Math.floor((basePoints * SOL_WAD) / BASE_POINTS);
20
- const calculateCurrentInterestSolPure = ({ loanValue, startTime, currentTime, rateBasePoints, }) => {
21
- const loanTime = currentTime - startTime;
22
- const secondsInYearWad = SECONDS_IN_YEAR * SOL_WAD;
23
- const yearsWad = wadDiv(loanTime * SOL_WAD, secondsInYearWad);
24
- return wadMul(loanValue, wadMul(yearsWad, basePointsToWads(rateBasePoints)));
25
- };
26
- const calculateLoanRepayValue = (acc) => {
27
- const loanValue = Number(acc.solAmount);
28
- const calculatedInterest = calculateCurrentInterestSolPure({
29
- loanValue,
30
- startTime: Number(acc.soldAt),
31
- currentTime: Date.now() / 1000,
32
- rateBasePoints: Number(acc.amountOfBonds) + BONDS.PROTOCOL_REPAY_FEE,
33
- });
34
- return new bignumber_js_1.default(loanValue).plus(calculatedInterest);
35
- };
36
- exports.calculateLoanRepayValue = calculateLoanRepayValue;
37
- const getInterestRepaid = (acc) => {
38
- const currentLoanValue = Number(acc.solAmount) + Number(acc.feeAmount);
39
- return new bignumber_js_1.default(acc.redeemedAt !== '0'
40
- ? calculateCurrentInterestSolPure({
41
- loanValue: currentLoanValue,
42
- startTime: acc.soldAt,
43
- currentTime: Number(acc.redeemedAt),
44
- rateBasePoints: acc.amountOfBonds,
45
- })
46
- : 0);
47
- };
48
- const calculateDebtValue = (acc) => {
49
- const loanValue = Number(acc.solAmount);
50
- const calculatedInterest = calculateCurrentInterestSolPure({
51
- loanValue,
52
- startTime: Number(acc.soldAt),
53
- currentTime: Date.now() / 1000,
54
- rateBasePoints: Number(acc.amountOfBonds) + BONDS.PROTOCOL_REPAY_FEE,
55
- });
56
- const repaid = getInterestRepaid(acc);
57
- const principal = new bignumber_js_1.default(acc.solAmount);
58
- return principal
59
- .minus(repaid.toNumber())
60
- .plus(calculatedInterest)
61
- .plus(Number(acc.feeAmount));
62
- };
63
- exports.calculateDebtValue = calculateDebtValue;
64
-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,MAAM,CAAC;QAC7B,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI;QAC9B,cAAc,EAAE,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,kBAAkB;KACrE,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAEtC,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAE/C,OAAO,SAAS;SACb,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;SACxB,IAAI,CAAC,kBAAkB,CAAC;SACxB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;AACjC,CAAC,CAAC;AApBW,QAAA,kBAAkB,sBAoB7B"}
@@ -1,123 +0,0 @@
1
- export declare const BanxIDL: {
2
- version: string;
3
- name: string;
4
- accounts: {
5
- name: string;
6
- type: {
7
- kind: string;
8
- fields: ({
9
- name: string;
10
- type: {
11
- defined: string;
12
- array?: undefined;
13
- };
14
- } | {
15
- name: string;
16
- type: {
17
- array: (string | number)[];
18
- defined?: undefined;
19
- };
20
- } | {
21
- name: string;
22
- type: string;
23
- })[];
24
- };
25
- }[];
26
- types: ({
27
- name: string;
28
- type: {
29
- kind: string;
30
- fields: ({
31
- name: string;
32
- type: {
33
- array: (string | number)[];
34
- };
35
- } | {
36
- name: string;
37
- type: string;
38
- })[];
39
- variants?: undefined;
40
- };
41
- } | {
42
- name: string;
43
- type: {
44
- kind: string;
45
- fields: ({
46
- name: string;
47
- type: string;
48
- } | {
49
- name: string;
50
- type: {
51
- defined: string;
52
- };
53
- })[];
54
- variants?: undefined;
55
- };
56
- } | {
57
- name: string;
58
- type: {
59
- kind: string;
60
- fields: {
61
- name: string;
62
- type: {
63
- vec: {
64
- defined: string;
65
- };
66
- };
67
- }[];
68
- variants?: undefined;
69
- };
70
- } | {
71
- name: string;
72
- type: {
73
- kind: string;
74
- fields: {
75
- name: string;
76
- docs: string[];
77
- type: {
78
- vec: string;
79
- };
80
- }[];
81
- variants?: undefined;
82
- };
83
- } | {
84
- name: string;
85
- type: {
86
- kind: string;
87
- fields: {
88
- name: string;
89
- docs: string[];
90
- type: {
91
- vec: {
92
- array: (string | number)[];
93
- };
94
- };
95
- }[];
96
- variants?: undefined;
97
- };
98
- } | {
99
- name: string;
100
- type: {
101
- kind: string;
102
- variants: {
103
- name: string;
104
- }[];
105
- fields?: undefined;
106
- };
107
- } | {
108
- name: string;
109
- type: {
110
- kind: string;
111
- variants: ({
112
- name: string;
113
- fields: string[];
114
- } | {
115
- name: string;
116
- fields: {
117
- defined: string;
118
- }[];
119
- })[];
120
- fields?: undefined;
121
- };
122
- })[];
123
- };