@agoric/portfolio-api 0.1.1-dev-0417cac.0.0417cac → 0.1.1-dev-4739e0f.0.4739e0f

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/README.md CHANGED
@@ -2,6 +2,83 @@
2
2
 
3
3
  API shared between on-chain contract and external clients
4
4
 
5
+ ## Withdrawals and typed observations
6
+
7
+ Movements use `withdraw?: WithdrawParams` without parameterizing `MovementDesc`
8
+ or `FundsFlowPlan`. The shared `WithdrawParamsShape` checks structural input:
9
+ optional `max` and nonnegative bigint `amountOfShares`.
10
+ Consumers implementing these options must also validate source/destination
11
+ routes and the selected holding's identity. A Shape match alone does not
12
+ authorize execution.
13
+
14
+ The movement's `amount` is default-token units (micro-USDC) received at `dest`.
15
+ It is a minimum if `max` is true or `amountOfShares` is supplied, otherwise exact.
16
+ `amountOfShares` is raw share-token units: exact unless `max` is true. Without
17
+ it, a position interprets the movement's `amount` in principal-token units.
18
+
19
+ Withdrawal options are additive. A contract that does not implement them can
20
+ accept the structure and execute the movement's `amount` exactly, ignoring the
21
+ options. This is the current contract's fallback; `amount: 0` may fail
22
+ validation. API acceptance does not imply full-exit or share-quantity support.
23
+
24
+ `MovementDescExt` and `FundsFlowPlanExt` provide forward-compatible structural
25
+ input types. They allow future source/destination place strings and additional
26
+ movement/plan fields, while preserving the required ERTP `amount`, known
27
+ withdrawal options, and other declared field types. The contract's
28
+ `makeOfferArgsShapes` exposes matching `movementDescShapeExt` and `planShapeExt`,
29
+ with the same flow/dependency size limits as ordinary plans. Ext acceptance
30
+ alone does not establish that a place or withdrawal operation is supported;
31
+ existing offer boundaries and execution behavior remain unchanged.
32
+
33
+ `PlanObservations` retains legacy aggregate `balances` and optionally carries
34
+ `holdings: TypedHoldingDetail[]`. Each raw holding identifies `place`, `kind`,
35
+ `tokenAddress`, and native-unit `amount`; `valueUsd` is optional micro-USD.
36
+ `HoldingDetail` is the union of legacy balance entries and typed raw holdings.
37
+ `HoldingDetailShape` and `PlanObservationsShape` check structural input;
38
+ converters also validate place/kind compatibility, addresses, native-token zero
39
+ addresses, integer ranges, and duplicate holding identities (case-insensitive
40
+ addresses). `claimable-reward` belongs to an instrument; `claimed-reward`
41
+ belongs to a chain account.
42
+
43
+ Use the existing observation schema, kit, and converters from
44
+ `./src/observation-messages.js`: `YmaxObservationMessageSchema`,
45
+ `ymaxObservationMessageKit`, `portfolioObservationsToEIP712`, and
46
+ `portfolioObservationsFromEIP712`. Both legacy balances and typed holdings use
47
+ `YmaxObservation` domain version `1`; resolved signed struct definitions identify
48
+ which optional fields were included. Legacy balance-only messages retain their
49
+ original signed field definitions. There are no separate v2 schema exports.
50
+
51
+ In application data, an unknown valuation is an absent `valueUsd`, distinct
52
+ from a known zero. EIP-712 cannot omit a field from only some instances of a
53
+ struct type, so on the wire every typed holding carries `valueUsd` as an
54
+ `int256`, with `VALUE_USD_UNKNOWN` (`-1n`) standing for an unknown valuation.
55
+ `portfolioObservationsToEIP712` encodes an absent valuation as the sentinel and
56
+ `portfolioObservationsFromEIP712` strips it; the sentinel never appears in
57
+ `TypedHoldingDetail`. Known valuations must satisfy
58
+ `0n <= value <= MAX_VALUE_USD` (`2n ** 255n - 1n`). Integer normalization works
59
+ without Endo initialization.
60
+
61
+ Deprecated `balanceUsdc` remains optional unsigned `uint256` without a
62
+ sentinel: include it on every raw holding or omit it from all of them. It is a
63
+ transitional bridge for consumers that still read legacy `balances`: decoding
64
+ typed holdings sums `balanceUsdc` per place into `balances`. Producers put the
65
+ place's legacy balance on one holding per place and `0n` on the others.
66
+ `valueUsd` never feeds `balances`. When authoring typed holdings, `balances`
67
+ may be empty or must equal that derivation (as decoding returns); anything else
68
+ is rejected rather than silently discarded.
69
+
70
+ Removal timeline: (1) deploy contracts that accept typed holdings; (2) switch
71
+ producers to typed holdings carrying `balanceUsdc`; (3) move contract consumers
72
+ from `balances` to `holdings`; (4) stop producing `balanceUsdc`, then drop
73
+ legacy balance-only holdings and `balanceUsdc` from the schema.
74
+
75
+ A raw zero is an explicit `amount: 0n`; an absent holding is unobserved. Empty holdings
76
+ and empty balances encode the same empty array and decode to empty balances.
77
+ The decoder expects normalized data extracted with
78
+ `onUnknownSignedField: 'throw'` after signature/domain verification; it does not
79
+ verify signatures itself. Supporting the schema does not implement withdrawal
80
+ execution or authorize a source holding. This API does not sign plans.
81
+
5
82
  ## YDS Target Balances
6
83
 
7
84
  The YMax Data Service (YDS) should import the shared target-balance helper and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/portfolio-api",
3
- "version": "0.1.1-dev-0417cac.0.0417cac",
3
+ "version": "0.1.1-dev-4739e0f.0.4739e0f",
4
4
  "description": "API for Portfolio management",
5
5
  "repository": {
6
6
  "type": "git",
@@ -47,8 +47,8 @@
47
47
  "generate:ymax-machine": "npx tsx scripts/gen-ymax-machine.mts"
48
48
  },
49
49
  "dependencies": {
50
- "@agoric/internal": "0.3.3-dev-0417cac.0.0417cac",
51
- "@agoric/orchestration": "0.1.1-dev-0417cac.0.0417cac",
50
+ "@agoric/internal": "0.3.3-dev-4739e0f.0.4739e0f",
51
+ "@agoric/orchestration": "0.1.1-dev-4739e0f.0.4739e0f",
52
52
  "@endo/common": "^1.4.0",
53
53
  "@endo/errors": "^1.3.1",
54
54
  "@endo/patterns": "^1.9.1"
@@ -74,5 +74,5 @@
74
74
  "engines": {
75
75
  "node": "^22.11 || ^24.14"
76
76
  },
77
- "gitHead": "0417caca9eee0154e65b74f62962edcf172cf118"
77
+ "gitHead": "4739e0fa869e9669e1eb6deafd603dda167b13a0"
78
78
  }
