@agoric/portfolio-api 0.1.1-dev-5e8e58b.0.5e8e58b → 0.1.1-dev-c4c46b1.0.c4c46b1

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
@@ -43,8 +43,9 @@ comparisons use exact `place` and `kind` values and chain-aware canonical
43
43
  in lowercase; non-EVM identifiers compare with their original case. EVM
44
44
  contract addresses are stored as lowercase `0x` hex; other chain identifiers
45
45
  retain their canonical spelling and case for signing and chain operations.
46
- `claimable-reward` belongs to an instrument; `claimed-reward` belongs to a chain
47
- account.
46
+ `claimable-reward` belongs to an instrument, or to the claiming EVM chain
47
+ account when unattributed (for example Merkl rewards); `claimed-reward` belongs
48
+ to a chain account.
48
49
 
49
50
  `tokenId` identifies the asset locally to the chain implied by `place`; it does
50
51
  not repeat the chain as a full CAIP-19 identifier. EVM contract holdings use the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/portfolio-api",
3
- "version": "0.1.1-dev-5e8e58b.0.5e8e58b",
3
+ "version": "0.1.1-dev-c4c46b1.0.c4c46b1",
4
4
  "description": "API for Portfolio management",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,6 +24,7 @@
24
24
  "./src/portfolio-permissions.js": "./src/portfolio-permissions.js",
25
25
  "./src/portfolio-constants.js": "./src/portfolio-constants.js",
26
26
  "./src/resolver.js": "./src/resolver.js",
27
+ "./src/reward-swaps.js": "./src/reward-swaps.js",
27
28
  "./src/target-balances.js": "./src/target-balances.js",
28
29
  "./src/type-guards.js": "./src/type-guards.js",
29
30
  "./package.json": "./package.json"
@@ -47,8 +48,8 @@
47
48
  "generate:ymax-machine": "npx tsx scripts/gen-ymax-machine.mts"
48
49
  },
49
50
  "dependencies": {
50
- "@agoric/internal": "0.3.3-dev-5e8e58b.0.5e8e58b",
51
- "@agoric/orchestration": "0.1.1-dev-5e8e58b.0.5e8e58b",
51
+ "@agoric/internal": "0.3.3-dev-c4c46b1.0.c4c46b1",
52
+ "@agoric/orchestration": "0.1.1-dev-c4c46b1.0.c4c46b1",
52
53
  "@endo/common": "^1.4.0",
53
54
  "@endo/errors": "^1.3.1",
54
55
  "@endo/patterns": "^1.9.1"
@@ -74,5 +75,5 @@
74
75
  "engines": {
75
76
  "node": "^22.11 || ^24.14"
76
77
  },
77
- "gitHead": "5e8e58b252528124f749ec4dc28b015012380fa6"
78
+ "gitHead": "c4c46b17bc24cd21f0d0ba5461e89409403d9585"
78
79
  }
package/src/main.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./instruments.js";
3
3
  export * from "./network/prod-network.js";
4
4
  export * from "./portfolio-permissions.js";
5
5
  export * from "./resolver.js";
6
+ export * from "./reward-swaps.js";
6
7
  export * from "./target-balances.js";
7
8
  export * from "./type-guards.js";
8
9
  export * from "./types-index.js";
package/src/main.js CHANGED
@@ -3,6 +3,7 @@ export * from './instruments.js';
3
3
  export * from './network/prod-network.js';
4
4
  export * from './portfolio-permissions.js';
5
5
  export * from './resolver.js';
6
+ export * from './reward-swaps.js';
6
7
  export * from './target-balances.js';
7
8
  export * from './type-guards.js';
8
9
 
@@ -20,12 +20,13 @@
20
20
  *
21
21
  * This module has no runtime dependency on Endo, so that it can be used
22
22
  * outside of a locked-down (SES) environment, e.g. by the attestor. In
23
- * particular, the values it returns are not hardened.
23
+ * particular, the values it returns are not hardened, but they share no
24
+ * state with the caller's: the converters validate a copy of their input.
24
25
  */
25
26
  import type { TypedDataToStructType } from '@agoric/orchestration/src/utils/abitype.js';
26
27
  import { type EIP712MessageKit, type FullDomain, type OperationType, type StandaloneOperationData } from '@agoric/orchestration/src/utils/eip712-messages.js';
