@agoric/portfolio-api 0.1.1-dev-423d565.0.423d565 → 0.1.1-dev-412bc11.0.412bc11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/portfolio-api",
3
- "version": "0.1.1-dev-423d565.0.423d565",
3
+ "version": "0.1.1-dev-412bc11.0.412bc11",
4
4
  "description": "API for Portfolio management",
5
5
  "type": "module",
6
6
  "files": [
@@ -11,6 +11,8 @@
11
11
  "bin": "./src/cli/bin.js",
12
12
  "scripts": {
13
13
  "build": "exit 0",
14
+ "prepack": "yarn run -T tsc --build tsconfig.build.json",
15
+ "postpack": "git clean -f '*.d.*ts*' '*.tsbuildinfo'",
14
16
  "test": "ava",
15
17
  "test:c8": "c8 --all $C8_OPTIONS ava",
16
18
  "test:xs": "exit 0",
@@ -20,33 +22,10 @@
20
22
  "lint:types": "yarn run -T tsc"
21
23
  },
22
24
  "devDependencies": {
23
- "@fast-check/ava": "^2.0.1",
24
25
  "ava": "^5.3.0",
25
26
  "c8": "^10.1.3",
26
27
  "ts-blank-space": "^0.6.2"
27
28
  },
28
- "dependencies": {
29
- "@agoric/client-utils": "0.1.1-dev-423d565.0.423d565",
30
- "@agoric/cosmic-proto": "0.4.1-dev-423d565.0.423d565",
31
- "@agoric/ertp": "0.16.3-dev-423d565.0.423d565",
32
- "@agoric/internal": "0.3.3-dev-423d565.0.423d565",
33
- "@agoric/notifier": "0.6.3-dev-423d565.0.423d565",
34
- "@agoric/orchestration": "0.1.1-dev-423d565.0.423d565",
35
- "@agoric/zoe": "0.26.3-dev-423d565.0.423d565",
36
- "@cosmjs/proto-signing": "^0.36.0",
37
- "@cosmjs/stargate": "^0.36.0",
38
- "@endo/base64": "^1.0.12",
39
- "@endo/common": "^1.2.13",
40
- "@endo/errors": "^1.2.13",
41
- "@endo/eventual-send": "^1.3.4",
42
- "@endo/far": "^1.1.14",
43
- "@endo/init": "^1.1.12",
44
- "@endo/marshal": "^1.8.0",
45
- "@endo/nat": "^5.1.3",
46
- "@endo/pass-style": "^1.6.3",
47
- "@endo/patterns": "^1.7.0",
48
- "@endo/promise-kit": "^1.1.13"
49
- },
50
29
  "ava": {
51
30
  "extensions": {
52
31
  "js": true,
@@ -71,5 +50,5 @@
71
50
  "engines": {
72
51
  "node": "^20.9 || ^22.11"
73
52
  },
74
- "gitHead": "423d5657fc5bf6ffdb9d778fcc3cb9adc6c4adf1"
53
+ "gitHead": "412bc11a50bd7a9712ca431e1d7c7d300be6e130"
75
54
  }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Yield protocols for Proof of Concept.
3
+ */
4
+ export type YieldProtocol = (typeof YieldProtocol)[keyof typeof YieldProtocol];
5
+ export namespace YieldProtocol {
6
+ let Aave: "Aave";
7
+ let Compound: "Compound";
8
+ let USDN: "USDN";
9
+ let Beefy: "Beefy";
10
+ }
11
+ /**
12
+ * EVM chain wallet operations that incur different gas costs.
13
+ * Supply: user is supplying assets to a yield protocol on the target chain.
14
+ * Withdraw: user is withdrawing assets from a yield protocol on the target chain.
15
+ * DepositForBurn: user is transferring assets off the target chain via CCTP.
16
+ */
17
+ export type EvmWalletOperationType = (typeof EvmWalletOperationType)[keyof typeof EvmWalletOperationType];
18
+ export namespace EvmWalletOperationType {
19
+ let Supply: "supply";
20
+ let Withdraw: "withdraw";
21
+ let DepositForBurn: "depositforburn";
22
+ }
23
+ export type AxelarChain = (typeof AxelarChain)[keyof typeof AxelarChain];
24
+ export namespace AxelarChain {
25
+ let Arbitrum: "Arbitrum";
26
+ let Avalanche: "Avalanche";
27
+ let Base: "Base";
28
+ let Ethereum: "Ethereum";
29
+ let Optimism: "Optimism";
30
+ }
31
+ export type SupportedChain = (typeof SupportedChain)[keyof typeof SupportedChain];
32
+ export namespace SupportedChain {
33
+ let agoric: "agoric";
34
+ let noble: "noble";
35
+ }
36
+ /**
37
+ * Strategies for portfolio rebalancing of bulk deposits.
38
+ */
39
+ export type RebalanceStrategy = (typeof RebalanceStrategy)[keyof typeof RebalanceStrategy];
40
+ export namespace RebalanceStrategy {
41
+ let Preset: "preset";
42
+ let PreserveExistingProportions: "pep";
43
+ }
44
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["constants.js"],"names":[],"mappings":";;;4BAOU,CAAC,OAAO,aAAa,EAAE,MAAM,OAAO,aAAa,CAAC;;;;;;;;;;;;;qCAgBlD,CAAC,OAAO,sBAAsB,EAAE,MAAM,OAAO,sBAAsB,CAAC;;;;;;0BAUpE,CAAC,OAAO,WAAW,EAAE,MAAM,OAAO,WAAW,CAAC;;;;;;;;6BAY9C,CAAC,OAAO,cAAc,EAAE,MAAM,OAAO,cAAc,CAAC;;;;;;;;gCAapD,CAAC,OAAO,iBAAiB,EAAE,MAAM,OAAO,iBAAiB,CAAC"}
package/src/constants.js CHANGED
@@ -15,6 +15,21 @@ export const YieldProtocol = /** @type {const} */ ({
15
15
  });
16
16
  harden(YieldProtocol);
17
17
 
18
+ /**
19
+ * EVM chain wallet operations that incur different gas costs.
20
+ * Supply: user is supplying assets to a yield protocol on the target chain.
21
+ * Withdraw: user is withdrawing assets from a yield protocol on the target chain.
22
+ * DepositForBurn: user is transferring assets off the target chain via CCTP.
23
+ *
24
+ * @enum {(typeof EvmWalletOperationType)[keyof typeof EvmWalletOperationType]}
25
+ */
26
+ export const EvmWalletOperationType = /** @type {const} */ ({
27
+ Supply: 'supply',
28
+ Withdraw: 'withdraw',
29
+ DepositForBurn: 'depositforburn',
30
+ });
31
+ harden(EvmWalletOperationType);
32
+
18
33
  /**
19
34
  * @enum {(typeof AxelarChain)[keyof typeof AxelarChain]}
20
35
  */
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Mnemonic IDs for supported financial instruments in which a portfolio can use
3
+ * assets to take a position.
4
+ *
5
+ * Treat these identifers as opaque strings. There are separate data structures
6
+ * to map them to functional interfaces for interoperation.
7
+ */
8
+ export type InstrumentId = (typeof InstrumentId)[keyof typeof InstrumentId];
9
+ export namespace InstrumentId {
10
+ let Aave_Arbitrum: "Aave_Arbitrum";
11
+ let Aave_Avalanche: "Aave_Avalanche";
12
+ let Aave_Base: "Aave_Base";
13
+ let Aave_Ethereum: "Aave_Ethereum";
14
+ let Aave_Optimism: "Aave_Optimism";
15
+ let Beefy_compoundUsdc_Arbitrum: "Beefy_compoundUsdc_Arbitrum";
16
+ let Beefy_compoundUsdc_Optimism: "Beefy_compoundUsdc_Optimism";
17
+ let Beefy_morphoGauntletUsdc_Ethereum: "Beefy_morphoGauntletUsdc_Ethereum";
18
+ let Beefy_morphoSeamlessUsdc_Base: "Beefy_morphoSeamlessUsdc_Base";
19
+ let Beefy_morphoSmokehouseUsdc_Ethereum: "Beefy_morphoSmokehouseUsdc_Ethereum";
20
+ let Beefy_re7_Avalanche: "Beefy_re7_Avalanche";
21
+ let Compound_Arbitrum: "Compound_Arbitrum";
22
+ let Compound_Base: "Compound_Base";
23
+ let Compound_Ethereum: "Compound_Ethereum";
24
+ let Compound_Optimism: "Compound_Optimism";
25
+ let USDN: "USDN";
26
+ let USDNVault: "USDNVault";
27
+ }
28
+ //# sourceMappingURL=instruments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instruments.d.ts","sourceRoot":"","sources":["instruments.js"],"names":[],"mappings":";;;;;;;2BAOU,CAAC,OAAO,YAAY,EAAE,MAAM,OAAO,YAAY,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Mnemonic IDs for supported financial instruments in which a portfolio can use
3
+ * assets to take a position.
4
+ *
5
+ * Treat these identifers as opaque strings. There are separate data structures
6
+ * to map them to functional interfaces for interoperation.
7
+ *
8
+ * @enum {(typeof InstrumentId)[keyof typeof InstrumentId]}
9
+ */
10
+ export const InstrumentId = /** @type {const} */ ({
11
+ Aave_Arbitrum: 'Aave_Arbitrum',
12
+ Aave_Avalanche: 'Aave_Avalanche',
13
+ Aave_Base: 'Aave_Base',
14
+ Aave_Ethereum: 'Aave_Ethereum',
15
+ Aave_Optimism: 'Aave_Optimism',
16
+ Beefy_compoundUsdc_Arbitrum: 'Beefy_compoundUsdc_Arbitrum',
17
+ Beefy_compoundUsdc_Optimism: 'Beefy_compoundUsdc_Optimism',
18
+ Beefy_morphoGauntletUsdc_Ethereum: 'Beefy_morphoGauntletUsdc_Ethereum',
19
+ Beefy_morphoSeamlessUsdc_Base: 'Beefy_morphoSeamlessUsdc_Base',
20
+ Beefy_morphoSmokehouseUsdc_Ethereum: 'Beefy_morphoSmokehouseUsdc_Ethereum',
21
+ Beefy_re7_Avalanche: 'Beefy_re7_Avalanche',
22
+ Compound_Arbitrum: 'Compound_Arbitrum',
23
+ Compound_Base: 'Compound_Base',
24
+ Compound_Ethereum: 'Compound_Ethereum',
25
+ Compound_Optimism: 'Compound_Optimism',
26
+ USDN: 'USDN',
27
+ USDNVault: 'USDNVault',
28
+ });
29
+ harden(InstrumentId);
package/src/main.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./constants.js";
2
+ export * from "./instruments.js";
3
+ export * from "./resolver.js";
4
+ export * from "./types.js";
5
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.js"],"names":[],"mappings":""}
package/src/main.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './constants.js';
2
+ export * from './instruments.js';
3
+ export * from './resolver.js';
2
4
  export * from './types.js';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Tx statuses for published transactions. Exhaustive state machine flows:
3
+ * - pending -> success (when cross-chain operation completes successfully)
4
+ * - pending -> failed (when operation fails or times out)
5
+ */
6
+ export type TxStatus = (typeof TxStatus)[keyof typeof TxStatus];
7
+ export namespace TxStatus {
8
+ let PENDING: "pending";
9
+ let SUCCESS: "success";
10
+ let FAILED: "failed";
11
+ }
12
+ /**
13
+ * Tx types for published transactions
14
+ */
15
+ export type TxType = (typeof TxType)[keyof typeof TxType];
16
+ export namespace TxType {
17
+ let CCTP_TO_EVM: "CCTP_TO_EVM";
18
+ let GMP: "GMP";
19
+ let CCTP_TO_AGORIC: "CCTP_TO_AGORIC";
20
+ let CCTP_TO_NOBLE: "CCTP_TO_NOBLE";
21
+ }
22
+ /**
23
+ * Represents a published transaction with its type, optional amount, destination, and status.
24
+ */
25
+ export type PublishedTx = {
26
+ /**
27
+ * - The type of transaction (CCTP_TO_EVM, GMP, CCTP_TO_AGORIC, or CCTP_TO_NOBLE)
28
+ */
29
+ type: TxType;
30
+ /**
31
+ * - Optional transaction amount as a bigint
32
+ */
33
+ amount?: bigint | undefined;
34
+ /**
35
+ * - The destination account identifier for the transaction
36
+ */
37
+ destinationAddress: AccountId;
38
+ /**
39
+ * - Current status of the transaction (pending, success, or failed)
40
+ */
41
+ status: TxStatus;
42
+ };
43
+ import type { AccountId } from '@agoric/orchestration';
44
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["resolver.js"],"names":[],"mappings":";;;;;uBAmBU,CAAC,OAAO,QAAQ,EAAE,MAAM,OAAO,QAAQ,CAAC;;;;;;;;;qBAYxC,CAAC,OAAO,MAAM,EAAE,MAAM,OAAO,MAAM,CAAC;;;;;;;;;;;;;;UAvBhC,MAAM;;;;;;;;wBAEN,SAAS;;;;YACT,QAAQ;;+BAVM,uBAAuB"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @import {AccountId} from '@agoric/orchestration';
3
+ */
4
+
5
+ /**
6
+ * Represents a published transaction with its type, optional amount, destination, and status.
7
+ *
8
+ * @typedef {object} PublishedTx
9
+ * @property {TxType} type - The type of transaction (CCTP_TO_EVM, GMP, CCTP_TO_AGORIC, or CCTP_TO_NOBLE)
10
+ * @property {bigint} [amount] - Optional transaction amount as a bigint
11
+ * @property {AccountId} destinationAddress - The destination account identifier for the transaction
12
+ * @property {TxStatus} status - Current status of the transaction (pending, success, or failed)
13
+ */
14
+
15
+ /**
16
+ * Tx statuses for published transactions. Exhaustive state machine flows:
17
+ * - pending -> success (when cross-chain operation completes successfully)
18
+ * - pending -> failed (when operation fails or times out)
19
+ *
20
+ * @enum {(typeof TxStatus)[keyof typeof TxStatus]}
21
+ */
22
+ export const TxStatus = /** @type {const} */ ({
23
+ PENDING: 'pending',
24
+ SUCCESS: 'success',
25
+ FAILED: 'failed',
26
+ });
27
+ harden(TxStatus);
28
+
29
+ /**
30
+ * Tx types for published transactions
31
+ *
32
+ * @enum {(typeof TxType)[keyof typeof TxType]}
33
+ */
34
+ export const TxType = /** @type {const} */ ({
35
+ CCTP_TO_EVM: 'CCTP_TO_EVM',
36
+ GMP: 'GMP',
37
+ CCTP_TO_AGORIC: 'CCTP_TO_AGORIC',
38
+ /** @deprecated - only supports 20 byte addresses */
39
+ CCTP_TO_NOBLE: 'CCTP_TO_NOBLE',
40
+ });
41
+ harden(TxType);
package/src/types.d.ts ADDED
@@ -0,0 +1,120 @@
1
+ import type { NatAmount } from '@agoric/ertp';
2
+ import { type AccountId, type Bech32Address, type CosmosChainAddress } from '@agoric/orchestration';
3
+ import type { SupportedChain, YieldProtocol } from './constants.js';
4
+ import type { InstrumentId } from './instruments.js';
5
+ import type { PublishedTx } from './resolver.js';
6
+ export type SeatKeyword = 'Cash' | 'Deposit';
7
+ export type AssetPlaceRef = `<${SeatKeyword}>` | '+agoric' | `@${SupportedChain}` | InstrumentId;
8
+ type Empty = Record<never, NatAmount>;
9
+ /**
10
+ * Proposal shapes for portfolio operations.
11
+ *
12
+ * **openPortfolio**: Create portfolio with initial funding across protocols
13
+ * **rebalance**: Add funds (give) or withdraw funds (want) from protocols
14
+ */
15
+ export type ProposalType = {
16
+ openPortfolio: {
17
+ give: {
18
+ /** required iff the contract was started with an Access issuer */
19
+ Access?: NatAmount;
20
+ Deposit?: NatAmount;
21
+ };
22
+ want?: Empty;
23
+ };
24
+ rebalance: {
25
+ give: {
26
+ Deposit?: NatAmount;
27
+ };
28
+ want: Empty;
29
+ } | {
30
+ want: {
31
+ Cash: NatAmount;
32
+ };
33
+ give: Empty;
34
+ };
35
+ withdraw: {
36
+ want: {
37
+ Cash: NatAmount;
38
+ };
39
+ give: Empty;
40
+ };
41
+ deposit: {
42
+ give: {
43
+ Deposit: NatAmount;
44
+ };
45
+ want: Empty;
46
+ };
47
+ };
48
+ /**
49
+ * Target allocation mapping from PoolKey to numerator (typically in basis points).
50
+ * Denominator is implicitly the sum of all numerators.
51
+ */
52
+ export type TargetAllocation = Partial<Record<InstrumentId, bigint>>;
53
+ export type FlowDetail = {
54
+ type: 'withdraw';
55
+ amount: NatAmount;
56
+ } | {
57
+ type: 'deposit';
58
+ amount: NatAmount;
59
+ } | {
60
+ type: 'rebalance';
61
+ };
62
+ export type FlowStatus = {
63
+ state: 'run';
64
+ step: number;
65
+ how: string;
66
+ } | {
67
+ state: 'undo';
68
+ step: number;
69
+ how: string;
70
+ } | {
71
+ state: 'done';
72
+ } | {
73
+ state: 'fail';
74
+ step: number;
75
+ how: string;
76
+ error: string;
77
+ where?: string;
78
+ };
79
+ export type FlowStep = {
80
+ how: string;
81
+ amount: NatAmount;
82
+ src: AssetPlaceRef;
83
+ dest: AssetPlaceRef;
84
+ };
85
+ export type PortfolioKey = `portfolio${number}`;
86
+ export type FlowKey = `flow${number}`;
87
+ export type StatusFor = {
88
+ contract: {
89
+ contractAccount: CosmosChainAddress['value'];
90
+ };
91
+ pendingTx: PublishedTx;
92
+ portfolios: {
93
+ addPortfolio: PortfolioKey;
94
+ };
95
+ portfolio: {
96
+ positionKeys: InstrumentId[];
97
+ accountIdByChain: Partial<Record<SupportedChain, AccountId>>;
98
+ accountsPending?: SupportedChain[];
99
+ depositAddress?: Bech32Address;
100
+ targetAllocation?: TargetAllocation;
101
+ /** incremented by the contract every time the user sends a transaction that the planner should respond to */
102
+ policyVersion: number;
103
+ /** the count of acknowledged submissions [from the planner] associated with the current policyVersion */
104
+ rebalanceCount: number;
105
+ /** @deprecated in favor of flowsRunning */
106
+ flowCount: number;
107
+ flowsRunning?: Record<FlowKey, FlowDetail>;
108
+ };
109
+ position: {
110
+ protocol: YieldProtocol;
111
+ accountId: AccountId;
112
+ netTransfers: NatAmount;
113
+ totalIn: NatAmount;
114
+ totalOut: NatAmount;
115
+ };
116
+ flow: FlowStatus;
117
+ flowSteps: FlowStep[];
118
+ };
119
+ export {};
120
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;AAE7C,MAAM,MAAM,aAAa,GACrB,IAAI,WAAW,GAAG,GAClB,SAAS,GACT,IAAI,cAAc,EAAE,GACpB,YAAY,CAAC;AAEjB,KAAK,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE;QACb,IAAI,EAAE;YACJ,kEAAkE;YAClE,MAAM,CAAC,EAAE,SAAS,CAAC;YACnB,OAAO,CAAC,EAAE,SAAS,CAAC;SACrB,CAAC;QACF,IAAI,CAAC,EAAE,KAAK,CAAC;KACd,CAAC;IACF,SAAS,EACL;QAAE,IAAI,EAAE;YAAE,OAAO,CAAC,EAAE,SAAS,CA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@agoric/ertp';
2
+ import {
3
+ type AccountId,
4
+ type Bech32Address,
5
+ type CosmosChainAddress,
6
+ } from '@agoric/orchestration';
7
+ import type { SupportedChain, YieldProtocol } from './constants.js';
8
+ import type { InstrumentId } from './instruments.js';
9
+ import type { PublishedTx } from './resolver.js';
10
+
11
+ export type SeatKeyword = 'Cash' | 'Deposit';
12
+
13
+ export type AssetPlaceRef =
14
+ | `<${SeatKeyword}>`
15
+ | '+agoric' // deposit LCA
16
+ | `@${SupportedChain}`
17
+ | InstrumentId;
18
+
19
+ type Empty = Record<never, NatAmount>;
20
+
21
+ /**
22
+ * Proposal shapes for portfolio operations.
23
+ *
24
+ * **openPortfolio**: Create portfolio with initial funding across protocols
25
+ * **rebalance**: Add funds (give) or withdraw funds (want) from protocols
26
+ */
27
+ export type ProposalType = {
28
+ openPortfolio: {
29
+ give: {
30
+ /** required iff the contract was started with an Access issuer */
31
+ Access?: NatAmount;
32
+ Deposit?: NatAmount;
33
+ };
34
+ want?: Empty;
35
+ };
36
+ rebalance:
37
+ | { give: { Deposit?: NatAmount }; want: Empty }
38
+ | { want: { Cash: NatAmount }; give: Empty };
39
+ withdraw: { want: { Cash: NatAmount }; give: Empty };
40
+ deposit: { give: { Deposit: NatAmount }; want: Empty };
41
+ };
42
+
43
+ /**
44
+ * Target allocation mapping from PoolKey to numerator (typically in basis points).
45
+ * Denominator is implicitly the sum of all numerators.
46
+ */
47
+ export type TargetAllocation = Partial<Record<InstrumentId, bigint>>;
48
+
49
+ export type FlowDetail =
50
+ | { type: 'withdraw'; amount: NatAmount }
51
+ | { type: 'deposit'; amount: NatAmount }
52
+ | { type: 'rebalance' }; // aka simpleRebalance
53
+
54
+ export type FlowStatus =
55
+ | { state: 'run'; step: number; how: string }
56
+ | { state: 'undo'; step: number; how: string }
57
+ | { state: 'done' }
58
+ | { state: 'fail'; step: number; how: string; error: string; where?: string };
59
+
60
+ export type FlowStep = {
61
+ how: string;
62
+ amount: NatAmount;
63
+ src: AssetPlaceRef;
64
+ dest: AssetPlaceRef;
65
+ };
66
+
67
+ export type PortfolioKey = `portfolio${number}`;
68
+ export type FlowKey = `flow${number}`;
69
+
70
+ export type StatusFor = {
71
+ contract: {
72
+ contractAccount: CosmosChainAddress['value'];
73
+ };
74
+ pendingTx: PublishedTx;
75
+ portfolios: {
76
+ addPortfolio: PortfolioKey;
77
+ };
78
+ portfolio: {
79
+ positionKeys: InstrumentId[];
80
+ accountIdByChain: Partial<Record<SupportedChain, AccountId>>;
81
+ accountsPending?: SupportedChain[];
82
+ depositAddress?: Bech32Address;
83
+ targetAllocation?: TargetAllocation;
84
+ /** incremented by the contract every time the user sends a transaction that the planner should respond to */
85
+ policyVersion: number;
86
+ /** the count of acknowledged submissions [from the planner] associated with the current policyVersion */
87
+ rebalanceCount: number;
88
+ /** @deprecated in favor of flowsRunning */
89
+ flowCount: number;
90
+ flowsRunning?: Record<FlowKey, FlowDetail>;
91
+ };
92
+ position: {
93
+ protocol: YieldProtocol;
94
+ accountId: AccountId;
95
+ netTransfers: NatAmount;
96
+ totalIn: NatAmount;
97
+ totalOut: NatAmount;
98
+ };
99
+ flow: FlowStatus;
100
+ flowSteps: FlowStep[];
101
+ };