@agoric/portfolio-api 0.1.1-dev-159ee8a.0.159ee8a → 0.1.1-dev-6deecfc.0.6deecfc

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
@@ -1,3 +1,41 @@
1
1
  # Portfolio management API
2
2
 
3
3
  API shared between on-chain contract and external clients
4
+
5
+ ## YDS Target Balances
6
+
7
+ The YMax Data Service (YDS) should import the shared target-balance helper and
8
+ production network data from this public package. `@agoric/portfolio-api`
9
+ participates in the repo's after-merge canary publish flow, so production
10
+ network changes can propagate without waiting for `@aglocal/portfolio-contract`
11
+ packaging.
12
+
13
+ ```js
14
+ import { computeTargetBalances } from '@agoric/portfolio-api/src/target-balances.js';
15
+ import { PROD_NETWORK } from '@agoric/portfolio-api/src/network/prod-network.js';
16
+
17
+ const changedTargets = computeTargetBalances({
18
+ brand: usdcBrand,
19
+ currentBalances,
20
+ balanceDelta,
21
+ targetAllocation,
22
+ network: PROD_NETWORK,
23
+ depositFromChain,
24
+ });
25
+ ```
26
+
27
+ `changedTargets` contains only balances that need to change. Use signed
28
+ minor-unit deltas: positive for deposits, negative for withdrawals, and `0n` for
29
+ rebalances.
30
+
31
+ Relevant explicit `package.json` subpath exports are:
32
+
33
+ - `./src/target-balances.js`
34
+ - `./src/network/prod-network.js`
35
+ - `./src/network/network-spec.js`
36
+ - `./src/places.js`
37
+ - `./src/type-guards.js`
38
+ - `./src/evm-wallet/eip712-messages.js`
39
+ - `./src/evm-wallet/message-handler-helpers.js`
40
+
41
+ Keep importing the `.js` subpaths so the same source works after packaging.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/portfolio-api",
3
- "version": "0.1.1-dev-159ee8a.0.159ee8a",
3
+ "version": "0.1.1-dev-6deecfc.0.6deecfc",
4
4
  "description": "API for Portfolio management",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,6 +12,20 @@
12
12
  "tools"
13
13
  ],
14
14
  "main": "src/main.js",
15
+ "exports": {
16
+ ".": "./src/main.js",
17
+ "./src/constants.js": "./src/constants.js",
18
+ "./src/evm-wallet/eip712-messages.js": "./src/evm-wallet/eip712-messages.js",
19
+ "./src/evm-wallet/message-handler-helpers.js": "./src/evm-wallet/message-handler-helpers.js",
20
+ "./src/network/network-spec.js": "./src/network/network-spec.js",
21
+ "./src/network/prod-network.js": "./src/network/prod-network.js",
22
+ "./src/places.js": "./src/places.js",
23
+ "./src/portfolio-constants.js": "./src/portfolio-constants.js",
24
+ "./src/resolver.js": "./src/resolver.js",
25
+ "./src/target-balances.js": "./src/target-balances.js",
26
+ "./src/type-guards.js": "./src/type-guards.js",
27
+ "./package.json": "./package.json"
28
+ },
15
29
  "bin": "./src/cli/bin.js",
16
30
  "scripts": {
17
31
  "build": "exit 0",
@@ -31,8 +45,8 @@
31
45
  "generate:ymax-machine": "npx tsx scripts/gen-ymax-machine.mts"
32
46
  },
33
47
  "dependencies": {
34
- "@agoric/internal": "0.3.3-dev-159ee8a.0.159ee8a",
35
- "@agoric/orchestration": "0.1.1-dev-159ee8a.0.159ee8a",
48
+ "@agoric/internal": "0.3.3-dev-6deecfc.0.6deecfc",
49
+ "@agoric/orchestration": "0.1.1-dev-6deecfc.0.6deecfc",
36
50
  "@endo/common": "^1.2.13",
37
51
  "@endo/errors": "^1.2.13",
38
52
  "@endo/patterns": "^1.7.0"
@@ -73,5 +87,5 @@
73
87
  "engines": {
74
88
  "node": "^20.9 || ^22.11"
75
89
  },
76
- "gitHead": "159ee8acf8ecd2c46a15d34a46b344de65f7e099"
90
+ "gitHead": "6deecfc17452ceb1faae9290b8f76112cc4f26a1"
77
91
  }
