@sonarwatch/portfolio-plugins 0.12.26 → 0.12.28
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1802 -1794
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/bluefin/positionFetcher.js +11 -6
- package/src/plugins/bluefin/positionFetcher.js.map +1 -1
- package/src/plugins/flash/perpetualFetcher.js +8 -13
- package/src/plugins/flash/perpetualFetcher.js.map +1 -1
- package/src/plugins/flash/poolJob.js +1 -1
- package/src/plugins/flash/poolJob.js.map +1 -1
- package/src/plugins/flash/structs.d.ts +2 -2
- package/src/plugins/flash/structs.js +2 -2
- package/src/plugins/flash/structs.js.map +1 -1
- package/src/plugins/jupiter/exchange/constants.d.ts +1 -0
- package/src/plugins/jupiter/exchange/constants.js +2 -1
- package/src/plugins/jupiter/exchange/constants.js.map +1 -1
- package/src/plugins/jupiter/exchange/custodiesJob.js +11 -4
- package/src/plugins/jupiter/exchange/custodiesJob.js.map +1 -1
- package/src/plugins/jupiter/exchange/perpetualFetcher.js +69 -100
- package/src/plugins/jupiter/exchange/perpetualFetcher.js.map +1 -1
- package/src/plugins/jupiter/types.d.ts +27 -2
- package/src/plugins/jupiter/types.js.map +1 -1
- package/src/plugins/kamino/constants.js +4 -0
- package/src/plugins/kamino/constants.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
- package/src/utils/solana/pyth/helpers.d.ts +2 -2
- package/src/utils/solana/pyth/helpers.js +13 -7
- package/src/utils/solana/pyth/helpers.js.map +1 -1
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;
|
@@ -75,7 +75,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
75
75
|
const oiOpen = new bignumber_js_1.default((_v = (_u = (_t = (_s = position.data) === null || _s === void 0 ? void 0 : _s.content) === null || _t === void 0 ? void 0 : _t.fields) === null || _u === void 0 ? void 0 : _u.value) === null || _v === void 0 ? void 0 : _v.fields.oiOpen);
|
76
76
|
const leverage = oiOpen.dividedBy(margin);
|
77
77
|
const oraclePrice = new bignumber_js_1.default(perp.priceOracle).dividedBy(Math.pow(10, 9));
|
78
|
-
const
|
78
|
+
const collatUsd = margin.dividedBy(Math.pow(10, 9));
|
79
79
|
const avgEntryPrice = qPos.isGreaterThan(0)
|
80
80
|
? oiOpen.dividedBy(qPos).dividedBy(Math.pow(10, 9))
|
81
81
|
: new bignumber_js_1.default(0);
|
@@ -86,10 +86,10 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
86
86
|
else {
|
87
87
|
pnl = qPos.multipliedBy(avgEntryPrice.minus(oraclePrice));
|
88
88
|
}
|
89
|
-
if (
|
90
|
-
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPrice.address,
|
91
|
-
if (
|
92
|
-
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPrice.address,
|
89
|
+
if (collatUsd.isPositive())
|
90
|
+
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPrice.address, collatUsd.toNumber(), portfolio_core_1.NetworkId.sui, tokenPrice));
|
91
|
+
if (collatUsd.times(leverage).isPositive())
|
92
|
+
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPrice.address, collatUsd.times(leverage).toNumber(), portfolio_core_1.NetworkId.sui, tokenPrice));
|
93
93
|
const pnlAsset = {
|
94
94
|
type: portfolio_core_1.PortfolioAssetType.generic,
|
95
95
|
networkId: portfolio_core_1.NetworkId.solana,
|
@@ -107,7 +107,12 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
107
107
|
borrowedAssets.length === 0 &&
|
108
108
|
rewardAssets.length === 0)
|
109
109
|
return;
|
110
|
-
const value =
|
110
|
+
const value = margin
|
111
|
+
.dividedBy(Math.pow(10, 9))
|
112
|
+
.plus(pnl)
|
113
|
+
.toNumber();
|
114
|
+
if (value === 0)
|
115
|
+
return;
|
111
116
|
const side = ((_3 = (_2 = (_1 = (_0 = position.data) === null || _0 === void 0 ? void 0 : _0.content) === null || _1 === void 0 ? void 0 : _1.fields) === null || _2 === void 0 ? void 0 : _2.value) === null || _3 === void 0 ? void 0 : _3.fields.isPosPositive)
|
112
117
|
? 'Long'
|
113
118
|
: 'Short';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"positionFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluefin/positionFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAGrC,2CAA0D;AAC1D,iFAA8E;AAC9E,iDAAmD;AAEnD,qEAAkE;AAClE,qGAA6E;AAC7E,yDAAwD;AACxD,0DAAyD;AAEzD,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB,MAAM,KAAK,GAA6B,IAAI,GAAG,EAAE,CAAC;AAClD,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,oBAAoB;IACpB,IAAI,eAAe,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,CAAW,2BAAe,EAAE;YAC7D,MAAM,EAAE,sBAAU;YAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;SACzB,CAAC,CAAC;QACH,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,aAAa,GAAG,MAAM,IAAA,iCAAe,EAAc,MAAM,EAAE,OAAO,CAAC,CAAC;YAC1E,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;;gBAC1B,IAAI,CAAA,MAAA,CAAC,CAAC,IAAI,0CAAE,QAAQ,MAAI,MAAA,MAAA,CAAC,CAAC,IAAI,0CAAE,OAAO,0CAAE,MAAM,CAAA;oBAC7C,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE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Aa;YACtE,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,OAAO,CAAC;QAEZ,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,qCAAoB,CAAC,UAAU;YACrC,SAAS,EAAE,0BAAS,CAAC,GAAG;YACxB,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,UAAU;YACjB,KAAK;YACL,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG;YAC1D,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa,EAAE,IAAA,+BAAc,EAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACjE,cAAc;gBACd,cAAc;gBACd,aAAa,EAAE,IAAA,+BAAc,EAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACjE,cAAc;gBACd,eAAe,EAAE,IAAI;gBACrB,YAAY;gBACZ,WAAW,EAAE,IAAA,+BAAc,EAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC7D,WAAW,EAAE,IAAI;gBACjB,KAAK;aACN;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -18,7 +18,6 @@ const web3_js_1 = require("@solana/web3.js");
|
|
18
18
|
const constants_1 = require("./constants");
|
19
19
|
const clients_1 = require("../../utils/clients");
|
20
20
|
const solana_1 = require("../../utils/solana");
|
21
|
-
const getMultipleAccountsInfoSafe_1 = require("../../utils/solana/getMultipleAccountsInfoSafe");
|
22
21
|
const helpers_1 = require("../../utils/solana/pyth/helpers");
|
23
22
|
const constants_2 = require("../tokens/constants");
|
24
23
|
const filters_1 = require("./filters");
|
@@ -44,8 +43,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
44
43
|
oraclesPubkeys.push(new web3_js_1.PublicKey(market.collateralCustodyAccount.oracle.oracleAccount));
|
45
44
|
MarketById.set(market.pubkey, market);
|
46
45
|
});
|
47
|
-
const
|
48
|
-
const pythPricesByAccount = (0, helpers_1.getPythPricesDatasMap)(oraclesPubkeys, oracleAccounts);
|
46
|
+
const pythPricesByAccount = yield (0, helpers_1.getPythPricesAsMap)(client, oraclesPubkeys);
|
49
47
|
const tokensDetailsById = new Map();
|
50
48
|
const tokensDetails = yield cache.getItems(marketsInfos
|
51
49
|
.map((acc) => [
|
@@ -75,19 +73,16 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
75
73
|
const rewardAssets = [];
|
76
74
|
const { collateralUsd, sizeUsd, entryPrice: oraclePrice } = position;
|
77
75
|
const openingPrice = oraclePrice.price.multipliedBy(Math.pow(10, oraclePrice.exponent));
|
78
|
-
const
|
79
|
-
const
|
80
|
-
if (!
|
81
|
-
!targetPriceData.price ||
|
82
|
-
!collateralCustodyPriceData ||
|
83
|
-
!collateralCustodyPriceData.price)
|
76
|
+
const targetPrice = pythPricesByAccount.get(targetCustody.oracle.oracleAccount);
|
77
|
+
const collateralCustodyPrice = pythPricesByAccount.get(collateralCustody.oracle.oracleAccount);
|
78
|
+
if (!targetPrice || !collateralCustodyPrice)
|
84
79
|
continue;
|
85
|
-
const currentPrice = new bignumber_js_1.default(
|
80
|
+
const currentPrice = new bignumber_js_1.default(targetPrice);
|
86
81
|
const leverage = sizeUsd.dividedBy(collateralUsd);
|
87
82
|
const targetDetails = tokensDetailsById.get(targetCustody.mint);
|
88
83
|
const targetName = targetDetails ? targetDetails.symbol : '';
|
89
84
|
const collatAmount = collateralUsd
|
90
|
-
.dividedBy(
|
85
|
+
.dividedBy(collateralCustodyPrice)
|
91
86
|
.dividedBy(usdFactor);
|
92
87
|
const collatValue = collateralUsd.dividedBy(usdFactor).toNumber();
|
93
88
|
const targetAmount = collatAmount.times(leverage);
|
@@ -105,7 +100,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
105
100
|
data: {
|
106
101
|
amount: collatAmount.toNumber(),
|
107
102
|
address: collateralCustody.mint,
|
108
|
-
price:
|
103
|
+
price: collateralCustodyPrice,
|
109
104
|
},
|
110
105
|
});
|
111
106
|
borrowedAssets.push({
|
@@ -116,7 +111,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
116
111
|
data: {
|
117
112
|
amount: targetAmount.toNumber(),
|
118
113
|
address: targetCustody.mint,
|
119
|
-
price:
|
114
|
+
price: targetPrice,
|
120
115
|
},
|
121
116
|
});
|
122
117
|
rewardAssets.push({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"perpetualFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flash/perpetualFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AACrC,6CAA4C;AAG5C,2CAA+D;AAC/D,iDAAsD;AACtD,+CAA8D;AAC9D,
|
1
|
+
{"version":3,"file":"perpetualFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flash/perpetualFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AACrC,6CAA4C;AAG5C,2CAA+D;AAC/D,iDAAsD;AACtD,+CAA8D;AAC9D,6DAAqE;AACrE,mDAA8D;AAC9D,uCAAsD;AACtD,uCAA2C;AAE3C,yDAAmD;AAEnD,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,CAA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IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QAEzE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,GAC9D,IAAA,wCAAuB,EAAC,cAAc,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QAExE,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QACtE,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QAEvC,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,qCAAoB,CAAC,UAAU;YACrC,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,UAAU;YACjB,KAAK;YACL,IAAI,EAAE,GAAG,UAAU,IAAI,IAAI,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG;YAC3D,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,eAAe,EAAE,IAAI;gBAErB,YAAY;gBACZ,WAAW;gBACX,WAAW;gBACX,KAAK;aACN;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,aAAa;IAC9B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -19,7 +19,7 @@ const constants_2 = require("../tokens/constants");
|
|
19
19
|
const constants_3 = require("../jupiter/exchange/constants");
|
20
20
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
21
21
|
const client = (0, clients_1.getClientSolana)();
|
22
|
-
const poolsAccounts = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, structs_1.
|
22
|
+
const poolsAccounts = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, structs_1.flPoolStruct, constants_1.poolsPkeys);
|
23
23
|
const custodiesInfo = yield cache.getItem(constants_3.custodiesKey, {
|
24
24
|
prefix: constants_1.platformId,
|
25
25
|
networkId: portfolio_core_1.NetworkId.solana,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flash/poolJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,iDAAsD;AACtD,2CAA+D;AAC/D,
|
1
|
+
{"version":3,"file":"poolJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flash/poolJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,iDAAsD;AACtD,2CAA+D;AAC/D,uCAAyC;AACzC,gGAA6F;AAC7F,+CAI4B;AAC5B,mDAA2D;AAE3D,6DAA6D;AAE7D,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,aAAa,GAAG,MAAM,IAAA,sCAA6B,EACvD,MAAM,EACN,sBAAY,EACZ,sBAAU,CACX,CAAC;IAEF,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,OAAO,CAAgB,wBAAY,EAAE;QACrE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;IACH,IAAI,CAAC,aAAa;QAAE,OAAO;IAE3B,MAAM,eAAe,GAA6B,IAAI,GAAG,EAAE,CAAC;IAC5D,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAChC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO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C3B,UAAU,EAAE,gCAAoB,CAAC,EAAE;YACnC,KAAK;YACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,MAAM,EAAE,CAAC;YACT,WAAW,EAAE,IAAA,wBAAe,EAAC,IAAI,CAAC,IAAI,CAAC;SACxC,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW;YAAE,SAAS;QAE3B,SAAS,CAAC,IAAI,CAAC;YACb,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YAChC,IAAI,EAAE,sBAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;YAC9B,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,CAAC,OAAO,CAAC,oBAAQ,EAAE,SAAS,EAAE;QACvC,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,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"}
|
@@ -211,7 +211,7 @@ export type TokenRatios = {
|
|
211
211
|
max: BigNumber;
|
212
212
|
};
|
213
213
|
export declare const tokenRatiosStruct: BeetStruct<TokenRatios, Partial<TokenRatios>>;
|
214
|
-
export type
|
214
|
+
export type FLPool = {
|
215
215
|
buffer: Buffer;
|
216
216
|
name: number[];
|
217
217
|
permissions: Permissions;
|
@@ -232,4 +232,4 @@ export type PoolBis = {
|
|
232
232
|
flpTokenAccountBump: number;
|
233
233
|
vpVolumeFactor: number;
|
234
234
|
};
|
235
|
-
export declare const
|
235
|
+
export declare const flPoolStruct: FixableBeetStruct<FLPool, Partial<FLPool>>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.flPoolStruct = exports.tokenRatiosStruct = exports.positionStruct = exports.marketStruct = exports.positionStatsStruct = exports.oraclePriceStruct = exports.marketPermissionsStruct = exports.flpStakeStruct = exports.stakeStatsStruct = exports.custodyStruct = exports.permissionsStruct = exports.feesStatsStruct = exports.borrowRateStateStruct = exports.assetsStruct = exports.borrowRateParamsStruct = exports.feesStruct = exports.ratioFeesStruct = exports.FeesMode = exports.pricingParamsStruct = exports.oracleParamsStruct = void 0;
|
4
4
|
const beet_1 = require("@metaplex-foundation/beet");
|
5
5
|
const beet_solana_1 = require("@metaplex-foundation/beet-solana");
|
6
6
|
const solana_1 = require("../../utils/solana");
|
@@ -195,7 +195,7 @@ exports.tokenRatiosStruct = new beet_1.BeetStruct([
|
|
195
195
|
['min', solana_1.u64],
|
196
196
|
['max', solana_1.u64],
|
197
197
|
], (args) => args);
|
198
|
-
exports.
|
198
|
+
exports.flPoolStruct = new beet_1.FixableBeetStruct([
|
199
199
|
['buffer', (0, solana_1.blob)(8)],
|
200
200
|
['name', (0, beet_1.array)(beet_1.u8)],
|
201
201
|
['permissions', exports.permissionsStruct],
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flash/structs.ts"],"names":[],"mappings":";;;AAAA,oDAOmC;AAGnC,kEAA6D;AAC7D,+CAA0D;AAY7C,QAAA,kBAAkB,GAAG,IAAI,iBAAU,CAC9C;IACE,CAAC,eAAe,EAAE,uBAAS,CAAC;IAC5B,CAAC,qBAAqB,EAAE,uBAAS,CAAC;IAClC,CAAC,YAAY,EAAE,SAAE,CAAC;IAClB,CAAC,kBAAkB,EAAE,YAAG,CAAC;IACzB,CAAC,YAAY,EAAE,YAAG,CAAC;IACnB,CAAC,gBAAgB,EAAE,YAAG,CAAC;CACxB,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAoB,CAC/B,CAAC;AAgBW,QAAA,mBAAmB,GAAG,IAAI,iBAAU,CAC/C;IACE,CAA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ACnB,CAAC,QAAQ,EAAE,aAAI,CAAC;IAChB,CAAC,aAAa,EAAE,wBAAgB,CAAC;IACjC,CAAC,oBAAoB,EAAE,YAAG,CAAC;IAC3B,CAAC,MAAM,EAAE,SAAE,CAAC;IACZ,CAAC,aAAa,EAAE,SAAE,CAAC;IACnB,CAAC,qBAAqB,EAAE,SAAE,CAAC;IAC3B,CAAC,gBAAgB,EAAE,SAAE,CAAC;CACvB,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAc,CACzB,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.custodiesKey = exports.jlpToken = exports.jlpPool = exports.dcaProgramId = exports.limitProgramId = exports.valueAverageProgramId = exports.perpsProgramId = exports.platform = exports.platformId = void 0;
|
3
|
+
exports.perpPoolsKey = exports.custodiesKey = exports.jlpToken = exports.jlpPool = exports.dcaProgramId = exports.limitProgramId = exports.valueAverageProgramId = exports.perpsProgramId = exports.platform = exports.platformId = void 0;
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
5
5
|
exports.platformId = 'jupiter-exchange';
|
6
6
|
exports.platform = {
|
@@ -18,4 +18,5 @@ exports.dcaProgramId = new web3_js_1.PublicKey('DCA265Vj8a9CEuX1eb1LWRnDT7uK6q1x
|
|
18
18
|
exports.jlpPool = new web3_js_1.PublicKey('5BUwFW4nRbftYTDMbgxykoFWqWHPzahFSNAaaaJtVKsq');
|
19
19
|
exports.jlpToken = new web3_js_1.PublicKey('27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4');
|
20
20
|
exports.custodiesKey = 'custodies';
|
21
|
+
exports.perpPoolsKey = 'perppools';
|
21
22
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/exchange/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAI/B,QAAA,UAAU,GAAG,kBAAkB,CAAC;AAChC,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,+CAA+C;IACtD,WAAW,EAAE,gBAAgB;IAC7B,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,qCAAqC;CAC/C,CAAC;AAEW,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,qBAAqB,GAAG,IAAI,mBAAS,CAChD,6CAA6C,CAC9C,CAAC;AACW,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,YAAY,GAAG,IAAI,mBAAS,CACvC,8CAA8C,CAC/C,CAAC;AAEW,QAAA,OAAO,GAAG,IAAI,mBAAS,CAClC,8CAA8C,CAC/C,CAAC;AACW,QAAA,QAAQ,GAAG,IAAI,mBAAS,CACnC,8CAA8C,CAC/C,CAAC;AACW,QAAA,YAAY,GAAG,WAAW,CAAC"}
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/exchange/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAI/B,QAAA,UAAU,GAAG,kBAAkB,CAAC;AAChC,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,+CAA+C;IACtD,WAAW,EAAE,gBAAgB;IAC7B,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,qCAAqC;CAC/C,CAAC;AAEW,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,qBAAqB,GAAG,IAAI,mBAAS,CAChD,6CAA6C,CAC9C,CAAC;AACW,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,YAAY,GAAG,IAAI,mBAAS,CACvC,8CAA8C,CAC/C,CAAC;AAEW,QAAA,OAAO,GAAG,IAAI,mBAAS,CAClC,8CAA8C,CAC/C,CAAC;AACW,QAAA,QAAQ,GAAG,IAAI,mBAAS,CACnC,8CAA8C,CAC/C,CAAC;AACW,QAAA,YAAY,GAAG,WAAW,CAAC;AAC3B,QAAA,YAAY,GAAG,WAAW,CAAC"}
|
@@ -17,11 +17,18 @@ const constants_1 = require("./constants");
|
|
17
17
|
const structs_1 = require("./structs");
|
18
18
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
19
19
|
const client = (0, clients_1.getClientSolana)();
|
20
|
-
const
|
21
|
-
if (
|
20
|
+
const custodiesAccs = yield (0, solana_1.getParsedProgramAccounts)(client, structs_1.custodyStruct, constants_1.perpsProgramId, (0, filters_1.dataStructSizeFilter)(structs_1.custodyStruct));
|
21
|
+
if (custodiesAccs.length === 0)
|
22
22
|
return;
|
23
|
-
const
|
24
|
-
yield
|
23
|
+
const custodyAccsInfo = custodiesAccs.map((acc) => (Object.assign({ pubkey: acc.pubkey.toString() }, acc)));
|
24
|
+
const pools = (yield (0, solana_1.getParsedMultipleAccountsInfo)(client, structs_1.perpetualPoolStruct, custodiesAccs.map((acc) => acc.pool)))
|
25
|
+
.map((acc) => (acc === null ? [] : [acc]))
|
26
|
+
.flat(1);
|
27
|
+
yield cache.setItem(constants_1.custodiesKey, custodyAccsInfo, {
|
28
|
+
prefix: constants_1.platformId,
|
29
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
30
|
+
});
|
31
|
+
yield cache.setItem(constants_1.perpPoolsKey, pools, {
|
25
32
|
prefix: constants_1.platformId,
|
26
33
|
networkId: portfolio_core_1.NetworkId.solana,
|
27
34
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"custodiesJob.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/exchange/custodiesJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,oDAAyD;AACzD,
|
1
|
+
{"version":3,"file":"custodiesJob.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/exchange/custodiesJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,oDAAyD;AACzD,kDAG+B;AAC/B,2DAAqE;AACrE,2CAKqB;AACrB,uCAAwE;AAExE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,aAAa,GAAG,MAAM,IAAA,iCAAwB,EAClD,MAAM,EACN,uBAAa,EACb,0BAAc,EACd,IAAA,8BAAoB,EAAC,uBAAa,CAAC,CACpC,CAAC;IACF,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IACvC,MAAM,eAAe,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,iBACjD,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,IACzB,GAAe,EACnB,CAAC,CAAC;IAEJ,MAAM,KAAK,GAAG,CACZ,MAAM,IAAA,sCAA6B,EACjC,MAAM,EACN,6BAAmB,EACnB,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CACrC,CACF;SACE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SACzC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEX,MAAM,KAAK,CAAC,OAAO,CAAC,wBAAY,EAAE,eAAe,EAAE;QACjD,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;IACH,MAAM,KAAK,CAAC,OAAO,CAAC,wBAAY,EAAE,KAAK,EAAE;QACvC,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,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"}
|
@@ -18,7 +18,6 @@ const web3_js_1 = require("@solana/web3.js");
|
|
18
18
|
const clients_1 = require("../../../utils/clients");
|
19
19
|
const solana_1 = require("../../../utils/solana");
|
20
20
|
const filters_1 = require("../filters");
|
21
|
-
const getMultipleAccountsInfoSafe_1 = require("../../../utils/solana/getMultipleAccountsInfoSafe");
|
22
21
|
const helpers_1 = require("../../../utils/solana/pyth/helpers");
|
23
22
|
const constants_1 = require("../../tokens/constants");
|
24
23
|
const constants_2 = require("./constants");
|
@@ -26,9 +25,9 @@ const structs_1 = require("./structs");
|
|
26
25
|
const usdFactor = new bignumber_js_1.default(Math.pow(10, 6));
|
27
26
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
28
27
|
const client = (0, clients_1.getClientSolana)();
|
29
|
-
const
|
30
|
-
if (
|
31
|
-
|
28
|
+
const positionAccounts = yield (0, solana_1.getParsedProgramAccounts)(client, structs_1.positionStruct, constants_2.perpsProgramId, (0, filters_1.perpetualsPositionsFilter)(owner));
|
29
|
+
if (positionAccounts.length === 0 ||
|
30
|
+
positionAccounts.every((perp) => perp.sizeUsd.isLessThanOrEqualTo(0)))
|
32
31
|
return [];
|
33
32
|
const custodiesAccounts = yield cache.getItem(constants_2.custodiesKey, {
|
34
33
|
prefix: constants_2.platformId,
|
@@ -36,127 +35,97 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
36
35
|
});
|
37
36
|
if (!custodiesAccounts)
|
38
37
|
return [];
|
38
|
+
const perpPoolsArr = yield cache.getItem(constants_2.perpPoolsKey, {
|
39
|
+
prefix: constants_2.platformId,
|
40
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
41
|
+
});
|
42
|
+
if (!perpPoolsArr)
|
43
|
+
return [];
|
44
|
+
const perpPools = new Map();
|
45
|
+
perpPoolsArr.forEach((a) => {
|
46
|
+
perpPools.set(a.pubkey.toString(), a);
|
47
|
+
});
|
39
48
|
const oraclesPubkeys = [];
|
40
49
|
const custodyById = new Map();
|
41
|
-
custodiesAccounts.forEach((
|
42
|
-
oraclesPubkeys.push(new web3_js_1.PublicKey(
|
43
|
-
custodyById.set(
|
50
|
+
custodiesAccounts.forEach((a) => {
|
51
|
+
oraclesPubkeys.push(new web3_js_1.PublicKey(a.oracle.oracleAccount));
|
52
|
+
custodyById.set(a.pubkey, a);
|
44
53
|
});
|
45
|
-
const
|
46
|
-
const pythPricesByAccount = (0, helpers_1.getPythPricesDatasMap)(oraclesPubkeys, oracleAccounts);
|
54
|
+
const pythPricesByAccount = yield (0, helpers_1.getPythPricesAsMap)(client, oraclesPubkeys);
|
47
55
|
const tokensDetailsById = new Map();
|
48
56
|
const tokensDetails = yield cache.getItems(custodiesAccounts.map((acc) => acc.mint), { prefix: constants_1.tokenListsDetailsPrefix, networkId: portfolio_core_1.NetworkId.solana });
|
49
57
|
tokensDetails.forEach((tD) => tD ? tokensDetailsById.set(tD.address, tD) : undefined);
|
50
|
-
const
|
51
|
-
for (const position of
|
52
|
-
|
58
|
+
const positions = [];
|
59
|
+
for (const position of positionAccounts) {
|
60
|
+
const { collateralUsd, sizeUsd, price, side, cumulativeInterestSnapshot, lockedAmount, } = position;
|
61
|
+
if (sizeUsd.isLessThanOrEqualTo(0))
|
53
62
|
continue;
|
54
|
-
if (
|
63
|
+
if (side === structs_1.Side.None)
|
55
64
|
continue;
|
56
|
-
const isLong =
|
65
|
+
const isLong = side === structs_1.Side.Long;
|
57
66
|
const custody = custodyById.get(position.custody.toString());
|
58
67
|
const collateralCustody = custodyById.get(position.collateralCustody.toString());
|
59
68
|
if (!custody || !collateralCustody)
|
60
69
|
continue;
|
61
|
-
const
|
62
|
-
|
63
|
-
|
64
|
-
const
|
65
|
-
const
|
66
|
-
|
67
|
-
const openingPrice = price.dividedBy(usdFactor);
|
68
|
-
const custodyPriceData = pythPricesByAccount.get(custody.oracle.oracleAccount);
|
69
|
-
const collateralCustodyPriceData = pythPricesByAccount.get(collateralCustody.oracle.oracleAccount);
|
70
|
-
if (!custodyPriceData ||
|
71
|
-
!custodyPriceData.price ||
|
72
|
-
!collateralCustodyPriceData ||
|
73
|
-
!collateralCustodyPriceData.price)
|
70
|
+
const perpPool = perpPools.get(custody.pool);
|
71
|
+
if (!perpPool)
|
72
|
+
continue;
|
73
|
+
const entryPrice = price.dividedBy(usdFactor);
|
74
|
+
const currentPrice = pythPricesByAccount.get(custody.oracle.oracleAccount);
|
75
|
+
if (!currentPrice)
|
74
76
|
continue;
|
75
|
-
const
|
77
|
+
const size = lockedAmount.div(Math.pow(10, custody.decimals));
|
78
|
+
const sizeValue = sizeUsd.dividedBy(usdFactor);
|
76
79
|
const leverage = sizeUsd.dividedBy(collateralUsd);
|
77
|
-
const
|
78
|
-
const
|
79
|
-
const
|
80
|
-
|
81
|
-
|
82
|
-
const
|
83
|
-
const
|
84
|
-
const custodyValue = sizeUsd.dividedBy(usdFactor).toNumber();
|
80
|
+
const collateralValue = collateralUsd.dividedBy(usdFactor);
|
81
|
+
const { increasePositionBps, decreasePositionBps } = perpPool.fees;
|
82
|
+
const increaseFees = new bignumber_js_1.default(increasePositionBps).div(10000);
|
83
|
+
const decreaseFees = new bignumber_js_1.default(decreasePositionBps).div(10000);
|
84
|
+
const openFees = entryPrice.times(size).times(increaseFees);
|
85
|
+
const closeFees = sizeValue.times(decreaseFees);
|
86
|
+
const openAndCloseFees = openFees.plus(closeFees);
|
85
87
|
const borrowFee = sizeUsd
|
86
88
|
.times(new bignumber_js_1.default(collateralCustody.fundingRateState.cumulativeInterestRate).minus(cumulativeInterestSnapshot))
|
87
89
|
.dividedBy(Math.pow(10, 15))
|
88
90
|
.absoluteValue();
|
89
|
-
const
|
90
|
-
const fees = borrowFee.plus(openAndCloseFees).negated().toNumber();
|
91
|
+
const fees = borrowFee.plus(openAndCloseFees).toNumber();
|
91
92
|
const priceDelta = isLong
|
92
|
-
? currentPrice.minus(
|
93
|
-
:
|
94
|
-
const priceVar = priceDelta.dividedBy(
|
95
|
-
const
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
93
|
+
? new bignumber_js_1.default(currentPrice).minus(entryPrice)
|
94
|
+
: entryPrice.minus(currentPrice);
|
95
|
+
const priceVar = priceDelta.dividedBy(entryPrice);
|
96
|
+
const pnlValue = priceVar.times(collateralValue).times(leverage);
|
97
|
+
const value = collateralValue.plus(pnlValue).minus(fees);
|
98
|
+
positions.push({
|
99
|
+
address: custody.mint,
|
100
|
+
side: isLong ? portfolio_core_1.LeverageSide.long : portfolio_core_1.LeverageSide.short,
|
101
|
+
leverage: leverage.toNumber(),
|
102
|
+
liquidationPrice: null,
|
103
|
+
collateralValue: collateralValue.toNumber(),
|
104
|
+
size: size.toNumber(),
|
105
|
+
sizeValue: sizeValue.toNumber(),
|
106
|
+
pnlValue: pnlValue.toNumber(),
|
107
|
+
value: value.toNumber(),
|
106
108
|
});
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
109
|
+
}
|
110
|
+
if (positions.length === 0)
|
111
|
+
return [];
|
112
|
+
const value = (0, portfolio_core_1.getUsdValueSum)(positions.map((a) => a.value));
|
113
|
+
return [
|
114
|
+
{
|
115
|
+
type: portfolio_core_1.PortfolioElementType.leverage,
|
112
116
|
data: {
|
113
|
-
|
114
|
-
|
115
|
-
|
117
|
+
positions,
|
118
|
+
positionsValue: value,
|
119
|
+
value,
|
120
|
+
collateralAssets: [],
|
121
|
+
collateralValue: 0,
|
116
122
|
},
|
117
|
-
|
118
|
-
rewardAssets.push({
|
119
|
-
type: 'generic',
|
120
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
121
|
-
value: pnl,
|
122
|
-
attributes: {},
|
123
|
-
data: { name: 'PNL ($)', amount: pnl, price: null },
|
124
|
-
});
|
125
|
-
rewardAssets.push({
|
126
|
-
type: 'generic',
|
127
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
128
|
-
value: fees,
|
129
|
-
attributes: {},
|
130
|
-
data: { name: 'Fees O/C ($)', amount: fees, price: null },
|
131
|
-
});
|
132
|
-
if (suppliedAssets.length === 0 && borrowedAssets.length === 0)
|
133
|
-
continue;
|
134
|
-
const { borrowedValue, suppliedValue, healthRatio, rewardValue } = (0, portfolio_core_1.getElementLendingValues)(suppliedAssets, borrowedAssets, rewardAssets);
|
135
|
-
const value = collateralUsd.dividedBy(usdFactor).plus(pnl).toNumber();
|
136
|
-
const side = isLong ? 'Long' : 'Short';
|
137
|
-
elements.push({
|
138
|
-
type: portfolio_core_1.PortfolioElementType.borrowlend,
|
123
|
+
label: 'Leverage',
|
139
124
|
networkId: portfolio_core_1.NetworkId.solana,
|
140
125
|
platformId: constants_2.platformId,
|
141
|
-
label: 'Leverage',
|
142
126
|
value,
|
143
|
-
|
144
|
-
|
145
|
-
borrowedAssets,
|
146
|
-
borrowedValue,
|
147
|
-
borrowedYields,
|
148
|
-
suppliedAssets,
|
149
|
-
suppliedValue,
|
150
|
-
suppliedYields,
|
151
|
-
collateralRatio: null,
|
152
|
-
rewardAssets,
|
153
|
-
rewardValue,
|
154
|
-
healthRatio,
|
155
|
-
value,
|
156
|
-
},
|
157
|
-
});
|
158
|
-
}
|
159
|
-
return elements;
|
127
|
+
},
|
128
|
+
];
|
160
129
|
});
|
161
130
|
const fetcher = {
|
162
131
|
id: `${constants_2.platformId}-perpetual`,
|