@sonarwatch/portfolio-plugins 0.14.46 → 0.14.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/plugins/bluefin/clmmsFetcher.d.ts +3 -0
- package/src/plugins/bluefin/clmmsFetcher.js +85 -0
- package/src/plugins/bluefin/clmmsFetcher.js.map +1 -0
- package/src/plugins/bluefin/clmmsJob.d.ts +3 -0
- package/src/plugins/bluefin/clmmsJob.js +45 -0
- package/src/plugins/bluefin/clmmsJob.js.map +1 -0
- package/src/plugins/bluefin/constants.d.ts +5 -0
- package/src/plugins/bluefin/constants.js +6 -1
- package/src/plugins/bluefin/constants.js.map +1 -1
- package/src/plugins/bluefin/helpers.d.ts +7 -0
- package/src/plugins/bluefin/helpers.js +65 -0
- package/src/plugins/bluefin/helpers.js.map +1 -0
- package/src/plugins/bluefin/index.js +9 -2
- package/src/plugins/bluefin/index.js.map +1 -1
- package/src/plugins/bluefin/types.d.ts +76 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.14.47](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.46...plugins-0.14.47) (2024-11-28)
|
6
|
+
|
7
|
+
|
8
|
+
|
5
9
|
## [0.14.46](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.45...plugins-0.14.46) (2024-11-28)
|
6
10
|
|
7
11
|
|
package/package.json
CHANGED
@@ -0,0 +1,85 @@
|
|
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 getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
|
16
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
17
|
+
const bitsToNumber_1 = require("../../utils/sui/bitsToNumber");
|
18
|
+
const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
|
19
|
+
const helpers_1 = require("./helpers");
|
20
|
+
const poolsMemo = new MemoizedCache_1.MemoizedCache(constants_1.clmmsPoolsKey, {
|
21
|
+
prefix: constants_1.platformId,
|
22
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
23
|
+
});
|
24
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
25
|
+
var _a, _b, _c, _d, _e;
|
26
|
+
const client = (0, clients_1.getClientSui)();
|
27
|
+
const objects = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
|
28
|
+
filter: {
|
29
|
+
StructType: constants_1.clmmPoolPositionType,
|
30
|
+
},
|
31
|
+
});
|
32
|
+
if (objects.length === 0)
|
33
|
+
return [];
|
34
|
+
const pools = yield poolsMemo.getItem(cache);
|
35
|
+
if (!pools)
|
36
|
+
return [];
|
37
|
+
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
|
38
|
+
for (const clmmPosition of objects) {
|
39
|
+
if (!((_a = clmmPosition.data) === null || _a === void 0 ? void 0 : _a.content))
|
40
|
+
continue;
|
41
|
+
const pool = pools.find((p) => {
|
42
|
+
var _a, _b, _c, _d;
|
43
|
+
return ((_b = (_a = p === null || p === void 0 ? void 0 : p.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.id.id) ===
|
44
|
+
((_d = (_c = clmmPosition.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.pool_id);
|
45
|
+
});
|
46
|
+
if (!pool || !((_b = pool.data) === null || _b === void 0 ? void 0 : _b.content))
|
47
|
+
continue;
|
48
|
+
const feesAndRewards = yield (0, helpers_1.getAccruedFeeAndRewards)(clmmPosition.data.content.fields.coin_type_a, clmmPosition.data.content.fields.coin_type_b, pool.data.content.fields.id.id, clmmPosition.data.content.fields.id.id, pool.data.content.fields.reward_infos.map((r) => r.fields.reward_coin_type), owner);
|
49
|
+
const element = elementRegistry.addElementConcentratedLiquidity();
|
50
|
+
const liquidity = element.setLiquidity({
|
51
|
+
addressA: clmmPosition.data.content.fields.coin_type_a,
|
52
|
+
addressB: clmmPosition.data.content.fields.coin_type_b,
|
53
|
+
liquidity: clmmPosition.data.content.fields.liquidity,
|
54
|
+
tickCurrentIndex: (0, bitsToNumber_1.bitsToNumber)(pool.data.content.fields.current_tick_index.fields.bits),
|
55
|
+
tickLowerIndex: (0, bitsToNumber_1.bitsToNumber)(clmmPosition.data.content.fields.lower_tick.fields.bits),
|
56
|
+
tickUpperIndex: (0, bitsToNumber_1.bitsToNumber)(clmmPosition.data.content.fields.upper_tick.fields.bits),
|
57
|
+
currentSqrtPrice: pool.data.content.fields.current_sqrt_price,
|
58
|
+
poolLiquidity: pool.data.content.fields.liquidity,
|
59
|
+
feeRate: Number(pool.data.content.fields.fee_rate) / 10000,
|
60
|
+
swapVolume24h: (_c = pool.stats) === null || _c === void 0 ? void 0 : _c.day.volume,
|
61
|
+
});
|
62
|
+
liquidity.addRewardAsset({
|
63
|
+
address: clmmPosition.data.content.fields.coin_type_a,
|
64
|
+
amount: (_d = feesAndRewards === null || feesAndRewards === void 0 ? void 0 : feesAndRewards.fee) === null || _d === void 0 ? void 0 : _d.coinA,
|
65
|
+
});
|
66
|
+
liquidity.addRewardAsset({
|
67
|
+
address: clmmPosition.data.content.fields.coin_type_b,
|
68
|
+
amount: (_e = feesAndRewards === null || feesAndRewards === void 0 ? void 0 : feesAndRewards.fee) === null || _e === void 0 ? void 0 : _e.coinB,
|
69
|
+
});
|
70
|
+
pool.data.content.fields.reward_infos.forEach((reward, i) => {
|
71
|
+
liquidity.addRewardAsset({
|
72
|
+
address: reward.fields.reward_coin_type,
|
73
|
+
amount: feesAndRewards === null || feesAndRewards === void 0 ? void 0 : feesAndRewards.rewards[i],
|
74
|
+
});
|
75
|
+
});
|
76
|
+
}
|
77
|
+
return elementRegistry.getElements(cache);
|
78
|
+
});
|
79
|
+
const fetcher = {
|
80
|
+
id: `${constants_1.platformId}-clmms`,
|
81
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
82
|
+
executor,
|
83
|
+
};
|
84
|
+
exports.default = fetcher;
|
85
|
+
//# sourceMappingURL=clmmsFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"clmmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluefin/clmmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAA8E;AAC9E,iDAAmD;AAEnD,qEAAkE;AAClE,gFAA6E;AAC7E,+DAA4D;AAC5D,kEAA+D;AAE/D,uCAAoD;AAEpD,MAAM,SAAS,GAAG,IAAI,6BAAa,CAEjC,yBAAa,EAAE;IACf,MAAM,EAAE,sBAAU;IAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;CACzB,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAe,EAAe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YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW;YACrD,MAAM,EAAE,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,0CAAE,KAAK;SACnC,CAAC,CAAC;QAEH,SAAS,CAAC,cAAc,CAAC;YACvB,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW;YACrD,MAAM,EAAE,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,0CAAE,KAAK;SACnC,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1D,SAAS,CAAC,cAAc,CAAC;gBACvB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB;gBACvC,MAAM,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,CAAC,CAAC,CAAC;aACnC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,45 @@
|
|
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 axios_1 = __importDefault(require("axios"));
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const clients_1 = require("../../utils/clients");
|
19
|
+
const queryEventsSafe_1 = require("../../utils/sui/queryEventsSafe");
|
20
|
+
const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
|
21
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
22
|
+
const client = (0, clients_1.getClientSui)();
|
23
|
+
const poolCreatedEvents = yield (0, queryEventsSafe_1.queryEventsSafe)(client, {
|
24
|
+
MoveEventType: constants_1.clmmPoolCreatedEventType,
|
25
|
+
});
|
26
|
+
const poolIds = poolCreatedEvents.map((e) => { var _a; return (_a = e.parsedJson) === null || _a === void 0 ? void 0 : _a.id; });
|
27
|
+
const [pools, apiRes] = yield Promise.all([
|
28
|
+
(0, multiGetObjects_1.multiGetObjects)(client, poolIds),
|
29
|
+
axios_1.default.get(constants_1.clmmPoolsApiUrl).catch(() => null), // fail silently
|
30
|
+
]);
|
31
|
+
yield cache.setItem(constants_1.clmmsPoolsKey, pools.map((p) => {
|
32
|
+
const poolStat = apiRes === null || apiRes === void 0 ? void 0 : apiRes.data.find((s) => { var _a; return ((_a = p.data) === null || _a === void 0 ? void 0 : _a.content) && s.address === p.data.content.fields.id.id; });
|
33
|
+
return Object.assign(Object.assign({}, p), { stats: Object.assign({}, poolStat) });
|
34
|
+
}), {
|
35
|
+
prefix: constants_1.platformId,
|
36
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
37
|
+
});
|
38
|
+
});
|
39
|
+
const job = {
|
40
|
+
id: `${constants_1.platformId}-clmms`,
|
41
|
+
executor,
|
42
|
+
label: 'normal',
|
43
|
+
};
|
44
|
+
exports.default = job;
|
45
|
+
//# sourceMappingURL=clmmsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"clmmsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluefin/clmmsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,kDAA0B;AAG1B,2CAKqB;AACrB,iDAAmD;AAEnD,qEAAkE;AAClE,qEAAkE;AAElE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,iBAAiB,GAAG,MAAM,IAAA,iCAAe,EAE5C,MAAM,EAAE;QACT,aAAa,EAAE,oCAAwB;KACxC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,UAAU,0CAAE,EAAE,CAAA,EAAA,CAAa,CAAC;IAE3E,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACxC,IAAA,iCAAe,EAAW,MAAM,EAAE,OAAO,CAAC;QAC1C,eAAK,CAAC,GAAG,CAAiB,2BAAe,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB;KAC/E,CAAC,CAAC;IAEH,MAAM,KAAK,CAAC,OAAO,CACjB,yBAAa,EACb,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,MAAM,QAAQ,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,IAAI,CAChC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,CAAC,CAAC,IAAI,0CAAE,OAAO,KAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA,EAAA,CACpE,CAAC;QACF,uCAAY,CAAC,KAAE,KAAK,oBAAO,QAAQ,KAAK;IAC1C,CAAC,CAAC,EACF;QACE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF,kBAAe,GAAG,CAAC"}
|
@@ -6,3 +6,8 @@ export declare const bankObjectId = "0x39c65abefaee0a18ffa0e059a0074fcc9910216fa
|
|
6
6
|
export declare const poolKey = "pool";
|
7
7
|
export declare const perpetualIdsKey = "perpetualIdsKey";
|
8
8
|
export declare const metaUrl = "https://dapi.api.sui-prod.bluefin.io/meta";
|
9
|
+
export declare const clmmsPoolsKey = "clmms-pools";
|
10
|
+
export declare const clmmPoolCreatedEventType = "0x3492c874c1e3b3e2984e8c41b589e642d4d0a5d6459e5a9cfc2d52fd7c89c267::events::PoolCreated";
|
11
|
+
export declare const clmmPoolsApiUrl = "https://swap.api.sui-prod.bluefin.io/api/v1/pools/info";
|
12
|
+
export declare const clmmPoolPositionType = "0x3492c874c1e3b3e2984e8c41b589e642d4d0a5d6459e5a9cfc2d52fd7c89c267::position::Position";
|
13
|
+
export declare const clmmPackage = "0xa31282fc0a0ad50cf5f20908cfbb1539a143f5a38912eb8823a8dd6cbf98bc44";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.metaUrl = exports.perpetualIdsKey = exports.poolKey = exports.bankObjectId = exports.aquaVault = exports.platform = exports.platformId = void 0;
|
3
|
+
exports.clmmPackage = exports.clmmPoolPositionType = exports.clmmPoolsApiUrl = exports.clmmPoolCreatedEventType = exports.clmmsPoolsKey = exports.metaUrl = exports.perpetualIdsKey = exports.poolKey = exports.bankObjectId = exports.aquaVault = exports.platform = exports.platformId = void 0;
|
4
4
|
exports.platformId = 'bluefin';
|
5
5
|
exports.platform = {
|
6
6
|
id: exports.platformId,
|
@@ -15,4 +15,9 @@ exports.bankObjectId = '0x39c65abefaee0a18ffa0e059a0074fcc9910216fa1a3550aa32c2e
|
|
15
15
|
exports.poolKey = 'pool';
|
16
16
|
exports.perpetualIdsKey = 'perpetualIdsKey';
|
17
17
|
exports.metaUrl = 'https://dapi.api.sui-prod.bluefin.io/meta';
|
18
|
+
exports.clmmsPoolsKey = 'clmms-pools';
|
19
|
+
exports.clmmPoolCreatedEventType = `0x3492c874c1e3b3e2984e8c41b589e642d4d0a5d6459e5a9cfc2d52fd7c89c267::events::PoolCreated`;
|
20
|
+
exports.clmmPoolsApiUrl = `https://swap.api.sui-prod.bluefin.io/api/v1/pools/info`;
|
21
|
+
exports.clmmPoolPositionType = '0x3492c874c1e3b3e2984e8c41b589e642d4d0a5d6459e5a9cfc2d52fd7c89c267::position::Position';
|
22
|
+
exports.clmmPackage = '0xa31282fc0a0ad50cf5f20908cfbb1539a143f5a38912eb8823a8dd6cbf98bc44';
|
18
23
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluefin/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,SAAS,CAAC;AACvB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,gDAAgD;IACvD,WAAW,EAAE,SAAS,EAAE,sCAAsC;IAC9D,OAAO,EAAE,2BAA2B;IACpC,OAAO,EAAE,0BAA0B;CACpC,CAAC;AAEW,QAAA,SAAS,GACpB,oEAAoE,CAAC;AAE1D,QAAA,YAAY,GACvB,oEAAoE,CAAC;AAE1D,QAAA,OAAO,GAAG,MAAM,CAAC;AACjB,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAEpC,QAAA,OAAO,GAAG,2CAA2C,CAAC"}
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluefin/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,SAAS,CAAC;AACvB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,gDAAgD;IACvD,WAAW,EAAE,SAAS,EAAE,sCAAsC;IAC9D,OAAO,EAAE,2BAA2B;IACpC,OAAO,EAAE,0BAA0B;CACpC,CAAC;AAEW,QAAA,SAAS,GACpB,oEAAoE,CAAC;AAE1D,QAAA,YAAY,GACvB,oEAAoE,CAAC;AAE1D,QAAA,OAAO,GAAG,MAAM,CAAC;AACjB,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAEpC,QAAA,OAAO,GAAG,2CAA2C,CAAC;AAEtD,QAAA,aAAa,GAAG,aAAa,CAAC;AAC9B,QAAA,wBAAwB,GAAG,yFAAyF,CAAC;AACrH,QAAA,eAAe,GAAG,wDAAwD,CAAC;AAC3E,QAAA,oBAAoB,GAC/B,wFAAwF,CAAC;AAC9E,QAAA,WAAW,GACtB,oEAAoE,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.getAccruedFeeAndRewards = void 0;
|
13
|
+
const transactions_1 = require("@mysten/sui/transactions");
|
14
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
15
|
+
const clients_1 = require("../../utils/clients");
|
16
|
+
const helpers_1 = require("../mole/helpers");
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const getAccruedFeeAndRewards = (coinA, coinB, poolId, positionId, rewards, owner) => __awaiter(void 0, void 0, void 0, function* () {
|
19
|
+
const tx = new transactions_1.Transaction();
|
20
|
+
rewards.forEach((reward) => {
|
21
|
+
tx.moveCall({
|
22
|
+
arguments: [
|
23
|
+
tx.object(portfolio_core_1.suiClockAddress),
|
24
|
+
tx.object(poolId),
|
25
|
+
tx.object(positionId),
|
26
|
+
],
|
27
|
+
target: `${constants_1.clmmPackage}::pool::get_accrued_rewards`,
|
28
|
+
typeArguments: [coinA, coinB, reward],
|
29
|
+
});
|
30
|
+
});
|
31
|
+
tx.moveCall({
|
32
|
+
arguments: [
|
33
|
+
tx.object(portfolio_core_1.suiClockAddress),
|
34
|
+
tx.object(poolId),
|
35
|
+
tx.object(positionId),
|
36
|
+
],
|
37
|
+
target: `${constants_1.clmmPackage}::pool::get_accrued_fee`,
|
38
|
+
typeArguments: [coinA, coinB],
|
39
|
+
});
|
40
|
+
const simulateRes = yield (0, clients_1.getClientSui)().devInspectTransactionBlock({
|
41
|
+
transactionBlock: tx,
|
42
|
+
sender: owner,
|
43
|
+
});
|
44
|
+
if (!simulateRes.results)
|
45
|
+
return null;
|
46
|
+
const { returnValues } = simulateRes.results[simulateRes.results.length - 1];
|
47
|
+
if (!returnValues)
|
48
|
+
return null;
|
49
|
+
return {
|
50
|
+
rewards: rewards.map((reward, i) => {
|
51
|
+
if (!simulateRes.results)
|
52
|
+
return null;
|
53
|
+
const { returnValues: rewardReturnValues } = simulateRes.results[i];
|
54
|
+
if (!rewardReturnValues)
|
55
|
+
return null;
|
56
|
+
return (0, helpers_1.serializeReturnValue)(rewardReturnValues[0]);
|
57
|
+
}),
|
58
|
+
fee: {
|
59
|
+
coinA: (0, helpers_1.serializeReturnValue)(returnValues[0]),
|
60
|
+
coinB: (0, helpers_1.serializeReturnValue)(returnValues[1]),
|
61
|
+
},
|
62
|
+
};
|
63
|
+
});
|
64
|
+
exports.getAccruedFeeAndRewards = getAccruedFeeAndRewards;
|
65
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluefin/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuD;AACvD,+DAA6D;AAC7D,iDAAmD;AACnD,6CAAuD;AACvD,2CAA0C;AAEnC,MAAM,uBAAuB,GAAG,CACrC,KAAa,EACb,KAAa,EACb,MAAc,EACd,UAAkB,EAClB,OAAiB,EACjB,KAAa,EACb,EAAE;IACF,MAAM,EAAE,GAAG,IAAI,0BAAW,EAAE,CAAC;IAE7B,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACzB,EAAE,CAAC,QAAQ,CAAC;YACV,SAAS,EAAE;gBACT,EAAE,CAAC,MAAM,CAAC,gCAAe,CAAC;gBAC1B,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;gBACjB,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;aACtB;YACD,MAAM,EAAE,GAAG,uBAAW,6BAA6B;YACnD,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;SACtC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,QAAQ,CAAC;QACV,SAAS,EAAE;YACT,EAAE,CAAC,MAAM,CAAC,gCAAe,CAAC;YAC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
const bankFetcher_1 = __importDefault(require("./bankFetcher"));
|
11
11
|
const positionFetcher_1 = __importDefault(require("./positionFetcher"));
|
12
12
|
const perpsJob_1 = __importDefault(require("./perpsJob"));
|
13
|
+
const clmmsFetcher_1 = __importDefault(require("./clmmsFetcher"));
|
14
|
+
const clmmsJob_1 = __importDefault(require("./clmmsJob"));
|
13
15
|
exports.platforms = [constants_1.platform];
|
14
|
-
exports.jobs = [poolJob_1.default, perpsJob_1.default];
|
15
|
-
exports.fetchers = [
|
16
|
+
exports.jobs = [poolJob_1.default, perpsJob_1.default, clmmsJob_1.default];
|
17
|
+
exports.fetchers = [
|
18
|
+
poolFetcher_1.default,
|
19
|
+
bankFetcher_1.default,
|
20
|
+
positionFetcher_1.default,
|
21
|
+
clmmsFetcher_1.default,
|
22
|
+
];
|
16
23
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluefin/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,gEAAwC;AACxC,wDAAgC;AAChC,gEAAwC;AACxC,wEAAgD;AAChD,0DAAkC;AAErB,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,iBAAO,EAAE,kBAAQ,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluefin/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,gEAAwC;AACxC,wDAAgC;AAChC,gEAAwC;AACxC,wEAAgD;AAChD,0DAAkC;AAClC,kEAA0C;AAC1C,0DAAkC;AAErB,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,iBAAO,EAAE,kBAAQ,EAAE,kBAAQ,CAAC,CAAC;AAC5C,QAAA,QAAQ,GAAc;IACjC,qBAAW;IACX,qBAAW;IACX,yBAAe;IACf,sBAAY;CACb,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { ID } from '../../utils/sui/structs/id';
|
1
2
|
export type Vault = {
|
2
3
|
name: string;
|
3
4
|
users: {
|
@@ -86,3 +87,78 @@ export type PerpetualMeta = {
|
|
86
87
|
dataType: string;
|
87
88
|
};
|
88
89
|
};
|
90
|
+
export type ClmmPosition = {
|
91
|
+
coin_type_a: string;
|
92
|
+
coin_type_b: string;
|
93
|
+
description: string;
|
94
|
+
fee_growth_coin_a: string;
|
95
|
+
fee_growth_coin_b: string;
|
96
|
+
fee_rate: string;
|
97
|
+
id: ID;
|
98
|
+
liquidity: string;
|
99
|
+
lower_tick: {
|
100
|
+
fields: {
|
101
|
+
bits: number;
|
102
|
+
};
|
103
|
+
type: string;
|
104
|
+
};
|
105
|
+
upper_tick: {
|
106
|
+
fields: {
|
107
|
+
bits: number;
|
108
|
+
};
|
109
|
+
type: string;
|
110
|
+
};
|
111
|
+
pool_id: string;
|
112
|
+
position_index: string;
|
113
|
+
reward_infos: {
|
114
|
+
fields: {
|
115
|
+
coins_owed_reward: string;
|
116
|
+
reward_growth_inside_last: string;
|
117
|
+
};
|
118
|
+
type: string;
|
119
|
+
}[];
|
120
|
+
token_a_fee: string;
|
121
|
+
token_b_fee: string;
|
122
|
+
};
|
123
|
+
export type ClmmPool = {
|
124
|
+
coin_a: string;
|
125
|
+
coin_b: string;
|
126
|
+
current_sqrt_price: string;
|
127
|
+
current_tick_index: {
|
128
|
+
fields: {
|
129
|
+
bits: number;
|
130
|
+
};
|
131
|
+
type: string;
|
132
|
+
};
|
133
|
+
fee_growth_global_coin_a: string;
|
134
|
+
fee_growth_global_coin_b: string;
|
135
|
+
fee_rate: string;
|
136
|
+
id: ID;
|
137
|
+
is_paused: boolean;
|
138
|
+
liquidity: string;
|
139
|
+
protocol_fee_coin_a: string;
|
140
|
+
protocol_fee_coin_b: string;
|
141
|
+
protocol_fee_share: string;
|
142
|
+
reward_infos: {
|
143
|
+
fields: {
|
144
|
+
ended_at_seconds: string;
|
145
|
+
last_update_time: string;
|
146
|
+
reward_coin_decimals: number;
|
147
|
+
reward_coin_symbol: string;
|
148
|
+
reward_coin_type: string;
|
149
|
+
reward_growth_global: string;
|
150
|
+
reward_per_seconds: string;
|
151
|
+
total_reward: string;
|
152
|
+
total_reward_allocated: string;
|
153
|
+
};
|
154
|
+
type: string;
|
155
|
+
}[];
|
156
|
+
};
|
157
|
+
export type ClmmPoolStat = {
|
158
|
+
address: string;
|
159
|
+
day: {
|
160
|
+
volume: string;
|
161
|
+
};
|
162
|
+
feeRate: string;
|
163
|
+
tvl: string;
|
164
|
+
};
|