package/src/main.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from "./constants.js";
2
2
  export * from "./instruments.js";
3
+ export * from "./network/prod-network.js";
3
4
  export * from "./resolver.js";
5
+ export * from "./target-balances.js";
4
6
  export * from "./type-guards.js";
5
7
  export * from "./types-index.js";
6
8
  //# sourceMappingURL=main.d.ts.map
package/src/main.js CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from './constants.js';
2
2
  export * from './instruments.js';
3
+ export * from './network/prod-network.js';
3
4
  export * from './resolver.js';
5
+ export * from './target-balances.js';
4
6
  export * from './type-guards.js';
5
7
 
6
8
  // eslint-disable-next-line import/export -- just types
@@ -0,0 +1,88 @@
1
+ import type { NatValue } from '@agoric/ertp';
2
+ import type { SupportedChain, YieldProtocol } from '../constants.js';
3
+ import type { InstrumentId } from '../instruments.js';
4
+ import type { AssetPlaceRef } from '../types.js';
5
+ export type ControlProtocol = 'ibc' | 'axelar' | 'local';
6
+ export type TransferProtocol = 'ibc' | 'fastusdc' | 'cctpFromNoble' | 'cctpToNoble' | 'cctpV2' | 'local';
7
+ /**
8
+ * Link to Factory and Wallet contracts:
9
+ * https://github.com/agoric-labs/agoric-to-axelar-local/blob/cd6087fa44de3b019b2cdac6962bb49b6a2bc1ca/packages/axelar-local-dev-cosmos/src/__tests__/contracts/Factory.sol
10
+ *
11
+ * Steps submitted to the contract are expected to include fee/gas payment
12
+ * details which vary by the traversed link.
13
+ * - toUSDN: transferring into USDN transfer reduces the *payload* (e.g., $10k
14
+ * might get reduced to $9995)
15
+ * - makeEvmAccount: the fee for executing the Factory contract to create a new
16
+ * remote wallet
17
+ * - evmToNoble: the fee for running the tx to send tokens from the remote
18
+ * wallet to Noble
19
+ * - evmToPool: the fee for sending and executing a tx on the Wallet contract
20
+ * to supply tokens to a specified pool
21
+ * - poolToEvm: the fee for sending and executing a tx on the Wallet contract
22
+ * to withdraw tokens from a specified pool
23
+ */
24
+ export type FeeMode = 'toUSDN' | 'makeEvmAccount' | 'evmToNoble' | 'evmToPool' | 'poolToEvm' | 'evmToEvm';
25
+ export interface ChainSpec {
26
+ readonly name: SupportedChain;
27
+ /** how agoric reaches this chain: 'ibc' (noble) or 'axelar' (EVM) or 'local' */
28
+ readonly control: ControlProtocol;
29
+ /** minimum delta amount for planned moves involving this chain */
30
+ readonly deltaSoftMin?: NatValue;
31
+ }
32
+ type BlockWithdrawReason = 'LOW_LIQUIDITY';
33
+ type BlockDepositReason = BlockWithdrawReason | 'AT_CAPACITY';
34
+ export type PoolKey = InstrumentId;
35
+ export interface PoolSpec {
36
+ readonly pool: PoolKey;
37
+ /** host chain of the corresponding instrument */
38
+ readonly chain: SupportedChain;
39
+ /** protocol of the corresponding instrument */
40
+ readonly protocol: YieldProtocol;
41
+ /** when increases are unavailable, the (primary) reason why */
42
+ readonly blockDepositReason?: BlockDepositReason;
43
+ /** when decreases are unavailable, the (primary) reason why */
44
+ readonly blockWithdrawReason?: BlockWithdrawReason;
45
+ }
46
+ /**
47
+ * A +agoric local account or <Deposit>/<Cash> Agoric blockchain contract seat.
48
+ */
49
+ export interface LocalPlaceSpec {
50
+ readonly id: '<Deposit>' | '<Cash>' | '+agoric';
51
+ readonly chain: 'agoric';
52
+ }
53
+ /**
54
+ * A directed edge from one place to another, usually having at least one hub
55
+ * endpoint.
56
+ */
57
+ export interface LinkSpec {
58
+ readonly src: AssetPlaceRef;
59
+ readonly dest: AssetPlaceRef;
60
+ /**
61
+ * variable transfer fee in basis points to be applied against the transferred
62
+ * amount of major units (e.g., USDC)
63
+ */
64
+ readonly variableFeeBps: number;
65
+ /** flat-rate transfer fee in minor units (e.g., uusdc) */
66
+ readonly flatFee?: NatValue;
67
+ /** expected transfer settlement time in seconds */
68
+ readonly timeSec: number;
69
+ /** inclusive maximum transfer amount in minor units (e.g., uusdc) */
70
+ readonly capacity?: NatValue;
71
+ /** inclusive minimum transfer amount in minor units (e.g., uusdc) */
72
+ readonly min?: NatValue;
73
+ /** mechanism by which the transfer occurs */
74
+ readonly transfer: TransferProtocol;
75
+ /** designator for how fees apply to transactions over this link */
76
+ readonly feeMode?: FeeMode;
77
+ }
78
+ /** Details of how chains/pools/etc. and how they connect. */
79
+ export interface NetworkSpec {
80
+ readonly debug?: boolean;
81
+ readonly environment?: 'dev' | 'test' | 'prod';
82
+ readonly chains: ChainSpec[];
83
+ readonly pools: PoolSpec[];
84
+ readonly localPlaces?: LocalPlaceSpec[];
85
+ readonly links: LinkSpec[];
86
+ }
87
+ export {};
88
+ //# sourceMappingURL=network-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-spec.d.ts","sourceRoot":"","sources":["network-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AACzD,MAAM,MAAM,gBAAgB,GACxB,KAAK,GACL,UAAU,GACV,eAAe,GACf,aAAa,GACb,QAAQ,GACR,OAAO,CAAC;AACZ;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,OAAO,GACf,QAAQ,GACR,gBAAgB,GAChB,YAAY,GACZ,WAAW,GACX,WAAW,GACX,UAAU,CAAC;AAGf,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,kEAAkE;IAClE,QAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC;CAClC;AAID,KAAK,mBAAmB,GAAG,eAAe,CAAC;AAC3C,KAAK,kBAAkB,GAAG,mBAAmB,GAAG,aAAa,CAAC;AAE9D,MAAM,MAAM,OAAO,GAAG,YAAY,CAAC;AAGnC,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,+CAA+C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EAAE,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;CAC5B"}
@@ -0,0 +1,115 @@
1
+
2
+
3
+
4
+
5
+
6
+ // Control and transfer planes
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ /**
16
+ * Link to Factory and Wallet contracts:
17
+ * https://github.com/agoric-labs/agoric-to-axelar-local/blob/cd6087fa44de3b019b2cdac6962bb49b6a2bc1ca/packages/axelar-local-dev-cosmos/src/__tests__/contracts/Factory.sol
18
+ *
19
+ * Steps submitted to the contract are expected to include fee/gas payment
20
+ * details which vary by the traversed link.
21
+ * - toUSDN: transferring into USDN transfer reduces the *payload* (e.g., $10k
22
+ * might get reduced to $9995)
23
+ * - makeEvmAccount: the fee for executing the Factory contract to create a new
24
+ * remote wallet
25
+ * - evmToNoble: the fee for running the tx to send tokens from the remote
26
+ * wallet to Noble
27
+ * - evmToPool: the fee for sending and executing a tx on the Wallet contract
28
+ * to supply tokens to a specified pool
29
+ * - poolToEvm: the fee for sending and executing a tx on the Wallet contract
30
+ * to withdraw tokens from a specified pool
31
+ */
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+ // Chains (hubs)
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+ // Any reason to block withdrawal is by extension also a reason to block
50
+ // deposit.
51
+
52
+
53
+
54
+
55
+
56
+ // Pools (leaves)
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+ /**
70
+ * A +agoric local account or <Deposit>/<Cash> Agoric blockchain contract seat.
71
+ */
72
+
73
+
74
+
75
+
76
+
77
+ /**
78
+ * A directed edge from one place to another, usually having at least one hub
79
+ * endpoint.
80
+ */
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+ /** Details of how chains/pools/etc. and how they connect. */
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
@@ -0,0 +1,4 @@
1
+ import type { NetworkSpec } from './network-spec.js';
2
+ export declare const PROD_NETWORK: NetworkSpec;
3
+ export default PROD_NETWORK;
4
+ //# sourceMappingURL=prod-network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prod-network.d.ts","sourceRoot":"","sources":["prod-network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAerD,eAAO,MAAM,YAAY,EAAE,WA6XzB,CAAC;AAEH,eAAe,YAAY,CAAC"}