@sonarwatch/portfolio-plugins 0.12.185 → 0.12.187
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1546 -1538
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/plugins/abex/constants.d.ts +8 -1
- package/src/plugins/abex/constants.js +9 -2
- package/src/plugins/abex/constants.js.map +1 -1
- package/src/plugins/abex/getVaultInfo.d.ts +3 -0
- package/src/plugins/abex/getVaultInfo.js +65 -0
- package/src/plugins/abex/getVaultInfo.js.map +1 -0
- package/src/plugins/abex/helpers.d.ts +25 -0
- package/src/plugins/abex/helpers.js +353 -0
- package/src/plugins/abex/helpers.js.map +1 -0
- package/src/plugins/abex/index.js +7 -1
- package/src/plugins/abex/index.js.map +1 -1
- package/src/plugins/abex/marketsJob.js +13 -7
- package/src/plugins/abex/marketsJob.js.map +1 -1
- package/src/plugins/abex/ordersFetcher.d.ts +3 -0
- package/src/plugins/abex/ordersFetcher.js +49 -0
- package/src/plugins/abex/ordersFetcher.js.map +1 -0
- package/src/plugins/abex/parseValue.d.ts +1 -0
- package/src/plugins/abex/parseValue.js +30 -0
- package/src/plugins/abex/parseValue.js.map +1 -0
- package/src/plugins/abex/positionsFetcher.js +39 -57
- package/src/plugins/abex/positionsFetcher.js.map +1 -1
- package/src/plugins/abex/stakingFetcher.d.ts +3 -0
- package/src/plugins/abex/stakingFetcher.js +87 -0
- package/src/plugins/abex/stakingFetcher.js.map +1 -0
- package/src/plugins/abex/types.d.ts +172 -10
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/bluemove/poolsJob.js +13 -11
- package/src/plugins/bluemove/poolsJob.js.map +1 -1
- package/src/plugins/raydium/index.js +7 -2
- package/src/plugins/raydium/index.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/elementbuilder/ElementLeverageBuilder.d.ts +13 -0
- package/src/utils/elementbuilder/ElementLeverageBuilder.js +40 -0
- package/src/utils/elementbuilder/ElementLeverageBuilder.js.map +1 -0
- package/src/utils/elementbuilder/ElementRegistry.d.ts +2 -0
- package/src/utils/elementbuilder/ElementRegistry.js +6 -0
- package/src/utils/elementbuilder/ElementRegistry.js.map +1 -1
- package/src/utils/elementbuilder/LevPositionBuilder.d.ts +9 -0
- package/src/utils/elementbuilder/LevPositionBuilder.js +49 -0
- package/src/utils/elementbuilder/LevPositionBuilder.js.map +1 -0
- package/src/utils/elementbuilder/LevPositionParams.d.ts +14 -0
- package/src/utils/elementbuilder/LevPositionParams.js +3 -0
- package/src/utils/elementbuilder/LevPositionParams.js.map +1 -0
- package/src/utils/misc/Memoized.d.ts +8 -0
- package/src/utils/misc/Memoized.js +31 -0
- package/src/utils/misc/Memoized.js.map +1 -0
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/marketsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,gEAAqC;AAGrC,2CAQqB;AACrB,iDAAmD;AACnD,uEAAoE;AAEpE,qEAAkE;AAClE,qGAEiD;AACjD,yDAAsD;AACtD,mDAA2D;
|
1
|
+
{"version":3,"file":"marketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/marketsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,gEAAqC;AAGrC,2CAQqB;AACrB,iDAAmD;AACnD,uEAAoE;AAEpE,qEAAkE;AAClE,qGAEiD;AACjD,yDAAsD;AACtD,mDAA2D;AAC3D,uCAA0C;AAE1C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,cAAc;IACd,MAAM,UAAU,GAAG,MAAM,I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AC,CAAC;IACL,CAAC;IAED,MAAM,QAAQ,GAAG,IAAA,gCAAsB,EACrC,0BAAS,CAAC,GAAG,EACb,sBAAU,EACV,sBAAU,EACV;QACE,OAAO,EAAE,mBAAO;QAChB,QAAQ,EAAE,uBAAW;QACrB,SAAS,EAAE,IAAI,sBAAS,CAAC,QAAQ,CAAC;KACnC,EACD,aAAa,EACb,QAAQ,CACT,CAAC;IACF,MAAM,KAAK,CAAC,mBAAmB,CAAC;QAC9B,EAAE,EAAE,KAAK;QACT,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,UAAU,EAAE,gCAAoB,CAAC,EAAE;QACnC,OAAO,EAAE,mBAAO;QAChB,QAAQ,EAAE,uBAAW;QACrB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE,SAAS;QACtB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC,CAAC;AACL,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,49 @@
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
+
const constants_1 = require("./constants");
|
14
|
+
const clients_1 = require("../../utils/clients");
|
15
|
+
const helpers_1 = require("./helpers");
|
16
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
17
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
18
|
+
const client = (0, clients_1.getClientSui)();
|
19
|
+
const orderCapInfoList = yield (0, helpers_1.getOrderCapInfoList)(client, owner);
|
20
|
+
if (!orderCapInfoList.length)
|
21
|
+
return [];
|
22
|
+
const positionInfoList = yield (0, helpers_1.getOrderInfoList)(client, orderCapInfoList, owner);
|
23
|
+
if (!positionInfoList.length)
|
24
|
+
return [];
|
25
|
+
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
|
26
|
+
const element = elementRegistry.addElementMultiple({
|
27
|
+
label: 'Deposit',
|
28
|
+
tags: ['Orders'],
|
29
|
+
});
|
30
|
+
positionInfoList.forEach((positionInfo) => {
|
31
|
+
var _a;
|
32
|
+
if (positionInfo.executed)
|
33
|
+
return;
|
34
|
+
if (!((_a = positionInfo.openOrder) === null || _a === void 0 ? void 0 : _a.collateralAmount))
|
35
|
+
return;
|
36
|
+
element.addAsset({
|
37
|
+
address: positionInfo.collateralToken,
|
38
|
+
amount: positionInfo.openOrder.collateralAmount,
|
39
|
+
});
|
40
|
+
});
|
41
|
+
return elementRegistry.getElements(cache);
|
42
|
+
});
|
43
|
+
const fetcher = {
|
44
|
+
id: `${constants_1.platformId}-orders`,
|
45
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
46
|
+
executor,
|
47
|
+
};
|
48
|
+
exports.default = fetcher;
|
49
|
+
//# sourceMappingURL=ordersFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ordersFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/ordersFetcher.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AS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const parseValue: (field: any) => number;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.parseValue = void 0;
|
4
|
+
const decimalToObject = (decimal) => Number(BigInt(decimal.value)) / 1e18;
|
5
|
+
const rateToObject = (rate) => Number(BigInt(rate.value)) / 1e18;
|
6
|
+
const srateToObject = (srate) => {
|
7
|
+
const sign = srate.fields.is_positive ? 1 : -1;
|
8
|
+
return (Number(BigInt(srate.fields.value.fields.value)) / 1e18) * sign;
|
9
|
+
};
|
10
|
+
const sdecimalToObject = (sdecimal) => {
|
11
|
+
const sign = sdecimal.fields.is_positive ? 1 : -1;
|
12
|
+
return (Number(BigInt(sdecimal.fields.value.fields.value)) / 1e18) * sign;
|
13
|
+
};
|
14
|
+
const parseValue = (field) => {
|
15
|
+
if (field.type && field.type.endsWith('::decimal::Decimal')) {
|
16
|
+
return decimalToObject({ value: field.fields.value });
|
17
|
+
}
|
18
|
+
if (field.type && field.type.endsWith('::rate::Rate')) {
|
19
|
+
return rateToObject({ value: field.fields.value });
|
20
|
+
}
|
21
|
+
if (field.type && field.type.endsWith('::srate::SRate')) {
|
22
|
+
return srateToObject(field);
|
23
|
+
}
|
24
|
+
if (field.type && field.type.endsWith('::sdecimal::SDecimal')) {
|
25
|
+
return sdecimalToObject(field);
|
26
|
+
}
|
27
|
+
return parseInt(field, 10);
|
28
|
+
};
|
29
|
+
exports.parseValue = parseValue;
|
30
|
+
//# sourceMappingURL=parseValue.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"parseValue.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/parseValue.ts"],"names":[],"mappings":";;;AAAA,MAAM,eAAe,GAAG,CAAC,OAA0B,EAAE,EAAE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Y,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACxD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC9D,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC,CAAC;AAdW,QAAA,UAAU,cAcrB"}
|
@@ -16,72 +16,54 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
|
16
16
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
17
|
const constants_1 = require("./constants");
|
18
18
|
const clients_1 = require("../../utils/clients");
|
19
|
-
const
|
20
|
-
const
|
19
|
+
const helpers_1 = require("./helpers");
|
20
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
21
21
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
22
|
-
var _a, _b, _c, _d;
|
23
22
|
const client = (0, clients_1.getClientSui)();
|
24
|
-
const
|
25
|
-
|
26
|
-
Package: '0xc985ff436f334f864d74f35c3da9e116419b63a0c027cbe2ac7815afc4abc450',
|
27
|
-
},
|
28
|
-
});
|
29
|
-
if (objects.length === 0)
|
23
|
+
const positionCapInfoList = yield (0, helpers_1.getPositionCapInfoList)(client, owner);
|
24
|
+
if (positionCapInfoList.length === 0)
|
30
25
|
return [];
|
31
|
-
const
|
32
|
-
const poolAccRewardPerShareStr = yield cache.getItem(constants_1.poolAccRewardPerShareKey, {
|
26
|
+
const marketInfo = yield cache.getItem(constants_1.abexMarketCacheKey, {
|
33
27
|
prefix: constants_1.platformId,
|
34
28
|
networkId: portfolio_core_1.NetworkId.sui,
|
35
29
|
});
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
const object = objects[i];
|
43
|
-
const cAlpAmount = (_b = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.stake;
|
44
|
-
if (!cAlpAmount)
|
45
|
-
continue;
|
46
|
-
alpAmount = alpAmount.plus(cAlpAmount);
|
47
|
-
if (!poolAccRewardPerShare)
|
30
|
+
if (!marketInfo)
|
31
|
+
return [];
|
32
|
+
const positionInfoList = yield (0, helpers_1.getPositionInfoList)(client, positionCapInfoList, marketInfo, cache, owner);
|
33
|
+
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
|
34
|
+
for (const positionInfo of positionInfoList) {
|
35
|
+
if (positionInfo.closed)
|
48
36
|
continue;
|
49
|
-
const
|
50
|
-
|
37
|
+
const element = elementRegistry.addElementLeverage({
|
38
|
+
label: 'Leverage',
|
39
|
+
});
|
40
|
+
const tokenPrices = yield cache.getTokenPricesAsMap([positionInfo.indexToken, positionInfo.collateralToken], portfolio_core_1.NetworkId.sui);
|
41
|
+
const tokenPriceIndex = tokenPrices.get(positionInfo.indexToken);
|
42
|
+
const tokenPriceCollateral = tokenPrices.get(positionInfo.collateralToken);
|
43
|
+
if (!tokenPriceCollateral)
|
51
44
|
continue;
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
let pnlValue;
|
46
|
+
let leverage;
|
47
|
+
if (tokenPriceIndex) {
|
48
|
+
const calcPnl = yield (0, helpers_1.calculatePNL)(positionInfo, tokenPriceIndex, tokenPriceCollateral);
|
49
|
+
if (calcPnl) {
|
50
|
+
pnlValue = new bignumber_js_1.default(calcPnl.pnlValue);
|
51
|
+
leverage = calcPnl.leverage;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
element.addPosition({
|
55
|
+
address: positionInfo.collateralToken,
|
56
|
+
collateralValue: new bignumber_js_1.default(positionInfo.collateralAmount)
|
57
|
+
.multipliedBy(tokenPriceCollateral.price)
|
58
|
+
.dividedBy(Math.pow(10, tokenPriceCollateral.decimals))
|
59
|
+
.toNumber(),
|
60
|
+
side: positionInfo.long ? portfolio_core_1.LeverageSide.long : portfolio_core_1.LeverageSide.short,
|
61
|
+
sizeValue: new bignumber_js_1.default(positionInfo.positionSize),
|
62
|
+
pnlValue,
|
63
|
+
leverage,
|
64
|
+
});
|
57
65
|
}
|
58
|
-
|
59
|
-
const rewardAsset = (0, tokenPriceToAssetToken_1.default)(portfolio_core_1.suiNativeAddress, claimmableAmount.dividedBy(Math.pow(10, portfolio_core_1.suiNativeDecimals)).toNumber(), portfolio_core_1.NetworkId.sui, suiPrice, undefined, {
|
60
|
-
isClaimable: true,
|
61
|
-
});
|
62
|
-
if (claimmableAmount.isZero() && alpAmount.isZero())
|
63
|
-
return [];
|
64
|
-
const value = (0, portfolio_core_1.getUsdValueSum)([rewardAsset.value, asset.value]);
|
65
|
-
const element = {
|
66
|
-
networkId: portfolio_core_1.NetworkId.sui,
|
67
|
-
label: 'Staked',
|
68
|
-
platformId: constants_1.platformId,
|
69
|
-
type: 'liquidity',
|
70
|
-
data: {
|
71
|
-
liquidities: [
|
72
|
-
{
|
73
|
-
assets: [asset],
|
74
|
-
assetsValue: asset.value,
|
75
|
-
rewardAssets: [rewardAsset],
|
76
|
-
rewardAssetsValue: rewardAsset.value,
|
77
|
-
value,
|
78
|
-
yields: [],
|
79
|
-
},
|
80
|
-
],
|
81
|
-
},
|
82
|
-
value,
|
83
|
-
};
|
84
|
-
return [element];
|
66
|
+
return elementRegistry.getElements(cache);
|
85
67
|
});
|
86
68
|
const fetcher = {
|
87
69
|
id: `${constants_1.platformId}-positions`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAqE;AACrE,gEAAqC;AAErC,2CAA6D;AAE7D,iDAAmD;AACnD,uCAImB;AACnB,gFAA6E;AAG7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,mBAAmB,GAAG,MAAM,IAAA,gCAAsB,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAExE,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEhD,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,OAAO,CAAc,8BAAkB,EAAE;QACtE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IAEH,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,MAAM,gBAAgB,GAAG,MAAM,IAAA,6BAAmB,EAChD,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,KAAK,EACL,KAAK,CACN,CAAC;IAEF,MAAM,eAAe,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,GAAG,EAAE,sBAAU,CAAC,CAAC;IAEvE,KAAK,MAAM,YAAY,IAAI,gBAAgB,EAAE,CAAC;QAC5C,IAAI,YAAY,CAAC,MAAM;YAAE,SAAS;QAClC,MAAM,OAAO,GAAG,eAAe,CAAC,kBAAkB,CAAC;YACjD,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,mBAAmB,CACjD,CAAC,YAAY,CAAC,UAAU,EAAE,YAAY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AC7B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,87 @@
|
|
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 getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
|
20
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
21
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
22
|
+
var _a, _b, _c, _d;
|
23
|
+
const client = (0, clients_1.getClientSui)();
|
24
|
+
const objects = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
|
25
|
+
filter: {
|
26
|
+
MoveModule: {
|
27
|
+
package: constants_1.stakingPackage,
|
28
|
+
module: 'pool',
|
29
|
+
},
|
30
|
+
},
|
31
|
+
});
|
32
|
+
if (objects.length === 0)
|
33
|
+
return [];
|
34
|
+
const poolAccRewardPerShareStr = yield cache.getItem(constants_1.poolAccRewardPerShareKey, {
|
35
|
+
prefix: constants_1.platformId,
|
36
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
37
|
+
});
|
38
|
+
const poolAccRewardPerShare = poolAccRewardPerShareStr
|
39
|
+
? new bignumber_js_1.default(poolAccRewardPerShareStr)
|
40
|
+
: undefined;
|
41
|
+
let alpAmount = new bignumber_js_1.default(0);
|
42
|
+
let claimableAmount = new bignumber_js_1.default(0);
|
43
|
+
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
|
44
|
+
const element = elementRegistry.addElementLiquidity({
|
45
|
+
label: 'Staked',
|
46
|
+
});
|
47
|
+
const liquidity = element.addLiquidity();
|
48
|
+
for (let i = 0; i < objects.length; i++) {
|
49
|
+
const object = objects[i];
|
50
|
+
const cAlpAmount = (_b = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.stake;
|
51
|
+
if (!cAlpAmount)
|
52
|
+
continue;
|
53
|
+
alpAmount = alpAmount.plus(cAlpAmount);
|
54
|
+
if (!poolAccRewardPerShare)
|
55
|
+
continue;
|
56
|
+
const accRewardPerShare = (_d = (_c = object.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.acc_reward_per_share;
|
57
|
+
if (!accRewardPerShare)
|
58
|
+
continue;
|
59
|
+
const cClaimableAmount = poolAccRewardPerShare
|
60
|
+
.minus(accRewardPerShare)
|
61
|
+
.times(cAlpAmount)
|
62
|
+
.div(Math.pow(10, 18));
|
63
|
+
claimableAmount = claimableAmount.plus(cClaimableAmount);
|
64
|
+
}
|
65
|
+
liquidity.addAsset({
|
66
|
+
address: constants_1.alpType,
|
67
|
+
amount: alpAmount,
|
68
|
+
});
|
69
|
+
if (claimableAmount.isGreaterThan(0))
|
70
|
+
liquidity.addRewardAsset({
|
71
|
+
address: portfolio_core_1.suiNativeAddress,
|
72
|
+
amount: claimableAmount,
|
73
|
+
attributes: {
|
74
|
+
isClaimable: true,
|
75
|
+
},
|
76
|
+
});
|
77
|
+
if (claimableAmount.isZero() && alpAmount.isZero())
|
78
|
+
return [];
|
79
|
+
return elementRegistry.getElements(cache);
|
80
|
+
});
|
81
|
+
const fetcher = {
|
82
|
+
id: `${constants_1.platformId}-staking`,
|
83
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
84
|
+
executor,
|
85
|
+
};
|
86
|
+
exports.default = fetcher;
|
87
|
+
//# sourceMappingURL=stakingFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"stakingFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/stakingFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAyE;AACzE,gEAAqC;AAErC,2CAKqB;AAErB,iDAAmD;AACnD,qEAAkE;AAElE,gFAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAe,EAAa,MAAM,EAAE,KAAK,EAAE;QAC/D,MAAM,EAAE;YACN,UAAU,EAAE;gBACV,OAAO,EAAE,0BAAc;gBACvB,MAAM,EAAE,MAAM;aACf;SACF;KACF,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpC,MAAM,wBAAwB,GAAG,MAAM,KAAK,CAAC,OAAO,CAClD,oCAAwB,EACxB;QACE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CACF,CAAC;IACF,MAAM,qBAAqB,GAAG,wBAAwB;QACpD,CAAC,CAAC,IAAI,sBAAS,CAAC,wBAAwB,CAAC;QACzC,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,SAAS,GAAG,I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a,CAAC,CAAC,CAAC;QAClC,SAAS,CAAC,cAAc,CAAC;YACvB,OAAO,EAAE,iCAAgB;YACzB,MAAM,EAAE,eAAe;YACvB,UAAU,EAAE;gBACV,WAAW,EAAE,IAAI;aAClB;SACF,CAAC,CAAC;IAEL,IAAI,eAAe,CAAC,MAAM,EAAE,IAAI,SAAS,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC;IAE9D,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
1
2
|
import { ID } from '../../utils/sui/structs/id';
|
2
3
|
export type Credential = {
|
3
4
|
acc_reward_per_share: string;
|
@@ -16,16 +17,6 @@ export type Pool = {
|
|
16
17
|
staked_amount: string;
|
17
18
|
start_time: string;
|
18
19
|
};
|
19
|
-
export type AlpMarket = {
|
20
|
-
fun_mask: string;
|
21
|
-
id: ID;
|
22
|
-
lp_supply: {
|
23
|
-
type: string;
|
24
|
-
fields: {
|
25
|
-
value: string;
|
26
|
-
};
|
27
|
-
};
|
28
|
-
};
|
29
20
|
export type Market = {
|
30
21
|
id: ID;
|
31
22
|
name: {
|
@@ -73,3 +64,174 @@ export type MarketFields = {
|
|
73
64
|
};
|
74
65
|
};
|
75
66
|
};
|
67
|
+
export interface IMarketInfo {
|
68
|
+
lpSupply: string;
|
69
|
+
positionId: string;
|
70
|
+
vaultId: string;
|
71
|
+
symbolId: string;
|
72
|
+
referralId: string;
|
73
|
+
orderId: string;
|
74
|
+
rebaseFeeModel: string;
|
75
|
+
lpSupplyWithDecimals: number;
|
76
|
+
}
|
77
|
+
export interface IRebaseFeeModel {
|
78
|
+
base: number;
|
79
|
+
multiplier: number;
|
80
|
+
}
|
81
|
+
export interface IReservingFeeModel {
|
82
|
+
multiplier: number;
|
83
|
+
}
|
84
|
+
export interface IFundingFeeModel {
|
85
|
+
multiplier: number;
|
86
|
+
max: number;
|
87
|
+
}
|
88
|
+
export interface IVaultInfo {
|
89
|
+
liquidity: number;
|
90
|
+
reservedAmount: number;
|
91
|
+
unrealisedReservingFeeAmount: number;
|
92
|
+
accReservingRate: number;
|
93
|
+
enabled: boolean;
|
94
|
+
weight: number;
|
95
|
+
lastUpdate: number;
|
96
|
+
reservingFeeModel: IReservingFeeModel;
|
97
|
+
priceConfig: {
|
98
|
+
maxInterval: number;
|
99
|
+
maxConfidence: number;
|
100
|
+
precision: number;
|
101
|
+
feeder: string;
|
102
|
+
};
|
103
|
+
}
|
104
|
+
export interface ISymbolInfo {
|
105
|
+
openingSize: number;
|
106
|
+
openingAmount: number;
|
107
|
+
accFundingRate: number;
|
108
|
+
realisedPnl: number;
|
109
|
+
unrealisedFundingFeeValue: number;
|
110
|
+
openEnabled: boolean;
|
111
|
+
liquidateEnabled: boolean;
|
112
|
+
decreaseEnabled: boolean;
|
113
|
+
lastUpdate: number;
|
114
|
+
fundingFeeModel: IFundingFeeModel;
|
115
|
+
long: boolean;
|
116
|
+
priceConfig: {
|
117
|
+
maxInterval: number;
|
118
|
+
maxConfidence: number;
|
119
|
+
precision: number;
|
120
|
+
feeder: string;
|
121
|
+
};
|
122
|
+
}
|
123
|
+
export interface IPositionInfo {
|
124
|
+
id: string;
|
125
|
+
long: boolean;
|
126
|
+
owner: string;
|
127
|
+
version: number;
|
128
|
+
collateralToken: string;
|
129
|
+
indexToken: string;
|
130
|
+
collateralAmount: number;
|
131
|
+
positionAmount: number;
|
132
|
+
reservedAmount: number;
|
133
|
+
positionSize: number;
|
134
|
+
lastFundingRate: number;
|
135
|
+
lastReservingRate: number;
|
136
|
+
reservingFeeAmount: number;
|
137
|
+
fundingFeeValue: number;
|
138
|
+
closed: boolean;
|
139
|
+
openTimestamp: number;
|
140
|
+
openFeeBps: number;
|
141
|
+
}
|
142
|
+
export interface IPositionCapInfo {
|
143
|
+
positionCapId: string;
|
144
|
+
symbol0: string;
|
145
|
+
symbol1: string;
|
146
|
+
long: boolean;
|
147
|
+
}
|
148
|
+
export interface IOrderCapInfo {
|
149
|
+
orderCapId: string;
|
150
|
+
symbol0: string;
|
151
|
+
symbol1: string;
|
152
|
+
long: boolean;
|
153
|
+
positionId: string | null;
|
154
|
+
}
|
155
|
+
export interface IOrderInfo {
|
156
|
+
id: string;
|
157
|
+
capId: string;
|
158
|
+
executed: boolean;
|
159
|
+
owner: string;
|
160
|
+
collateralToken: string;
|
161
|
+
indexToken: string;
|
162
|
+
feeToken: string;
|
163
|
+
collateralPriceThreshold: number;
|
164
|
+
feeAmount: BigNumber;
|
165
|
+
long: boolean;
|
166
|
+
indexPrice: number;
|
167
|
+
openOrder?: {
|
168
|
+
reserveAmount: BigNumber;
|
169
|
+
collateralAmount: BigNumber;
|
170
|
+
openAmount: BigNumber;
|
171
|
+
};
|
172
|
+
decreaseOrder?: {
|
173
|
+
decreaseAmount: BigNumber;
|
174
|
+
takeProfit: boolean;
|
175
|
+
};
|
176
|
+
orderType: 'OPEN_POSITION' | 'DECREASE_POSITION';
|
177
|
+
createdAt: number;
|
178
|
+
v11Order: boolean;
|
179
|
+
}
|
180
|
+
export interface IMarketValuationInfo {
|
181
|
+
marketCap: number;
|
182
|
+
alpPrice: number;
|
183
|
+
alpSupply: number;
|
184
|
+
apr?: number;
|
185
|
+
}
|
186
|
+
export interface IPositionConfig {
|
187
|
+
decreaseFeeBps: number;
|
188
|
+
liquidationBonus: number;
|
189
|
+
liquidationThreshold: number;
|
190
|
+
maxLeverage: number;
|
191
|
+
minHoldingDuration: number;
|
192
|
+
openFeeBps: number;
|
193
|
+
maxReservedMultiplier: number;
|
194
|
+
minCollateralValue: number;
|
195
|
+
}
|
196
|
+
export interface IHistory {
|
197
|
+
owner: string;
|
198
|
+
txid: string;
|
199
|
+
id: string;
|
200
|
+
created: number;
|
201
|
+
eventName: string;
|
202
|
+
parsedDetail: {
|
203
|
+
[key: string]: any;
|
204
|
+
};
|
205
|
+
detailRaw: string;
|
206
|
+
volume: number;
|
207
|
+
network: string;
|
208
|
+
}
|
209
|
+
export interface IStaked {
|
210
|
+
credentials: ICredential[];
|
211
|
+
amount: bigint;
|
212
|
+
claimable: bigint;
|
213
|
+
}
|
214
|
+
export interface ICredential {
|
215
|
+
id: string;
|
216
|
+
lockUntil: number;
|
217
|
+
accRewardPerShare: bigint;
|
218
|
+
amount: bigint;
|
219
|
+
claimable: bigint;
|
220
|
+
}
|
221
|
+
export interface IStakePool {
|
222
|
+
id: string;
|
223
|
+
enabled: boolean;
|
224
|
+
lastUpdatedTime: number;
|
225
|
+
stakedAmount: bigint;
|
226
|
+
reward: bigint;
|
227
|
+
startTime: number;
|
228
|
+
endTime: number;
|
229
|
+
accRewardPerShare: bigint;
|
230
|
+
lockDuration: number;
|
231
|
+
}
|
232
|
+
export interface ICoin {
|
233
|
+
decimals: number;
|
234
|
+
module: string;
|
235
|
+
metadata: string;
|
236
|
+
treasury?: string | null;
|
237
|
+
}
|
@@ -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;
|
@@ -9,22 +9,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
});
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
12
13
|
const constants_1 = require("./constants");
|
13
14
|
const clients_1 = require("../../utils/clients");
|
14
15
|
const getDynamicFieldObjects_1 = require("../../utils/sui/getDynamicFieldObjects");
|
15
|
-
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
16
|
const getLpTokenSourceRaw_1 = require("../../utils/misc/getLpTokenSourceRaw");
|
17
17
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
18
18
|
const client = (0, clients_1.getClientSui)();
|
19
19
|
const pools = yield (0, getDynamicFieldObjects_1.getDynamicFieldObjects)(client, constants_1.dexInfoId);
|
20
20
|
const mints = new Set();
|
21
21
|
pools.forEach((pool) => {
|
22
|
-
var _a, _b, _c
|
23
|
-
if (
|
24
|
-
!
|
25
|
-
|
22
|
+
var _a, _b, _c;
|
23
|
+
if (!pool.data ||
|
24
|
+
!pool.data.type ||
|
25
|
+
((_a = pool.data.content) === null || _a === void 0 ? void 0 : _a.fields.is_freeze) ||
|
26
|
+
!((_c = (_b = pool.data.content) === null || _b === void 0 ? void 0 : _b.fields.lsp_supply) === null || _c === void 0 ? void 0 : _c.type))
|
26
27
|
return;
|
27
|
-
|
28
|
+
const { keys: coinTypeKeys } = (0, portfolio_core_1.parseTypeString)(pool.data.type);
|
28
29
|
if (!coinTypeKeys)
|
29
30
|
return;
|
30
31
|
const coinTypeX = coinTypeKeys[0].type;
|
@@ -37,12 +38,13 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
38
|
const tokenPrices = yield cache.getTokenPricesAsMap(mints, portfolio_core_1.NetworkId.sui);
|
38
39
|
const lpSources = [];
|
39
40
|
pools.forEach((pool) => {
|
40
|
-
var _a, _b, _c
|
41
|
-
if (
|
42
|
-
!
|
43
|
-
|
41
|
+
var _a, _b, _c;
|
42
|
+
if (!pool.data ||
|
43
|
+
!pool.data.type ||
|
44
|
+
((_a = pool.data.content) === null || _a === void 0 ? void 0 : _a.fields.is_freeze) ||
|
45
|
+
!((_c = (_b = pool.data.content) === null || _b === void 0 ? void 0 : _b.fields.lsp_supply) === null || _c === void 0 ? void 0 : _c.type))
|
44
46
|
return;
|
45
|
-
|
47
|
+
const { keys: coinTypeKeys } = (0, portfolio_core_1.parseTypeString)(pool.data.type);
|
46
48
|
if (!coinTypeKeys)
|
47
49
|
return;
|
48
50
|
const coinTypeX = coinTypeKeys[0].type;
|