@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
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
@@ -1,9 +1,16 @@
|
|
1
1
|
import { Platform } from '@sonarwatch/portfolio-core';
|
2
2
|
export declare const platformId = "abex";
|
3
3
|
export declare const platform: Platform;
|
4
|
+
export declare const stakingPackage = "0xc985ff436f334f864d74f35c3da9e116419b63a0c027cbe2ac7815afc4abc450";
|
5
|
+
export declare const corePackage = "0xceab84acf6bf70f503c3b0627acaff6b3f84cee0f2d7ed53d00fa6c2a168d14f";
|
6
|
+
export declare const positionsParent = "0x251910096bd975afdb4413a3b4c0a158b0097c0c4cd242e1a24db5882011cac2";
|
7
|
+
export declare const ordersParent = "0x6a318ab871926d031bd3bf2cebb0426d44d917f0cc649ffea40ccba02b89700d";
|
8
|
+
export declare const vaultsParent = "0x3c6595e543c4766dd63b5b2fa918516bac2920bc1944da068be031dced46a18d";
|
9
|
+
export declare const symbolsParent = "0xa23d31c1fed163b675911aef7ed57bf4acf9f21f41fca02df7cef42c87083351";
|
10
|
+
export declare const abexMarket = "0x7705d4670e7ef4623d6392888f73f6773b5f0218b6cb1486a4be238692a58bca";
|
11
|
+
export declare const abexMarketCacheKey = "abexmarket";
|
4
12
|
export declare const alpType = "0xceab84acf6bf70f503c3b0627acaff6b3f84cee0f2d7ed53d00fa6c2a168d14f::alp::ALP";
|
5
13
|
export declare const alpDecimals = 6;
|
6
14
|
export declare const depositVaultRegistry = "0x3c6595e543c4766dd63b5b2fa918516bac2920bc1944da068be031dced46a18d";
|
7
|
-
export declare const alpSupplyObjectId = "0x7705d4670e7ef4623d6392888f73f6773b5f0218b6cb1486a4be238692a58bca";
|
8
15
|
export declare const poolObjectId = "0x9a1c1130b6c8c6b465397ef8a99b2917c5a7a957df98cb4812212674aa971f63";
|
9
16
|
export declare const poolAccRewardPerShareKey = "accRewardPerShare";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.poolAccRewardPerShareKey = exports.poolObjectId = exports.
|
3
|
+
exports.poolAccRewardPerShareKey = exports.poolObjectId = exports.depositVaultRegistry = exports.alpDecimals = exports.alpType = exports.abexMarketCacheKey = exports.abexMarket = exports.symbolsParent = exports.vaultsParent = exports.ordersParent = exports.positionsParent = exports.corePackage = exports.stakingPackage = exports.platform = exports.platformId = void 0;
|
4
4
|
exports.platformId = 'abex';
|
5
5
|
exports.platform = {
|
6
6
|
id: exports.platformId,
|
@@ -10,10 +10,17 @@ exports.platform = {
|
|
10
10
|
twitter: 'https://twitter.com/ABExFinance',
|
11
11
|
defiLlamaId: 'abex-finance', // from https://defillama.com/docs/api
|
12
12
|
};
|
13
|
+
exports.stakingPackage = '0xc985ff436f334f864d74f35c3da9e116419b63a0c027cbe2ac7815afc4abc450';
|
14
|
+
exports.corePackage = '0xceab84acf6bf70f503c3b0627acaff6b3f84cee0f2d7ed53d00fa6c2a168d14f';
|
15
|
+
exports.positionsParent = '0x251910096bd975afdb4413a3b4c0a158b0097c0c4cd242e1a24db5882011cac2';
|
16
|
+
exports.ordersParent = '0x6a318ab871926d031bd3bf2cebb0426d44d917f0cc649ffea40ccba02b89700d';
|
17
|
+
exports.vaultsParent = '0x3c6595e543c4766dd63b5b2fa918516bac2920bc1944da068be031dced46a18d';
|
18
|
+
exports.symbolsParent = '0xa23d31c1fed163b675911aef7ed57bf4acf9f21f41fca02df7cef42c87083351';
|
19
|
+
exports.abexMarket = '0x7705d4670e7ef4623d6392888f73f6773b5f0218b6cb1486a4be238692a58bca';
|
20
|
+
exports.abexMarketCacheKey = 'abexmarket';
|
13
21
|
exports.alpType = '0xceab84acf6bf70f503c3b0627acaff6b3f84cee0f2d7ed53d00fa6c2a168d14f::alp::ALP';
|
14
22
|
exports.alpDecimals = 6;
|
15
23
|
exports.depositVaultRegistry = '0x3c6595e543c4766dd63b5b2fa918516bac2920bc1944da068be031dced46a18d';
|
16
|
-
exports.alpSupplyObjectId = '0x7705d4670e7ef4623d6392888f73f6773b5f0218b6cb1486a4be238692a58bca';
|
17
24
|
exports.poolObjectId = '0x9a1c1130b6c8c6b465397ef8a99b2917c5a7a957df98cb4812212674aa971f63';
|
18
25
|
exports.poolAccRewardPerShareKey = 'accRewardPerShare';
|
19
26
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,6CAA6C;IACpD,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,iCAAiC;IAC1C,WAAW,EAAE,cAAc,EAAE,sCAAsC;CACpE,CAAC;AAEW,QAAA,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,6CAA6C;IACpD,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,iCAAiC;IAC1C,WAAW,EAAE,cAAc,EAAE,sCAAsC;CACpE,CAAC;AAEW,QAAA,cAAc,GACzB,oEAAoE,CAAC;AAC1D,QAAA,WAAW,GACtB,oEAAoE,CAAC;AAC1D,QAAA,eAAe,GAC1B,oEAAoE,CAAC;AAC1D,QAAA,YAAY,GACvB,oEAAoE,CAAC;AAC1D,QAAA,YAAY,GACvB,oEAAoE,CAAC;AAC1D,QAAA,aAAa,GACxB,oEAAoE,CAAC;AAC1D,QAAA,UAAU,GACrB,oEAAoE,CAAC;AAC1D,QAAA,kBAAkB,GAAG,YAAY,CAAC;AAElC,QAAA,OAAO,GAClB,8EAA8E,CAAC;AACpE,QAAA,WAAW,GAAG,CAAC,CAAC;AAChB,QAAA,oBAAoB,GAC/B,oEAAoE,CAAC;AAC1D,QAAA,YAAY,GACvB,oEAAoE,CAAC;AAC1D,QAAA,wBAAwB,GAAG,mBAAmB,CAAC"}
|
@@ -0,0 +1,65 @@
|
|
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
|
+
exports.getVaultInfo = void 0;
|
13
|
+
const Memoized_1 = require("../../utils/misc/Memoized");
|
14
|
+
const getDynamicFieldObject_1 = require("../../utils/sui/getDynamicFieldObject");
|
15
|
+
const constants_1 = require("./constants");
|
16
|
+
const getObject_1 = require("../../utils/sui/getObject");
|
17
|
+
const parseValue_1 = require("./parseValue");
|
18
|
+
const vaultsMemo = {};
|
19
|
+
const getVaultInfo = (client, vaultToken) => __awaiter(void 0, void 0, void 0, function* () {
|
20
|
+
if (!vaultsMemo[vaultToken]) {
|
21
|
+
vaultsMemo[vaultToken] = new Memoized_1.Memoized(() => __awaiter(void 0, void 0, void 0, function* () {
|
22
|
+
const rawData = yield (0, getDynamicFieldObject_1.getDynamicFieldObject)(client, {
|
23
|
+
parentId: constants_1.vaultsParent,
|
24
|
+
name: {
|
25
|
+
type: `${constants_1.corePackage}::market::VaultName<${vaultToken}>`,
|
26
|
+
value: { dummy_field: false },
|
27
|
+
},
|
28
|
+
});
|
29
|
+
return parseVaultInfo(client, rawData);
|
30
|
+
}));
|
31
|
+
}
|
32
|
+
return vaultsMemo[vaultToken].getItem();
|
33
|
+
});
|
34
|
+
exports.getVaultInfo = getVaultInfo;
|
35
|
+
const parseVaultInfo = (client, raw) => __awaiter(void 0, void 0, void 0, function* () {
|
36
|
+
const vaultFields = raw.data.content.fields.value.fields;
|
37
|
+
const reservingFeeModelAddr = vaultFields.reserving_fee_model;
|
38
|
+
const reservingFeeModelRaw = yield (0, getObject_1.getObject)(client, reservingFeeModelAddr, {
|
39
|
+
showContent: true,
|
40
|
+
});
|
41
|
+
const reservingFeeModel = parseReservingFeeModel(reservingFeeModelRaw);
|
42
|
+
return {
|
43
|
+
liquidity: (0, parseValue_1.parseValue)(vaultFields.liquidity),
|
44
|
+
reservedAmount: (0, parseValue_1.parseValue)(vaultFields.reserved_amount),
|
45
|
+
unrealisedReservingFeeAmount: (0, parseValue_1.parseValue)(vaultFields.unrealised_reserving_fee_amount),
|
46
|
+
accReservingRate: (0, parseValue_1.parseValue)(vaultFields.acc_reserving_rate),
|
47
|
+
enabled: vaultFields.enabled,
|
48
|
+
weight: (0, parseValue_1.parseValue)(vaultFields.weight),
|
49
|
+
lastUpdate: (0, parseValue_1.parseValue)(vaultFields.last_update),
|
50
|
+
reservingFeeModel,
|
51
|
+
priceConfig: {
|
52
|
+
maxInterval: (0, parseValue_1.parseValue)(vaultFields.price_config.fields.max_interval),
|
53
|
+
maxConfidence: (0, parseValue_1.parseValue)(vaultFields.price_config.fields.max_confidence),
|
54
|
+
precision: (0, parseValue_1.parseValue)(vaultFields.price_config.fields.precision),
|
55
|
+
feeder: vaultFields.price_config.fields.feeder,
|
56
|
+
},
|
57
|
+
};
|
58
|
+
});
|
59
|
+
const parseReservingFeeModel = (raw) => {
|
60
|
+
const { fields } = raw.data.content;
|
61
|
+
return {
|
62
|
+
multiplier: (0, parseValue_1.parseValue)(fields.multiplier),
|
63
|
+
};
|
64
|
+
};
|
65
|
+
//# sourceMappingURL=getVaultInfo.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getVaultInfo.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/getVaultInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAqD;AAGrD,iFAA8E;AAC9E,2CAAwD;AACxD,yDAAsD;AACtD,6CAA0C;AAE1C,MAAM,UAAU,GAA4C,EAAE,CAAC;AAExD,MAAM,YAAY,GAAG,CAAO,MAAiB,EAAE,UAAkB,EAAE,EAAE;IAC1E,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,UAAU,CAAC,UAAU,CAAC,GAAG,IAAI,mBAAQ,CAAa,GAAS,EAAE;YAC3D,MAAM,OAAO,GAAG,MAAM,IAAA,6CAAqB,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iB;QACjB,WAAW,EAAE;YACX,WAAW,EAAE,IAAA,uBAAU,EAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC;YACrE,aAAa,EAAE,IAAA,uBAAU,EAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC;YACzE,SAAS,EAAE,IAAA,uBAAU,EAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;YAChE,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM;SAC/C;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,GAAQ,EAAsB,EAAE;IAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;IAEpC,OAAO;QACL,UAAU,EAAE,IAAA,uBAAU,EAAC,MAAM,CAAC,UAAU,CAAC;KAC1C,CAAC;AACJ,CAAC,CAAC"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { TokenPrice } from '@sonarwatch/portfolio-core';
|
2
|
+
import { SuiClient } from '../../utils/clients/types';
|
3
|
+
import { IMarketInfo, IOrderCapInfo, IOrderInfo, IPositionCapInfo, IPositionInfo } from './types';
|
4
|
+
import { Cache } from '../../Cache';
|
5
|
+
export declare const getPositionCapInfoList: (client: SuiClient, owner: string) => Promise<IPositionCapInfo[]>;
|
6
|
+
export declare const getPositionInfoList: (client: SuiClient, positionCapInfoList: IPositionCapInfo[], marketInfo: IMarketInfo, cache: Cache, owner: string) => Promise<IPositionInfo[]>;
|
7
|
+
export declare const getMarketInfo: (client: SuiClient) => Promise<IMarketInfo>;
|
8
|
+
export declare const getOrderCapInfoList: (client: SuiClient, owner: string) => Promise<{
|
9
|
+
orderCapId: string;
|
10
|
+
symbol0: string;
|
11
|
+
symbol1: string;
|
12
|
+
long: boolean;
|
13
|
+
positionId: any;
|
14
|
+
}[]>;
|
15
|
+
export declare const getOrderInfoList: (client: SuiClient, orderCapInfoList: IOrderCapInfo[], owner: string) => Promise<IOrderInfo[]>;
|
16
|
+
export declare const calculatePNL: (position: IPositionInfo, tokenPriceIndex: TokenPrice, tokenPriceCollateral: TokenPrice) => Promise<{
|
17
|
+
delta: number;
|
18
|
+
reservingFee: number;
|
19
|
+
fundingFee: number;
|
20
|
+
pnlValue: number;
|
21
|
+
pnlInCollateral: number;
|
22
|
+
pnlInCollateralPercentage: number;
|
23
|
+
openFee: number;
|
24
|
+
leverage: number;
|
25
|
+
}>;
|
@@ -0,0 +1,353 @@
|
|
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
|
+
exports.calculatePNL = exports.getOrderInfoList = exports.getOrderCapInfoList = exports.getMarketInfo = exports.getPositionInfoList = exports.getPositionCapInfoList = void 0;
|
16
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
18
|
+
const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
|
19
|
+
const constants_1 = require("./constants");
|
20
|
+
const getDynamicFieldObject_1 = require("../../utils/sui/getDynamicFieldObject");
|
21
|
+
const getObject_1 = require("../../utils/sui/getObject");
|
22
|
+
const getVaultInfo_1 = require("./getVaultInfo");
|
23
|
+
const parseValue_1 = require("./parseValue");
|
24
|
+
const getPositionCapInfoList = (client, owner) => __awaiter(void 0, void 0, void 0, function* () {
|
25
|
+
var _a, _b;
|
26
|
+
const positionCaps = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
|
27
|
+
filter: {
|
28
|
+
MoveModule: {
|
29
|
+
package: constants_1.corePackage,
|
30
|
+
module: 'market',
|
31
|
+
},
|
32
|
+
},
|
33
|
+
options: {
|
34
|
+
showType: true,
|
35
|
+
},
|
36
|
+
});
|
37
|
+
const positionCapInfoList = [];
|
38
|
+
for (const positionCap of positionCaps) {
|
39
|
+
if ((_b = (_a = positionCap.data) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.includes('PositionCap')) {
|
40
|
+
positionCapInfoList.push({
|
41
|
+
positionCapId: positionCap.data.objectId,
|
42
|
+
symbol0: positionCap.data.type.split('<')[1].split(',')[0].trim(),
|
43
|
+
symbol1: positionCap.data.type
|
44
|
+
.split('<')[1]
|
45
|
+
.split(',')[1]
|
46
|
+
.split(',')[0]
|
47
|
+
.trim(),
|
48
|
+
long: positionCap.data.type.includes('LONG'),
|
49
|
+
});
|
50
|
+
}
|
51
|
+
}
|
52
|
+
return positionCapInfoList;
|
53
|
+
});
|
54
|
+
exports.getPositionCapInfoList = getPositionCapInfoList;
|
55
|
+
const getPositionInfoList = (client, positionCapInfoList, marketInfo, cache, owner) => __awaiter(void 0, void 0, void 0, function* () {
|
56
|
+
const positionInfoList = [];
|
57
|
+
yield Promise.all(positionCapInfoList.map((positionCapInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
58
|
+
const positionRaw = yield (0, getDynamicFieldObject_1.getDynamicFieldObject)(client, {
|
59
|
+
parentId: constants_1.positionsParent,
|
60
|
+
name: {
|
61
|
+
type: `${constants_1.corePackage}::market::PositionName<${positionCapInfo.symbol0}, ${positionCapInfo.symbol1}, ${constants_1.corePackage}::market::${positionCapInfo.long ? 'LONG' : 'SHORT'}>`,
|
62
|
+
value: {
|
63
|
+
owner,
|
64
|
+
id: positionCapInfo.positionCapId,
|
65
|
+
},
|
66
|
+
},
|
67
|
+
});
|
68
|
+
positionInfoList.push(yield parsePositionInfo(client, marketInfo, cache, positionRaw, positionCapInfo.positionCapId));
|
69
|
+
})));
|
70
|
+
return positionInfoList.sort((a, b) => a.openTimestamp > b.openTimestamp ? 1 : -1);
|
71
|
+
});
|
72
|
+
exports.getPositionInfoList = getPositionInfoList;
|
73
|
+
const calculatePositionReserveFee = (position, vault, model, timestamp) => {
|
74
|
+
const accReservingRate = calcAccReservingFeeRate(vault, model, timestamp);
|
75
|
+
return (position.reservingFeeAmount +
|
76
|
+
(accReservingRate - vault.accReservingRate) * position.collateralAmount);
|
77
|
+
};
|
78
|
+
const calcAccReservingFeeRate = (vault, model, timestamp) => {
|
79
|
+
if (vault.lastUpdate > 0) {
|
80
|
+
const elapsed = timestamp - vault.lastUpdate;
|
81
|
+
if (elapsed > 0) {
|
82
|
+
const utilization = vaultUtilization(vault);
|
83
|
+
return (vault.accReservingRate +
|
84
|
+
calcReservingFeeRate(model, utilization, elapsed));
|
85
|
+
}
|
86
|
+
}
|
87
|
+
return vault.accReservingRate;
|
88
|
+
};
|
89
|
+
const vaultUtilization = (vault) => {
|
90
|
+
const supplyAmount = vault.liquidity + vault.reservedAmount + vault.unrealisedReservingFeeAmount;
|
91
|
+
if (supplyAmount === 0) {
|
92
|
+
return 0;
|
93
|
+
}
|
94
|
+
return vault.reservedAmount / supplyAmount;
|
95
|
+
};
|
96
|
+
const SECONDS_PER_EIGHT_HOUR = 8 * 60 * 60;
|
97
|
+
const calcReservingFeeRate = (model, utilization, elapsed) => (model.multiplier * utilization * elapsed) / SECONDS_PER_EIGHT_HOUR;
|
98
|
+
const calculatePositionFundingFee = (position, symbol, model, price, lpSupplyAmount, timestamp) => {
|
99
|
+
const accFundingRate = calcAccFundingFeeRate(symbol, model, price, lpSupplyAmount, timestamp);
|
100
|
+
return (position.fundingFeeValue +
|
101
|
+
(accFundingRate - symbol.accFundingRate) * position.positionSize);
|
102
|
+
};
|
103
|
+
const calcDeltaSize = (symbol, price) => {
|
104
|
+
const latestSize = (symbol.openingAmount / symbol.priceConfig.precision) * price;
|
105
|
+
return symbol.long
|
106
|
+
? symbol.openingSize - latestSize
|
107
|
+
: latestSize - symbol.openingSize;
|
108
|
+
};
|
109
|
+
const calcFundingFeeRate = (model, pnlPerRate, elapsed) => {
|
110
|
+
const dailyRate = Math.min(model.multiplier * Math.abs(pnlPerRate), model.max);
|
111
|
+
const secondsRate = (dailyRate * elapsed) / SECONDS_PER_EIGHT_HOUR;
|
112
|
+
return pnlPerRate >= 0 ? -secondsRate : secondsRate;
|
113
|
+
};
|
114
|
+
const calcAccFundingFeeRate = (symbol, model, price, lpSupplyAmount, timestamp) => {
|
115
|
+
if (symbol.lastUpdate > 0) {
|
116
|
+
const elapsed = timestamp - symbol.lastUpdate;
|
117
|
+
if (elapsed > 0) {
|
118
|
+
const deltaSize = calcDeltaSize(symbol, price);
|
119
|
+
const pnlPerLp = (symbol.realisedPnl + symbol.unrealisedFundingFeeValue + deltaSize) /
|
120
|
+
lpSupplyAmount;
|
121
|
+
return (symbol.accFundingRate + calcFundingFeeRate(model, pnlPerLp, elapsed));
|
122
|
+
}
|
123
|
+
}
|
124
|
+
return symbol.accFundingRate;
|
125
|
+
};
|
126
|
+
const parsePositionInfo = (client, marketInfo, cache, raw, id_) => __awaiter(void 0, void 0, void 0, function* () {
|
127
|
+
const { content } = raw.data;
|
128
|
+
const { fields } = content;
|
129
|
+
const positionFields = fields.value.fields;
|
130
|
+
const dataType = fields.name.type;
|
131
|
+
const positionInfo = {
|
132
|
+
id: id_,
|
133
|
+
long: dataType.includes('::market::LONG'),
|
134
|
+
owner: fields.name.fields.owner,
|
135
|
+
version: parseInt(raw.data.version, 10),
|
136
|
+
collateralToken: dataType.split('<')[1].split(',')[0].trim(),
|
137
|
+
indexToken: dataType.split(',')[1].trim(),
|
138
|
+
collateralAmount: (0, parseValue_1.parseValue)(positionFields.collateral),
|
139
|
+
positionAmount: (0, parseValue_1.parseValue)(positionFields.position_amount),
|
140
|
+
reservedAmount: (0, parseValue_1.parseValue)(positionFields.reserved),
|
141
|
+
positionSize: (0, parseValue_1.parseValue)(positionFields.position_size),
|
142
|
+
lastFundingRate: (0, parseValue_1.parseValue)(positionFields.last_funding_rate),
|
143
|
+
lastReservingRate: (0, parseValue_1.parseValue)(positionFields.last_reserving_rate),
|
144
|
+
reservingFeeAmount: (0, parseValue_1.parseValue)(positionFields.reserving_fee_amount),
|
145
|
+
fundingFeeValue: (0, parseValue_1.parseValue)(positionFields.funding_fee_value),
|
146
|
+
closed: positionFields.closed,
|
147
|
+
openTimestamp: (0, parseValue_1.parseValue)(positionFields.open_timestamp),
|
148
|
+
openFeeBps: (0, parseValue_1.parseValue)(positionFields.config.fields.open_fee_bps),
|
149
|
+
};
|
150
|
+
const vaultInfo = yield (0, getVaultInfo_1.getVaultInfo)(client, positionInfo.collateralToken);
|
151
|
+
positionInfo.reservingFeeAmount = calculatePositionReserveFee(positionInfo, vaultInfo, vaultInfo.reservingFeeModel, Date.now() / 1000);
|
152
|
+
const indexTokenPrice = yield cache.getTokenPrice(positionInfo.indexToken, portfolio_core_1.NetworkId.sui);
|
153
|
+
if (indexTokenPrice) {
|
154
|
+
positionInfo.fundingFeeValue = calculatePositionFundingFee(positionInfo, yield getSymbolInfo(client, positionInfo.indexToken, positionInfo.long), (yield getSymbolInfo(client, positionInfo.indexToken, positionInfo.long))
|
155
|
+
.fundingFeeModel, indexTokenPrice.price, marketInfo.lpSupplyWithDecimals, Date.now() / 1000);
|
156
|
+
}
|
157
|
+
return positionInfo;
|
158
|
+
});
|
159
|
+
const getMarketInfo = (client) => __awaiter(void 0, void 0, void 0, function* () {
|
160
|
+
const rawData = yield (0, getObject_1.getObject)(client, constants_1.abexMarket, {
|
161
|
+
showContent: true,
|
162
|
+
});
|
163
|
+
return parseMarketInfo(rawData);
|
164
|
+
});
|
165
|
+
exports.getMarketInfo = getMarketInfo;
|
166
|
+
const ALP_TOKEN_DECIMALS = 6;
|
167
|
+
const parseMarketInfo = (raw) => {
|
168
|
+
const content = raw.data.content.fields;
|
169
|
+
return {
|
170
|
+
lpSupply: content.lp_supply.fields.value,
|
171
|
+
positionId: content.positions.fields.id.id,
|
172
|
+
vaultId: content.vaults.fields.id.id,
|
173
|
+
symbolId: content.symbols.fields.id.id,
|
174
|
+
referralId: content.referrals.fields.id.id,
|
175
|
+
orderId: content.orders.fields.id.id,
|
176
|
+
rebaseFeeModel: content.rebase_fee_model,
|
177
|
+
lpSupplyWithDecimals: content.lp_supply.fields.value / Math.pow(10, ALP_TOKEN_DECIMALS),
|
178
|
+
};
|
179
|
+
};
|
180
|
+
const getSymbolInfo = (client, indexToken, long) => __awaiter(void 0, void 0, void 0, function* () {
|
181
|
+
const rawData = yield (0, getDynamicFieldObject_1.getDynamicFieldObject)(client, {
|
182
|
+
parentId: constants_1.symbolsParent,
|
183
|
+
name: {
|
184
|
+
type: `${constants_1.corePackage}::market::SymbolName<${indexToken}, ${constants_1.corePackage}::market::${long ? 'LONG' : 'SHORT'}>`,
|
185
|
+
value: { dummy_field: false },
|
186
|
+
},
|
187
|
+
});
|
188
|
+
return parseSymbolInfo(client, rawData, long);
|
189
|
+
});
|
190
|
+
const parseSymbolInfo = (client, raw, long) => __awaiter(void 0, void 0, void 0, function* () {
|
191
|
+
const { fields } = raw.data.content.fields.value;
|
192
|
+
const fundingFeeModelAddr = fields.funding_fee_model;
|
193
|
+
const fundingFeeModelRaw = yield (0, getObject_1.getObject)(client, fundingFeeModelAddr, {
|
194
|
+
showContent: true,
|
195
|
+
});
|
196
|
+
const fundingFeeModel = parseFundingFeeModel(fundingFeeModelRaw);
|
197
|
+
return {
|
198
|
+
openingSize: (0, parseValue_1.parseValue)(fields.opening_size),
|
199
|
+
openingAmount: (0, parseValue_1.parseValue)(fields.opening_amount),
|
200
|
+
accFundingRate: (0, parseValue_1.parseValue)(fields.acc_funding_rate),
|
201
|
+
realisedPnl: (0, parseValue_1.parseValue)(fields.realised_pnl),
|
202
|
+
unrealisedFundingFeeValue: (0, parseValue_1.parseValue)(fields.unrealised_funding_fee_value),
|
203
|
+
openEnabled: fields.open_enabled,
|
204
|
+
liquidateEnabled: fields.liquidate_enabled,
|
205
|
+
decreaseEnabled: fields.decrease_enabled,
|
206
|
+
lastUpdate: (0, parseValue_1.parseValue)(fields.last_update),
|
207
|
+
fundingFeeModel,
|
208
|
+
long,
|
209
|
+
priceConfig: {
|
210
|
+
maxInterval: (0, parseValue_1.parseValue)(fields.price_config.fields.max_interval),
|
211
|
+
maxConfidence: (0, parseValue_1.parseValue)(fields.price_config.fields.max_confidence),
|
212
|
+
precision: (0, parseValue_1.parseValue)(fields.price_config.fields.precision),
|
213
|
+
feeder: fields.price_config.fields.feeder,
|
214
|
+
},
|
215
|
+
};
|
216
|
+
});
|
217
|
+
const parseFundingFeeModel = (raw) => {
|
218
|
+
const { fields } = raw.data.content;
|
219
|
+
return {
|
220
|
+
multiplier: (0, parseValue_1.parseValue)(fields.multiplier),
|
221
|
+
max: (0, parseValue_1.parseValue)(fields.max),
|
222
|
+
};
|
223
|
+
};
|
224
|
+
const getOrderCapInfoList = (client, owner) => __awaiter(void 0, void 0, void 0, function* () {
|
225
|
+
var _c, _d, _e, _f;
|
226
|
+
const orderCaps = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
|
227
|
+
filter: {
|
228
|
+
MoveModule: {
|
229
|
+
package: constants_1.corePackage,
|
230
|
+
module: 'market',
|
231
|
+
},
|
232
|
+
},
|
233
|
+
options: {
|
234
|
+
showType: true,
|
235
|
+
showContent: true,
|
236
|
+
},
|
237
|
+
});
|
238
|
+
const orderCapInfoList = [];
|
239
|
+
for (const orderCap of orderCaps) {
|
240
|
+
if ((_d = (_c = orderCap.data) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.includes('OrderCap')) {
|
241
|
+
orderCapInfoList.push({
|
242
|
+
orderCapId: orderCap.data.objectId,
|
243
|
+
symbol0: orderCap.data.type.split('<')[1].split(',')[0].trim(),
|
244
|
+
symbol1: orderCap.data.type
|
245
|
+
.split('<')[1]
|
246
|
+
.split(',')[1]
|
247
|
+
.split(',')[0]
|
248
|
+
.trim(),
|
249
|
+
long: orderCap.data.type.includes('LONG'),
|
250
|
+
positionId: (_f = (_e = orderCap.data.content) === null || _e === void 0 ? void 0 : _e.fields) === null || _f === void 0 ? void 0 : _f.position_id,
|
251
|
+
});
|
252
|
+
}
|
253
|
+
}
|
254
|
+
return orderCapInfoList;
|
255
|
+
});
|
256
|
+
exports.getOrderCapInfoList = getOrderCapInfoList;
|
257
|
+
const getOrderInfoList = (client, orderCapInfoList, owner) => __awaiter(void 0, void 0, void 0, function* () {
|
258
|
+
const orderInfoList = [];
|
259
|
+
yield Promise.all(orderCapInfoList.map((orderCapInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
260
|
+
const orderRaw = yield (0, getDynamicFieldObject_1.getDynamicFieldObject)(client, {
|
261
|
+
parentId: constants_1.ordersParent,
|
262
|
+
name: {
|
263
|
+
type: `${constants_1.corePackage}::market::OrderName<${orderCapInfo.symbol0}, ${orderCapInfo.symbol1}, ${constants_1.corePackage}::market::${orderCapInfo.long ? 'LONG' : 'SHORT'}, ${portfolio_core_1.suiNativeAddress}>`,
|
264
|
+
value: {
|
265
|
+
owner,
|
266
|
+
id: orderCapInfo.orderCapId,
|
267
|
+
position_id: {
|
268
|
+
vec: orderCapInfo.positionId ? [orderCapInfo.positionId] : [],
|
269
|
+
},
|
270
|
+
},
|
271
|
+
},
|
272
|
+
});
|
273
|
+
orderInfoList.push(parseOrderInfo(orderRaw, orderCapInfo.orderCapId));
|
274
|
+
})));
|
275
|
+
return orderInfoList.sort((a, b) => (a.createdAt > b.createdAt ? 1 : -1));
|
276
|
+
});
|
277
|
+
exports.getOrderInfoList = getOrderInfoList;
|
278
|
+
const parseOrderInfo = (raw, capId) => {
|
279
|
+
const { content } = raw.data;
|
280
|
+
const { fields } = content.fields.value;
|
281
|
+
// Extract tokens from dataType
|
282
|
+
const dataType = content.type;
|
283
|
+
const orderType = content.fields.value.type.includes('OpenPositionOrder')
|
284
|
+
? 'OPEN_POSITION'
|
285
|
+
: 'DECREASE_POSITION';
|
286
|
+
const ret = {
|
287
|
+
id: content.fields.id.id,
|
288
|
+
capId,
|
289
|
+
executed: fields.executed,
|
290
|
+
owner: content.fields.name.fields.owner,
|
291
|
+
collateralToken: dataType.split('<')[2].split(',')[0].trim(),
|
292
|
+
indexToken: dataType.split(',')[1].trim(),
|
293
|
+
feeToken: dataType.split(',')[3].split('>')[0].trim(),
|
294
|
+
indexPrice: (0, parseValue_1.parseValue)(fields.limited_index_price.fields.price || fields.limited_index_price),
|
295
|
+
collateralPriceThreshold: (0, parseValue_1.parseValue)(fields.collateral_price_threshold),
|
296
|
+
feeAmount: (0, bignumber_js_1.default)(fields.fee),
|
297
|
+
long: dataType.includes('::market::LONG'),
|
298
|
+
orderType,
|
299
|
+
createdAt: (0, parseValue_1.parseValue)(fields.created_at),
|
300
|
+
v11Order: !fields.limited_index_price.fields.price,
|
301
|
+
};
|
302
|
+
if (orderType === 'OPEN_POSITION') {
|
303
|
+
ret.openOrder = {
|
304
|
+
reserveAmount: (0, bignumber_js_1.default)(fields.reserve_amount),
|
305
|
+
collateralAmount: (0, bignumber_js_1.default)(fields.collateral),
|
306
|
+
openAmount: (0, bignumber_js_1.default)(fields.open_amount),
|
307
|
+
};
|
308
|
+
}
|
309
|
+
else {
|
310
|
+
ret.decreaseOrder = {
|
311
|
+
decreaseAmount: (0, bignumber_js_1.default)(fields.decrease_amount),
|
312
|
+
takeProfit: fields.take_profit,
|
313
|
+
};
|
314
|
+
}
|
315
|
+
return ret;
|
316
|
+
};
|
317
|
+
const calculatePNL = (position, tokenPriceIndex, tokenPriceCollateral) => __awaiter(void 0, void 0, void 0, function* () {
|
318
|
+
// Size = indexTokenPrice * indexTokenAmount
|
319
|
+
// OpenFee = EntrySize * openFeeBps
|
320
|
+
// ReservingFee = accReservingRate ???
|
321
|
+
// FundingFee = accFundingRate ???
|
322
|
+
// $PNL = Size - EntrySize - OpenFee - ReservingFee - FundingFee
|
323
|
+
// PNL% ???
|
324
|
+
const indexPrice = tokenPriceIndex.price;
|
325
|
+
const collateralPrice = tokenPriceCollateral.price;
|
326
|
+
const size = (indexPrice * position.positionAmount) / Math.pow(10, tokenPriceIndex.decimals);
|
327
|
+
const openFee = position.positionSize * position.openFeeBps;
|
328
|
+
const reservingFee = (position.reservingFeeAmount * collateralPrice) /
|
329
|
+
Math.pow(10, tokenPriceCollateral.decimals);
|
330
|
+
const fundingFee = position.fundingFeeValue;
|
331
|
+
const delta = (size - position.positionSize) * (position.long ? 1 : -1);
|
332
|
+
const pnlValue = delta - openFee - reservingFee - fundingFee;
|
333
|
+
const pnlInCollateral = pnlValue / collateralPrice;
|
334
|
+
const pnlInCollateralPercentage = (pnlInCollateral / position.collateralAmount) *
|
335
|
+
Math.pow(10, tokenPriceCollateral.decimals);
|
336
|
+
const leverage = ((position.positionAmount * indexPrice) / Math.pow(10, tokenPriceIndex.decimals) -
|
337
|
+
pnlValue +
|
338
|
+
openFee) /
|
339
|
+
((position.collateralAmount * collateralPrice) /
|
340
|
+
Math.pow(10, tokenPriceCollateral.decimals));
|
341
|
+
return {
|
342
|
+
delta,
|
343
|
+
reservingFee,
|
344
|
+
fundingFee,
|
345
|
+
pnlValue,
|
346
|
+
pnlInCollateral,
|
347
|
+
pnlInCollateralPercentage,
|
348
|
+
openFee,
|
349
|
+
leverage,
|
350
|
+
};
|
351
|
+
});
|
352
|
+
exports.calculatePNL = calculatePNL;
|
353
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/helpers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,GAAG,QAAQ,CAAC,gBAAgB,CAAC;QAC7C,SAAA,EAAE,EAAI,oBAAoB,CAAC,QAAQ,CAAA,CAAC;IAEtC,MAAM,QAAQ,GACZ,CAAC,CAAC,QAAQ,CAAC,cAAc,GAAG,UAAU,CAAC,GAAG,SAAA,EAAE,EAAI,eAAe,CAAC,QAAQ,CAAA;QACtE,QAAQ;QACR,OAAO,CAAC;QACV,CAAC,CAAC,QAAQ,CAAC,gBAAgB,GAAG,eAAe,CAAC;YAC5C,SAAA,EAAE,EAAI,oBAAoB,CAAC,QAAQ,CAAA,CAAC,CAAC;IAEzC,OAAO;QACL,KAAK;QACL,YAAY;QACZ,UAAU;QACV,QAAQ;QACR,eAAe;QACf,yBAAyB;QACzB,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC,CAAA,CAAC;AA9CW,QAAA,YAAY,gBA8CvB"}
|
@@ -6,8 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fetchers = exports.jobs = exports.platforms = void 0;
|
7
7
|
const constants_1 = require("./constants");
|
8
8
|
const marketsJob_1 = __importDefault(require("./marketsJob"));
|
9
|
+
const stakingFetcher_1 = __importDefault(require("./stakingFetcher"));
|
9
10
|
const positionsFetcher_1 = __importDefault(require("./positionsFetcher"));
|
11
|
+
const ordersFetcher_1 = __importDefault(require("./ordersFetcher"));
|
10
12
|
exports.platforms = [constants_1.platform];
|
11
13
|
exports.jobs = [marketsJob_1.default];
|
12
|
-
exports.fetchers = [
|
14
|
+
exports.fetchers = [
|
15
|
+
stakingFetcher_1.default,
|
16
|
+
positionsFetcher_1.default,
|
17
|
+
ordersFetcher_1.default,
|
18
|
+
];
|
13
19
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,8DAAsC;AACtC,0EAAkD;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,8DAAsC;AACtC,sEAA8C;AAC9C,0EAAkD;AAClD,oEAA4C;AAE/B,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,oBAAU,CAAC,CAAC;AAC3B,QAAA,QAAQ,GAAc;IACjC,wBAAc;IACd,0BAAgB;IAChB,uBAAa;CACd,CAAC"}
|
@@ -21,9 +21,19 @@ const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
|
|
21
21
|
const getLpTokenSourceRawOld_1 = __importDefault(require("../../utils/misc/getLpTokenSourceRawOld"));
|
22
22
|
const getObject_1 = require("../../utils/sui/getObject");
|
23
23
|
const constants_2 = require("../tokens/constants");
|
24
|
+
const helpers_1 = require("./helpers");
|
24
25
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
25
|
-
var _a, _b, _c, _d, _e, _f
|
26
|
+
var _a, _b, _c, _d, _e, _f;
|
26
27
|
const client = (0, clients_1.getClientSui)();
|
28
|
+
// Abex market
|
29
|
+
const marketInfo = yield (0, helpers_1.getMarketInfo)(client);
|
30
|
+
const { lpSupply } = marketInfo;
|
31
|
+
if (!lpSupply)
|
32
|
+
return;
|
33
|
+
yield cache.setItem(constants_1.abexMarketCacheKey, marketInfo, {
|
34
|
+
prefix: constants_1.platformId,
|
35
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
36
|
+
});
|
27
37
|
// Pool
|
28
38
|
const poolObject = yield (0, getObject_1.getObject)(client, constants_1.poolObjectId);
|
29
39
|
const accRewardPerShare = (_b = (_a = poolObject.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.acc_reward_per_share;
|
@@ -33,10 +43,6 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
43
|
networkId: portfolio_core_1.NetworkId.sui,
|
34
44
|
});
|
35
45
|
}
|
36
|
-
const lpObject = yield (0, getObject_1.getObject)(client, constants_1.alpSupplyObjectId);
|
37
|
-
const lpSupply = (_d = (_c = lpObject.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.lp_supply.fields.value;
|
38
|
-
if (!lpSupply)
|
39
|
-
return;
|
40
46
|
const depositVaultFields = yield (0, getDynamicFields_1.getDynamicFields)(client, constants_1.depositVaultRegistry);
|
41
47
|
const objects = yield (0, multiGetObjects_1.multiGetObjects)(client, depositVaultFields.map((f) => f.objectId));
|
42
48
|
const uTypes = [];
|
@@ -54,10 +60,10 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
60
|
const lpUnderlyings = [];
|
55
61
|
for (let i = 0; i < objects.length; i++) {
|
56
62
|
const object = objects[i];
|
57
|
-
const market = (
|
63
|
+
const market = (_d = (_c = object.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields;
|
58
64
|
if (!market)
|
59
65
|
return;
|
60
|
-
const uType = (
|
66
|
+
const uType = (_f = (_e = (0, portfolio_core_1.parseTypeString)(market.value.type).keys) === null || _e === void 0 ? void 0 : _e.at(0)) === null || _f === void 0 ? void 0 : _f.type;
|
61
67
|
if (!uType)
|
62
68
|
return;
|
63
69
|
const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(uType, portfolio_core_1.NetworkId.sui));
|