27
28
  import type { WithSignature } from '@agoric/orchestration/src/utils/viem.js';
28
- import type { PlanObservations, PortfolioSyncState } from './types.js';
29
+ import type { MerklClaimEvidence, PlanObservations, PortfolioSyncState } from './types.js';
29
30
  declare const ObservationOperationTypes: {
30
31
  /**
31
32
  * The state of a portfolio and of the instruments relevant to it, as
@@ -34,6 +35,11 @@ declare const ObservationOperationTypes: {
34
35
  * - syncState: the portfolio state the observations correspond to
35
36
  * - holdings: the balance of every balance-bearing place of the portfolio
36
37
  * - instruments: details of the instruments relevant to the portfolio
38
+ * - aaveClaims, compoundClaims, merklClaims, oneInchSwaps: optional claim
39
+ * evidence and swap instructions, which plan steps select by index (see
40
+ * {@link SelectableObservations}), each present only when requested. As
41
+ * there is a single `PortfolioObservations` per message, their presence
42
+ * never conflicts.
37
43
  */
38
44
  readonly PortfolioObservations: readonly [{
39
45
  readonly name: "portfolio";
@@ -47,6 +53,22 @@ declare const ObservationOperationTypes: {
47
53
  }, {
48
54
  readonly name: "instruments";
49
55
  readonly type: "InstrumentDetail[]";
56
+ }, {
57
+ readonly name: "aaveClaims";
58
+ readonly type: "AaveClaim[]";
59
+ readonly optional: true;
60
+ }, {
61
+ readonly name: "compoundClaims";
62
+ readonly type: "CompoundClaim[]";
63
+ readonly optional: true;
64
+ }, {
65
+ readonly name: "merklClaims";
66
+ readonly type: "MerklClaim[]";
67
+ readonly optional: true;
68
+ }, {
69
+ readonly name: "oneInchSwaps";
70
+ readonly type: "OneInchSwap[]";
71
+ readonly optional: true;
50
72
  }];
51
73
  };
52
74
  declare const ObservationSubTypes: {
@@ -89,6 +111,86 @@ declare const ObservationSubTypes: {
89
111
  readonly name: "tvlUsd";
90
112
  readonly type: "uint256";
91
113
  }];
114
+ /** @see {@link AaveClaimEvidence} */
115
+ readonly AaveClaim: readonly [{
116
+ readonly name: "instrumentId";
117
+ readonly type: "string";
118
+ }, {
119
+ readonly name: "tokenId";
120
+ readonly type: "address";
121
+ }, {
122
+ readonly name: "expectedAmount";
123
+ readonly type: "uint256";
124
+ }];
125
+ /** @see {@link CompoundClaimEvidence} */
126
+ readonly CompoundClaim: readonly [{
127
+ readonly name: "instrumentId";
128
+ readonly type: "string";
129
+ }, {
130
+ readonly name: "tokenId";
131
+ readonly type: "address";
132
+ }, {
133
+ readonly name: "expectedAmount";
134
+ readonly type: "uint256";
135
+ }];
136
+ /** @see {@link MerklClaimEvidence} */
137
+ readonly MerklClaim: readonly [{
138
+ readonly name: "accountPlace";
139
+ readonly type: "string";
140
+ }, {
141
+ readonly name: "distributor";
142
+ readonly type: "address";
143
+ }, {
144
+ readonly name: "tokenId";
145
+ readonly type: "address";
146
+ }, {
147
+ readonly name: "cumulativeAmount";
148
+ readonly type: "uint256";
149
+ }, {
150
+ readonly name: "claimedAmount";
151
+ readonly type: "uint256";
152
+ }, {
153
+ readonly name: "proof";
154
+ readonly type: "bytes32[]";
155
+ }];
156
+ /** @see {@link OneInchSwapInstructions} */
157
+ readonly OneInchSwap: readonly [{
158
+ readonly name: "accountPlace";
159
+ readonly type: "string";
160
+ }, {
161
+ readonly name: "tokenIn";
162
+ readonly type: "address";
163
+ }, {
164
+ readonly name: "tokenOut";
165
+ readonly type: "address";
166
+ }, {
167
+ readonly name: "amountIn";
168
+ readonly type: "uint256";
169
+ }, {
170
+ readonly name: "quotedAmountOut";
171
+ readonly type: "uint256";
172
+ }, {
173
+ readonly name: "minAmountOut";
174
+ readonly type: "uint256";
175
+ }, {
176
+ readonly name: "slippageBps";
177
+ readonly type: "uint16";
178
+ }, {
179
+ readonly name: "expiresAt";
180
+ readonly type: "uint64";
181
+ }, {
182
+ readonly name: "flags";
183
+ readonly type: "uint256";
184
+ }, {
185
+ readonly name: "executor";
186
+ readonly type: "address";
187
+ }, {
188
+ readonly name: "srcReceiver";
189
+ readonly type: "address";
190
+ }, {
191
+ readonly name: "data";
192
+ readonly type: "bytes";
193
+ }];
92
194
  };
