@sonarwatch/portfolio-plugins 0.12.161 → 0.12.163
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1446 -1438
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/kriya/constants.d.ts +2 -0
- package/src/plugins/kriya/constants.js +3 -1
- package/src/plugins/kriya/constants.js.map +1 -1
- package/src/plugins/kriya/farmsJob.js +0 -1
- package/src/plugins/kriya/farmsJob.js.map +1 -1
- package/src/plugins/kriya/index.js +8 -2
- package/src/plugins/kriya/index.js.map +1 -1
- package/src/plugins/kriya/leverageVaultsFetcher.d.ts +3 -0
- package/src/plugins/kriya/leverageVaultsFetcher.js +111 -0
- package/src/plugins/kriya/leverageVaultsFetcher.js.map +1 -0
- package/src/plugins/kriya/leverageVaultsJob.d.ts +3 -0
- package/src/plugins/kriya/leverageVaultsJob.js +35 -0
- package/src/plugins/kriya/leverageVaultsJob.js.map +1 -0
- package/src/plugins/kriya/types.d.ts +50 -0
- package/src/plugins/kriya/vaultsFetcher.js +0 -1
- package/src/plugins/kriya/vaultsFetcher.js.map +1 -1
- package/src/plugins/orca/getWhirlpoolPositions.js +59 -15
- package/src/plugins/orca/getWhirlpoolPositions.js.map +1 -1
- package/src/plugins/orca/helpers_fees.d.ts +22 -0
- package/src/plugins/orca/helpers_fees.js +248 -0
- package/src/plugins/orca/helpers_fees.js.map +1 -0
- package/src/plugins/orca/structs/whirlpool.d.ts +18 -0
- package/src/plugins/orca/structs/whirlpool.js +17 -1
- package/src/plugins/orca/structs/whirlpool.js.map +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/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
package/README.md
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
# @sonarwatch/portfolio-plugins
|
2
|
-
|
3
|
-
This library is @sonarwatch/portfolio-plugins
|
1
|
+
# @sonarwatch/portfolio-plugins
|
2
|
+
|
3
|
+
This library is @sonarwatch/portfolio-plugins
|
package/package.json
CHANGED
@@ -36,27 +36,27 @@ exports.getBalancerPoolsV2 = void 0;
|
|
36
36
|
const graphql_request_1 = __importStar(require("graphql-request"));
|
37
37
|
function getBalancerPoolsV2(url) {
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
39
|
-
const query = (0, graphql_request_1.gql) `
|
40
|
-
query pools {
|
41
|
-
pools(
|
42
|
-
first: 1000
|
43
|
-
orderBy: totalLiquidity
|
44
|
-
orderDirection: desc
|
45
|
-
where: { totalLiquidity_gt: "500" }
|
46
|
-
) {
|
47
|
-
id
|
48
|
-
address
|
49
|
-
symbol
|
50
|
-
totalLiquidity
|
51
|
-
totalShares
|
52
|
-
tokens {
|
53
|
-
balance
|
54
|
-
decimals
|
55
|
-
symbol
|
56
|
-
address
|
57
|
-
}
|
58
|
-
}
|
59
|
-
}
|
39
|
+
const query = (0, graphql_request_1.gql) `
|
40
|
+
query pools {
|
41
|
+
pools(
|
42
|
+
first: 1000
|
43
|
+
orderBy: totalLiquidity
|
44
|
+
orderDirection: desc
|
45
|
+
where: { totalLiquidity_gt: "500" }
|
46
|
+
) {
|
47
|
+
id
|
48
|
+
address
|
49
|
+
symbol
|
50
|
+
totalLiquidity
|
51
|
+
totalShares
|
52
|
+
tokens {
|
53
|
+
balance
|
54
|
+
decimals
|
55
|
+
symbol
|
56
|
+
address
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
60
|
`;
|
61
61
|
const res = yield (0, graphql_request_1.default)(url, query);
|
62
62
|
const pools = res.pools;
|
@@ -5,9 +5,11 @@ export declare const platform: Platform;
|
|
5
5
|
export declare const vaultsPackageId = "0xc4ee7b00ea981402a6285b14ffa5dcd1ee7f97eb2a91df3bcc04fa88c56ac7d7";
|
6
6
|
export declare const farmsPackageId = "0x88701243d0445aa38c0a13f02a9af49a58092dfadb93af9754edb41c52f40085";
|
7
7
|
export declare const vaultsInfoKey = "vaultsInfos";
|
8
|
+
export declare const leverageVaultsInfoKey = "leverageVaultsInfos";
|
8
9
|
export declare const farmsInfoKey = "farmsInfos";
|
9
10
|
export declare const vaultsUrl = "https://88ob93rfva.execute-api.ap-southeast-1.amazonaws.com/release/vaults";
|
10
11
|
export declare const poolsUrl = "https://xd0ljetd33.execute-api.ap-southeast-1.amazonaws.com/release/pools";
|
12
|
+
export declare const leverageVaultsUrl = "https://4sacq88271.execute-api.ap-southeast-1.amazonaws.com/release/vaults";
|
11
13
|
export declare const vaultsCointsTypes: string[];
|
12
14
|
export declare const vaultsInfo: VaultInfo[];
|
13
15
|
export declare const dynamicFieldPositionType = "0x2::dynamic_field::Field<vector<u8>, 0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb::position::Position>";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.dynamicFieldPositionType = exports.vaultsInfo = exports.vaultsCointsTypes = exports.poolsUrl = exports.vaultsUrl = exports.farmsInfoKey = exports.vaultsInfoKey = exports.farmsPackageId = exports.vaultsPackageId = exports.platform = exports.platformId = void 0;
|
3
|
+
exports.dynamicFieldPositionType = exports.vaultsInfo = exports.vaultsCointsTypes = exports.leverageVaultsUrl = exports.poolsUrl = exports.vaultsUrl = exports.farmsInfoKey = exports.leverageVaultsInfoKey = exports.vaultsInfoKey = exports.farmsPackageId = exports.vaultsPackageId = exports.platform = exports.platformId = void 0;
|
4
4
|
exports.platformId = 'kriya';
|
5
5
|
exports.platform = {
|
6
6
|
id: exports.platformId,
|
@@ -13,9 +13,11 @@ exports.platform = {
|
|
13
13
|
exports.vaultsPackageId = '0xc4ee7b00ea981402a6285b14ffa5dcd1ee7f97eb2a91df3bcc04fa88c56ac7d7';
|
14
14
|
exports.farmsPackageId = '0x88701243d0445aa38c0a13f02a9af49a58092dfadb93af9754edb41c52f40085';
|
15
15
|
exports.vaultsInfoKey = 'vaultsInfos';
|
16
|
+
exports.leverageVaultsInfoKey = 'leverageVaultsInfos';
|
16
17
|
exports.farmsInfoKey = 'farmsInfos';
|
17
18
|
exports.vaultsUrl = 'https://88ob93rfva.execute-api.ap-southeast-1.amazonaws.com/release/vaults';
|
18
19
|
exports.poolsUrl = 'https://xd0ljetd33.execute-api.ap-southeast-1.amazonaws.com/release/pools';
|
20
|
+
exports.leverageVaultsUrl = 'https://4sacq88271.execute-api.ap-southeast-1.amazonaws.com/release/vaults';
|
19
21
|
exports.vaultsCointsTypes = [
|
20
22
|
'0xc4ee7b00ea981402a6285b14ffa5dcd1ee7f97eb2a91df3bcc04fa88c56ac7d7::kc_allweather_vt::KC_ALLWEATHER_VT',
|
21
23
|
];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/constants.ts"],"names":[],"mappings":";;;AAGa,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,8CAA8C;IACrD,WAAW,EAAE,YAAY,EAAE,sCAAsC;IACjE,OAAO,EAAE,gCAAgC;IACzC,OAAO,EAAE,8BAA8B;CACxC,CAAC;AAEW,QAAA,eAAe,GAC1B,oEAAoE,CAAC;AAC1D,QAAA,cAAc,GACzB,oEAAoE,CAAC;AAE1D,QAAA,aAAa,GAAG,aAAa,CAAC;AAC9B,QAAA,YAAY,GAAG,YAAY,CAAC;AAE5B,QAAA,SAAS,GACpB,4EAA4E,CAAC;AAClE,QAAA,QAAQ,GACnB,2EAA2E,CAAC;
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/constants.ts"],"names":[],"mappings":";;;AAGa,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,8CAA8C;IACrD,WAAW,EAAE,YAAY,EAAE,sCAAsC;IACjE,OAAO,EAAE,gCAAgC;IACzC,OAAO,EAAE,8BAA8B;CACxC,CAAC;AAEW,QAAA,eAAe,GAC1B,oEAAoE,CAAC;AAC1D,QAAA,cAAc,GACzB,oEAAoE,CAAC;AAE1D,QAAA,aAAa,GAAG,aAAa,CAAC;AAC9B,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAC9C,QAAA,YAAY,GAAG,YAAY,CAAC;AAE5B,QAAA,SAAS,GACpB,4EAA4E,CAAC;AAClE,QAAA,QAAQ,GACnB,2EAA2E,CAAC;AACjE,QAAA,iBAAiB,GAC5B,4EAA4E,CAAC;AAElE,QAAA,iBAAiB,GAAG;IAC/B,wGAAwG;CACzG,CAAC;AAEW,QAAA,UAAU,GAAgB;IACrC;QACE,SAAS,EACP,wGAAwG;QAC1G,EAAE,EAAE,oEAAoE;QACxE,cAAc,EACZ,oEAAoE;KACvE;IACD;QACE,SAAS,EACP,4GAA4G;QAC9G,EAAE,EAAE,oEAAoE;QACxE,cAAc,EACZ,oEAAoE;KACvE;IACD;QACE,SAAS,EACP,8FAA8F;QAChG,EAAE,EAAE,oEAAoE;QACxE,cAAc,EACZ,oEAAoE;KACvE;CACF,CAAC;AAEW,QAAA,wBAAwB,GACnC,+HAA+H,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"farmsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/farmsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA6C;AAC7C,+DAAuD;AAGvD,2CAAiE;AAGjE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,KAAK,GAAqC,MAAM,eAAK;SACxD,GAAG,CAAC,oBAAQ,EAAE;QACb,OAAO,EAAE;YACP,MAAM,EAAE,gCAAgC;YACxC,OAAO,EAAE,+BAA+B;YACxC,WAAW,EAAE,0CAA0C;SACxD;KACF,CAAC;SACD,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"farmsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/farmsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA6C;AAC7C,+DAAuD;AAGvD,2CAAiE;AAGjE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,KAAK,GAAqC,MAAM,eAAK;SACxD,GAAG,CAAC,oBAAQ,EAAE;QACb,OAAO,EAAE;YACP,MAAM,EAAE,gCAAgC;YACxC,OAAO,EAAE,+BAA+B;YACxC,WAAW,EAAE,0CAA0C;SACxD;KACF,CAAC;SACD,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAErB,IAAI,CAAC,KAAK;QAAE,OAAO;IAEnB,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,SAAS,KAAK,GAAG;YAAE,SAAS;QAErC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,KAAK,CAAC,OAAO,CAAC,wBAAY,EAAE,SAAS,EAAE;QAC3C,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -9,7 +9,13 @@ const vaultsFetcher_1 = __importDefault(require("./vaultsFetcher"));
|
|
9
9
|
const vaultsJob_1 = __importDefault(require("./vaultsJob"));
|
10
10
|
const farmsJob_1 = __importDefault(require("./farmsJob"));
|
11
11
|
const farmsFetcher_1 = __importDefault(require("./farmsFetcher"));
|
12
|
+
const leverageVaultsFetcher_1 = __importDefault(require("./leverageVaultsFetcher"));
|
13
|
+
const leverageVaultsJob_1 = __importDefault(require("./leverageVaultsJob"));
|
12
14
|
exports.platforms = [constants_1.platform];
|
13
|
-
exports.jobs = [vaultsJob_1.default, farmsJob_1.default];
|
14
|
-
exports.fetchers = [
|
15
|
+
exports.jobs = [vaultsJob_1.default, leverageVaultsJob_1.default, farmsJob_1.default];
|
16
|
+
exports.fetchers = [
|
17
|
+
vaultsFetcher_1.default,
|
18
|
+
leverageVaultsFetcher_1.default,
|
19
|
+
farmsFetcher_1.default,
|
20
|
+
];
|
15
21
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,oEAA4C;AAC5C,4DAAoC;AACpC,0DAAkC;AAClC,kEAA0C;AAC1C,oFAA4D;AAC5D,4EAAoD;AAEvC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,mBAAS,EAAE,2BAAiB,EAAE,kBAAQ,CAAC,CAAC;AACvD,QAAA,QAAQ,GAAc;IACjC,uBAAa;IACb,+BAAqB;IACrB,sBAAY;CACb,CAAC"}
|
@@ -0,0 +1,111 @@
|
|
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 bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const clients_1 = require("../../utils/clients");
|
19
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
20
|
+
const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
|
21
|
+
const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
|
22
|
+
const leverageVaultsMemo = new MemoizedCache_1.MemoizedCache(constants_1.leverageVaultsInfoKey, {
|
23
|
+
prefix: constants_1.platformId,
|
24
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
25
|
+
});
|
26
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
27
|
+
const client = (0, clients_1.getClientSui)();
|
28
|
+
const leverageVaults = yield leverageVaultsMemo.getItem(cache);
|
29
|
+
const receipts = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
|
30
|
+
filter: {
|
31
|
+
MatchAny: leverageVaults.map((v) => ({
|
32
|
+
StructType: v.farmStakeReceiptType,
|
33
|
+
})),
|
34
|
+
},
|
35
|
+
});
|
36
|
+
if (receipts.length === 0)
|
37
|
+
return [];
|
38
|
+
const mints = new Set();
|
39
|
+
receipts.forEach((pos) => {
|
40
|
+
var _a;
|
41
|
+
const posContent = (_a = pos.data) === null || _a === void 0 ? void 0 : _a.content;
|
42
|
+
if (!posContent)
|
43
|
+
return;
|
44
|
+
const vault = leverageVaults.find((v) => { var _a, _b; return v.farmId === ((_b = (_a = pos.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.farm_id); });
|
45
|
+
if (!vault)
|
46
|
+
return;
|
47
|
+
mints.add((0, portfolio_core_1.formatMoveTokenAddress)(vault.coinA));
|
48
|
+
mints.add((0, portfolio_core_1.formatMoveTokenAddress)(vault.coinB));
|
49
|
+
});
|
50
|
+
const tokenPrices = yield cache.getTokenPricesAsMap([...mints], portfolio_core_1.NetworkId.sui);
|
51
|
+
if (!tokenPrices)
|
52
|
+
return [];
|
53
|
+
const elements = [];
|
54
|
+
receipts.forEach((pos) => {
|
55
|
+
var _a;
|
56
|
+
const posContent = (_a = pos.data) === null || _a === void 0 ? void 0 : _a.content;
|
57
|
+
if (!posContent)
|
58
|
+
return;
|
59
|
+
const vault = leverageVaults.find((v) => { var _a, _b; return v.farmId === ((_b = (_a = pos.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.farm_id); });
|
60
|
+
if (!vault)
|
61
|
+
return;
|
62
|
+
const tokenPriceA = tokenPrices.get((0, portfolio_core_1.formatMoveTokenAddress)(vault.coinA));
|
63
|
+
const tokenPriceB = tokenPrices.get((0, portfolio_core_1.formatMoveTokenAddress)(vault.coinB));
|
64
|
+
if (!tokenPriceA || !tokenPriceB)
|
65
|
+
return;
|
66
|
+
const sharesPercentage = new bignumber_js_1.default(posContent.fields.rewards_stake_receipt.fields.shares).dividedBy(vault.lpSupply);
|
67
|
+
const depositedUsd = sharesPercentage.multipliedBy(vault.tvl);
|
68
|
+
if (depositedUsd.isZero())
|
69
|
+
return;
|
70
|
+
const borrowedAssets = [];
|
71
|
+
const borrowedYields = [];
|
72
|
+
const suppliedAssets = [];
|
73
|
+
const suppliedYields = [];
|
74
|
+
const rewardAssets = [];
|
75
|
+
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceA.address, sharesPercentage.multipliedBy(vault.depositedA).toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceA));
|
76
|
+
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceB.address, sharesPercentage.multipliedBy(vault.borrowedB).toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceB));
|
77
|
+
const { borrowedValue, suppliedValue, value, rewardValue, healthRatio } = (0, portfolio_core_1.getElementLendingValues)({
|
78
|
+
suppliedAssets,
|
79
|
+
borrowedAssets,
|
80
|
+
rewardAssets,
|
81
|
+
});
|
82
|
+
elements.push({
|
83
|
+
type: portfolio_core_1.PortfolioElementType.borrowlend,
|
84
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
85
|
+
platformId: constants_1.platformId,
|
86
|
+
label: 'Lending',
|
87
|
+
name: `${vault.vaultSource} ${vault.vaultName}`,
|
88
|
+
value,
|
89
|
+
data: {
|
90
|
+
borrowedAssets,
|
91
|
+
borrowedValue,
|
92
|
+
borrowedYields,
|
93
|
+
suppliedAssets,
|
94
|
+
suppliedValue,
|
95
|
+
suppliedYields,
|
96
|
+
healthRatio,
|
97
|
+
rewardAssets,
|
98
|
+
rewardValue,
|
99
|
+
value,
|
100
|
+
},
|
101
|
+
});
|
102
|
+
});
|
103
|
+
return elements;
|
104
|
+
});
|
105
|
+
const fetcher = {
|
106
|
+
id: `${constants_1.platformId}-leverage-vaults`,
|
107
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
108
|
+
executor,
|
109
|
+
};
|
110
|
+
exports.default = fetcher;
|
111
|
+
//# sourceMappingURL=leverageVaultsFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"leverageVaultsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/leverageVaultsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAA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CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,kBAAkB;IACnC,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,35 @@
|
|
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 axios_1 = __importDefault(require("axios"));
|
16
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
19
|
+
const vaults = yield axios_1.default
|
20
|
+
.get(constants_1.leverageVaultsUrl)
|
21
|
+
.catch(() => null);
|
22
|
+
if (!vaults)
|
23
|
+
return;
|
24
|
+
yield cache.setItem(constants_1.leverageVaultsInfoKey, vaults.data, {
|
25
|
+
prefix: constants_1.platformId,
|
26
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
27
|
+
});
|
28
|
+
});
|
29
|
+
const job = {
|
30
|
+
id: `${constants_1.platformId}-leverage-vaults`,
|
31
|
+
executor,
|
32
|
+
label: 'normal',
|
33
|
+
};
|
34
|
+
exports.default = job;
|
35
|
+
//# sourceMappingURL=leverageVaultsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"leverageVaultsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/leverageVaultsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA6C;AAC7C,+DAAuD;AAGvD,2CAIqB;AAGrB,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAA8C,MAAM,eAAK;SAClE,GAAG,CAAC,6BAAiB,CAAC;SACtB,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAErB,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,MAAM,KAAK,CAAC,OAAO,CAAC,iCAAqB,EAAE,MAAM,CAAC,IAAI,EAAE;QACtD,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,kBAAkB;IACnC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -153,3 +153,53 @@ export type LiquidityPosition = {
|
|
153
153
|
stake_weight: string;
|
154
154
|
start_unit: string;
|
155
155
|
};
|
156
|
+
export type StakeReceiptWithPoints = {
|
157
|
+
farm_id: string;
|
158
|
+
id: ID;
|
159
|
+
rewards_stake_receipt: {
|
160
|
+
fields: {
|
161
|
+
farm_id: string;
|
162
|
+
id: ID;
|
163
|
+
reward_infos: {
|
164
|
+
fields: {
|
165
|
+
id: ID;
|
166
|
+
size: string;
|
167
|
+
};
|
168
|
+
type: string;
|
169
|
+
};
|
170
|
+
shares: string;
|
171
|
+
};
|
172
|
+
type: string;
|
173
|
+
};
|
174
|
+
user_points_info: {
|
175
|
+
fields: {
|
176
|
+
claimed_points: string;
|
177
|
+
index: string;
|
178
|
+
updated_at: string;
|
179
|
+
};
|
180
|
+
type: string;
|
181
|
+
};
|
182
|
+
};
|
183
|
+
export type LeverageVaultInfo = {
|
184
|
+
depositedA: string;
|
185
|
+
apr: string;
|
186
|
+
borrowedBUsd: string;
|
187
|
+
farmStakeReceiptType: string;
|
188
|
+
decimalA: string;
|
189
|
+
createdAt: string;
|
190
|
+
farmSource: string;
|
191
|
+
coinB: string;
|
192
|
+
decimalB: string;
|
193
|
+
tvl: string;
|
194
|
+
borrowedB: string;
|
195
|
+
targetLeverage: string;
|
196
|
+
vaultName: string;
|
197
|
+
depositedAUsd: string;
|
198
|
+
lpSupply: string;
|
199
|
+
vaultSource: string;
|
200
|
+
farmId: string;
|
201
|
+
fees: string;
|
202
|
+
coinA: string;
|
203
|
+
updatedAt: string;
|
204
|
+
id: string;
|
205
|
+
};
|
@@ -26,7 +26,6 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
26
26
|
if (!vaultsBalances.some((balance) => balance.totalBalance !== '0'))
|
27
27
|
return [];
|
28
28
|
const poolInfos = yield cache.getItems(constants_1.vaultsInfo.map((vault) => vault.underlyingPool), { prefix: constants_2.clmmPoolsPrefix, networkId: portfolio_core_1.NetworkId.sui });
|
29
|
-
console.log('constexecutor:FetcherExecutor= ~ poolInfos:', poolInfos);
|
30
29
|
const vaultsPositionInfo = yield cache.getItem(constants_1.vaultsInfoKey, {
|
31
30
|
prefix: constants_1.platformId,
|
32
31
|
networkId: portfolio_core_1.NetworkId.sui,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vaultsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/vaultsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAGrC,2CAAoE;AACpE,iDAAmD;AACnD,6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AClB,0BAAS,CAAC,GAAG,EACb,WAAW,CACZ,CAAC;QACF,MAAM,KAAK,GAAG,IAAA,+BAAc,EAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAE3D,UAAU,GAAG,IAAA,+BAAc,EAAC,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;QACjD,WAAW,CAAC,IAAI,CAAC;YACf,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;YACxB,WAAW,EAAE,KAAK;YAClB,YAAY,EAAE,EAAE;YAChB,iBAAiB,EAAE,IAAI;YACvB,KAAK;YACL,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;IACL,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAExC,OAAO;QACL;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE;gBACJ,WAAW;aACZ;YACD,KAAK,EAAE,eAAe;YACtB,SAAS,EAAE,0BAAS,CAAC,GAAG;YACxB,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,QAAQ;SACf;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,SAAS;IAC1B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -20,8 +20,8 @@ const clients_1 = require("../../utils/clients");
|
|
20
20
|
const solana_1 = require("../../utils/solana");
|
21
21
|
const whirlpool_1 = require("./structs/whirlpool");
|
22
22
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
23
|
-
const runInBatch_1 = __importDefault(require("../../utils/misc/runInBatch"));
|
24
23
|
const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
|
24
|
+
const helpers_fees_1 = require("./helpers_fees");
|
25
25
|
exports.getWhirlpoolPositions = getOrcaNftFetcher(constants_1.platformId, constants_1.whirlpoolProgram);
|
26
26
|
function getOrcaNftFetcher(platformId, programId) {
|
27
27
|
return (cache, nfts) => __awaiter(this, void 0, void 0, function* () {
|
@@ -47,27 +47,33 @@ function getOrcaNftFetcher(platformId, programId) {
|
|
47
47
|
prefix: constants_1.whirlpoolPrefix,
|
48
48
|
networkId: portfolio_core_1.NetworkId.solana,
|
49
49
|
});
|
50
|
-
const tokensMints =
|
50
|
+
const tokensMints = new Set();
|
51
51
|
const whirlpoolMap = new Map();
|
52
52
|
allWhirlpoolsInfo.forEach((wInfo) => {
|
53
|
+
var _a, _b, _c;
|
53
54
|
if (!wInfo)
|
54
55
|
return;
|
55
56
|
if (whirlpoolAddresses.has(wInfo.pubkey.toString())) {
|
56
57
|
whirlpoolMap.set(wInfo.pubkey.toString(), wInfo);
|
57
|
-
tokensMints.
|
58
|
+
tokensMints.add(wInfo.tokenMintA.toString());
|
59
|
+
tokensMints.add(wInfo.tokenMintB.toString());
|
60
|
+
if (!(0, helpers_fees_1.isRewardInitialized)(wInfo.rewardInfos[0])) {
|
61
|
+
tokensMints.add((_a = wInfo.rewardInfos[0]) === null || _a === void 0 ? void 0 : _a.mint.toString());
|
62
|
+
}
|
63
|
+
if (!(0, helpers_fees_1.isRewardInitialized)(wInfo.rewardInfos[1])) {
|
64
|
+
tokensMints.add((_b = wInfo.rewardInfos[1]) === null || _b === void 0 ? void 0 : _b.mint.toString());
|
65
|
+
}
|
66
|
+
if (!(0, helpers_fees_1.isRewardInitialized)(wInfo.rewardInfos[2])) {
|
67
|
+
tokensMints.add((_c = wInfo.rewardInfos[2]) === null || _c === void 0 ? void 0 : _c.mint.toString());
|
68
|
+
}
|
58
69
|
}
|
59
70
|
});
|
60
|
-
const tokenPriceResults = yield (0, runInBatch_1.default)(tokensMints.map((mint) => () => cache.getTokenPrice(mint, portfolio_core_1.NetworkId.solana)));
|
61
|
-
const tokenPrices = new Map();
|
62
|
-
tokenPriceResults.forEach((r) => {
|
63
|
-
if (r.status === 'rejected')
|
64
|
-
return;
|
65
|
-
if (!r.value)
|
66
|
-
return;
|
67
|
-
tokenPrices.set(r.value.address, r.value);
|
68
|
-
});
|
69
71
|
if (whirlpoolMap.size === 0)
|
70
72
|
return [];
|
73
|
+
const [tokenPrices, tickArrays] = yield Promise.all([
|
74
|
+
cache.getTokenPricesAsMap([...tokensMints], portfolio_core_1.NetworkId.solana),
|
75
|
+
(0, helpers_fees_1.getTickArraysAsMap)(positionsInfo, whirlpoolMap),
|
76
|
+
]);
|
71
77
|
const assets = [];
|
72
78
|
let totalLiquidityValue = 0;
|
73
79
|
for (let index = 0; index < positionsInfo.length; index++) {
|
@@ -82,14 +88,52 @@ function getOrcaNftFetcher(platformId, programId) {
|
|
82
88
|
!whirlpoolInfo.tickCurrentIndex)
|
83
89
|
continue;
|
84
90
|
const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(positionInfo.liquidity, whirlpoolInfo.tickCurrentIndex, positionInfo.tickLowerIndex, positionInfo.tickUpperIndex, false);
|
91
|
+
const rewardAssets = [];
|
85
92
|
const tokenPriceA = tokenPrices.get(whirlpoolInfo.tokenMintA.toString());
|
86
93
|
if (!tokenPriceA)
|
87
94
|
continue;
|
88
|
-
const assetTokenA = (0, tokenPriceToAssetToken_1.default)(whirlpoolInfo.tokenMintA.toString(), tokenAmountA.dividedBy(Math.pow(10, tokenPriceA.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA);
|
89
95
|
const tokenPriceB = tokenPrices.get(whirlpoolInfo.tokenMintB.toString());
|
90
96
|
if (!tokenPriceB)
|
91
97
|
continue;
|
98
|
+
const assetTokenA = (0, tokenPriceToAssetToken_1.default)(whirlpoolInfo.tokenMintA.toString(), tokenAmountA.dividedBy(Math.pow(10, tokenPriceA.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA);
|
92
99
|
const assetTokenB = (0, tokenPriceToAssetToken_1.default)(whirlpoolInfo.tokenMintB.toString(), tokenAmountB.dividedBy(Math.pow(10, tokenPriceB.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceB);
|
100
|
+
const feesAndRewards = (0, helpers_fees_1.calcFeesAndRewards)(whirlpoolInfo, positionInfo, tickArrays);
|
101
|
+
if (feesAndRewards) {
|
102
|
+
if (feesAndRewards.feeOwedA.isGreaterThan(0)) {
|
103
|
+
rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceA.address, feesAndRewards.feeOwedA
|
104
|
+
.dividedBy(Math.pow(10, tokenPriceA.decimals))
|
105
|
+
.toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA));
|
106
|
+
}
|
107
|
+
if (feesAndRewards.feeOwedB.isGreaterThan(0)) {
|
108
|
+
rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceB.address, feesAndRewards.feeOwedB
|
109
|
+
.dividedBy(Math.pow(10, tokenPriceB.decimals))
|
110
|
+
.toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceB));
|
111
|
+
}
|
112
|
+
if (feesAndRewards.rewardOwedA.isGreaterThan(0)) {
|
113
|
+
const tokenPriceRewardA = tokenPrices.get(whirlpoolInfo.rewardInfos[0].mint.toString());
|
114
|
+
if (tokenPriceRewardA) {
|
115
|
+
rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardA.address, feesAndRewards.rewardOwedA
|
116
|
+
.dividedBy(Math.pow(10, tokenPriceRewardA.decimals))
|
117
|
+
.toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardA));
|
118
|
+
}
|
119
|
+
}
|
120
|
+
if (feesAndRewards.rewardOwedB.isGreaterThan(0)) {
|
121
|
+
const tokenPriceRewardB = tokenPrices.get(whirlpoolInfo.rewardInfos[1].mint.toString());
|
122
|
+
if (tokenPriceRewardB) {
|
123
|
+
rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardB.address, feesAndRewards.rewardOwedB
|
124
|
+
.dividedBy(Math.pow(10, tokenPriceRewardB.decimals))
|
125
|
+
.toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardB));
|
126
|
+
}
|
127
|
+
}
|
128
|
+
if (feesAndRewards.rewardOwedC.isGreaterThan(0)) {
|
129
|
+
const tokenPriceRewardC = tokenPrices.get(whirlpoolInfo.rewardInfos[2].mint.toString());
|
130
|
+
if (tokenPriceRewardC) {
|
131
|
+
rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardC.address, feesAndRewards.rewardOwedC
|
132
|
+
.dividedBy(Math.pow(10, tokenPriceRewardC.decimals))
|
133
|
+
.toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardC));
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
93
137
|
if (!assetTokenA ||
|
94
138
|
!assetTokenB ||
|
95
139
|
assetTokenA.value === null ||
|
@@ -99,8 +143,8 @@ function getOrcaNftFetcher(platformId, programId) {
|
|
99
143
|
assets.push({
|
100
144
|
assets: [assetTokenA, assetTokenB],
|
101
145
|
assetsValue: value,
|
102
|
-
rewardAssets
|
103
|
-
rewardAssetsValue: 0,
|
146
|
+
rewardAssets,
|
147
|
+
rewardAssetsValue: (0, portfolio_core_1.getUsdValueSum)(rewardAssets.map((a) => a.value)),
|
104
148
|
value,
|
105
149
|
yields: [],
|
106
150
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getWhirlpoolPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/orca/getWhirlpoolPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"getWhirlpoolPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/orca/getWhirlpoolPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,6CAA4C;AAC5C,2CAIqB;AACrB,iDAAs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AAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,UAAU;gBACV,KAAK,EAAE,eAAe;gBACtB,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,mBAAmB;gBAC1B,IAAI,EAAE;oBACJ,WAAW,EAAE,MAAM;iBACpB;aACF;SACF,CAAC;IACJ,CAAC,CAAA,CAAC;AACJ,CAAC;AA/OD,8CA+OC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { Position, Tick, TickArray, Whirlpool, WhirlpoolRewardInfo } from './structs/whirlpool';
|
2
|
+
import { ParsedAccount } from '../../utils/solana';
|
3
|
+
import BigNumber from 'bignumber.js';
|
4
|
+
export declare const getTickArraysAsMap: (positionsInfo: (ParsedAccount<Position> | null)[], whirlpoolMap: Map<string, Whirlpool>) => Promise<Map<string, TickArray>>;
|
5
|
+
export declare const calcFeesAndRewards: (whirlpool: Whirlpool, position: ParsedAccount<Position>, tickArrays: Map<string, TickArray>) => {
|
6
|
+
feeOwedA: BigNumber;
|
7
|
+
feeOwedB: BigNumber;
|
8
|
+
rewardOwedA: BigNumber;
|
9
|
+
rewardOwedB: BigNumber;
|
10
|
+
rewardOwedC: BigNumber;
|
11
|
+
} | null;
|
12
|
+
export declare function isRewardInitialized(rewardInfo: WhirlpoolRewardInfo): boolean;
|
13
|
+
export declare function getCollectRewardsQuoteInternal(param: {
|
14
|
+
whirlpool: Whirlpool;
|
15
|
+
position: Position;
|
16
|
+
tickLower: Tick;
|
17
|
+
tickUpper: Tick;
|
18
|
+
}): {
|
19
|
+
rewardOwedA: BigNumber;
|
20
|
+
rewardOwedB: BigNumber;
|
21
|
+
rewardOwedC: BigNumber;
|
22
|
+
};
|