@sonarwatch/portfolio-plugins 0.5.8 → 0.5.10
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 +8 -0
- package/package.json +2 -3
- package/src/Cache.d.ts +3 -1
- package/src/Cache.js +52 -14
- package/src/Cache.js.map +1 -1
- package/src/index.js +6 -0
- package/src/index.js.map +1 -1
- package/src/platforms.d.ts +2 -0
- package/src/platforms.js +11 -1
- package/src/platforms.js.map +1 -1
- package/src/plugins/cetus/clmmsFetcher.d.ts +3 -0
- package/src/plugins/cetus/clmmsFetcher.js +109 -0
- package/src/plugins/cetus/clmmsFetcher.js.map +1 -0
- package/src/plugins/cetus/constants.d.ts +5 -0
- package/src/plugins/cetus/constants.js +9 -0
- package/src/plugins/cetus/constants.js.map +1 -0
- package/src/plugins/cetus/helpers.d.ts +16 -0
- package/src/plugins/cetus/helpers.js +194 -0
- package/src/plugins/cetus/helpers.js.map +1 -0
- package/src/plugins/cetus/index.d.ts +4 -0
- package/src/plugins/cetus/index.js +11 -0
- package/src/plugins/cetus/index.js.map +1 -0
- package/src/plugins/cetus/poolsJob.d.ts +3 -0
- package/src/plugins/cetus/poolsJob.js +54 -0
- package/src/plugins/cetus/poolsJob.js.map +1 -0
- package/src/plugins/cetus/types.d.ts +90 -0
- package/src/plugins/cetus/types.js +10 -0
- package/src/plugins/cetus/types.js.map +1 -0
- package/src/plugins/orca/clmmPositionsFetcher.js +2 -2
- package/src/plugins/orca/clmmPositionsFetcher.js.map +1 -1
- package/src/plugins/orca/helpers.d.ts +0 -10
- package/src/plugins/orca/helpers.js +1 -193
- package/src/plugins/orca/helpers.js.map +1 -1
- package/src/plugins/tokens/fetchers/evms/evmNativeExecutorGenerator.d.ts +3 -0
- package/src/plugins/tokens/fetchers/evms/evmNativeExecutorGenerator.js +49 -0
- package/src/plugins/tokens/fetchers/evms/evmNativeExecutorGenerator.js.map +1 -0
- package/src/plugins/tokens/fetchers/evms/index.js +7 -5
- package/src/plugins/tokens/fetchers/evms/index.js.map +1 -1
- package/src/plugins/tokens/index.js +4 -0
- package/src/plugins/tokens/index.js.map +1 -1
- package/src/plugins/turbos/clmmsPositionsFetcher.d.ts +3 -0
- package/src/plugins/turbos/clmmsPositionsFetcher.js +128 -0
- package/src/plugins/turbos/clmmsPositionsFetcher.js.map +1 -0
- package/src/plugins/turbos/constants.d.ts +5 -0
- package/src/plugins/turbos/constants.js +9 -0
- package/src/plugins/turbos/constants.js.map +1 -0
- package/src/plugins/turbos/helper.d.ts +8 -0
- package/src/plugins/turbos/helper.js +34 -0
- package/src/plugins/turbos/helper.js.map +1 -0
- package/src/plugins/turbos/index.d.ts +4 -0
- package/src/plugins/turbos/index.js +11 -0
- package/src/plugins/turbos/index.js.map +1 -0
- package/src/plugins/turbos/poolsJob.d.ts +3 -0
- package/src/plugins/turbos/poolsJob.js +53 -0
- package/src/plugins/turbos/poolsJob.js.map +1 -0
- package/src/plugins/turbos/types.d.ts +103 -0
- package/src/plugins/turbos/types.js +3 -0
- package/src/plugins/turbos/types.js.map +1 -0
- package/src/utils/clients/constants.js +2 -0
- package/src/utils/clients/constants.js.map +1 -1
- package/src/utils/clients/getEvmClients.js +1 -0
- package/src/utils/clients/getEvmClients.js.map +1 -1
- package/src/utils/clmm/tokenAmountFromLiquidity.d.ts +10 -0
- package/src/utils/clmm/tokenAmountFromLiquidity.js +199 -0
- package/src/utils/clmm/tokenAmountFromLiquidity.js.map +1 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.5.10](https://github.com/sonarwatch/portfolio/compare/plugins-0.5.9...plugins-0.5.10) (2023-08-02)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
## [0.5.9](https://github.com/sonarwatch/portfolio/compare/plugins-0.5.8...plugins-0.5.9) (2023-07-31)
|
10
|
+
|
11
|
+
|
12
|
+
|
5
13
|
## [0.5.8](https://github.com/sonarwatch/portfolio/compare/plugins-0.5.7...plugins-0.5.8) (2023-07-27)
|
6
14
|
|
7
15
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sonarwatch/portfolio-plugins",
|
3
|
-
"version": "0.5.
|
3
|
+
"version": "0.5.10",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
@@ -17,12 +17,11 @@
|
|
17
17
|
"bitcoin-address-validation": "^2.2.1",
|
18
18
|
"bn.js": "^5.2.1",
|
19
19
|
"decimal.js": "^10.4.3",
|
20
|
-
"listhen": "^1.0.4",
|
21
20
|
"unstorage": "^1.8.0",
|
22
21
|
"viem": "^1.2.9"
|
23
22
|
},
|
24
23
|
"peerDependencies": {
|
25
|
-
"@sonarwatch/portfolio-core": "0.5.
|
24
|
+
"@sonarwatch/portfolio-core": "0.5.10"
|
26
25
|
},
|
27
26
|
"main": "./src/index.js",
|
28
27
|
"types": "./src/index.d.ts"
|
package/src/Cache.d.ts
CHANGED
@@ -62,11 +62,13 @@ export declare class Cache {
|
|
62
62
|
getItem<K extends StorageValue>(key: string, opts: TransactionOptions): Promise<K | undefined>;
|
63
63
|
private getCachedTokenPrice;
|
64
64
|
getTokenPrice(address: string, networkId: NetworkIdType): Promise<TokenPrice | undefined>;
|
65
|
+
getTokenPrices(addresses: string[], networkId: NetworkIdType): Promise<(TokenPrice | undefined)[]>;
|
65
66
|
private getTokenPriceSources;
|
67
|
+
private getTokenPricesSources;
|
66
68
|
getItems<K extends StorageValue>(keys: string[], opts: TransactionOptions): Promise<(K | undefined)[]>;
|
67
69
|
getAllItems<K extends StorageValue>(opts: TransactionOptions): Promise<K[]>;
|
68
70
|
getAllItemsAsMap<K extends StorageValue>(opts: TransactionOptions): Promise<Map<string, K>>;
|
69
|
-
|
71
|
+
getAllTokenPrices(networkId: NetworkIdType): Promise<Map<string, TokenPrice>>;
|
70
72
|
setItem<K extends StorageValue>(key: string, value: K, opts: TransactionOptions): Promise<void>;
|
71
73
|
setTokenPriceSource(source: TokenPriceSource): Promise<void>;
|
72
74
|
removeItem(key: string, opts: TransactionOptions): Promise<void>;
|
package/src/Cache.js
CHANGED
@@ -52,24 +52,22 @@ class Cache {
|
|
52
52
|
});
|
53
53
|
}
|
54
54
|
getCachedTokenPrice(address, networkId) {
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
return cachedTokenPrice.tp;
|
66
|
-
});
|
55
|
+
const cachedTokenPrice = this.tokenPricesCache.get(getTokenPriceCacheKey(address, networkId));
|
56
|
+
if (!cachedTokenPrice) {
|
57
|
+
this.tokenPricesCache.delete(getTokenPriceCacheKey(address, networkId));
|
58
|
+
return undefined;
|
59
|
+
}
|
60
|
+
if (Date.now() > cachedTokenPrice.ts + tokenPricesCacheTtl) {
|
61
|
+
this.tokenPricesCache.delete(getTokenPriceCacheKey(address, networkId));
|
62
|
+
return undefined;
|
63
|
+
}
|
64
|
+
return cachedTokenPrice.tp;
|
67
65
|
}
|
68
66
|
getTokenPrice(address, networkId) {
|
69
67
|
return __awaiter(this, void 0, void 0, function* () {
|
70
68
|
const fAddress = (0, portfolio_core_1.formatTokenAddress)(address, networkId);
|
71
69
|
// Check if in cache
|
72
|
-
const cTokenPrice =
|
70
|
+
const cTokenPrice = this.getCachedTokenPrice(fAddress, networkId);
|
73
71
|
if (cTokenPrice)
|
74
72
|
return cTokenPrice;
|
75
73
|
const sources = yield this.getTokenPriceSources(fAddress, networkId);
|
@@ -86,6 +84,38 @@ class Cache {
|
|
86
84
|
return tokenPrice;
|
87
85
|
});
|
88
86
|
}
|
87
|
+
getTokenPrices(addresses, networkId) {
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
89
|
+
const fAddresses = addresses.map((a) => (0, portfolio_core_1.formatTokenAddress)(a, networkId));
|
90
|
+
const ffAddresses = [...new Set(fAddresses)];
|
91
|
+
const tokenPriceByAddress = new Map();
|
92
|
+
const notCachedAddresses = [];
|
93
|
+
ffAddresses.forEach((address) => {
|
94
|
+
const tokenPrice = this.getCachedTokenPrice(address, networkId);
|
95
|
+
if (tokenPrice)
|
96
|
+
tokenPriceByAddress.set(address, tokenPrice);
|
97
|
+
else
|
98
|
+
notCachedAddresses.push(address);
|
99
|
+
});
|
100
|
+
const notCachedSources = yield this.getTokenPricesSources(notCachedAddresses, networkId);
|
101
|
+
notCachedSources.forEach((sources, i) => {
|
102
|
+
const address = notCachedAddresses[i];
|
103
|
+
if (!sources)
|
104
|
+
tokenPriceByAddress.set(address, undefined);
|
105
|
+
else {
|
106
|
+
const tokenPrice = (0, portfolio_core_1.tokenPriceFromSources)(sources);
|
107
|
+
tokenPriceByAddress.set(address, (0, portfolio_core_1.tokenPriceFromSources)(sources));
|
108
|
+
if (tokenPrice) {
|
109
|
+
this.tokenPricesCache.set(getTokenPriceCacheKey(address, networkId), {
|
110
|
+
tp: tokenPrice,
|
111
|
+
ts: Date.now(),
|
112
|
+
});
|
113
|
+
}
|
114
|
+
}
|
115
|
+
});
|
116
|
+
return fAddresses.map((address) => tokenPriceByAddress.get(address));
|
117
|
+
});
|
118
|
+
}
|
89
119
|
getTokenPriceSources(address, networkId) {
|
90
120
|
return __awaiter(this, void 0, void 0, function* () {
|
91
121
|
return this.getItem(address, {
|
@@ -94,6 +124,14 @@ class Cache {
|
|
94
124
|
});
|
95
125
|
});
|
96
126
|
}
|
127
|
+
getTokenPricesSources(addresses, networkId) {
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
129
|
+
return this.getItems(addresses, {
|
130
|
+
prefix: tokenPriceSourcePrefix,
|
131
|
+
networkId,
|
132
|
+
});
|
133
|
+
});
|
134
|
+
}
|
97
135
|
getItems(keys, opts) {
|
98
136
|
return __awaiter(this, void 0, void 0, function* () {
|
99
137
|
const fullKeys = keys.map((k) => getFullKey(k, opts));
|
@@ -120,7 +158,7 @@ class Cache {
|
|
120
158
|
return itemsMap;
|
121
159
|
});
|
122
160
|
}
|
123
|
-
|
161
|
+
getAllTokenPrices(networkId) {
|
124
162
|
return __awaiter(this, void 0, void 0, function* () {
|
125
163
|
const addresses = yield this.getTokenPriceAddresses(networkId);
|
126
164
|
const tokenPrices = new Map();
|
package/src/Cache.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../../packages/plugins/src/Cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAyE;AACzE,8DAA4C;AAC5C,oEAAkD;AAClD,kEAAgD;AAChD,+DAQoC;AACpC,oEAA4C;AAC5C,kEAA0C;AAC1C,yEAAiD;AAOjD,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAClD,MAAM,mBAAmB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAoEhD,MAAa,KAAK;IAIhB,YAAY,WAAwB;QAF5B,qBAAgB,GAAkC,IAAI,GAAG,EAAE,CAAC;QAGlE,MAAM,MAAM,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,IAAA,yBAAa,EAAC;YAC3B,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAEK,OAAO,CAAC,GAAW,EAAE,IAAwB;;YACjD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC3C,OAAO,IAAI,KAAK,SAAS,CAAC;QAC5B,CAAC;KAAA;IAEK,aAAa,CAAC,OAAe,EAAE,SAAwB;;YAC3D,MAAM,QAAQ,GAAG,IAAA,mCAAkB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACxD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YACjE,OAAO,UAA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AAE;oBACN,IAAI,EACF,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,wBAAwB;oBACnE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;wBAC9C,CAAC,CAAC;4BACE,aAAa,EAAE,UAAU,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAAE;yBACnE;wBACH,CAAC,CAAC,SAAS;iBACd;aACF,CAAC;QACJ;YACE,OAAO;gBACL,IAAI,EAAE,YAAY;gBAClB,MAAM,EAAE;oBACN,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,IAAI,SAAS;iBAC/D;aACF,CAAC;KACL;AACH,CAAC;AAtDD,wCAsDC;AAED,SAAgB,QAAQ;IACtB,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,OAAO,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC;AAHD,4BAGC"}
|
package/src/index.js
CHANGED
@@ -35,6 +35,8 @@ const solend_1 = require("./plugins/solend");
|
|
35
35
|
const raydium_1 = require("./plugins/raydium");
|
36
36
|
const orca_1 = require("./plugins/orca");
|
37
37
|
const meteora_1 = require("./plugins/meteora");
|
38
|
+
const cetus_1 = require("./plugins/cetus");
|
39
|
+
const turbos_1 = require("./plugins/turbos");
|
38
40
|
const thala_1 = require("./plugins/thala");
|
39
41
|
const tensor_1 = require("./plugins/tensor");
|
40
42
|
const foo_1 = require("./plugins/foo");
|
@@ -57,6 +59,8 @@ exports.jobs = [
|
|
57
59
|
...orca_1.jobs,
|
58
60
|
...drift_1.jobs,
|
59
61
|
...mango_1.jobs,
|
62
|
+
...cetus_1.jobs,
|
63
|
+
...turbos_1.jobs,
|
60
64
|
];
|
61
65
|
exports.fetchers = [
|
62
66
|
...tokens_1.fetchers,
|
@@ -70,6 +74,8 @@ exports.fetchers = [
|
|
70
74
|
...orca_1.fetchers,
|
71
75
|
...drift_1.fetchers,
|
72
76
|
...mango_1.fetchers,
|
77
|
+
...cetus_1.fetchers,
|
78
|
+
...turbos_1.fetchers,
|
73
79
|
];
|
74
80
|
exports.fetchersByAddressSystem = (0, getFetchersByAddressSystem_1.getFetchersByAddressSystem)(exports.fetchers);
|
75
81
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/plugins/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,0DAA4C;AAC5C,6CAG0B;AAC1B,iDAAkE;AAClE,iDAG4B;AAC5B,6CAG0B;AAC1B,+CAG2B;AAC3B,yCAA4E;AAC5E,+CAAwD;AACxD,2CAA+E;AAC/E,6CAA8D;AAC9D,uCAAyE;AACzE,2CAA+E;AAC/E,2CAA+E;AAC/E,wFAAqF;AAErF,0CAAwB;AACxB,4CAA0B;AAC1B,wCAAsB;AAEtB,8CAA4B;AACf,QAAA,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAExC,QAAA,IAAI,GAAU;IACzB,GAAG,aAAU;IACb,GAAG,YAAS;IACZ,GAAG,UAAO;IACV,GAAG,eAAY;IACf,GAAG,cAAW;IACd,GAAG,aAAU;IACb,GAAG,cAAW;IACd,GAAG,WAAQ;IACX,GAAG,YAAS;IACZ,GAAG,YAAS;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/plugins/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,0DAA4C;AAC5C,6CAG0B;AAC1B,iDAAkE;AAClE,iDAG4B;AAC5B,6CAG0B;AAC1B,+CAG2B;AAC3B,yCAA4E;AAC5E,+CAAwD;AACxD,2CAA+E;AAC/E,6CAG0B;AAC1B,2CAA+E;AAC/E,6CAA8D;AAC9D,uCAAyE;AACzE,2CAA+E;AAC/E,2CAA+E;AAC/E,wFAAqF;AAErF,0CAAwB;AACxB,4CAA0B;AAC1B,wCAAsB;AAEtB,8CAA4B;AACf,QAAA,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAExC,QAAA,IAAI,GAAU;IACzB,GAAG,aAAU;IACb,GAAG,YAAS;IACZ,GAAG,UAAO;IACV,GAAG,eAAY;IACf,GAAG,cAAW;IACd,GAAG,aAAU;IACb,GAAG,cAAW;IACd,GAAG,WAAQ;IACX,GAAG,YAAS;IACZ,GAAG,YAAS;IACZ,GAAG,YAAS;IACZ,GAAG,aAAU;CACd,CAAC;AAEW,QAAA,QAAQ,GAAc;IACjC,GAAG,iBAAc;IACjB,GAAG,cAAW;IACd,GAAG,iBAAc;IACjB,GAAG,mBAAgB;IACnB,GAAG,mBAAgB;IACnB,GAAG,iBAAc;IACjB,GAAG,gBAAa;IAChB,GAAG,kBAAe;IAClB,GAAG,eAAY;IACf,GAAG,gBAAa;IAChB,GAAG,gBAAa;IAChB,GAAG,gBAAa;IAChB,GAAG,iBAAc;CAClB,CAAC;AAEW,QAAA,uBAAuB,GAAG,IAAA,uDAA0B,EAAC,gBAAQ,CAAC,CAAC"}
|
package/src/platforms.d.ts
CHANGED
@@ -12,3 +12,5 @@ export declare const orcaPlatform: Platform;
|
|
12
12
|
export declare const meteoraPlatform: Platform;
|
13
13
|
export declare const driftPlatform: Platform;
|
14
14
|
export declare const mangoPlatform: Platform;
|
15
|
+
export declare const cetusPlatform: Platform;
|
16
|
+
export declare const turbosPlatform: Platform;
|
package/src/platforms.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.mangoPlatform = exports.driftPlatform = exports.meteoraPlatform = exports.orcaPlatform = exports.solendPlatform = exports.raydiumPlatform = exports.thalaPlatform = exports.tensorPlatform = exports.marginfiPlatform = exports.walletTokensPlatform = exports.walletNftsPlatform = exports.aavePlatform = exports.marinadePlatform = void 0;
|
3
|
+
exports.turbosPlatform = exports.cetusPlatform = exports.mangoPlatform = exports.driftPlatform = exports.meteoraPlatform = exports.orcaPlatform = exports.solendPlatform = exports.raydiumPlatform = exports.thalaPlatform = exports.tensorPlatform = exports.marginfiPlatform = exports.walletTokensPlatform = exports.walletNftsPlatform = exports.aavePlatform = exports.marinadePlatform = void 0;
|
4
4
|
exports.marinadePlatform = {
|
5
5
|
id: 'marinade',
|
6
6
|
name: 'Marinade',
|
@@ -66,4 +66,14 @@ exports.mangoPlatform = {
|
|
66
66
|
name: 'Mango',
|
67
67
|
image: 'https://beta.sonar.watch/img/platforms/mango.png',
|
68
68
|
};
|
69
|
+
exports.cetusPlatform = {
|
70
|
+
id: 'cetus',
|
71
|
+
name: 'Cetus',
|
72
|
+
image: 'https://beta.sonar.watch/img/platforms/cetus.png',
|
73
|
+
};
|
74
|
+
exports.turbosPlatform = {
|
75
|
+
id: 'turbos',
|
76
|
+
name: 'Turbos',
|
77
|
+
image: 'https://beta.sonar.watch/img/platforms/turbos.png',
|
78
|
+
};
|
69
79
|
//# sourceMappingURL=platforms.js.map
|
package/src/platforms.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"platforms.js","sourceRoot":"","sources":["../../../../packages/plugins/src/platforms.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAa;IACxC,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,qDAAqD;CAC7D,CAAC;AACW,QAAA,YAAY,GAAa;IACpC,EAAE,EAAE,MAAM;IACV,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,iDAAiD;CACzD,CAAC;AACW,QAAA,kBAAkB,GAAa;IAC1C,EAAE,EAAE,aAAa;IACjB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,wDAAwD;CAChE,CAAC;AACW,QAAA,oBAAoB,GAAa;IAC5C,EAAE,EAAE,eAAe;IACnB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,0DAA0D;CAClE,CAAC;AACW,QAAA,gBAAgB,GAAa;IACxC,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,qDAAqD;CAC7D,CAAC;AACW,QAAA,cAAc,GAAa;IACtC,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,mDAAmD;CAC3D,CAAC;AACW,QAAA,aAAa,GAAa;IACrC,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,kDAAkD;CAC1D,CAAC;AACW,QAAA,eAAe,GAAa;IACvC,EAAE,EAAE,SAAS;IACb,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,oDAAoD;CAC5D,CAAC;AACW,QAAA,cAAc,GAAa;IACtC,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,mDAAmD;CAC3D,CAAC;AACW,QAAA,YAAY,GAAa;IACpC,EAAE,EAAE,MAAM;IACV,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,iDAAiD;CACzD,CAAC;AACW,QAAA,eAAe,GAAa;IACvC,EAAE,EAAE,SAAS;IACb,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,oDAAoD;CAC5D,CAAC;AACW,QAAA,aAAa,GAAa;IACrC,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,kDAAkD;CAC1D,CAAC;AACW,QAAA,aAAa,GAAa;IACrC,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,kDAAkD;CAC1D,CAAC"}
|
1
|
+
{"version":3,"file":"platforms.js","sourceRoot":"","sources":["../../../../packages/plugins/src/platforms.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAa;IACxC,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,qDAAqD;CAC7D,CAAC;AACW,QAAA,YAAY,GAAa;IACpC,EAAE,EAAE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AE,OAAO;IACb,KAAK,EAAE,kDAAkD;CAC1D,CAAC;AACW,QAAA,aAAa,GAAa;IACrC,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,kDAAkD;CAC1D,CAAC;AACW,QAAA,cAAc,GAAa;IACtC,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,mDAAmD;CAC3D,CAAC"}
|
@@ -0,0 +1,109 @@
|
|
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 helpers_1 = require("./helpers");
|
20
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
21
|
+
const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
|
22
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
|
+
const client = (0, clients_1.getClientSui)();
|
24
|
+
const ownerRes = yield client.getOwnedObjects({
|
25
|
+
owner,
|
26
|
+
options: {
|
27
|
+
showType: true,
|
28
|
+
showContent: true,
|
29
|
+
showDisplay: true,
|
30
|
+
showOwner: true,
|
31
|
+
},
|
32
|
+
filter: { Package: constants_1.clmmPoolPackageId },
|
33
|
+
});
|
34
|
+
if (!ownerRes.data)
|
35
|
+
return [];
|
36
|
+
const clmmPositions = [];
|
37
|
+
for (let i = 0; i < ownerRes.data.length; i++) {
|
38
|
+
const clmmPositionRes = ownerRes.data[i];
|
39
|
+
if (!clmmPositionRes.data || !clmmPositionRes.data.type)
|
40
|
+
continue;
|
41
|
+
const type = (0, helpers_1.extractStructTagFromType)(clmmPositionRes.data.type);
|
42
|
+
if (type.full_address === constants_1.clmmType) {
|
43
|
+
const position = (0, helpers_1.buildPosition)(clmmPositionRes);
|
44
|
+
clmmPositions.push(position);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
const poolsIds = clmmPositions.map((position) => position.pool);
|
48
|
+
const pools = yield cache.getItems(poolsIds, {
|
49
|
+
prefix: constants_1.clmmPoolsPrefix,
|
50
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
51
|
+
});
|
52
|
+
const poolsById = new Map();
|
53
|
+
pools.forEach((pool) => {
|
54
|
+
if (pool) {
|
55
|
+
poolsById.set(pool.poolAddress, pool);
|
56
|
+
}
|
57
|
+
});
|
58
|
+
const assets = [];
|
59
|
+
let totalLiquidityValue = 0;
|
60
|
+
for (const clmmPosition of clmmPositions) {
|
61
|
+
const pool = poolsById.get(clmmPosition.pool);
|
62
|
+
if (!pool)
|
63
|
+
continue;
|
64
|
+
const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(new bignumber_js_1.default(clmmPosition.liquidity).toNumber(), pool.current_tick_index, clmmPosition.tick_lower_index, clmmPosition.tick_upper_index, 0);
|
65
|
+
const tokenPriceA = yield cache.getTokenPrice(pool.coinTypeA, portfolio_core_1.NetworkId.sui);
|
66
|
+
if (!tokenPriceA)
|
67
|
+
continue;
|
68
|
+
const assetTokenA = (0, tokenPriceToAssetToken_1.default)(pool.coinTypeA, tokenAmountA / Math.pow(10, tokenPriceA.decimals), portfolio_core_1.NetworkId.sui, tokenPriceA);
|
69
|
+
const tokenPriceB = yield cache.getTokenPrice(pool.coinTypeB, portfolio_core_1.NetworkId.sui);
|
70
|
+
if (!tokenPriceB)
|
71
|
+
continue;
|
72
|
+
const assetTokenB = (0, tokenPriceToAssetToken_1.default)(pool.coinTypeB, tokenAmountB / Math.pow(10, tokenPriceB.decimals), portfolio_core_1.NetworkId.sui, tokenPriceB);
|
73
|
+
if (!assetTokenA ||
|
74
|
+
!assetTokenB ||
|
75
|
+
assetTokenA.value === null ||
|
76
|
+
assetTokenB.value === null)
|
77
|
+
continue;
|
78
|
+
const value = assetTokenA.value + assetTokenB.value;
|
79
|
+
assets.push({
|
80
|
+
assets: [assetTokenA, assetTokenB],
|
81
|
+
assetsValue: value,
|
82
|
+
rewardAssets: [],
|
83
|
+
rewardAssetsValue: 0,
|
84
|
+
value,
|
85
|
+
yields: [],
|
86
|
+
});
|
87
|
+
totalLiquidityValue += value;
|
88
|
+
}
|
89
|
+
return [
|
90
|
+
{
|
91
|
+
type: portfolio_core_1.PortfolioElementType.liquidity,
|
92
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
93
|
+
platformId: constants_1.platformId,
|
94
|
+
label: 'LiquidityPool',
|
95
|
+
tags: ['Concentrated'],
|
96
|
+
value: totalLiquidityValue,
|
97
|
+
data: {
|
98
|
+
liquidities: assets,
|
99
|
+
},
|
100
|
+
},
|
101
|
+
];
|
102
|
+
});
|
103
|
+
const fetcher = {
|
104
|
+
id: `${constants_1.platformId}-clmms`,
|
105
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
106
|
+
executor,
|
107
|
+
};
|
108
|
+
exports.default = fetcher;
|
109
|
+
//# sourceMappingURL=clmmsFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{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,5 @@
|
|
1
|
+
export declare const platformId = "cetus";
|
2
|
+
export declare const clmmPoolsPrefix: string;
|
3
|
+
export declare const clmmPoolPackageId = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
|
4
|
+
export declare const clmmType: string;
|
5
|
+
export declare const clmmPoolsHandle = "0x37f60eb2d9d227949b95da8fea810db3c32d1e1fa8ed87434fc51664f87d83cb";
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.clmmPoolsHandle = exports.clmmType = exports.clmmPoolPackageId = exports.clmmPoolsPrefix = exports.platformId = void 0;
|
4
|
+
exports.platformId = 'cetus';
|
5
|
+
exports.clmmPoolsPrefix = `${exports.platformId}-clmmPools`;
|
6
|
+
exports.clmmPoolPackageId = '0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb';
|
7
|
+
exports.clmmType = `${exports.clmmPoolPackageId}::position::Position`;
|
8
|
+
exports.clmmPoolsHandle = '0x37f60eb2d9d227949b95da8fea810db3c32d1e1fa8ed87434fc51664f87d83cb';
|
9
|
+
//# sourceMappingURL=constants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/cetus/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,eAAe,GAAG,GAAG,kBAAU,YAAY,CAAC;AAE5C,QAAA,iBAAiB,GAC5B,oEAAoE,CAAC;AAE1D,QAAA,QAAQ,GAAG,GAAG,yBAAiB,sBAAsB,CAAC;AAEtD,QAAA,eAAe,GAC1B,oEAAoE,CAAC"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { SuiObjectResponse } from '@mysten/sui.js';
|
2
|
+
import Decimal from 'decimal.js';
|
3
|
+
import BigNumber from 'bignumber.js';
|
4
|
+
import { NFT, Pool, Position, SuiAddressType, SuiStructTag } from './types';
|
5
|
+
export declare function fromX64(num: BigNumber): Decimal;
|
6
|
+
export declare function composeType(address: string, generics: SuiAddressType[]): SuiAddressType;
|
7
|
+
export declare function composeType(address: string, struct: string, generics?: SuiAddressType[]): SuiAddressType;
|
8
|
+
export declare function composeType(address: string, module: string, struct: string, generics?: SuiAddressType[]): SuiAddressType;
|
9
|
+
export declare function extractStructTagFromType(type: string): SuiStructTag;
|
10
|
+
export declare function isSuiCoin(coinAddress: SuiAddressType): boolean;
|
11
|
+
export declare function buildPoolName(coin_type_a: string, coin_type_b: string, tick_spacing: string): string;
|
12
|
+
export declare function normalizeCoinType(coinType: string): string;
|
13
|
+
export declare function asIntN(int: bigint, bits?: number): number;
|
14
|
+
export declare function getPoolFromObject(object: SuiObjectResponse): Pool;
|
15
|
+
export declare function buildPosition(objects: SuiObjectResponse): Position;
|
16
|
+
export declare function buildNFT(objects: SuiObjectResponse): NFT;
|
@@ -0,0 +1,194 @@
|
|
1
|
+
"use strict";
|
2
|
+
/* eslint-disable no-param-reassign */
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
|
+
};
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
+
exports.buildNFT = exports.buildPosition = exports.getPoolFromObject = exports.asIntN = exports.normalizeCoinType = exports.buildPoolName = exports.isSuiCoin = exports.extractStructTagFromType = exports.composeType = exports.fromX64 = void 0;
|
8
|
+
const sui_js_1 = require("@mysten/sui.js");
|
9
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
10
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
11
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
12
|
+
const types_1 = require("./types");
|
13
|
+
function fromX64(num) {
|
14
|
+
return new decimal_js_1.default(num.toString()).mul(decimal_js_1.default.pow(2, -64));
|
15
|
+
}
|
16
|
+
exports.fromX64 = fromX64;
|
17
|
+
function composeType(address, ...args) {
|
18
|
+
const generics = Array.isArray(args[args.length - 1])
|
19
|
+
? args.pop()
|
20
|
+
: [];
|
21
|
+
const chains = [address, ...args].filter(Boolean);
|
22
|
+
let result = chains.join('::');
|
23
|
+
if (generics && generics.length) {
|
24
|
+
result += `<${generics.join(', ')}>`;
|
25
|
+
}
|
26
|
+
return result;
|
27
|
+
}
|
28
|
+
exports.composeType = composeType;
|
29
|
+
function extractStructTagFromType(type) {
|
30
|
+
var _a;
|
31
|
+
try {
|
32
|
+
let newType = type.replace(/\s/g, '');
|
33
|
+
const genericsString = newType.match(/(<.+>)$/);
|
34
|
+
const generics = (_a = genericsString === null || genericsString === void 0 ? void 0 : genericsString[0]) === null || _a === void 0 ? void 0 : _a.match(/(\w+::\w+::\w+)(?:<.*?>(?!>))?/g);
|
35
|
+
if (generics) {
|
36
|
+
newType = newType.slice(0, newType.indexOf('<'));
|
37
|
+
const tag = extractStructTagFromType(newType);
|
38
|
+
const structTag = Object.assign(Object.assign({}, tag), { type_arguments: generics.map((item) => extractStructTagFromType(item).source_address) });
|
39
|
+
structTag.type_arguments = structTag.type_arguments.map((item) => isSuiCoin(item) ? item : extractStructTagFromType(item).source_address);
|
40
|
+
structTag.source_address = composeType(structTag.full_address, structTag.type_arguments);
|
41
|
+
return structTag;
|
42
|
+
}
|
43
|
+
const parts = newType.split('::');
|
44
|
+
const structTag = {
|
45
|
+
full_address: newType,
|
46
|
+
address: parts[2] === 'SUI' ? '0x2' : (0, sui_js_1.normalizeSuiObjectId)(parts[0]),
|
47
|
+
module: parts[1],
|
48
|
+
name: parts[2],
|
49
|
+
type_arguments: [],
|
50
|
+
source_address: '',
|
51
|
+
};
|
52
|
+
structTag.full_address = `${structTag.address}::${structTag.module}::${structTag.name}`;
|
53
|
+
structTag.source_address = composeType(structTag.full_address, structTag.type_arguments);
|
54
|
+
return structTag;
|
55
|
+
}
|
56
|
+
catch (error) {
|
57
|
+
return {
|
58
|
+
full_address: type,
|
59
|
+
address: '',
|
60
|
+
module: '',
|
61
|
+
name: '',
|
62
|
+
type_arguments: [],
|
63
|
+
source_address: type,
|
64
|
+
};
|
65
|
+
}
|
66
|
+
}
|
67
|
+
exports.extractStructTagFromType = extractStructTagFromType;
|
68
|
+
function isSuiCoin(coinAddress) {
|
69
|
+
return (extractStructTagFromType(coinAddress).full_address ===
|
70
|
+
portfolio_core_1.suiNetwork.native.address);
|
71
|
+
}
|
72
|
+
exports.isSuiCoin = isSuiCoin;
|
73
|
+
function buildPoolName(coin_type_a, coin_type_b, tick_spacing) {
|
74
|
+
const coinNameA = extractStructTagFromType(coin_type_a).name;
|
75
|
+
const coinNameB = extractStructTagFromType(coin_type_b).name;
|
76
|
+
return `${coinNameA}-${coinNameB}[${tick_spacing}]`;
|
77
|
+
}
|
78
|
+
exports.buildPoolName = buildPoolName;
|
79
|
+
function normalizeCoinType(coinType) {
|
80
|
+
return extractStructTagFromType(coinType).source_address;
|
81
|
+
}
|
82
|
+
exports.normalizeCoinType = normalizeCoinType;
|
83
|
+
function asIntN(int, bits = 32) {
|
84
|
+
return Number(BigInt.asIntN(bits, BigInt(int)));
|
85
|
+
}
|
86
|
+
exports.asIntN = asIntN;
|
87
|
+
function getPoolFromObject(object) {
|
88
|
+
const type = (0, sui_js_1.getMoveObjectType)(object);
|
89
|
+
const formatType = extractStructTagFromType(type);
|
90
|
+
const fields = (0, sui_js_1.getObjectFields)(object);
|
91
|
+
const rewarders = [];
|
92
|
+
fields['rewarder_manager'].fields.rewarders.forEach((item) => {
|
93
|
+
const { emissions_per_second: emissionsPerSecond } = item.fields.emissions_per_second;
|
94
|
+
const emissionSeconds = fromX64(new bignumber_js_1.default(emissionsPerSecond));
|
95
|
+
const emissionsEveryDay = Math.floor(emissionSeconds.toNumber() * 60 * 60 * 24);
|
96
|
+
rewarders.push({
|
97
|
+
emissions_per_second: emissionsPerSecond,
|
98
|
+
coinAddress: extractStructTagFromType(item.fields.reward_coin.fields.name)
|
99
|
+
.source_address,
|
100
|
+
growth_global: item.fields.growth_global,
|
101
|
+
emissionsEveryDay,
|
102
|
+
});
|
103
|
+
});
|
104
|
+
const name = buildPoolName(formatType.type_arguments[0], formatType.type_arguments[1], fields['tick_spacing']);
|
105
|
+
return {
|
106
|
+
poolAddress: (0, sui_js_1.getObjectId)(object),
|
107
|
+
poolType: type,
|
108
|
+
coinTypeA: formatType.type_arguments[0],
|
109
|
+
coinTypeB: formatType.type_arguments[1],
|
110
|
+
coinAmountA: fields['coin_a'],
|
111
|
+
coinAmountB: fields['coin_b'],
|
112
|
+
current_sqrt_price: fields['current_sqrt_price'],
|
113
|
+
current_tick_index: asIntN(BigInt(fields['current_tick_index'].fields.bits)),
|
114
|
+
fee_growth_global_a: fields['fee_growth_global_a'],
|
115
|
+
fee_growth_global_b: fields['fee_growth_global_b'],
|
116
|
+
fee_protocol_coin_a: fields['fee_protocol_coin_a'],
|
117
|
+
fee_protocol_coin_b: fields['fee_protocol_coin_b'],
|
118
|
+
fee_rate: fields['fee_rate'],
|
119
|
+
is_pause: fields['is_pause'],
|
120
|
+
liquidity: fields['liquidity'],
|
121
|
+
position_manager: {
|
122
|
+
positions_handle: fields['position_manager'].fields.positions.fields.id.id,
|
123
|
+
size: fields['position_manager'].fields.positions.fields.size,
|
124
|
+
},
|
125
|
+
rewarder_infos: rewarders,
|
126
|
+
rewarder_last_updated_time: fields['rewarder_manager'].fields.last_updated_time,
|
127
|
+
tickSpacing: fields['tick_spacing'],
|
128
|
+
ticks_handle: fields['tick_manager'].fields.ticks.fields.id.id,
|
129
|
+
uri: fields['url'],
|
130
|
+
index: Number(fields['index']),
|
131
|
+
name,
|
132
|
+
};
|
133
|
+
}
|
134
|
+
exports.getPoolFromObject = getPoolFromObject;
|
135
|
+
function buildPosition(objects) {
|
136
|
+
let nft = {
|
137
|
+
creator: '',
|
138
|
+
description: '',
|
139
|
+
image_url: '',
|
140
|
+
link: '',
|
141
|
+
name: '',
|
142
|
+
project_url: '',
|
143
|
+
};
|
144
|
+
let position = Object.assign(Object.assign({}, nft), { pos_object_id: '', owner: '', type: '', coin_type_a: '', coin_type_b: '', liquidity: '', tick_lower_index: 0, tick_upper_index: 0, index: 0, pool: '', reward_amount_owed_0: '0', reward_amount_owed_1: '0', reward_amount_owed_2: '0', reward_growth_inside_0: '0', reward_growth_inside_1: '0', reward_growth_inside_2: '0', fee_growth_inside_a: '0', fee_owed_a: '0', fee_growth_inside_b: '0', fee_owed_b: '0', position_status: types_1.ClmmPositionStatus.Exists });
|
145
|
+
let fields = (0, sui_js_1.getObjectFields)(objects);
|
146
|
+
if (fields) {
|
147
|
+
const type = (0, sui_js_1.getMoveObjectType)(objects);
|
148
|
+
const ownerWarp = (0, sui_js_1.getObjectOwner)(objects);
|
149
|
+
if ('nft' in fields) {
|
150
|
+
fields = fields['nft'].fields;
|
151
|
+
nft.description = fields['description'];
|
152
|
+
nft.name = fields['name'];
|
153
|
+
nft.link = fields['url'];
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
nft = buildNFT(objects);
|
157
|
+
}
|
158
|
+
position = Object.assign(Object.assign({}, nft), { pos_object_id: fields['id'].id, owner: ownerWarp.AddressOwner, type, coin_type_a: fields['coin_type_a'].fields.name, coin_type_b: fields['coin_type_b'].fields.name, liquidity: fields['liquidity'], tick_lower_index: asIntN(BigInt(fields['tick_lower_index'].fields.bits)), tick_upper_index: asIntN(BigInt(fields['tick_upper_index'].fields.bits)), index: fields['index'], pool: fields['pool'], reward_amount_owed_0: '0', reward_amount_owed_1: '0', reward_amount_owed_2: '0', reward_growth_inside_0: '0', reward_growth_inside_1: '0', reward_growth_inside_2: '0', fee_growth_inside_a: '0', fee_owed_a: '0', fee_growth_inside_b: '0', fee_owed_b: '0', position_status: types_1.ClmmPositionStatus.Exists });
|
159
|
+
}
|
160
|
+
const deletedResponse = (0, sui_js_1.getObjectDeletedResponse)(objects);
|
161
|
+
if (deletedResponse) {
|
162
|
+
position.pos_object_id = deletedResponse.objectId;
|
163
|
+
position.position_status = types_1.ClmmPositionStatus.Deleted;
|
164
|
+
}
|
165
|
+
const objectNotExistsResponse = (0, sui_js_1.getObjectNotExistsResponse)(objects);
|
166
|
+
if (objectNotExistsResponse) {
|
167
|
+
position.pos_object_id = objectNotExistsResponse;
|
168
|
+
position.position_status = types_1.ClmmPositionStatus.NotExists;
|
169
|
+
}
|
170
|
+
return position;
|
171
|
+
}
|
172
|
+
exports.buildPosition = buildPosition;
|
173
|
+
function buildNFT(objects) {
|
174
|
+
const fields = (0, sui_js_1.getObjectDisplay)(objects).data;
|
175
|
+
const nft = {
|
176
|
+
creator: '',
|
177
|
+
description: '',
|
178
|
+
image_url: '',
|
179
|
+
link: '',
|
180
|
+
name: '',
|
181
|
+
project_url: '',
|
182
|
+
};
|
183
|
+
if (fields) {
|
184
|
+
nft.creator = fields['creator'];
|
185
|
+
nft.description = fields['description'];
|
186
|
+
nft.image_url = fields['image_url'];
|
187
|
+
nft.link = fields['link'];
|
188
|
+
nft.name = fields['name'];
|
189
|
+
nft.project_url = fields['project_url'];
|
190
|
+
}
|
191
|
+
return nft;
|
192
|
+
}
|
193
|
+
exports.buildNFT = buildNFT;
|
194
|
+
//# sourceMappingURL=helpers.js.map
|