93
195
  /**
94
196
  * The schema of Ymax observation messages. The domain name intentionally
@@ -105,6 +207,11 @@ export declare const YmaxObservationMessageSchema: {
105
207
  * - syncState: the portfolio state the observations correspond to
106
208
  * - holdings: the balance of every balance-bearing place of the portfolio
107
209
  * - instruments: details of the instruments relevant to the portfolio
210
+ * - aaveClaims, compoundClaims, merklClaims, oneInchSwaps: optional claim
211
+ * evidence and swap instructions, which plan steps select by index (see
212
+ * {@link SelectableObservations}), each present only when requested. As
213
+ * there is a single `PortfolioObservations` per message, their presence
214
+ * never conflicts.
108
215
  */
109
216
  readonly PortfolioObservations: readonly [{
110
217
  readonly name: "portfolio";
@@ -118,6 +225,22 @@ export declare const YmaxObservationMessageSchema: {
118
225
  }, {
119
226
  readonly name: "instruments";
120
227
  readonly type: "InstrumentDetail[]";
228
+ }, {
229
+ readonly name: "aaveClaims";
230
+ readonly type: "AaveClaim[]";
231
+ readonly optional: true;
232
+ }, {
233
+ readonly name: "compoundClaims";
234
+ readonly type: "CompoundClaim[]";
235
+ readonly optional: true;
236
+ }, {
237
+ readonly name: "merklClaims";
238
+ readonly type: "MerklClaim[]";
239
+ readonly optional: true;
240
+ }, {
241
+ readonly name: "oneInchSwaps";
242
+ readonly type: "OneInchSwap[]";
243
+ readonly optional: true;
121
244
  }];
122
245
  };
123
246
  readonly subTypes: {
@@ -160,6 +283,86 @@ export declare const YmaxObservationMessageSchema: {
160
283
  readonly name: "tvlUsd";
161
284
  readonly type: "uint256";
162
285
  }];
286
+ /** @see {@link AaveClaimEvidence} */
287
+ readonly AaveClaim: readonly [{
288
+ readonly name: "instrumentId";
289
+ readonly type: "string";
290
+ }, {
291
+ readonly name: "tokenId";
292
+ readonly type: "address";
293
+ }, {
294
+ readonly name: "expectedAmount";
295
+ readonly type: "uint256";
296
+ }];
297
+ /** @see {@link CompoundClaimEvidence} */
298
+ readonly CompoundClaim: readonly [{
299
+ readonly name: "instrumentId";
300
+ readonly type: "string";
301
+ }, {
302
+ readonly name: "tokenId";
303
+ readonly type: "address";
304
+ }, {
305
+ readonly name: "expectedAmount";
306
+ readonly type: "uint256";
307
+ }];
308
+ /** @see {@link MerklClaimEvidence} */
309
+ readonly MerklClaim: readonly [{
310
+ readonly name: "accountPlace";
311
+ readonly type: "string";
312
+ }, {
313
+ readonly name: "distributor";
314
+ readonly type: "address";
315
+ }, {
316
+ readonly name: "tokenId";
317
+ readonly type: "address";
318
+ }, {
319
+ readonly name: "cumulativeAmount";
320
+ readonly type: "uint256";
321
+ }, {
322
+ readonly name: "claimedAmount";
323
+ readonly type: "uint256";
324
+ }, {
325
+ readonly name: "proof";
326
+ readonly type: "bytes32[]";
327
+ }];
328
+ /** @see {@link OneInchSwapInstructions} */
329
+ readonly OneInchSwap: readonly [{
330
+ readonly name: "accountPlace";
331
+ readonly type: "string";
332
+ }, {
333
+ readonly name: "tokenIn";
334
+ readonly type: "address";
335
+ }, {
336
+ readonly name: "tokenOut";
337
+ readonly type: "address";
338
+ }, {
339
+ readonly name: "amountIn";
340
+ readonly type: "uint256";
341
+ }, {
342
+ readonly name: "quotedAmountOut";
343
+ readonly type: "uint256";
344
+ }, {
345
+ readonly name: "minAmountOut";
346
+ readonly type: "uint256";
347
+ }, {
348
+ readonly name: "slippageBps";
349
+ readonly type: "uint16";
350
+ }, {
351
+ readonly name: "expiresAt";
352
+ readonly type: "uint64";
353
+ }, {
354
+ readonly name: "flags";
355
+ readonly type: "uint256";
356
+ }, {
357
+ readonly name: "executor";
358
+ readonly type: "address";
359
+ }, {
360
+ readonly name: "srcReceiver";
361
+ readonly type: "address";
362
+ }, {
363
+ readonly name: "data";
364
+ readonly type: "bytes";
365
+ }];
163
366
  };
