@ouronet/ouronet-core 4.3.6

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +3043 -0
  2. package/README.md +1940 -0
  3. package/dist/codex/codec.d.ts +77 -0
  4. package/dist/codex/codec.js +123 -0
  5. package/dist/codex/errors.d.ts +14 -0
  6. package/dist/codex/errors.js +20 -0
  7. package/dist/codex/index.d.ts +27 -0
  8. package/dist/codex/index.js +25 -0
  9. package/dist/codex/seedTypeMigration.d.ts +35 -0
  10. package/dist/codex/seedTypeMigration.js +45 -0
  11. package/dist/codex/types.d.ts +100 -0
  12. package/dist/codex/types.js +19 -0
  13. package/dist/constants/index.d.ts +2 -0
  14. package/dist/constants/index.js +3 -0
  15. package/dist/constants/ouronet.d.ts +33 -0
  16. package/dist/constants/ouronet.js +59 -0
  17. package/dist/constants/tokenIds.d.ts +13 -0
  18. package/dist/constants/tokenIds.js +21 -0
  19. package/dist/index.d.ts +18 -0
  20. package/dist/index.js +1 -0
  21. package/dist/interactions/activateFunctions.d.ts +67 -0
  22. package/dist/interactions/activateFunctions.js +154 -0
  23. package/dist/interactions/addLiquidityFunctions.d.ts +140 -0
  24. package/dist/interactions/addLiquidityFunctions.js +485 -0
  25. package/dist/interactions/coilFunctions.d.ts +73 -0
  26. package/dist/interactions/coilFunctions.js +213 -0
  27. package/dist/interactions/crossChainFunctions.d.ts +211 -0
  28. package/dist/interactions/crossChainFunctions.js +463 -0
  29. package/dist/interactions/dexAcquisitionPoolFunctions.d.ts +18 -0
  30. package/dist/interactions/dexAcquisitionPoolFunctions.js +18 -0
  31. package/dist/interactions/dexCollectablesFunctions.d.ts +28 -0
  32. package/dist/interactions/dexCollectablesFunctions.js +227 -0
  33. package/dist/interactions/dexFunctions.d.ts +23 -0
  34. package/dist/interactions/dexFunctions.js +23 -0
  35. package/dist/interactions/dexOrtoFungibleFunctions.d.ts +33 -0
  36. package/dist/interactions/dexOrtoFungibleFunctions.js +171 -0
  37. package/dist/interactions/dexParseFunctions.d.ts +150 -0
  38. package/dist/interactions/dexParseFunctions.js +316 -0
  39. package/dist/interactions/dexSwapPairAdminFunctions.d.ts +75 -0
  40. package/dist/interactions/dexSwapPairAdminFunctions.js +255 -0
  41. package/dist/interactions/dexSwapPairCalcFunctions.d.ts +55 -0
  42. package/dist/interactions/dexSwapPairCalcFunctions.js +218 -0
  43. package/dist/interactions/dexSwapPairDashboardFunctions.d.ts +47 -0
  44. package/dist/interactions/dexSwapPairDashboardFunctions.js +179 -0
  45. package/dist/interactions/dexSwapPairExecuteFunctions.d.ts +40 -0
  46. package/dist/interactions/dexSwapPairExecuteFunctions.js +301 -0
  47. package/dist/interactions/dexSwapPairSmartSwapFunctions.d.ts +25 -0
  48. package/dist/interactions/dexSwapPairSmartSwapFunctions.js +166 -0
  49. package/dist/interactions/dexTrueFungibleFunctions.d.ts +52 -0
  50. package/dist/interactions/dexTrueFungibleFunctions.js +220 -0
  51. package/dist/interactions/dexTypes.d.ts +465 -0
  52. package/dist/interactions/dexTypes.js +6 -0
  53. package/dist/interactions/errors.d.ts +12 -0
  54. package/dist/interactions/errors.js +13 -0
  55. package/dist/interactions/guardFunctions.d.ts +33 -0
  56. package/dist/interactions/guardFunctions.js +110 -0
  57. package/dist/interactions/index.d.ts +1 -0
  58. package/dist/interactions/index.js +20 -0
  59. package/dist/interactions/infoOneFunctions.d.ts +133 -0
  60. package/dist/interactions/infoOneFunctions.js +566 -0
  61. package/dist/interactions/kadenaFunctions.d.ts +11 -0
  62. package/dist/interactions/kadenaFunctions.js +40 -0
  63. package/dist/interactions/kpayFunctions.d.ts +45 -0
  64. package/dist/interactions/kpayFunctions.js +191 -0
  65. package/dist/interactions/ouroAccountFunctions.d.ts +64 -0
  66. package/dist/interactions/ouroAccountFunctions.js +229 -0
  67. package/dist/interactions/ouroBalanceFunctions.d.ts +39 -0
  68. package/dist/interactions/ouroBalanceFunctions.js +100 -0
  69. package/dist/interactions/ouroCoilFunctions.d.ts +33 -0
  70. package/dist/interactions/ouroCoilFunctions.js +190 -0
  71. package/dist/interactions/ouroFunctions.d.ts +23 -0
  72. package/dist/interactions/ouroFunctions.js +23 -0
  73. package/dist/interactions/ouroMovieBoosterFunctions.d.ts +18 -0
  74. package/dist/interactions/ouroMovieBoosterFunctions.js +203 -0
  75. package/dist/interactions/ouroPriceFunctions.d.ts +38 -0
  76. package/dist/interactions/ouroPriceFunctions.js +96 -0
  77. package/dist/interactions/ouroPrimordialsFunctions.d.ts +10 -0
  78. package/dist/interactions/ouroPrimordialsFunctions.js +480 -0
  79. package/dist/interactions/ouroRotateFunctions.d.ts +22 -0
  80. package/dist/interactions/ouroRotateFunctions.js +114 -0
  81. package/dist/interactions/ouroSubCompressFunctions.d.ts +23 -0
  82. package/dist/interactions/ouroSubCompressFunctions.js +191 -0
  83. package/dist/interactions/ouroTransferFunctions.d.ts +14 -0
  84. package/dist/interactions/ouroTransferFunctions.js +87 -0
  85. package/dist/interactions/ouroTypes.d.ts +113 -0
  86. package/dist/interactions/ouroTypes.js +6 -0
  87. package/dist/interactions/ouroUrStoaFunctions.d.ts +16 -0
  88. package/dist/interactions/ouroUrStoaFunctions.js +121 -0
  89. package/dist/interactions/ouroWrapFunctions.d.ts +22 -0
  90. package/dist/interactions/ouroWrapFunctions.js +234 -0
  91. package/dist/interactions/pensionFunctions.d.ts +12 -0
  92. package/dist/interactions/pensionFunctions.js +127 -0
  93. package/dist/interactions/urStoaFunctions.d.ts +104 -0
  94. package/dist/interactions/urStoaFunctions.js +475 -0
  95. package/dist/interactions/wrapFunctions.d.ts +46 -0
  96. package/dist/interactions/wrapFunctions.js +221 -0
  97. package/dist/pact/cfmBuilders.d.ts +807 -0
  98. package/dist/pact/cfmBuilders.js +812 -0
  99. package/dist/pact/index.d.ts +1 -0
  100. package/dist/pact/index.js +10 -0
  101. package/package.json +64 -0