@@ -61,10 +61,27 @@ declare const ObservationSubTypes: {
61
61
  readonly HoldingDetail: readonly [{
62
62
  readonly name: "place";
63
63
  readonly type: "string";
64
- }, {
65
- readonly name: "balanceUsdc";
66
- readonly type: "uint256";
67
- }];
64
+ }, ...({
65
+ optional: true;
66
+ name: "balanceUsdc";
67
+ type: "uint256";
68
+ } | {
69
+ optional: true;
70
+ name: "kind";
71
+ type: "string";
72
+ } | {
73
+ optional: true;
74
+ name: "tokenAddress";
75
+ type: "address";
76
+ } | {
77
+ optional: true;
78
+ name: "amount";
79
+ type: "uint256";
80
+ } | {
81
+ optional: true;
82
+ name: "valueUsd";
83
+ type: "int256";
84
+ })[]];
68
85
  readonly InstrumentDetail: readonly [{
69
86
  readonly name: "instrumentId";
70
87
  readonly type: "string";
@@ -115,10 +132,27 @@ export declare const YmaxObservationMessageSchema: {
115
132
  readonly HoldingDetail: readonly [{
116
133
  readonly name: "place";
117
134
  readonly type: "string";
118
- }, {
119
- readonly name: "balanceUsdc";
120
- readonly type: "uint256";
121
- }];
135
+ }, ...({
136
+ optional: true;
137
+ name: "balanceUsdc";
138
+ type: "uint256";
139
+ } | {
140
+ optional: true;
141
+ name: "kind";
142
+ type: "string";
143
+ } | {
144
+ optional: true;
145
+ name: "tokenAddress";
146
+ type: "address";
147
+ } | {
148
+ optional: true;
149
+ name: "amount";
150
+ type: "uint256";
151
+ } | {
152
+ optional: true;
153
+ name: "valueUsd";
154
+ type: "int256";
155
+ })[]];
122
156
  readonly InstrumentDetail: readonly [{
123
157
  readonly name: "instrumentId";
124
158
  readonly type: "string";
@@ -145,22 +179,30 @@ export type PortfolioObservationsContent = {
145
179
  observations: PlanObservations;
146
180
  };
147
181
  /**
148
- * Convert the content of a portfolio observation to the data of a
149
- * `PortfolioObservations` message, e.g. for the attestor to sign.
150
- *
151
- * @param observation
182
+ * EIP-712 cannot omit a field from only some instances of a struct type, so
183
+ * typed holdings always carry `valueUsd` on the wire, using this sentinel for
184
+ * an unknown valuation. The converters below translate it to and from an
185
+ * absent `valueUsd` in {@link TypedHoldingDetail}; it never reaches
186
+ * application data.
152
187
  */
153
- export declare const portfolioObservationsToEIP712: ({ portfolioId, syncState: { policyVersion, rebalanceCount }, observations: { balances, instrumentTvls }, }: PortfolioObservationsContent) => PortfolioObservationsEIP712Input;
188
+ export declare const VALUE_USD_UNKNOWN = -1n;
189
+ /** Largest valuation representable in the signed `int256` wire field. */
190
+ export declare const MAX_VALUE_USD: bigint;
154
191
  /**
155
- * Convert the data of a signed `PortfolioObservations` message to its
156
- * application-level content.
157
- *
158
- * Expects the data as extracted by `makeEIP712MessageHandlerUtils` with
159
- * `onUnknownSignedField: 'throw'`, i.e. normalized and without fields this
160
- * version does not understand. Fails closed: rejects places or instruments
161
- * that are invalid or listed more than once, and values out of range.
162
- *
163
- * @param data
192
+ * Author either legacy balances or typed holdings using the shared schema.
193
+ * Typed holdings always carry `valueUsd`, with {@link VALUE_USD_UNKNOWN}
194
+ * standing for an absent valuation. With typed holdings, `balances` may only
195
+ * repeat what their `balanceUsdc` values derive (as decoding returns), so no
196
+ * balance is silently dropped.
197
+ */
198
+ export declare const portfolioObservationsToEIP712: ({ portfolioId, syncState, observations: { balances, holdings, instrumentTvls }, }: PortfolioObservationsContent) => PortfolioObservationsEIP712Input;
199
+ /**
200
+ * Decode normalized authenticated observations. The handler must use
201
+ * onUnknownSignedField: 'throw'. This converter does not verify signatures.
202
+ * For typed holdings, `balances` is derived from their deprecated
203
+ * `balanceUsdc` (see {@link balancesFromTypedHoldings}), never from `valueUsd`.
204
+ * A typed holding's {@link VALUE_USD_UNKNOWN} valuation decodes to an absent
205
+ * `valueUsd`.
164
206
  */
165
207
  export declare const portfolioObservationsFromEIP712: ({ portfolio, syncState, holdings, instruments, }: PortfolioObservationsEIP712) => PortfolioObservationsContent;
166
208
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"observation-messages.d.ts","sourceRoot":"","sources":["observation-messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAEf,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC7B,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EA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B,OAAO,CACR,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,mCAAmC,GAAG,uBAAuB,CACvE,4BAA4B,EAC5B,uBAAuB,CACxB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GACrC,aAAa,CAAC,mCAAmC,CAAC,CAAC;AAErD,0EAA0E;AAC1E,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,YAAY,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,yEAAyE;AACzE,eAAO,MAAM,aAAa,QAAkB,CAAC;AA6I7C;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,GAAI,mFAI3C,4BAA4B,KAAG,gCAsDjC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,GAAI,kDAK7C,2BAA2B,KAAG,4BAyDhC,CAAC"}
@@ -36,11 +36,14 @@ import {
36
36
 
37
37
  } from '@agoric/orchestration/src/utils/eip712-messages.js';
38
38
  ;
39
- ;
40
- import { isInstrumentId, isPortfolioBalancePlaceRef } from './places.js';
39
+ import {
40
+ isInterChainAccountRef,
41
+ isInstrumentId,
42
+ isPortfolioBalancePlaceRef,
43
+ } from './places.js';
41
44
  ;
42
45
 
43
-
46
+
44
47
 
45
48
 
46
49
 
@@ -67,6 +70,21 @@ const ObservationOperationTypes = {
67
70
  ],
68
71
  } ;
69
72
 
73
+ const holdingDetailV1 = [
74
+ { name: 'balanceUsdc', type: 'uint256' },
75
+ ] ;
76
+
77
+ const holdingDetailV2 = [
78
+ { name: 'kind', type: 'string' },
79
+ { name: 'tokenAddress', type: 'address' },
80
+ { name: 'amount', type: 'uint256' },
81
+ /**
82
+ * Valuation in micro-USD, or {@link VALUE_USD_UNKNOWN} if not observed.
83
+ * Signed only to make room for that sentinel.
84
+ */
85
+ { name: 'valueUsd', type: 'int256' },
86
+ ] ;
87
+
70
88
  const ObservationSubTypes = {
71
89
  /** @see {@link PortfolioSyncState} */
72
90
  SyncState: [
@@ -76,8 +94,8 @@ const ObservationSubTypes = {
76
94
  HoldingDetail: [
77
95
  /** a {@link PortfolioBalancePlaceRef} */
78
96
  { name: 'place', type: 'string' },
79
- /** in micro-USDC (6 decimal places) */
80
- { name: 'balanceUsdc', type: 'uint256' },
97
+ ...holdingDetailV1.map(el => ({ ...el, optional: true })),
98
+ ...holdingDetailV2.map(el => ({ ...el, optional: true })),
81
99
  ],
82
100
  InstrumentDetail: [
83
101
  /** an {@link InstrumentId} */
@@ -134,44 +152,231 @@ export const ymaxObservationMessageKit
134
152
 
135
153
 
136
154
 
155
+ /**
156
+ * EIP-712 cannot omit a field from only some instances of a struct type, so
157
+ * typed holdings always carry `valueUsd` on the wire, using this sentinel for
158
+ * an unknown valuation. The converters below translate it to and from an
159
+ * absent `valueUsd` in {@link TypedHoldingDetail}; it never reaches
160
+ * application data.
161
+ */
162
+ export const VALUE_USD_UNKNOWN = -1n;
163
+
164
+ /** Largest valuation representable in the signed `int256` wire field. */
165
+ export const MAX_VALUE_USD = 2n ** 255n - 1n;
166
+
167
+ /** A `HoldingDetail` entry as it appears on the wire. */
168
+ ;
169
+
170
+
171
+ /** A typed holding as it appears on the (normalized) wire. */
172
+ ;
173
+
174
+
175
+
176
+
177
+ /** Application -> wire: an absent valuation becomes the sentinel. */
178
+ const typedHoldingToEIP712 = ({
179
+ place,
180
+ kind,
181
+ tokenAddress,
182
+ amount,
183
+ valueUsd,
184
+ ...rest
185
+ } ) => ({
186
+ place,
187
+ kind,
188
+ tokenAddress,
189
+ amount,
190
+ valueUsd: valueUsd ?? VALUE_USD_UNKNOWN,
191
+ // deprecated, and must be uniformly present or absent
192
+ ...(rest.balanceUsdc === undefined ? {} : { balanceUsdc: rest.balanceUsdc }),
193
+ });
194
+
195
+ /** Wire -> application: the sentinel (or an absent field) becomes absent. */
196
+ const typedHoldingFromEIP712 = ({
197
+ valueUsd,
198
+ ...rest
199
+ } ) =>
200
+ ({
201
+ ...rest,
202
+ ...(valueUsd === undefined || valueUsd === VALUE_USD_UNKNOWN
203
+ ? {}
204
+ : { valueUsd }),
205
+ }) ;
206
+
207
+ const assertUint256 = (value , field ) => {
208
+ if (typeof value !== 'bigint' || value < 0n || value >= 2n ** 256n) {
209
+ throw RangeError(`invalid uint256 ${field}: ${String(value)}`);
210
+ }
211
+ };
212
+
137
213
  const toSafeNumber = (value , what ) => {
214
+ assertUint256(value, what);
215
+ // Negate the lte to prevent non-BigInt values from sneaking in.
138
216
  if (!(value <= BigInt(Number.MAX_SAFE_INTEGER))) {
139
217
  throw RangeError(`${JSON.stringify(what)} out of range: ${value}`);
140
218
  }
141
219
  return Number(value);
142
220
  };
143
221
 
222
+ /** Validate identities and units without inventing valuations or holdings. */
223
+ const assertTypedHoldings
224
+
225
+ = holdings => {
226
+ const identities = new Set ();
227
+ for (const {
228
+ place,
229
+ kind,
230
+ tokenAddress,
231
+ amount,
232
+ valueUsd,
233
+ balanceUsdc,
234
+ } of holdings) {
235
+ if (!isPortfolioBalancePlaceRef(place)) {
236
+ throw TypeError(`invalid holding place ${JSON.stringify(place)}`);
237
+ }
238
+ const isNative =
239
+ typeof kind === 'string' && kind.startsWith('$') && kind.length > 1;
240
+ const isInstrument =
241
+ kind === 'shares' || kind === 'principal' || kind === 'claimable-reward';
242
+ const isAccountHolding =
243
+ isNative || kind === 'token' || kind === 'claimed-reward';
244
+ if (!isAccountHolding && !isInstrument) {
245
+ throw TypeError(`invalid holding kind ${JSON.stringify(kind)}`);
246
+ }
247
+ if (
248
+ isInstrument ? !isInstrumentId(place) : !isInterChainAccountRef(place)
249
+ ) {
250
+ throw TypeError(
251
+ `holding kind ${kind} is incompatible with place ${place}`,
252
+ );
253
+ }
254
+ if (
255
+ typeof tokenAddress !== 'string' ||
256
+ !/^0x[0-9a-fA-F]{40}$/.test(tokenAddress)
257
+ ) {
258
+ throw TypeError(`invalid holding token address ${String(tokenAddress)}`);
259
+ }
260
+ if (isNative !== /^0x0{40}$/i.test(tokenAddress)) {
261
+ throw TypeError(`holding kind ${kind} has an incompatible token address`);
262
+ }
263
+ const identity = JSON.stringify([place, kind, tokenAddress.toLowerCase()]);
264
+ if (identities.has(identity)) {
265
+ throw TypeError(`duplicate holding identity ${identity}`);
266
+ }
267
+ identities.add(identity);
268
+ assertUint256(amount, 'amount');
269
+ if (
270
+ valueUsd !== undefined &&
271
+ (typeof valueUsd !== 'bigint' ||
272
+ valueUsd < 0n ||
273
+ valueUsd > MAX_VALUE_USD)
274
+ ) {
275
+ throw RangeError(`invalid valuation valueUsd: ${String(valueUsd)}`);
276
+ }
277
+ if (balanceUsdc !== undefined) {
278
+ assertUint256(balanceUsdc, 'balanceUsdc');
279
+ }
280
+ }
281
+ };
282
+
144
283
  /**
145
- * Convert the content of a portfolio observation to the data of a
146
- * `PortfolioObservations` message, e.g. for the attestor to sign.
147
- *
148
- * @param observation
284
+ * Transitional: derive legacy per-place `balances` from the deprecated
285
+ * `balanceUsdc` of typed holdings, summed per place, so consumers of
286
+ * `balances` keep working when producers switch to typed holdings. Producers
287
+ * put the legacy place balance on one holding per place and `0n` on the
288
+ * others. Never derived from `valueUsd`. Empty if the holdings omit
289
+ * `balanceUsdc` (EIP-712 requires it on all of them or none).
290
+ */
291
+ const balancesFromTypedHoldings = (
292
+ holdings ,
293
+ ) => {
294
+ const balances = new Map ();
295
+ for (const { place, balanceUsdc } of holdings) {
296
+ if (balanceUsdc !== undefined) {
297
+ balances.set(place, (balances.get(place) ?? 0n) + balanceUsdc);
298
+ }
299
+ }
300
+ for (const [place, balance] of balances) {
301
+ assertUint256(balance, `balanceUsdc sum for ${place}`);
302
+ }
303
+ return Object.fromEntries(balances);
304
+ };
305
+
306
+ /**
307
+ * Author either legacy balances or typed holdings using the shared schema.
308
+ * Typed holdings always carry `valueUsd`, with {@link VALUE_USD_UNKNOWN}
309
+ * standing for an absent valuation. With typed holdings, `balances` may only
310
+ * repeat what their `balanceUsdc` values derive (as decoding returns), so no
311
+ * balance is silently dropped.
149
312
  */
150
313
  export const portfolioObservationsToEIP712 = ({
151
314
  portfolioId,
152
- syncState: { policyVersion, rebalanceCount },
153
- observations: { balances, instrumentTvls },
154
- } ) => ({
155
- portfolio: portfolioId,
156
- syncState: { policyVersion, rebalanceCount },
157
- holdings: Object.entries(balances).flatMap(([place, balanceUsdc]) =>
158
- balanceUsdc === undefined ? [] : [{ place, balanceUsdc }],
159
- ),
160
- instruments: Object.entries(instrumentTvls).flatMap(([instrumentId, tvl]) =>
161
- tvl === undefined ? [] : [{ instrumentId, tvlUsd: tvl.tvlUsd }],
162
- ),
163
- });
315
+ syncState,
316
+ observations: { balances, holdings, instrumentTvls },
317
+ } ) => {
318
+ for (const [field, value] of Object.entries({
319
+ portfolio: portfolioId,
320
+ ...syncState,
321
+ })) {
322
+ if (!Number.isSafeInteger(value) || value < 0) {
323
+ throw RangeError(`${field} out of range: ${value}`);
324
+ }
325
+ }
326
+ if (holdings !== undefined) {
327
+ assertTypedHoldings(holdings);
328
+ const derived = balancesFromTypedHoldings(holdings);
329
+ const given = Object.entries(balances).filter(([, v]) => v !== undefined);
330
+ if (
331
+ given.length > 0 &&
332
+ (given.length !== Object.keys(derived).length ||
333
+ given.some(([place, v]) => derived[place] !== v))
334
+ ) {
335
+ throw TypeError(
336
+ 'aggregate balances must match the balanceUsdc of typed holdings',
337
+ );
338
+ }
339
+ }
340
+ const legacy = Object.entries(balances).flatMap(
341
+ ([place, balanceUsdc]) => {
342
+ if (balanceUsdc === undefined) {
343
+ return [];
344
+ }
345
+ if (!isPortfolioBalancePlaceRef(place)) {
346
+ throw TypeError(`invalid holding place ${JSON.stringify(place)}`);
347
+ }
348
+ assertUint256(balanceUsdc, 'balanceUsdc');
349
+ return [{ place, balanceUsdc }];
350
+ },
351
+ );
352
+ const instruments = Object.entries(instrumentTvls).flatMap(
353
+ ([instrumentId, tvl]) => {
354
+ if (tvl === undefined) {
355
+ return [];
356
+ }
357
+ if (!isInstrumentId(instrumentId)) {
358
+ throw TypeError(`invalid instrument ${JSON.stringify(instrumentId)}`);
359
+ }
360
+ assertUint256(tvl.tvlUsd, 'tvlUsd');
361
+ return [{ instrumentId, tvlUsd: tvl.tvlUsd }];
362
+ },
363
+ );
364
+ return {
365
+ portfolio: portfolioId,
366
+ syncState: { ...syncState },
367
+ holdings:
368
+ holdings === undefined ? legacy : holdings.map(typedHoldingToEIP712),
369
+ instruments,
370
+ };
371
+ };
164
372
 
165
373
  /**
166
- * Convert the data of a signed `PortfolioObservations` message to its
167
- * application-level content.
168
- *
169
- * Expects the data as extracted by `makeEIP712MessageHandlerUtils` with
170
- * `onUnknownSignedField: 'throw'`, i.e. normalized and without fields this
171
- * version does not understand. Fails closed: rejects places or instruments
172
- * that are invalid or listed more than once, and values out of range.
173
- *
174
- * @param data
374
+ * Decode normalized authenticated observations. The handler must use
375
+ * onUnknownSignedField: 'throw'. This converter does not verify signatures.
376
+ * For typed holdings, `balances` is derived from their deprecated
377
+ * `balanceUsdc` (see {@link balancesFromTypedHoldings}), never from `valueUsd`.
378
+ * A typed holding's {@link VALUE_USD_UNKNOWN} valuation decodes to an absent
379
+ * `valueUsd`.
175
380
  */
176
381
  export const portfolioObservationsFromEIP712 = ({
177
382
  portfolio,
@@ -179,17 +384,39 @@ export const portfolioObservationsFromEIP712 = ({
179
384
  holdings,
180
385
  instruments,
181
386
  } ) => {
182
- const balances = {};
183
- for (const { place, balanceUsdc } of holdings) {
387
+ const legacyBalances = {};
388
+ const rawHoldings = [];
389
+ for (const holding of holdings) {
390
+ const { place, balanceUsdc, kind, tokenAddress, amount, valueUsd } =
391
+ holding;
184
392
  if (!isPortfolioBalancePlaceRef(place)) {
185
393
  throw TypeError(`invalid holding place ${JSON.stringify(place)}`);
186
394
  }
187
- if (Object.hasOwn(balances, place)) {
188
- throw TypeError(`duplicate holding place ${JSON.stringify(place)}`);
395
+ // Any typed field makes this a typed holding, validated as a whole, so a
396
+ // partial hybrid is rejected rather than having signed fields dropped.
397
+ if (
398
+ kind !== undefined ||
399
+ tokenAddress !== undefined ||
400
+ amount !== undefined ||
401
+ valueUsd !== undefined
402
+ ) {
403
+ rawHoldings.push(typedHoldingFromEIP712(holding));
404
+ } else {
405
+ if (Object.hasOwn(legacyBalances, place)) {
406
+ throw TypeError(`duplicate holding place ${JSON.stringify(place)}`);
407
+ }
408
+ assertUint256(balanceUsdc , 'balanceUsdc');
409
+ legacyBalances[place] = balanceUsdc;
189
410
  }
190
- balances[place] = balanceUsdc;
191
411
  }
192
-
412
+ // Uniform EIP-712 field presence already rules this out; fail closed anyway.
413
+ if (rawHoldings.length && Object.keys(legacyBalances).length) {
414
+ throw TypeError('cannot combine legacy balances with typed holdings');
415
+ }
416
+ assertTypedHoldings(rawHoldings);
417
+ const balances = rawHoldings.length
418
+ ? balancesFromTypedHoldings(rawHoldings)
419
+ : legacyBalances;
193
420
  const instrumentTvls = {};
194
421
  for (const { instrumentId, tvlUsd } of instruments) {
195
422
  if (!isInstrumentId(instrumentId)) {
@@ -198,15 +425,19 @@ export const portfolioObservationsFromEIP712 = ({
198
425
  if (Object.hasOwn(instrumentTvls, instrumentId)) {
199
426
  throw TypeError(`duplicate instrument ${JSON.stringify(instrumentId)}`);
200
427
  }
201
- instrumentTvls[instrumentId ] = { tvlUsd };
428
+ assertUint256(tvlUsd, 'tvlUsd');
429
+ instrumentTvls[instrumentId] = { tvlUsd };
202
430
  }
203
-
204
431
  return {
205
432
  portfolioId: toSafeNumber(portfolio, 'portfolio'),
206
433
  syncState: {
207
434
  policyVersion: toSafeNumber(syncState.policyVersion, 'policyVersion'),
208
435
  rebalanceCount: toSafeNumber(syncState.rebalanceCount, 'rebalanceCount'),
209
436
  },
210
- observations: { balances, instrumentTvls },
437
+ observations: {
438
+ balances,
439
+ ...(rawHoldings.length ? { holdings: rawHoldings } : {}),
440
+ instrumentTvls,
441
+ },
211
442
  };
212
443
  };
@@ -1,15 +1,39 @@
1
- import type { TypedPattern } from '@agoric/internal';
1
+ import { type CastedPattern } from '@endo/patterns';
2
2
  import type { ChainTokenMetadata, TokenMetadata } from './places.js';
3
- import type { PortfolioAgentKey, PortfolioDelegatedClaimRewardsParams, PortfolioDelegatedRebalanceParams, PortfolioSyncState } from './types.js';
3
+ import type { PortfolioAgentKey, PortfolioDelegatedClaimRewardsParams, PortfolioDelegatedRebalanceParams, PortfolioSyncState, WithdrawParams, HoldingKind, HoldingDetail, PlanObservations } from './types.js';
4
4
  export { isBeefyInstrumentId, isDepositFromChainRef, isERC4626InstrumentId, isERC4626MorphoInstrumentId, isInstrumentId, isInterChainAccountRef, isLocalChainAccountRef, isPortfolioBalancePlaceRef, isWithdrawToChainRef, makeTokenIdKey, } from './places.js';
5
5
  export type { ChainTokenMetadata, ChainTokenMetadataEntry, TokenIdKey, TokenMetadata, } from './places.js';
6
6
  export declare const TokenUsageShape: import("@endo/patterns").MatcherOf<"or", ["swapFrom", "swapTo"]>;
7
- export declare const TokenMetadataShape: TypedPattern<TokenMetadata>;
8
- export declare const ChainTokenMetadataShape: TypedPattern<ChainTokenMetadata>;
9
- export declare const PortfolioAgentKeyShape: TypedPattern<PortfolioAgentKey>;
7
+ /** Structural withdrawal parameters; route and holding identity need decoding. */
8
+ export declare const WithdrawParamsShape: CastedPattern<WithdrawParams>;
9
+ /** Native-token kinds start with '$' and have a nonempty symbol. */
10
+ export declare const HoldingKindShape: CastedPattern<HoldingKind>;
11
+ export declare const HoldingDetailV1Shape: import("@endo/patterns").MatcherOf<"splitRecord", [{
12
+ place: import("@endo/patterns").MatcherOf<"string", string>;
13
+ balanceUsdc: import("@endo/patterns").MatcherOf<"nat", bigint>;
14
+ }, {}, {}]>;
15
+ export declare const HoldingDetailV2Shape: import("@endo/patterns").MatcherOf<"splitRecord", [{
16
+ place: import("@endo/patterns").MatcherOf<"string", string>;
17
+ kind: (import("@endo/pass-style").CopyRecordInterface<import("@endo/pass-style").PassableCap, Error> & {
18
+ "Symbol(castedType)"?: HoldingKind | undefined;
19
+ }) | (import("@endo/pass-style").CopyTaggedInterface<import("@endo/pass-style").PassableCap, Error> & {
20
+ "Symbol(castedType)"?: HoldingKind | undefined;
21
+ });
22
+ tokenAddress: import("@endo/patterns").MatcherOf<"string", string>;
23
+ amount: import("@endo/patterns").MatcherOf<"nat", bigint>;
24
+ }, {
25
+ valueUsd: import("@endo/patterns").MatcherOf<"and", [import("@endo/patterns").MatcherOf<"nat", bigint>, import("@endo/patterns").MatcherOf<"lte", import("@endo/patterns").Key>]>;
26
+ balanceUsdc: import("@endo/patterns").MatcherOf<"nat", bigint>;
27
+ }, {}]>;
28
+ /** Structural shape; the observation decoder also checks places and addresses. */
29
+ export declare const HoldingDetailShape: CastedPattern<HoldingDetail>;
30
+ export declare const PlanObservationsShape: CastedPattern<PlanObservations>;
31
+ export declare const TokenMetadataShape: CastedPattern<TokenMetadata>;
32
+ export declare const ChainTokenMetadataShape: CastedPattern<ChainTokenMetadata>;
33
+ export declare const PortfolioAgentKeyShape: CastedPattern<PortfolioAgentKey>;
10
34
  /** The shape for the optional `agentMemo` field for flows started by an agent */
11
- export declare const PortfolioFlowAgentMemoShape: TypedPattern<string>;
12
- export declare const PortfolioSyncStateShape: TypedPattern<PortfolioSyncState>;
13
- export declare const PortfolioDelegatedRebalanceParamsShape: TypedPattern<PortfolioDelegatedRebalanceParams>;
14
- export declare const PortfolioDelegatedClaimRewardsParamsShape: TypedPattern<PortfolioDelegatedClaimRewardsParams>;
35
+ export declare const PortfolioFlowAgentMemoShape: CastedPattern<string>;
36
+ export declare const PortfolioSyncStateShape: CastedPattern<PortfolioSyncState>;
37
+ export declare const PortfolioDelegatedRebalanceParamsShape: CastedPattern<PortfolioDelegatedRebalanceParams>;
38
+ export declare const PortfolioDelegatedClaimRewardsParamsShape: CastedPattern<PortfolioDelegatedClaimRewardsParams>;
15
39
  //# sourceMappingURL=type-guards.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["type-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EACV,iBAAiB,EACjB,oCAAoC,EACpC,iCAAiC,EACjC,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,eAAe,kEAA6B,CAAC;AAG1D,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,aAAa,CAW1D,CAAC;AAGF,eAAO,MAAM,uBAAuB,EAAE,YAAY,CAAC,kBAAkB,CAWlE,CAAC;AAGJ,eAAO,MAAM,sBAAsB,EAAE,YAAY,CAAC,iBAAiB,CACvD,CAAC;AAEb,iFAAiF;AACjF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,MAAM,CAE3D,CAAC;AAEH,eAAO,MAAM,uBAAuB,EAAE,YAAY,CAAC,kBAAkB,CAIjE,CAAC;AAEL,eAAO,MAAM,sCAAsC,EAAE,YAAY,CAAC,iCAAiC,CAKhG,CAAC;AAEJ,eAAO,MAAM,yCAAyC,EAAE,YAAY,CAAC,oCAAoC,CAKtG,CAAC"}
1
+ {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["type-guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;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AiC,CAKjG,CAAC;AAEJ,eAAO,MAAM,yCAAyC,EAAE,aAAa,CAAC,oCAAoC,CAKvG,CAAC"}
@@ -1,11 +1,14 @@
1
-
2
- import { M } from '@endo/patterns';
1
+ import { M, } from '@endo/patterns';
3
2
  ;
4
3
  ;
5
4
 
6
5
 
7
6
 
8
7
 
8
+
9
+
10
+
11
+
9
12
 
10
13
 
11
14
  export {
@@ -27,10 +30,83 @@ export {
27
30
 
28
31
 
29
32
 
33
+ /**
34
+ * Application-level valuation: absent when unknown. The EIP-712 converters
35
+ * own the wire sentinel; it is not accepted here.
36
+ */
37
+ const ValueUsdShape = M.and(M.nat(), M.lte(2n ** 255n - 1n));
38
+
30
39
  export const TokenUsageShape = M.or('swapFrom', 'swapTo');
31
40
  harden(TokenUsageShape);
32
41
 
33
- export const TokenMetadataShape = M.splitRecord(
42
+ /** Structural withdrawal parameters; route and holding identity need decoding. */
43
+ export const WithdrawParamsShape = M.splitRecord(
44
+ {},
45
+ {
46
+ max: M.boolean(),
47
+ amountOfShares: M.nat(),
48
+ },
49
+ {},
50
+ );
51
+ harden(WithdrawParamsShape);
52
+
53
+ /** Native-token kinds start with '$' and have a nonempty symbol. */
54
+ export const HoldingKindShape = M.or(
55
+ 'shares',
56
+ 'principal',
57
+ 'claimable-reward',
58
+ 'claimed-reward',
59
+ 'token',
60
+ // Strings strictly between '$' and the following ASCII character ('%') have a nonempty '$' prefix.
61
+ M.and(
62
+ M.string(),
63
+ M.gt('$'),
64
+ M.lt(String.fromCharCode('$'.charCodeAt(0) + 1)),
65
+ ),
66
+ );
67
+ harden(HoldingKindShape);
68
+
69
+ export const HoldingDetailV1Shape = M.splitRecord(
70
+ { place: M.string(), balanceUsdc: M.nat() },
71
+ {},
72
+ {},
73
+ );
74
+ harden(HoldingDetailV1Shape);
75
+
76
+ export const HoldingDetailV2Shape = M.splitRecord(
77
+ {
78
+ place: M.string(),
79
+ kind: HoldingKindShape,
80
+ tokenAddress: M.string(),
81
+ amount: M.nat(),
82
+ },
83
+ { valueUsd: ValueUsdShape, balanceUsdc: M.nat() },
84
+ {},
85
+ );
86
+ harden(HoldingDetailV2Shape);
87
+
88
+ /** Structural shape; the observation decoder also checks places and addresses. */
89
+ export const HoldingDetailShape = M.or(
90
+ HoldingDetailV1Shape,
91
+ HoldingDetailV2Shape,
92
+ );
93
+ harden(HoldingDetailShape);
94
+
95
+ export const PlanObservationsShape =
96
+ M.splitRecord(
97
+ {
98
+ balances: M.recordOf(M.string(), M.nat()),
99
+ instrumentTvls: M.recordOf(
100
+ M.string(),
101
+ M.splitRecord({ tvlUsd: M.nat() }),
102
+ ),
103
+ },
104
+ { holdings: M.arrayOf(HoldingDetailV2Shape) },
105
+ {},
106
+ );
107
+ harden(PlanObservationsShape);
108
+
109
+ export const TokenMetadataShape = M.splitRecord(
34
110
  {
35
111
  caipChainId: M.string(),
36
112
  chainName: M.string(),
@@ -44,7 +120,7 @@ export const TokenMetadataShape = M.splitRecord(
44
120
  );
45
121
  harden(TokenMetadataShape);
46
122
 
47
- export const ChainTokenMetadataShape =
123
+ export const ChainTokenMetadataShape =
48
124
  M.recordOf(
49
125
  M.string(),
50
126
  M.splitRecord(
@@ -58,28 +134,28 @@ export const ChainTokenMetadataShape =
58
134
  );
59
135
  harden(ChainTokenMetadataShape);
60
136
 
61
- export const PortfolioAgentKeyShape =
137
+ export const PortfolioAgentKeyShape =
62
138
  M.string();
63
139
 
64
140
  /** The shape for the optional `agentMemo` field for flows started by an agent */
65
- export const PortfolioFlowAgentMemoShape = M.string({
141
+ export const PortfolioFlowAgentMemoShape = M.string({
66
142
  stringLengthLimit: 64,
67
143
  });
68
144
 
69
- export const PortfolioSyncStateShape =
145
+ export const PortfolioSyncStateShape =
70
146
  M.splitRecord({
71
147
  policyVersion: M.number(),
72
148
  rebalanceCount: M.number(),
73
149
  });
74
150
 
75
- export const PortfolioDelegatedRebalanceParamsShape =
151
+ export const PortfolioDelegatedRebalanceParamsShape =
76
152
  M.splitRecord(
77
153
  { syncState: PortfolioSyncStateShape },
78
154
  { agentMemo: PortfolioFlowAgentMemoShape },
79
155
  {},
80
156
  );
81
157
 
82
- export const PortfolioDelegatedClaimRewardsParamsShape =
158
+ export const PortfolioDelegatedClaimRewardsParamsShape =
83
159
  M.splitRecord(
84
160
  { syncState: PortfolioSyncStateShape },
85
161
  { agentMemo: PortfolioFlowAgentMemoShape },
package/src/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { NatAmount } from '@agoric/ertp';
2
+ import type { CopyRecord } from '@endo/pass-style';
2
3
  import { type AccountId, type Bech32Address, type CaipChainId, type CosmosChainAddress, type TrafficEntry } from '@agoric/orchestration';
3
4
  import type { Address as EvmAddress } from 'abitype';
4
5
  import type { AxelarChain, SupportedChain, YieldProtocol, PortfolioPlannerAgent as PortfolioPlannerAgentValue } from './constants.js';
@@ -49,7 +50,7 @@ export type InterChainAccountRef = `@${SupportedChain}`;
49
50
  * {@link WithdrawToChainRef}).
50
51
  */
51
52
  export type AssetPlaceRef = `<${SeatKeyword}>` | LocalChainAccountRef | DepositFromChainRef | WithdrawToChainRef | InterChainAccountRef | InstrumentId;
52
- type Empty = Record<never, NatAmount>;
53
+ type Empty = Record<string, never>;
53
54
  /**
54
55
  * Proposal shapes for portfolio operations.
55
56
  *
@@ -155,8 +156,75 @@ export type PortfolioBalancePlaceRef = InstrumentId | InterChainAccountRef;
155
156
  */
156
157
  export type PlanObservations = {
157
158
  balances: Partial<Record<PortfolioBalancePlaceRef, bigint>>;
159
+ /**
160
+ * Authenticated raw holdings. When present, `balances` is derived from their
161
+ * deprecated `balanceUsdc` (never from `valueUsd`).
162
+ */
163
+ holdings?: TypedHoldingDetail[];
158
164
  instrumentTvls: Partial<Record<InstrumentId, InstrumentTvlObservation>>;
159
165
  };
166
+ /**
167
+ * Holding kinds understood by the observation converters. `shares` identifies
168
+ * vault shares; `principal` identifies instrument principal (for example Aave
169
+ * or Compound). `claimable-reward` belongs to an instrument, while
170
+ * `claimed-reward` and other `token` holdings belong to a chain account.
171
+ * Native tokens use `$` followed by a nonempty symbol, such as `$ETH`.
172
+ */
173
+ export type HoldingKind = 'shares' | 'principal' | 'claimable-reward' | 'claimed-reward' | 'token' | `$${string}`;
174
+ /** A legacy balance observation, in micro-USDC. */
175
+ export type LegacyHoldingDetail = {
176
+ place: PortfolioBalancePlaceRef;
177
+ balanceUsdc: bigint;
178
+ };
179
+ /**
180
+ * One authenticated raw holding, independent of its USD valuation.
181
+ *
182
+ * The identity is `(place, kind, tokenAddress)`, with case-insensitive EVM
183
+ * addresses. Multiple holdings may share a place, including multiple reward
184
+ * tokens, but duplicate identities are rejected. Instrument holdings appear
185
+ * under the instrument, not again under its chain account. Missing holdings
186
+ * are unobserved and must never be treated as zero.
187
+ *
188
+ * Signed observations use the shared `YmaxObservation` version-1 schema.
189
+ * Legacy balance-only entries retain their original resolved signed type;
190
+ * typed fields are optional in that schema for compatibility, but must form a
191
+ * complete typed holding when present. Optional-field presence is uniform per
192
+ * signed struct type. The converters always include `valueUsd` for typed
193
+ * holdings on the wire, encoding an absent valuation as `-1n` and stripping
194
+ * that sentinel when decoding. Never add unsigned holdings to a legacy
195
+ * signature, or infer shares from either valuation field.
196
+ *
197
+ * Producer rollout must follow verifier support. Producers first include
198
+ * typed holdings with transitional `balanceUsdc`; consumers then adopt typed
199
+ * holdings before legacy balances and balance-only entries are retired.
200
+ */
201
+ export type TypedHoldingDetail = {
202
+ /** Instrument place or chain account, as required by the holding kind. */
203
+ place: PortfolioBalancePlaceRef;
204
+ kind: HoldingKind;
205
+ /**
206
+ * Vault address for shares; underlying token address for principal, rewards,
207
+ * and other ERC-20 holdings. Native tokens use the zero address.
208
+ */
209
+ tokenAddress: EvmAddress;
210
+ /** Native token units, independent of USD valuation. Zero is observed zero. */
211
+ amount: bigint;
212
+ /**
213
+ * Valuation in micro-USD; absent if not observed, distinct from known zero.
214
+ * Known values range from `0n` through `2n ** 255n - 1n`. This is not a raw
215
+ * token quantity and must not be added to `balanceUsdc`.
216
+ */
217
+ valueUsd?: bigint;
218
+ /**
219
+ * @deprecated Transitional legacy valuation in micro-USDC, summed per place
220
+ * into `PlanObservations['balances']` for consumers not yet reading typed
221
+ * holdings. Put the place's legacy balance on one holding and `0n` on its
222
+ * others; include on every holding or none. Removed with legacy balances.
223
+ */
224
+ balanceUsdc?: bigint;
225
+ };
226
+ /** Legacy balances and typed raw holdings share the observation schema. */
227
+ export type HoldingDetail = LegacyHoldingDetail | TypedHoldingDetail;
160
228
  export type FlowDetail = {
161
229
  type: 'withdraw';
162
230
  amount: NatAmount;
@@ -256,6 +324,27 @@ export type SwapDesc = OneInchSwapDesc;
256
324
  * Swap aggregator whose API produced the swap `data`
257
325
  */
258
326
  export type SwapProvider = SwapDesc['provider'];
327
+ /**
328
+ * Additive options for a position-to-same-chain-account withdrawal. Structural
329
+ * acceptance does not establish implementation support; an older contract may
330
+ * ignore these options and execute the movement's amount exactly.
331
+ *
332
+ * The movement retains its required default-token amount (micro-USDC at dest).
333
+ * It is a minimum when `max` is true or `amountOfShares` is present. An explicit
334
+ * share quantity is exact unless `max` is true. Missing movement amounts,
335
+ * negative share quantities, and unknown withdrawal options are rejected.
336
+ * Transfers, bridges, deposits, and downstream movements retain exact amounts.
337
+ */
338
+ export type WithdrawParams = {
339
+ /** When true, MovementDesc['amount'] and amountOfShares are minima, not exact. */
340
+ max?: boolean;
341
+ /**
342
+ * How many 'shares' tokens to withdraw.
343
+ * Without this, if the place is a Position, then
344
+ * `MovementDesc['amount']` refers to 'principal' tokens.
345
+ */
346
+ amountOfShares?: bigint;
347
+ };
259
348
  /**
260
349
  * Parameters for claiming external rewards.
261
350
  *
@@ -286,6 +375,7 @@ export type ClaimRewardsParams = {
286
375
  };
287
376
  };
288
377
  export type MovementDesc = {
378
+ /** Default-token units (micro-USDC) received at dest; a minimum when withdraw.max is true or withdraw.amountOfShares is specified, otherwise exact. */
289
379
  amount: NatAmount;
290
380
  src: AssetPlaceRef;
291
381
  dest: AssetPlaceRef;
@@ -293,11 +383,23 @@ export type MovementDesc = {
293
383
  fee?: NatAmount;
294
384
  /** for example: { usdnOut: 98n } */
295
385
  detail?: Record<string, bigint>;
386
+ /** Present only for withdrawing from a position to an account. */
387
+ withdraw?: WithdrawParams;
296
388
  /** Present only for reward-token claims. */
297
389
  claimRewards?: ClaimRewardsParams;
298
390
  /** Present only for reward-token -> stable-token swaps. */
299
391
  swap?: SwapDesc;
300
392
  };
393
+ /**
394
+ * Extensible structural input, not a validated movement. Known fields retain
395
+ * their types, including the required amount and optional withdrawal parameters;
396
+ * future source/destination places and additional fields remain representable.
397
+ * Consumers must validate place support and semantics before execution.
398
+ */
399
+ export type MovementDescExt = Omit<MovementDesc, 'src' | 'dest'> & {
400
+ src: string;
401
+ dest: string;
402
+ } & CopyRecord<any>;
301
403
  export type TxPhase = 'makeSrcAccount' | 'makeDestAccount' | 'apply';
302
404
  export type FlowStep = Pick<MovementDesc, 'amount' | 'src' | 'dest' | 'claimRewards' | 'swap'> & {
303
405
  /**
@@ -331,6 +433,10 @@ export type FundsFlowPlan = {
331
433
  /** When `order` is absent, default to fully sequential dependencies. */
332
434
  order?: FlowStepDependency[];
333
435
  };
436
+ /** Forward-compatible structural plan input; its movements still need validation. */
437
+ export type FundsFlowPlanExt = Omit<FundsFlowPlan, 'flow'> & {
438
+ flow: MovementDescExt[];
439
+ } & CopyRecord<any>;
334
440
  export type FundsFlow = MovementDesc[] | FundsFlowPlan;
335
441
  export type TxId = `tx${number}`;
336
442
  export type TrafficReport = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,OAAO,IAAI,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AAG;KACD,CAAC,IAAI,OAAO,GAAG,GAAG,GAAG,wBAAwB,MAAM,SAAS,GAAG,SAAS,CAAC,iBAAiB,CAAC;CAC7F,GAAG;KACD,CAAC,IAAI,OAAO,GAAG,GAAG,GAAG,wBAAwB,MAAM,gBAAgB,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC;CACtG,GAAG;KACD,CAAC,IAAI,OAAO,GAAG,GAAG,GAAG,wBAAwB,MAAM,cAAc,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC;CAC/F,GAAG;KACD,CAAC,IAAI,OAAO,GAAG,GAAG,GAAG,wBAAwB,MAAM,cAAc,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,CAAC;CAC1G,GAAG;KACD,CAAC,IAAI,OAAO,GAAG,GAAG,GAAG,iBAAiB,MAAM,YAAY,GAAG,SAAS,CAAC,qBAAqB,CAAC;CAC7F,GAAG;KACD,CAAC,IAAI,OAAO,GAAG,GAAG,GAAG,iBAAiB,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC;CACzE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,6BAA6B,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAC1C,SAAS,GACT,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,wBAAwB,CAAC"}
package/src/types.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars -- not detecting the TSDoc */
2
2
 
3
+
3
4
  import {
4
5
 
5
6
 
@@ -82,7 +83,7 @@ import {
82
83
 
83
84
 
84
85
 
85
- ;
86
+ ;
86
87
 
87
88
  /**
88
89
  * Proposal shapes for portfolio operations.
@@ -176,9 +177,86 @@ import {
176
177
  */
177
178
  ;
178
179
 
180
+
181
+
182
+
183
+
184
+
179
185
 
180
186
 
181
187
 
188
+ /**
189
+ * Holding kinds understood by the observation converters. `shares` identifies
190
+ * vault shares; `principal` identifies instrument principal (for example Aave
191
+ * or Compound). `claimable-reward` belongs to an instrument, while
192
+ * `claimed-reward` and other `token` holdings belong to a chain account.
193
+ * Native tokens use `$` followed by a nonempty symbol, such as `$ETH`.
194
+ */
195
+ ;
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+ /** A legacy balance observation, in micro-USDC. */
204
+ ;
205
+
206
+
207
+
208
+
209
+ /**
210
+ * One authenticated raw holding, independent of its USD valuation.
211
+ *
212
+ * The identity is `(place, kind, tokenAddress)`, with case-insensitive EVM
213
+ * addresses. Multiple holdings may share a place, including multiple reward
214
+ * tokens, but duplicate identities are rejected. Instrument holdings appear
215
+ * under the instrument, not again under its chain account. Missing holdings
216
+ * are unobserved and must never be treated as zero.
217
+ *
218
+ * Signed observations use the shared `YmaxObservation` version-1 schema.
219
+ * Legacy balance-only entries retain their original resolved signed type;
220
+ * typed fields are optional in that schema for compatibility, but must form a
221
+ * complete typed holding when present. Optional-field presence is uniform per
222
+ * signed struct type. The converters always include `valueUsd` for typed
223
+ * holdings on the wire, encoding an absent valuation as `-1n` and stripping
224
+ * that sentinel when decoding. Never add unsigned holdings to a legacy
225
+ * signature, or infer shares from either valuation field.
226
+ *
227
+ * Producer rollout must follow verifier support. Producers first include
228
+ * typed holdings with transitional `balanceUsdc`; consumers then adopt typed
229
+ * holdings before legacy balances and balance-only entries are retired.
230
+ */
231
+ ;
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+ /** Legacy balances and typed raw holdings share the observation schema. */
258
+ ;
259
+
182
260
  ;
183
261
 
184
262
 
@@ -283,6 +361,28 @@ import {
283
361
  */
284
362
  ;
285
363
 
364
+ /**
365
+ * Additive options for a position-to-same-chain-account withdrawal. Structural
366
+ * acceptance does not establish implementation support; an older contract may
367
+ * ignore these options and execute the movement's amount exactly.
368
+ *
369
+ * The movement retains its required default-token amount (micro-USDC at dest).
370
+ * It is a minimum when `max` is true or `amountOfShares` is present. An explicit
371
+ * share quantity is exact unless `max` is true. Missing movement amounts,
372
+ * negative share quantities, and unknown withdrawal options are rejected.
373
+ * Transfers, bridges, deposits, and downstream movements retain exact amounts.
374
+ */
375
+ ;
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
286
386
  /**
287
387
  * Parameters for claiming external rewards.
288
388
  *
@@ -314,6 +414,7 @@ import {
314
414
 
315
415
 
316
416
  ;
417
+
317
418
 
318
419
 
319
420
 
@@ -321,12 +422,25 @@ import {
321
422
 
322
423
 
323
424
 
425
+
426
+
324
427
 
325
428
 
326
429
 
327
430
 
328
431
 
329
432
 
433
+ /**
434
+ * Extensible structural input, not a validated movement. Known fields retain
435
+ * their types, including the required amount and optional withdrawal parameters;
436
+ * future source/destination places and additional fields remain representable.
437
+ * Consumers must validate place support and semantics before execution.
438
+ */
439
+ ;
440
+
441
+
442
+
443
+
330
444
  ;
331
445
 
332
446
  ;
@@ -368,6 +482,11 @@ import {
368
482
 
369
483
 
370
484
 
485
+ /** Forward-compatible structural plan input; its movements still need validation. */
486
+ ;
487
+
488
+
489
+
371
490
  ;
372
491
 
373
492
  // tx for transactions