164
367
  };
165
368
  export type YmaxObservationMessageSchema = typeof YmaxObservationMessageSchema;
@@ -188,6 +391,15 @@ export type PortfolioObservationsContent = {
188
391
  export declare const VALUE_UUSD_UNKNOWN = -1n;
189
392
  /** Largest valuation representable in the signed `int256` wire field. */
190
393
  export declare const MAX_VALUE_UUSD: bigint;
394
+ /**
395
+ * The estimated incremental payout of a Merkl claim: its cumulative
396
+ * entitlement less what was observed to be claimed already. Not guaranteed,
397
+ * since the distributor uses its own claimed state at execution time.
398
+ *
399
+ * @param claim
400
+ * @throws {RangeError} if more was claimed than the cumulative entitlement
401
+ */
402
+ export declare const getMerklClaimExpectedAmount: ({ cumulativeAmount, claimedAmount, }: Pick<MerklClaimEvidence, "cumulativeAmount" | "claimedAmount">) => bigint;
191
403
  /**
192
404
  * Author either legacy balances or typed holdings using the shared schema.
193
405
  * Typed holdings always carry `valueUusd`, with {@link VALUE_UUSD_UNKNOWN}
@@ -195,7 +407,7 @@ export declare const MAX_VALUE_UUSD: bigint;
195
407
  * repeat what their `balanceUsdc` values derive (as decoding returns), so no
196
408
  * balance is silently dropped.
197
409
  */
198
- export declare const portfolioObservationsToEIP712: ({ portfolioId, syncState, observations: { balances, holdings, instrumentTvls }, }: PortfolioObservationsContent) => PortfolioObservationsEIP712Input;
410
+ export declare const portfolioObservationsToEIP712: (content: PortfolioObservationsContent) => PortfolioObservationsEIP712Input;
199
411
  /**
200
412
  * Decode normalized authenticated observations. The handler must use
201
413
  * onUnknownSignedField: 'throw'. This converter does not verify signatures.
@@ -204,6 +416,6 @@ export declare const portfolioObservationsToEIP712: ({ portfolioId, syncState, o
204
416
  * A typed holding's {@link VALUE_UUSD_UNKNOWN} valuation decodes to an absent
205
417
  * `valueUusd`.
206
418
  */
207
- export declare const portfolioObservationsFromEIP712: ({ portfolio, syncState, holdings, instruments, }: PortfolioObservationsEIP712) => PortfolioObservationsContent;
419
+ export declare const portfolioObservationsFromEIP712: (message: PortfolioObservationsEIP712) => PortfolioObservationsContent;
208
420
  export {};
209
421
  //# sourceMappingURL=observation-messages.d.ts.map
@@ -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,EAAE,MAAM,yCAAyC,CAAC;AAS7E,OAAO,KAAK,EACV,gBAAgB,EAEhB,kBAAkB,E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