@@ -0,0 +1,227 @@
1
+ /**
2
+ * dexCollectablesFunctions.ts
3
+ * Collectables (Semi + Non Fungibles) entity reads — header, entries, nonce data, sets, filters, button state.
4
+ */
5
+ import { KADENA_NAMESPACE } from "../constants/index.js";
6
+ import { pactRead } from "@stoachain/stoa-core/reads";
7
+ import { getLogger } from "@stoachain/stoa-core/observability";
8
+ import { parseNonceData } from "./dexParseFunctions.js";
9
+ export async function getCollectablesHeader(account) {
10
+ try {
11
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0021_CollectablesHeader "${account}")`;
12
+ const response = await pactRead(pactCode, { tier: "T5" });
13
+ if (!response?.result || response.result.status === "failure")
14
+ return null;
15
+ const data = response.result.data;
16
+ if (!data || typeof data !== "object")
17
+ return null;
18
+ return data;
19
+ }
20
+ catch (err) {
21
+ getLogger().error("URC_0021_CollectablesHeader failed:", err);
22
+ return null;
23
+ }
24
+ }
25
+ export async function getSemifungibleEntries(account, dpdcIds) {
26
+ try {
27
+ const idList = `[${dpdcIds.map(id => `"${id}"`).join(" ")}]`;
28
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0022a_SemifungibleEntryMapper "${account}" ${idList})`;
29
+ const response = await pactRead(pactCode, { tier: "T5" });
30
+ if (!response?.result || response.result.status === "failure")
31
+ return dpdcIds.map(() => null);
32
+ const data = response.result.data;
33
+ if (!Array.isArray(data))
34
+ return dpdcIds.map(() => null);
35
+ return data;
36
+ }
37
+ catch (err) {
38
+ getLogger().error("URC_0022a_SemifungibleEntryMapper failed:", err);
39
+ return dpdcIds.map(() => null);
40
+ }
41
+ }
42
+ export async function getNonfungibleEntries(account, dpdcIds) {
43
+ try {
44
+ const idList = `[${dpdcIds.map(id => `"${id}"`).join(" ")}]`;
45
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0022a_NonfungibleEntryMapper "${account}" ${idList})`;
46
+ const response = await pactRead(pactCode, { tier: "T5" });
47
+ if (!response?.result || response.result.status === "failure")
48
+ return dpdcIds.map(() => null);
49
+ const data = response.result.data;
50
+ if (!Array.isArray(data))
51
+ return dpdcIds.map(() => null);
52
+ return data;
53
+ }
54
+ catch (err) {
55
+ getLogger().error("URC_0022a_NonfungibleEntryMapper failed:", err);
56
+ return dpdcIds.map(() => null);
57
+ }
58
+ }
59
+ export async function getCollectableNonceData(dpdcId, isSFT, nonces) {
60
+ if (nonces.length === 0)
61
+ return [];
62
+ const nonceList = nonces.join(" ");
63
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0023_CollectablesNonceData "${dpdcId}" ${isSFT} [${nonceList}])`;
64
+ try {
65
+ const response = await pactRead(pactCode, { tier: "T5" });
66
+ const data = response?.result?.data;
67
+ if (Array.isArray(data))
68
+ return data.map(parseNonceData);
69
+ return [];
70
+ }
71
+ catch (e) {
72
+ getLogger().error("URC_0023 fetch error:", e);
73
+ return [];
74
+ }
75
+ }
76
+ export async function getCollectableNonceSupply(dpdcId, isSFT, nonce) {
77
+ const pactCode = `(${KADENA_NAMESPACE}.DPDC.UR_NonceSupply "${dpdcId}" ${isSFT} ${nonce})`;
78
+ try {
79
+ const response = await pactRead(pactCode, { tier: "T5" });
80
+ const data = response?.result?.data;
81
+ if (typeof data === "number")
82
+ return data;
83
+ if (typeof data === "object" && data !== null) {
84
+ if ("decimal" in data)
85
+ return parseFloat(data.decimal) || 0;
86
+ if ("int" in data)
87
+ return parseFloat(data.int) || 0;
88
+ }
89
+ return 0;
90
+ }
91
+ catch (e) {
92
+ getLogger().error("UR_NonceSupply fetch error:", e);
93
+ return 0;
94
+ }
95
+ }
96
+ /**
97
+ * Batched per-account per-nonce supplies (DPDC.UR_AccountNoncesSupplies).
98
+ * Replaces the per-nonce UR_NonceSupply loop with a single read for N nonces.
99
+ */
100
+ export async function getAccountNoncesSupplies(account, dpdcId, isSFT, nonces) {
101
+ if (nonces.length === 0)
102
+ return [];
103
+ try {
104
+ const nonceList = nonces.join(" ");
105
+ const pactCode = `(${KADENA_NAMESPACE}.DPDC.UR_AccountNoncesSupplies "${account}" "${dpdcId}" ${isSFT} [${nonceList}])`;
106
+ const response = await pactRead(pactCode, { tier: "T5" });
107
+ if (!response?.result || response.result.status === "failure")
108
+ return nonces.map(() => 0);
109
+ const data = response.result.data;
110
+ if (!Array.isArray(data))
111
+ return nonces.map(() => 0);
112
+ return data.map((n) => {
113
+ if (typeof n === "number")
114
+ return n;
115
+ if (typeof n === "object" && n !== null) {
116
+ if ("decimal" in n)
117
+ return parseFloat(n.decimal) || 0;
118
+ if ("int" in n)
119
+ return parseFloat(n.int) || 0;
120
+ }
121
+ return parseFloat(String(n)) || 0;
122
+ });
123
+ }
124
+ catch (err) {
125
+ getLogger().error("DPDC.UR_AccountNoncesSupplies failed:", err);
126
+ return nonces.map(() => 0);
127
+ }
128
+ }
129
+ export async function getCollectableSets(dpdcId, isSFT) {
130
+ try {
131
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0024_SetReader "${dpdcId}" ${isSFT})`;
132
+ const response = await pactRead(pactCode, { tier: "T5" });
133
+ if (!response?.result || response.result.status === "failure")
134
+ return [];
135
+ const data = response.result.data;
136
+ if (!Array.isArray(data))
137
+ return [];
138
+ return data;
139
+ }
140
+ catch (err) {
141
+ getLogger().error("URC_0024_SetReader failed:", err);
142
+ return [];
143
+ }
144
+ }
145
+ /**
146
+ * Filter wallet nonces by nonce class for composite set positions.
147
+ * Returns only the nonces that match the given class.
148
+ */
149
+ export async function filterNoncesByClass(dpdcId, isSFT, nonces, nonceClass) {
150
+ if (nonces.length === 0)
151
+ return [];
152
+ try {
153
+ const nonceList = `[${nonces.join(" ")}]`;
154
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0025_FilterNoncesByClass "${dpdcId}" ${isSFT} ${nonceList} ${nonceClass})`;
155
+ const response = await pactRead(pactCode, { tier: "T5" });
156
+ if (!response?.result || response.result.status === "failure")
157
+ return [];
158
+ const data = response.result.data;
159
+ if (!Array.isArray(data))
160
+ return [];
161
+ return data.map((n) => {
162
+ if (typeof n === "number")
163
+ return n;
164
+ if (typeof n === "object" && n !== null && "int" in n)
165
+ return n.int;
166
+ return parseInt(String(n), 10) || 0;
167
+ }).filter((n) => n > 0);
168
+ }
169
+ catch (err) {
170
+ getLogger().error("URC_0025_FilterNoncesByClass failed:", err);
171
+ return [];
172
+ }
173
+ }
174
+ /**
175
+ * Batched filter-nonces-by-classes (URC_0025a_FilterNoncesByClasses).
176
+ * One network call returns one filtered nonce list per class, in order.
177
+ * Replaces N per-position calls to filterNoncesByClass.
178
+ */
179
+ export async function filterNoncesByClasses(dpdcId, isSFT, nonces, nonceClasses) {
180
+ if (nonceClasses.length === 0)
181
+ return [];
182
+ if (nonces.length === 0)
183
+ return nonceClasses.map(() => []);
184
+ try {
185
+ const nonceList = `[${nonces.join(" ")}]`;
186
+ const classList = `[${nonceClasses.join(" ")}]`;
187
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0025a_FilterNoncesByClasses "${dpdcId}" ${isSFT} ${nonceList} ${classList})`;
188
+ const response = await pactRead(pactCode, { tier: "T5" });
189
+ if (!response?.result || response.result.status === "failure")
190
+ return nonceClasses.map(() => []);
191
+ const data = response.result.data;
192
+ if (!Array.isArray(data))
193
+ return nonceClasses.map(() => []);
194
+ return data.map((row) => {
195
+ if (!Array.isArray(row))
196
+ return [];
197
+ return row.map((n) => {
198
+ if (typeof n === "number")
199
+ return n;
200
+ if (typeof n === "object" && n !== null && "int" in n)
201
+ return n.int;
202
+ return parseInt(String(n), 10) || 0;
203
+ }).filter((n) => n > 0);
204
+ });
205
+ }
206
+ catch (err) {
207
+ getLogger().error("URC_0025a_FilterNoncesByClasses failed:", err);
208
+ return nonceClasses.map(() => []);
209
+ }
210
+ }
211
+ export async function getCollectablesButtonState(account, dpdcId, isSFT, selectedNonces) {
212
+ try {
213
+ const nonceList = `[${selectedNonces.join(" ")}]`;
214
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0026_CollectablesButtons "${account}" "${dpdcId}" ${isSFT} ${nonceList})`;
215
+ const response = await pactRead(pactCode, { tier: "T5" });
216
+ if (!response?.result || response.result.status === "failure")
217
+ return null;
218
+ const data = response.result.data;
219
+ if (!data || typeof data !== "object")
220
+ return null;
221
+ return data;
222
+ }
223
+ catch (err) {
224
+ getLogger().error("URC_0026_CollectablesButtons failed:", err);
225
+ return null;
226
+ }
227
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * dexFunctions.ts
3
+ *
4
+ * Thin re-export shim for backward compat (Phase 1 of v4.2.0).
5
+ *
6
+ * The original 2663-line god file was split along Ouronet's locked seven-entity
7
+ * taxonomy. Real logic now lives in entity-oriented files: dexSwapPair*Functions
8
+ * (calc, execute, smart-swap, dashboard, admin), dexTrueFungibleFunctions,
9
+ * dexOrtoFungibleFunctions, dexCollectablesFunctions, dexAcquisitionPoolFunctions,
10
+ * dexParseFunctions, dexTypes. Every original symbol is reachable via this shim.
11
+ */
12
+ export * from "./dexTypes.js";
13
+ export * from "./dexParseFunctions.js";
14
+ export * from "./dexSwapPairCalcFunctions.js";
15
+ export * from "./dexSwapPairExecuteFunctions.js";
16
+ export * from "./dexSwapPairSmartSwapFunctions.js";
17
+ export * from "./dexSwapPairDashboardFunctions.js";
18
+ export * from "./dexSwapPairAdminFunctions.js";
19
+ export * from "./dexTrueFungibleFunctions.js";
20
+ export * from "./dexOrtoFungibleFunctions.js";
21
+ export * from "./dexCollectablesFunctions.js";
22
+ export * from "./dexAcquisitionPoolFunctions.js";
23
+ export * from "./addLiquidityFunctions.js";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * dexFunctions.ts
3
+ *
4
+ * Thin re-export shim for backward compat (Phase 1 of v4.2.0).
5
+ *
6
+ * The original 2663-line god file was split along Ouronet's locked seven-entity
7
+ * taxonomy. Real logic now lives in entity-oriented files: dexSwapPair*Functions
8
+ * (calc, execute, smart-swap, dashboard, admin), dexTrueFungibleFunctions,
9
+ * dexOrtoFungibleFunctions, dexCollectablesFunctions, dexAcquisitionPoolFunctions,
10
+ * dexParseFunctions, dexTypes. Every original symbol is reachable via this shim.
11
+ */
12
+ export * from "./dexTypes.js";
13
+ export * from "./dexParseFunctions.js";
14
+ export * from "./dexSwapPairCalcFunctions.js";
15
+ export * from "./dexSwapPairExecuteFunctions.js";
16
+ export * from "./dexSwapPairSmartSwapFunctions.js";
17
+ export * from "./dexSwapPairDashboardFunctions.js";
18
+ export * from "./dexSwapPairAdminFunctions.js";
19
+ export * from "./dexTrueFungibleFunctions.js";
20
+ export * from "./dexOrtoFungibleFunctions.js";
21
+ export * from "./dexCollectablesFunctions.js";
22
+ export * from "./dexAcquisitionPoolFunctions.js";
23
+ export * from "./addLiquidityFunctions.js";
@@ -0,0 +1,33 @@
1
+ /**
2
+ * dexOrtoFungibleFunctions.ts
3
+ * Orto Fungible (OF) entity reads — header, entries, sleeping-LP, nonces supplies/metadata, button state, hibernating.
4
+ */
5
+ import type { OrtoFungibleHeaderData, OrtoFungibleEntryData, OrtofungibleButtonState, HibernatingNonceData } from "./dexTypes.js";
6
+ /**
7
+ * Fetch Orto Fungible header data for an account.
8
+ * Returns global OF count + nonces, held OF list/count, managed OF list/count.
9
+ */
10
+ export declare function getOrtoFungibleHeader(account: string): Promise<OrtoFungibleHeaderData | null>;
11
+ /**
12
+ * Batch-fetch OrtoFungibleEntry data for Native/Vesting/Sleeping/Hibernating tokens.
13
+ * Uses URC_0009a_OrtoFungibleEntryMapper(account, dpofs:[string])
14
+ */
15
+ export declare function getOrtoFungibleEntries(account: string, tokenIds: string[]): Promise<(OrtoFungibleEntryData | null)[]>;
16
+ /**
17
+ * Batch-fetch Sleeping LP Orto Fungible data.
18
+ * Uses URC_0009b_OrtoFungibleSleepingLPMapper(account, lp-ids:[string])
19
+ */
20
+ export declare function getOrtoFungibleSleepingLPEntries(account: string, lpIds: string[]): Promise<(OrtoFungibleEntryData | null)[]>;
21
+ /**
22
+ * Fetch supplies for specific nonces of an Orto Fungible.
23
+ * Returns a list of decimal strings (one per nonce, in order).
24
+ */
25
+ export declare function getOrtoFungibleNoncesSupplies(dpofId: string, nonces: number[]): Promise<string[]>;
26
+ /**
27
+ * Fetch metadata for specific nonces of an Orto Fungible.
28
+ * Returns array of metadata objects (one per nonce).
29
+ * Each nonce's metadata is itself an array of objects [object].
30
+ */
31
+ export declare function getOrtoFungibleNoncesMetaDatas(dpofId: string, nonces: number[]): Promise<(any[] | null)[]>;
32
+ export declare function getOrtofungibleButtonState(account: string, dpofId: string, selectedNonces: number[]): Promise<OrtofungibleButtonState | null>;
33
+ export declare function getHibernatingNonceData(dpofId: string, nonce: number): Promise<HibernatingNonceData | null>;
@@ -0,0 +1,171 @@
1
+ /**
2
+ * dexOrtoFungibleFunctions.ts
3
+ * Orto Fungible (OF) entity reads — header, entries, sleeping-LP, nonces supplies/metadata, button state, hibernating.
4
+ */
5
+ import { KADENA_NAMESPACE } from "../constants/index.js";
6
+ import { pactRead } from "@stoachain/stoa-core/reads";
7
+ import { getLogger } from "@stoachain/stoa-core/observability";
8
+ /**
9
+ * Fetch Orto Fungible header data for an account.
10
+ * Returns global OF count + nonces, held OF list/count, managed OF list/count.
11
+ */
12
+ export async function getOrtoFungibleHeader(account) {
13
+ try {
14
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0018_OrtofungibleHeader "${account}")`;
15
+ const response = await pactRead(pactCode, { tier: "T5" });
16
+ if (!response?.result || response.result.status === "failure")
17
+ return null;
18
+ const data = response.result.data;
19
+ if (!data || typeof data !== "object")
20
+ return null;
21
+ return data;
22
+ }
23
+ catch (err) {
24
+ getLogger().error("URC_0018_OrtofungibleHeader failed:", err);
25
+ return null;
26
+ }
27
+ }
28
+ /**
29
+ * Batch-fetch OrtoFungibleEntry data for Native/Vesting/Sleeping/Hibernating tokens.
30
+ * Uses URC_0009a_OrtoFungibleEntryMapper(account, dpofs:[string])
31
+ */
32
+ export async function getOrtoFungibleEntries(account, tokenIds) {
33
+ if (tokenIds.length === 0)
34
+ return [];
35
+ try {
36
+ const listItems = tokenIds.map(id => `"${id}"`).join(" ");
37
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0009a_OrtoFungibleEntryMapper "${account}" [${listItems}])`;
38
+ const response = await pactRead(pactCode, { tier: "T5" });
39
+ if (!response?.result || response.result.status === "failure")
40
+ return tokenIds.map(() => null);
41
+ const data = response.result.data;
42
+ if (!Array.isArray(data))
43
+ return tokenIds.map(() => null);
44
+ return data.map((item) => {
45
+ if (!item || typeof item !== "object" || item === false)
46
+ return null;
47
+ return item;
48
+ });
49
+ }
50
+ catch (err) {
51
+ getLogger().error("URC_0009a_OrtoFungibleEntryMapper failed:", err);
52
+ return tokenIds.map(() => null);
53
+ }
54
+ }
55
+ /**
56
+ * Batch-fetch Sleeping LP Orto Fungible data.
57
+ * Uses URC_0009b_OrtoFungibleSleepingLPMapper(account, lp-ids:[string])
58
+ */
59
+ export async function getOrtoFungibleSleepingLPEntries(account, lpIds) {
60
+ if (lpIds.length === 0)
61
+ return [];
62
+ try {
63
+ const listItems = lpIds.map(id => `"${id}"`).join(" ");
64
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0009b_OrtoFungibleSleepingLPMapper "${account}" [${listItems}])`;
65
+ const response = await pactRead(pactCode, { tier: "T5" });
66
+ if (!response?.result || response.result.status === "failure")
67
+ return lpIds.map(() => null);
68
+ const data = response.result.data;
69
+ if (!Array.isArray(data))
70
+ return lpIds.map(() => null);
71
+ return data.map((item) => {
72
+ if (!item || typeof item !== "object" || item === false)
73
+ return null;
74
+ return item;
75
+ });
76
+ }
77
+ catch (err) {
78
+ getLogger().error("URC_0009b_OrtoFungibleSleepingLPMapper failed:", err);
79
+ return lpIds.map(() => null);
80
+ }
81
+ }
82
+ /**
83
+ * Fetch supplies for specific nonces of an Orto Fungible.
84
+ * Returns a list of decimal strings (one per nonce, in order).
85
+ */
86
+ export async function getOrtoFungibleNoncesSupplies(dpofId, nonces) {
87
+ if (nonces.length === 0)
88
+ return [];
89
+ try {
90
+ const nonceList = nonces.join(" ");
91
+ const pactCode = `(${KADENA_NAMESPACE}.DPOF.UR_NoncesSupplies "${dpofId}" [${nonceList}])`;
92
+ const response = await pactRead(pactCode, { tier: "T5" });
93
+ if (!response?.result || response.result.status === "failure")
94
+ return nonces.map(() => "0");
95
+ const data = response.result.data;
96
+ if (!Array.isArray(data))
97
+ return nonces.map(() => "0");
98
+ return data.map((item) => {
99
+ if (item === null || item === undefined)
100
+ return "0";
101
+ if (typeof item === "object" && "decimal" in item)
102
+ return String(item.decimal);
103
+ return String(item);
104
+ });
105
+ }
106
+ catch (err) {
107
+ getLogger().error("DPOF.UR_NoncesSupplies failed:", err);
108
+ return nonces.map(() => "0");
109
+ }
110
+ }
111
+ /**
112
+ * Fetch metadata for specific nonces of an Orto Fungible.
113
+ * Returns array of metadata objects (one per nonce).
114
+ * Each nonce's metadata is itself an array of objects [object].
115
+ */
116
+ export async function getOrtoFungibleNoncesMetaDatas(dpofId, nonces) {
117
+ if (nonces.length === 0)
118
+ return [];
119
+ try {
120
+ const nonceList = nonces.join(" ");
121
+ const pactCode = `(${KADENA_NAMESPACE}.DPOF.UR_NoncesMetaDatas "${dpofId}" [${nonceList}])`;
122
+ const response = await pactRead(pactCode, { tier: "T5" });
123
+ if (!response?.result || response.result.status === "failure")
124
+ return nonces.map(() => null);
125
+ const data = response.result.data;
126
+ if (!Array.isArray(data))
127
+ return nonces.map(() => null);
128
+ return data.map((item) => {
129
+ if (!item || !Array.isArray(item))
130
+ return item ? [item] : null;
131
+ return item;
132
+ });
133
+ }
134
+ catch (err) {
135
+ getLogger().error("DPOF.UR_NoncesMetaDatas failed:", err);
136
+ return nonces.map(() => null);
137
+ }
138
+ }
139
+ export async function getOrtofungibleButtonState(account, dpofId, selectedNonces) {
140
+ try {
141
+ const nonceList = `[${selectedNonces.join(" ")}]`;
142
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0019_OrtofungibleButton "${account}" "${dpofId}" ${nonceList})`;
143
+ const response = await pactRead(pactCode, { tier: "T5" });
144
+ if (!response?.result || response.result.status === "failure")
145
+ return null;
146
+ const data = response.result.data;
147
+ if (!data || typeof data !== "object")
148
+ return null;
149
+ return data;
150
+ }
151
+ catch (err) {
152
+ getLogger().error("URC_0019_OrtofungibleButton failed:", err);
153
+ return null;
154
+ }
155
+ }
156
+ export async function getHibernatingNonceData(dpofId, nonce) {
157
+ try {
158
+ const pactCode = `(${KADENA_NAMESPACE}.DPL-UR.URC_0020_HibernatingNonceData "${dpofId}" ${nonce})`;
159
+ const response = await pactRead(pactCode, { tier: "T5" });
160
+ if (!response?.result || response.result.status === "failure")
161
+ return null;
162
+ const data = response.result.data;
163
+ if (!data || typeof data !== "object")
164
+ return null;
165
+ return data;
166
+ }
167
+ catch (err) {
168
+ getLogger().error("URC_0020_HibernatingNonceData failed:", err);
169
+ return null;
170
+ }
171
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * dexParseFunctions.ts
3
+ * Pact response parsers and formatters for dex entities (cross-cutting helpers).
4
+ */
5
+ import type { DecimalValue, SwapPoolData, PoolPreviewData, SwapLiquidityProviderItem, SwapLiquidityProviderItemPrecise, TrueFungibleLPEntry, TrueFungibleEntryData, OrtoFungibleEntryData, OrtoFungibleCategory, NonceData } from "./dexTypes.js";
6
+ export declare function parseSwapAmount(amountString: string): number;
7
+ /**
8
+ * Parse swap amount as string to preserve full decimal precision
9
+ * @param amountString - String like "WSTOA-8Nh-JO8JO4F5 Output: 28.633136871920000000000000"
10
+ * @returns The numeric value as a string with full precision
11
+ */
12
+ export declare function parseSwapAmountPrecise(amountString: string): string;
13
+ export declare function parseSwapLiquidityProviders(providers: string[]): number;
14
+ export declare function parseSwapLiquidityProvidersDetailed(providers: string[]): SwapLiquidityProviderItem[];
15
+ /**
16
+ * Parse liquidity provider fees with full precision
17
+ * @param providers - Array of provider strings from API
18
+ * @returns Array of {token, amount} with amount as string for full precision
19
+ */
20
+ export declare function parseSwapLiquidityProvidersDetailedPrecise(providers: string[]): SwapLiquidityProviderItemPrecise[];
21
+ /**
22
+ * Parse decimal string to number for display
23
+ */
24
+ export declare function parseDecimalValue(decimalValue: DecimalValue): number;
25
+ /**
26
+ * Parse decimal value as string to preserve full precision
27
+ * @param decimalValue - DecimalValue object with decimal string
28
+ * @returns The decimal value as a string with full precision
29
+ */
30
+ export declare function parseDecimalValuePrecise(decimalValue: DecimalValue): string;
31
+ /**
32
+ * Format pool type for display
33
+ */
34
+ export declare function formatPoolType(poolType: string, poolTypeWord: string): string;
35
+ /**
36
+ * Get total pool value in USD from a pool
37
+ */
38
+ export declare function getPoolValueUSD(pool: SwapPoolData): string;
39
+ /**
40
+ * Get pool tokens summary
41
+ */
42
+ export declare function getPoolTokensSummary(pool: SwapPoolData): {
43
+ tokens: readonly string[];
44
+ supplies: number[];
45
+ totalTokens: number;
46
+ };
47
+ /**
48
+ * Calculate total fees for pool
49
+ */
50
+ export declare function getPoolFeeStructure(pool: SwapPoolData): {
51
+ liquidFee: number;
52
+ lpFee: number;
53
+ specialFee: number;
54
+ totalFee: number;
55
+ };
56
+ /**
57
+ * Get special fee targets with proportions
58
+ */
59
+ export declare function getSpecialFeeTargets(pool: SwapPoolData): {
60
+ targets: readonly string[];
61
+ shortTargets: readonly string[];
62
+ proportions: readonly number[];
63
+ };
64
+ /**
65
+ * Get formatted pool values from enhanced preview data
66
+ */
67
+ export declare function getFormattedPoolValues(pool: PoolPreviewData): {
68
+ formattedPoolValue: string;
69
+ formattedLpSupply: string;
70
+ formattedLpValue: string;
71
+ formattedTokenSupplies: readonly string[];
72
+ };
73
+ /**
74
+ * Get pool weights and calculate percentages
75
+ */
76
+ export declare function getPoolWeights(pool: PoolPreviewData): {
77
+ weights: readonly number[];
78
+ weightPercentages: string[];
79
+ isBalanced: boolean;
80
+ };
81
+ /**
82
+ * Calculate pool composition data for charts/visualizations
83
+ */
84
+ export declare function getPoolComposition(pool: PoolPreviewData): {
85
+ tokens: readonly string[];
86
+ supplies: number[];
87
+ weights: readonly number[];
88
+ compositions: Array<{
89
+ token: string;
90
+ supply: number;
91
+ weight: number;
92
+ percentage: string;
93
+ formattedSupply: string;
94
+ }>;
95
+ };
96
+ export declare function formatLPEntry(entry: TrueFungibleLPEntry): {
97
+ name: string;
98
+ tokenId: string;
99
+ walletSupply: string;
100
+ totalSupply: string;
101
+ walletStoa: string;
102
+ walletUsd: string;
103
+ tokenStoa: string;
104
+ tokenUsd: string;
105
+ };
106
+ /**
107
+ * Format a TrueFungibleEntry response into display-ready values.
108
+ */
109
+ export declare function formatTFEntry(entry: TrueFungibleEntryData): {
110
+ name: string;
111
+ tokenId: string;
112
+ walletSupply: string;
113
+ totalSupply: string;
114
+ walletStoa: string;
115
+ walletUsd: string;
116
+ tokenStoa: string;
117
+ tokenUsd: string;
118
+ };
119
+ /**
120
+ * Format an OrtoFungibleEntryData into display-ready values.
121
+ * Same as formatTFEntry but includes wallet-nonces.
122
+ */
123
+ export declare function formatOFEntry(entry: OrtoFungibleEntryData): {
124
+ name: string;
125
+ tokenId: string;
126
+ walletSupply: string;
127
+ totalSupply: string;
128
+ walletStoa: string;
129
+ walletUsd: string;
130
+ tokenStoa: string;
131
+ tokenUsd: string;
132
+ walletNonces: number[];
133
+ walletNoncesNo: number;
134
+ };
135
+ /**
136
+ * Classify a token ID into its category based on prefix.
137
+ * Returns: "lp" | "frozen-lp" | "frozen" | "reserved" | "native"
138
+ */
139
+ export declare function classifyTokenId(tokenId: string): "lp" | "frozen-lp" | "frozen" | "reserved" | "native";
140
+ /**
141
+ * Classify an Orto Fungible token ID into one of 5 categories.
142
+ *
143
+ * Sleeping LP: Z|S|, Z|W|, Z|P|
144
+ * Vesting: V|
145
+ * Sleeping: Z| (but NOT Z|S|, Z|W|, Z|P|)
146
+ * Hibernating: H|
147
+ * Native: everything else
148
+ */
149
+ export declare function classifyOrtoFungibleId(tokenId: string): OrtoFungibleCategory;
150
+ export declare function parseNonceData(raw: any): NonceData;