@owney/sdk 0.5.3 → 0.5.4

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/dist/index.cjs CHANGED
@@ -268,6 +268,14 @@ function mapApyHistory(raw) {
268
268
  apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
269
269
  };
270
270
  }
271
+ function splitOpportunity(opportunity) {
272
+ const match = opportunity.match(/^(.*?)\s*\(([^)]*)\)\s*$/);
273
+ if (match) {
274
+ const pool = match[2].trim();
275
+ return { protocol: match[1].trim(), pool: pool || void 0 };
276
+ }
277
+ return { protocol: opportunity.trim() };
278
+ }
271
279
  function mapEntries(rawEntries, chainId) {
272
280
  const actionMap = {
273
281
  "Top up wallet": "Top up",
@@ -287,10 +295,14 @@ function mapEntries(rawEntries, chainId) {
287
295
  );
288
296
  oldApy = Number(rawLog.oldApy);
289
297
  newApy = Number(rawLog.newApy);
298
+ const from = splitOpportunity(rawLog.oldOpportunity);
299
+ const to = splitOpportunity(rawLog.newOpportunity);
290
300
  rebalanceLog = [
291
301
  {
292
- fromProtocol: rawLog.oldOpportunity.replace(/\s*\(.*?\)/g, "").trim(),
293
- toProtocol: rawLog.newOpportunity.replace(/\s*\(.*?\)/g, "").trim(),
302
+ fromProtocol: from.protocol,
303
+ toProtocol: to.protocol,
304
+ fromPool: from.pool,
305
+ toPool: to.pool,
294
306
  tokenSymbol: matched?.token_symbol ?? "",
295
307
  amount: matched ? String(hexToDecimal(matched.amount || "0x")) : "",
296
308
  status: "success"
package/dist/index.d.cts CHANGED
@@ -114,6 +114,15 @@ interface HistoryTransaction {
114
114
  interface RebalanceLog {
115
115
  fromProtocol: string;
116
116
  toProtocol: string;
117
+ /**
118
+ * Pool/vault sub-label for the source position (e.g. "USDC Core"), when the
119
+ * agent exposes one. Lets consumers disambiguate moves within the same
120
+ * protocol ("Morpho · USDC Core → Morpho · Spark USDC"). Absent when the
121
+ * agent only reports a bare protocol name.
122
+ */
123
+ fromPool?: string;
124
+ /** Pool/vault sub-label for the destination position. See {@link fromPool}. */
125
+ toPool?: string;
117
126
  tokenSymbol: string;
118
127
  amount: string;
119
128
  status: "success" | "failed";
package/dist/index.d.ts CHANGED
@@ -114,6 +114,15 @@ interface HistoryTransaction {
114
114
  interface RebalanceLog {
115
115
  fromProtocol: string;
116
116
  toProtocol: string;
117
+ /**
118
+ * Pool/vault sub-label for the source position (e.g. "USDC Core"), when the
119
+ * agent exposes one. Lets consumers disambiguate moves within the same
120
+ * protocol ("Morpho · USDC Core → Morpho · Spark USDC"). Absent when the
121
+ * agent only reports a bare protocol name.
122
+ */
123
+ fromPool?: string;
124
+ /** Pool/vault sub-label for the destination position. See {@link fromPool}. */
125
+ toPool?: string;
117
126
  tokenSymbol: string;
118
127
  amount: string;
119
128
  status: "success" | "failed";
package/dist/index.js CHANGED
@@ -236,6 +236,14 @@ function mapApyHistory(raw) {
236
236
  apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
237
237
  };
238
238
  }
239
+ function splitOpportunity(opportunity) {
240
+ const match = opportunity.match(/^(.*?)\s*\(([^)]*)\)\s*$/);
241
+ if (match) {
242
+ const pool = match[2].trim();
243
+ return { protocol: match[1].trim(), pool: pool || void 0 };
244
+ }
245
+ return { protocol: opportunity.trim() };
246
+ }
239
247
  function mapEntries(rawEntries, chainId) {
240
248
  const actionMap = {
241
249
  "Top up wallet": "Top up",
@@ -255,10 +263,14 @@ function mapEntries(rawEntries, chainId) {
255
263
  );
256
264
  oldApy = Number(rawLog.oldApy);
257
265
  newApy = Number(rawLog.newApy);
266
+ const from = splitOpportunity(rawLog.oldOpportunity);
267
+ const to = splitOpportunity(rawLog.newOpportunity);
258
268
  rebalanceLog = [
259
269
  {
260
- fromProtocol: rawLog.oldOpportunity.replace(/\s*\(.*?\)/g, "").trim(),
261
- toProtocol: rawLog.newOpportunity.replace(/\s*\(.*?\)/g, "").trim(),
270
+ fromProtocol: from.protocol,
271
+ toProtocol: to.protocol,
272
+ fromPool: from.pool,
273
+ toPool: to.pool,
262
274
  tokenSymbol: matched?.token_symbol ?? "",
263
275
  amount: matched ? String(hexToDecimal(matched.amount || "0x")) : "",
264
276
  status: "success"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",