@sonarwatch/portfolio-plugins 0.11.114 → 0.11.115
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1171 -1167
- package/README.md +3 -3
- package/package.json +2 -2
- package/src/index.d.ts +0 -1
- package/src/index.js +14 -4
- package/src/index.js.map +1 -1
- package/src/plugins/abex/constants.d.ts +7 -0
- package/src/plugins/abex/constants.js +17 -0
- package/src/plugins/abex/constants.js.map +1 -0
- package/src/plugins/abex/index.d.ts +6 -0
- package/src/plugins/abex/index.js +13 -0
- package/src/plugins/abex/index.js.map +1 -0
- package/src/plugins/abex/marketsJob.d.ts +3 -0
- package/src/plugins/abex/marketsJob.js +90 -0
- package/src/plugins/abex/marketsJob.js.map +1 -0
- package/src/plugins/abex/positionsFetcher.js +65 -0
- package/src/plugins/abex/positionsFetcher.js.map +1 -0
- package/src/plugins/abex/types.d.ts +69 -0
- package/src/plugins/abex/types.js +3 -0
- package/src/plugins/abex/types.js.map +1 -0
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/foo/index.js +2 -2
- package/src/plugins/foo/index.js.map +1 -1
- package/src/plugins/foo/positionsFetcher.d.ts +3 -0
- package/src/plugins/foo/{positionFetcher.js → positionsFetcher.js} +2 -2
- package/src/plugins/foo/positionsFetcher.js.map +1 -0
- package/src/plugins/kai/constants.d.ts +9 -0
- package/src/plugins/kai/constants.js +37 -0
- package/src/plugins/kai/constants.js.map +1 -0
- package/src/plugins/kai/index.d.ts +6 -0
- package/src/plugins/kai/index.js +12 -0
- package/src/plugins/kai/index.js.map +1 -0
- package/src/plugins/kai/types.d.ts +57 -0
- package/src/plugins/kai/types.js +3 -0
- package/src/plugins/kai/types.js.map +1 -0
- package/src/plugins/kai/vaultsJob.d.ts +3 -0
- package/src/plugins/kai/vaultsJob.js +60 -0
- package/src/plugins/kai/vaultsJob.js.map +1 -0
- package/src/plugins/raydium/lpTokensJob.js +4 -1
- package/src/plugins/raydium/lpTokensJob.js.map +1 -1
- package/src/plugins/suilend/obligationsFetcher.js +10 -8
- package/src/plugins/suilend/obligationsFetcher.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/symmetry/basketsJob.d.ts +3 -0
- package/src/plugins/symmetry/basketsJob.js +69 -0
- package/src/plugins/symmetry/basketsJob.js.map +1 -0
- package/src/plugins/symmetry/constants.d.ts +7 -0
- package/src/plugins/symmetry/constants.js +17 -0
- package/src/plugins/symmetry/constants.js.map +1 -0
- package/src/plugins/symmetry/filters.d.ts +2 -0
- package/src/plugins/symmetry/filters.js +15 -0
- package/src/plugins/symmetry/filters.js.map +1 -0
- package/src/plugins/symmetry/index.d.ts +6 -0
- package/src/plugins/symmetry/index.js +12 -0
- package/src/plugins/symmetry/index.js.map +1 -0
- package/src/plugins/symmetry/structs.d.ts +78 -0
- package/src/plugins/symmetry/structs.js +78 -0
- package/src/plugins/symmetry/structs.js.map +1 -0
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/utils/misc/getLpTokenSourceRaw.d.ts +1 -1
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
- package/src/plugins/foo/positionFetcher.js.map +0 -1
- /package/src/plugins/{foo/positionFetcher.d.ts → abex/positionsFetcher.d.ts} +0 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
export interface Vault {
|
2
|
+
free_balance: string;
|
3
|
+
id: {
|
4
|
+
id: string;
|
5
|
+
};
|
6
|
+
lp_treasury: {
|
7
|
+
type: string;
|
8
|
+
fields: {
|
9
|
+
id: {
|
10
|
+
id: string;
|
11
|
+
};
|
12
|
+
total_supply: {
|
13
|
+
type: string;
|
14
|
+
fields: {
|
15
|
+
value: string;
|
16
|
+
};
|
17
|
+
};
|
18
|
+
};
|
19
|
+
};
|
20
|
+
performance_fee_balance: string;
|
21
|
+
performance_fee_bps: string;
|
22
|
+
profit_unlock_duration_sec: string;
|
23
|
+
strategies: {
|
24
|
+
type: string;
|
25
|
+
fields: {
|
26
|
+
contents: {
|
27
|
+
type: string;
|
28
|
+
fields: {
|
29
|
+
key: string;
|
30
|
+
value: {
|
31
|
+
type: string;
|
32
|
+
fields: {
|
33
|
+
borrowed: string;
|
34
|
+
max_borrow: null;
|
35
|
+
target_alloc_weight_bps: string;
|
36
|
+
};
|
37
|
+
};
|
38
|
+
};
|
39
|
+
}[];
|
40
|
+
};
|
41
|
+
};
|
42
|
+
strategy_withdraw_priority_order: string[];
|
43
|
+
time_locked_profit: {
|
44
|
+
type: string;
|
45
|
+
fields: {
|
46
|
+
final_unlock_ts_sec: string;
|
47
|
+
locked_balance: string;
|
48
|
+
previous_unlock_at: string;
|
49
|
+
unlock_per_second: string;
|
50
|
+
unlock_start_ts_sec: string;
|
51
|
+
unlocked_balance: string;
|
52
|
+
};
|
53
|
+
};
|
54
|
+
tvl_cap: null;
|
55
|
+
version: string;
|
56
|
+
withdraw_ticket_issued: boolean;
|
57
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/types.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
16
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const clients_1 = require("../../utils/clients");
|
19
|
+
const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
|
20
|
+
const getLpTokenSourceRaw_1 = __importDefault(require("../../utils/misc/getLpTokenSourceRaw"));
|
21
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
22
|
+
var _a, _b, _c;
|
23
|
+
const client = (0, clients_1.getClientSui)();
|
24
|
+
const objects = yield (0, multiGetObjects_1.multiGetObjects)(client, constants_1.vaultsInfo.map((v) => v.id));
|
25
|
+
const tokenPrices = yield cache.getTokenPricesAsMap(constants_1.vaultsInfo.map((v) => v.tType), portfolio_core_1.NetworkId.sui);
|
26
|
+
for (let i = 0; i < objects.length; i++) {
|
27
|
+
const vaultInfo = constants_1.vaultsInfo[i];
|
28
|
+
const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(vaultInfo.tType, portfolio_core_1.NetworkId.sui));
|
29
|
+
if (!tokenPrice)
|
30
|
+
continue;
|
31
|
+
const object = objects[i];
|
32
|
+
if (!((_a = object.data) === null || _a === void 0 ? void 0 : _a.content))
|
33
|
+
continue;
|
34
|
+
const vault = object.data.content.fields;
|
35
|
+
let amount = new bignumber_js_1.default(vault.free_balance);
|
36
|
+
(_c = (_b = object.data) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.fields.strategies.fields.contents.forEach((c) => {
|
37
|
+
amount = amount.plus(c.fields.value.fields.borrowed);
|
38
|
+
});
|
39
|
+
const lpSource = (0, getLpTokenSourceRaw_1.default)(portfolio_core_1.NetworkId.sui, constants_1.platformId, constants_1.platformId, 'Vaults', {
|
40
|
+
address: vaultInfo.lpType,
|
41
|
+
decimals: vaultInfo.decimals,
|
42
|
+
supplyRaw: new bignumber_js_1.default(vault.lp_treasury.fields.total_supply.fields.value),
|
43
|
+
}, [
|
44
|
+
{
|
45
|
+
address: vaultInfo.tType,
|
46
|
+
decimals: vaultInfo.decimals,
|
47
|
+
reserveAmountRaw: amount,
|
48
|
+
price: tokenPrice.price,
|
49
|
+
},
|
50
|
+
]);
|
51
|
+
yield cache.setTokenPriceSource(lpSource);
|
52
|
+
}
|
53
|
+
});
|
54
|
+
const job = {
|
55
|
+
id: `${constants_1.platformId}-vaults`,
|
56
|
+
executor,
|
57
|
+
label: 'normal',
|
58
|
+
};
|
59
|
+
exports.default = job;
|
60
|
+
//# sourceMappingURL=vaultsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"vaultsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/vaultsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+DAA2E;AAG3E,2CAAqD;AACrD,iDAAmD;AACnD,qEAAkE;AAElE,+FAAuE;AAEvE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAe,EACnC,MAAM,EACN,sBAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC5B,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,mBAAmB,CACjD,sBAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAC9B,0BAAS,CAAC,GAAG,CACd,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,sBAAU,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,UAAU,GAAG,WAAW,CAAC,G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C,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,SAAS;IAC1B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
16
17
|
const clients_1 = require("../../utils/clients");
|
17
18
|
const constants_1 = require("./constants");
|
18
19
|
const amms_1 = require("./structs/amms");
|
@@ -155,7 +156,9 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
156
|
if (!lpMintAccount)
|
156
157
|
continue;
|
157
158
|
const lpDecimals = lpMintAccount.decimals;
|
158
|
-
const lpSupply =
|
159
|
+
const lpSupply = lpMint.toString() === 'CQurpF3WS3yEqFEt1Bu8s5zmZqznQG3EJkcYvsyg3sLc'
|
160
|
+
? new bignumber_js_1.default('3381427.37') // Temporary fix for SOL-WIF lp
|
161
|
+
: lpMintAccount.supply;
|
159
162
|
if (lpSupply.isZero())
|
160
163
|
continue;
|
161
164
|
tokenPriceSources.push((0, getLpTokenSourceRaw_1.default)(portfolio_core_1.NetworkId.solana, lpMint.toString(), constants_1.platformId, amm.ammName, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lpTokensJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/lpTokensJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;
|
1
|
+
{"version":3,"file":"lpTokensJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/lpTokensJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AAEvD,gEAAqC;AAGrC,iDAAsD;AACtD,2CAA+E;AA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wBACxB,gBAAgB,EAAE,YAAY;qBAC/B;oBACD;wBACE,OAAO,EAAE,WAAW,CAAC,OAAO;wBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;wBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;wBACxB,gBAAgB,EAAE,YAAY;qBAC/B;iBACF,CACF,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,IAAA,oBAAU,EACd,iBAAiB,CAAC,GAAG,CACnB,CAAC,gBAAgB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CACxE,CACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,YAAY;IAC7B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -20,10 +20,13 @@ const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
|
|
20
20
|
const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
|
21
21
|
const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
|
22
22
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
|
+
var _a, _b, _c, _d;
|
23
24
|
const client = (0, clients_1.getClientSui)();
|
24
25
|
const suilendObjects = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
|
25
26
|
filter: { Package: constants_1.packageId },
|
26
27
|
});
|
28
|
+
if (suilendObjects.length === 0)
|
29
|
+
return [];
|
27
30
|
const mints = new Set();
|
28
31
|
const rewardsInfo = yield cache.getItem(constants_1.poolsKey, {
|
29
32
|
prefix: constants_1.platformId,
|
@@ -37,15 +40,12 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
37
40
|
});
|
38
41
|
const obligationsId = [];
|
39
42
|
for (const object of suilendObjects) {
|
40
|
-
const
|
41
|
-
if (!data || !data.content)
|
42
|
-
continue;
|
43
|
-
const { type } = data.content;
|
43
|
+
const type = (_b = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.type;
|
44
44
|
if (!type || !type.startsWith(constants_1.obligationOwnerCapType))
|
45
45
|
continue;
|
46
|
-
const
|
47
|
-
if (
|
48
|
-
obligationsId.push(
|
46
|
+
const obligationId = (_d = (_c = object.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.obligation_id;
|
47
|
+
if (obligationId)
|
48
|
+
obligationsId.push(obligationId);
|
49
49
|
}
|
50
50
|
const obligationsObjects = yield (0, multiGetObjects_1.multiGetObjects)(client, obligationsId);
|
51
51
|
const borrowedAssets = [];
|
@@ -115,7 +115,9 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
115
115
|
rewardAssets.push(...(0, tokenPriceToAssetTokens_1.default)(tokenPrice.address, amount.dividedBy(Math.pow(10, tokenPrice.decimals)).toNumber(), portfolio_core_1.NetworkId.sui, tokenPrice));
|
116
116
|
});
|
117
117
|
}
|
118
|
-
if (suppliedAssets.length === 0 &&
|
118
|
+
if (suppliedAssets.length === 0 &&
|
119
|
+
borrowedAssets.length === 0 &&
|
120
|
+
rewardAssets.length === 0)
|
119
121
|
return [];
|
120
122
|
const { borrowedValue, suppliedValue, value, healthRatio, rewardValue } = (0, portfolio_core_1.getElementLendingValues)(suppliedAssets, borrowedAssets, rewardAssets);
|
121
123
|
const element = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qEAAkE;AAElE,qEAAkE;AAClE,uGAA+E;AAE/E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE
|
1
|
+
{"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qEAAkE;AAElE,qEAAkE;AAClE,uGAA+E;AAE/E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,cAAc,GAAG,MAAM,IAAA,iCAAe,EAC1C,MAAM,EACN,KAAK,EACL;QACE,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAS,EAAE;KAC/B,CACF,CAAC;IACF,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE3C,MAAM,KAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;IACrC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,OAAO,CAAe,oBAAQ,EAAE;QAC9D,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IACH,MAAM,cAAc,GAAwB,IAAI,GAAG,EAAE,CAAC;IACtD,IAAI,WAAW;QACb,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YACzB,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;YAC7C,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IAEL,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,MAAA,MAAA,MAAM,CAAC,IAAI,0CAAE,OAAO,0CAAE,I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;QAChC,IAAI,EAAE,qCAAoB,CAAC,UAAU;QACrC,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,UAAU,EAAV,sBAAU;QACV,KAAK,EAAE,SAAS;QAChB,KAAK;QACL,IAAI,EAAE;YACJ,cAAc;YACd,aAAa;YACb,cAAc;YACd,cAAc;YACd,aAAa;YACb,cAAc;YACd,eAAe,EAAE,IAAI;YACrB,WAAW;YACX,YAAY;YACZ,WAAW;YACX,KAAK;SACN;KACF,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,cAAc;IAC/B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -54,30 +54,30 @@ function sushiV3PairToUniV2(pair) {
|
|
54
54
|
}
|
55
55
|
function getV3PairsAddresses(url, length = 300) {
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
57
|
-
const query = (0, graphql_request_1.gql) `
|
58
|
-
{
|
59
|
-
pools(
|
60
|
-
orderBy: totalValueLockedUSD
|
61
|
-
first: ${length}
|
62
|
-
orderDirection: desc
|
63
|
-
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
-
) {
|
65
|
-
id
|
66
|
-
token0Price
|
67
|
-
token1Price
|
68
|
-
liquidity
|
69
|
-
token0 {
|
70
|
-
id
|
71
|
-
totalSupply
|
72
|
-
decimals
|
73
|
-
}
|
74
|
-
token1 {
|
75
|
-
id
|
76
|
-
totalSupply
|
77
|
-
decimals
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
57
|
+
const query = (0, graphql_request_1.gql) `
|
58
|
+
{
|
59
|
+
pools(
|
60
|
+
orderBy: totalValueLockedUSD
|
61
|
+
first: ${length}
|
62
|
+
orderDirection: desc
|
63
|
+
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
+
) {
|
65
|
+
id
|
66
|
+
token0Price
|
67
|
+
token1Price
|
68
|
+
liquidity
|
69
|
+
token0 {
|
70
|
+
id
|
71
|
+
totalSupply
|
72
|
+
decimals
|
73
|
+
}
|
74
|
+
token1 {
|
75
|
+
id
|
76
|
+
totalSupply
|
77
|
+
decimals
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
81
|
`;
|
82
82
|
const res = yield (0, graphql_request_1.default)(url, query);
|
83
83
|
const pools = res.pools;
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const constants_1 = require("./constants");
|
17
|
+
const solana_1 = require("../../utils/solana");
|
18
|
+
const clients_1 = require("../../utils/clients");
|
19
|
+
const structs_1 = require("./structs");
|
20
|
+
const filters_1 = require("./filters");
|
21
|
+
const getParsedAccountInfo_1 = require("../../utils/solana/getParsedAccountInfo");
|
22
|
+
const getLpTokenSourceRaw_1 = __importDefault(require("../../utils/misc/getLpTokenSourceRaw"));
|
23
|
+
const runInBatch_1 = __importDefault(require("../../utils/misc/runInBatch"));
|
24
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
25
|
+
const connection = (0, clients_1.getClientSolana)();
|
26
|
+
const tokenListRes = yield (0, getParsedAccountInfo_1.getParsedAccountInfo)(connection, structs_1.tokenListStruct, constants_1.tokenListAddress);
|
27
|
+
if (!tokenListRes)
|
28
|
+
return;
|
29
|
+
const tokenList = tokenListRes.list
|
30
|
+
.map((t) => t.tokenMint.toString())
|
31
|
+
.slice(0, tokenListRes.numTokens.toNumber());
|
32
|
+
const tokenPrices = yield cache.getTokenPrices(tokenList, portfolio_core_1.NetworkId.solana);
|
33
|
+
const accounts = yield (0, solana_1.getParsedProgramAccounts)(connection, structs_1.fundStruct, constants_1.basketProgramId, filters_1.fundFilters);
|
34
|
+
const lpSources = [];
|
35
|
+
for (let i = 0; i < accounts.length; i++) {
|
36
|
+
const account = accounts[i];
|
37
|
+
if (account.supplyOutstanding.isZero())
|
38
|
+
continue;
|
39
|
+
const poolUnderlyingRaw = [];
|
40
|
+
for (let j = 0; j < account.numOfTokens.toNumber(); j++) {
|
41
|
+
const tokenIndex = account.currentCompToken[j].toNumber();
|
42
|
+
const tokenPrice = tokenPrices[tokenIndex];
|
43
|
+
if (!tokenPrice)
|
44
|
+
continue;
|
45
|
+
poolUnderlyingRaw.push({
|
46
|
+
address: tokenPrice.address,
|
47
|
+
decimals: tokenPrice.decimals,
|
48
|
+
price: tokenPrice.price,
|
49
|
+
reserveAmountRaw: account.currentCompAmount[j],
|
50
|
+
});
|
51
|
+
}
|
52
|
+
if (poolUnderlyingRaw.length === 0)
|
53
|
+
continue;
|
54
|
+
const lpSource = (0, getLpTokenSourceRaw_1.default)(portfolio_core_1.NetworkId.solana, constants_1.platformId, constants_1.platformId, 'Basket', {
|
55
|
+
address: account.fundToken.toString(),
|
56
|
+
decimals: 6,
|
57
|
+
supplyRaw: account.supplyOutstanding,
|
58
|
+
}, poolUnderlyingRaw);
|
59
|
+
lpSources.push(lpSource);
|
60
|
+
}
|
61
|
+
yield (0, runInBatch_1.default)(lpSources.map((s) => () => cache.setTokenPriceSource(s)), 20);
|
62
|
+
});
|
63
|
+
const job = {
|
64
|
+
id: `${constants_1.platformId}-baskets`,
|
65
|
+
executor,
|
66
|
+
label: 'normal',
|
67
|
+
};
|
68
|
+
exports.default = job;
|
69
|
+
//# sourceMappingURL=basketsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"basketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/symmetry/basketsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAyE;AAGzE,2CAA4E;AAC5E,+CAA8D;AAC9D,iDAAsD;AACtD,uCAAwD;AACxD,uCAAwC;AACxC,kFAA+E;AAC/E,+FAE8C;AAC9C,6EAAqD;AAErD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IAErC,MAAM,YAAY,GAAG,MAAM,IAAA,2CAAoB,EAC7C,UAAU,EACV,yBAAe,EACf,4BAAgB,CACjB,CAAC;IACF,IAAI,CAAC,YAAY;QAAE,OAAO;IAC1B,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI;SAChC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;SAClC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,0BAAS,CAAC,MAAM,CAAC,CAAC;IAE5E,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAwB,EAC7C,UAAU,EACV,oBAAU,EACV,2BAAe,EACf,qBAAW,CACZ,CAAC;IAEF,MAAM,SAAS,GAAuB,EAAE,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CA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AAmB,CAAC,CAAC,CAAC,CAAC,EACxD,EAAE,CACH,CAAC;AACJ,CAAC,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
2
|
+
import { Platform } from '@sonarwatch/portfolio-core';
|
3
|
+
export declare const platformId = "symmetry";
|
4
|
+
export declare const platform: Platform;
|
5
|
+
export declare const basketsCachePrefix = "symmetry-baskets";
|
6
|
+
export declare const basketProgramId: PublicKey;
|
7
|
+
export declare const tokenListAddress: PublicKey;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.tokenListAddress = exports.basketProgramId = exports.basketsCachePrefix = exports.platform = exports.platformId = void 0;
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
5
|
+
exports.platformId = 'symmetry';
|
6
|
+
exports.platform = {
|
7
|
+
id: exports.platformId,
|
8
|
+
name: 'Symmetry',
|
9
|
+
image: 'https://sonar.watch/img/platforms/symmetry.webp',
|
10
|
+
website: 'https://www.symmetry.fi/',
|
11
|
+
twitter: 'https://twitter.com/symmetry_fi',
|
12
|
+
defiLlamaId: 'symmetry', // from https://defillama.com/docs/api
|
13
|
+
};
|
14
|
+
exports.basketsCachePrefix = `${exports.platformId}-baskets`;
|
15
|
+
exports.basketProgramId = new web3_js_1.PublicKey('2KehYt3KsEQR53jYcxjbQp2d2kCp4AkuQW68atufRwSr');
|
16
|
+
exports.tokenListAddress = new web3_js_1.PublicKey('3SnUughtueoVrhevXTLMf586qvKNNXggNsc7NgoMUU1t');
|
17
|
+
//# sourceMappingURL=constants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/symmetry/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,UAAU,CAAC;AACxB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,iDAAiD;IACxD,OAAO,EAAE,0BAA0B;IACnC,OAAO,EAAE,iCAAiC;IAC1C,WAAW,EAAE,UAAU,EAAE,sCAAsC;CAChE,CAAC;AACW,QAAA,kBAAkB,GAAG,GAAG,kBAAU,UAAU,CAAC;AAC7C,QAAA,eAAe,GAAG,IAAI,mBAAS,CAC1C,8CAA8C,CAC/C,CAAC;AACW,QAAA,gBAAgB,GAAG,IAAI,mBAAS,CAC3C,8CAA8C,CAC/C,CAAC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.fundFilters = void 0;
|
4
|
+
const structs_1 = require("./structs");
|
5
|
+
exports.fundFilters = [
|
6
|
+
{ dataSize: structs_1.fundStruct.byteSize },
|
7
|
+
{ memcmp: { offset: 112, bytes: '11111111' } },
|
8
|
+
{
|
9
|
+
memcmp: {
|
10
|
+
offset: 128,
|
11
|
+
bytes: '4Vry5hGDmbwGwhjgegHmoitjMHniSotpjBFkRuDYHcDG',
|
12
|
+
},
|
13
|
+
},
|
14
|
+
];
|
15
|
+
//# sourceMappingURL=filters.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/symmetry/filters.ts"],"names":[],"mappings":";;;AACA,uCAAuC;AAE1B,QAAA,WAAW,GAA+B;IACrD,EAAE,QAAQ,EAAE,oBAAU,CAAC,QAAQ,EAAE;IACjC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;IAC9C;QACE,MAAM,EAAE;YACN,MAAM,EAAE,GAAG;YACX,KAAK,EAAE,8CAA8C;SACtD;KACF;CACF,CAAC"}
|
@@ -0,0 +1,12 @@
|
|
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.fetchers = exports.jobs = exports.platforms = void 0;
|
7
|
+
const constants_1 = require("./constants");
|
8
|
+
const basketsJob_1 = __importDefault(require("./basketsJob"));
|
9
|
+
exports.platforms = [constants_1.platform];
|
10
|
+
exports.jobs = [basketsJob_1.default];
|
11
|
+
exports.fetchers = [];
|
12
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/symmetry/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,8DAAsC;AAEzB,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,oBAAU,CAAC,CAAC;AAC3B,QAAA,QAAQ,GAAc,EAAE,CAAC"}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { BeetStruct, FixableBeetStruct } from '@metaplex-foundation/beet';
|
3
|
+
import BigNumber from 'bignumber.js';
|
4
|
+
import { PublicKey } from '@solana/web3.js';
|
5
|
+
export type Fund = {
|
6
|
+
buffer: Buffer;
|
7
|
+
version: BigNumber;
|
8
|
+
manager: PublicKey;
|
9
|
+
fundToken: PublicKey;
|
10
|
+
managerFee: BigNumber;
|
11
|
+
supplyOutstanding: BigNumber;
|
12
|
+
activelyManaged: BigNumber;
|
13
|
+
activeBuyStates: BigNumber;
|
14
|
+
sellState: BigNumber;
|
15
|
+
rebalanceSellState: BigNumber;
|
16
|
+
hostPubkey: PublicKey;
|
17
|
+
hostFee: BigNumber;
|
18
|
+
numOfTokens: BigNumber;
|
19
|
+
currentCompToken: BigNumber[];
|
20
|
+
currentCompAmount: BigNumber[];
|
21
|
+
lastRebalanceTime: BigNumber[];
|
22
|
+
targetWeight: BigNumber[];
|
23
|
+
weightSum: BigNumber;
|
24
|
+
currentWeight: BigNumber[];
|
25
|
+
fundWorth: BigNumber;
|
26
|
+
lastUpdateTime: BigNumber;
|
27
|
+
refilterInterval: BigNumber;
|
28
|
+
reweightInterval: BigNumber;
|
29
|
+
rebalanceInterval: BigNumber;
|
30
|
+
rebalanceThreshold: BigNumber;
|
31
|
+
rebalanceSlippage: BigNumber;
|
32
|
+
lpOffsetThreshold: BigNumber;
|
33
|
+
lastRefilterTime: BigNumber;
|
34
|
+
lastReweightTime: BigNumber;
|
35
|
+
rulesReady: BigNumber;
|
36
|
+
assetPool: BigNumber[];
|
37
|
+
numOfRules: BigNumber;
|
38
|
+
rules: Buffer[];
|
39
|
+
numRuleTokens: BigNumber;
|
40
|
+
ruleTokens: BigNumber[];
|
41
|
+
ruleTokenWeights: BigNumber[];
|
42
|
+
messageDigestFive: number[];
|
43
|
+
disableRebalance: BigNumber;
|
44
|
+
disableLp: BigNumber;
|
45
|
+
allowMultiAssetContribution: number;
|
46
|
+
symbolLength: number;
|
47
|
+
symbol: number[];
|
48
|
+
nameLength: number;
|
49
|
+
name: number[];
|
50
|
+
uriLength: number;
|
51
|
+
uri: number[];
|
52
|
+
extraBytes: number[];
|
53
|
+
};
|
54
|
+
export declare const fundStruct: BeetStruct<Fund, Partial<Fund>>;
|
55
|
+
export type TokenSettings = {
|
56
|
+
tokenMint: PublicKey;
|
57
|
+
decimals: number;
|
58
|
+
coingeckoId: number[];
|
59
|
+
pdaTokenAccount: PublicKey;
|
60
|
+
oracleType: number;
|
61
|
+
oracleAccount: PublicKey;
|
62
|
+
oracleIndex: number;
|
63
|
+
oracleConfidencePct: number;
|
64
|
+
fixedConfidenceBps: number;
|
65
|
+
tokenSwapFeeAfterTwBps: number;
|
66
|
+
tokenSwapFeeBeforeTwBps: number;
|
67
|
+
isLive: number;
|
68
|
+
lpOn: number;
|
69
|
+
useCurveData: number;
|
70
|
+
additionalData: number[];
|
71
|
+
};
|
72
|
+
export declare const tokenSettingsStruct: BeetStruct<TokenSettings, Partial<TokenSettings>>;
|
73
|
+
export type TokenList = {
|
74
|
+
buffer: Buffer;
|
75
|
+
numTokens: BigNumber;
|
76
|
+
list: TokenSettings[];
|
77
|
+
};
|
78
|
+
export declare const tokenListStruct: FixableBeetStruct<TokenList, Partial<TokenList>>;
|