@agoric/portfolio-api 0.1.1-other-dev-d15096d.0.d15096d → 0.1.1-other-dev-ecf44df.0.ecf44df
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 +115 -0
- package/package.json +45 -27
- package/src/constants.d.ts +74 -31
- package/src/constants.d.ts.map +1 -1
- package/src/constants.js +82 -26
- package/src/evm/types.d.ts +19 -0
- package/src/evm/types.d.ts.map +1 -0
- package/src/evm/types.js +27 -0
- package/src/evm-wallet/eip712-messages.d.ts +493 -0
- package/src/evm-wallet/eip712-messages.d.ts.map +1 -0
- package/src/evm-wallet/eip712-messages.js +301 -0
- package/src/evm-wallet/message-handler-helpers.d.ts +2315 -0
- package/src/evm-wallet/message-handler-helpers.d.ts.map +1 -0
- package/src/evm-wallet/message-handler-helpers.js +98 -0
- package/src/instruments.d.ts +42 -2
- package/src/instruments.d.ts.map +1 -1
- package/src/instruments.js +68 -3
- package/src/main.d.ts +4 -0
- package/src/main.js +4 -0
- package/src/model/generated/ymax-machine.d.ts +71 -0
- package/src/model/generated/ymax-machine.d.ts.map +1 -0
- package/src/model/generated/ymax-machine.js +1292 -0
- package/src/model/ymax-machine.mmd +56 -0
- package/src/model/ymax-machine.schema.json +180 -0
- package/src/model/ymax-machine.yaml +942 -0
- package/src/network/network-spec.d.ts +87 -0
- package/src/network/network-spec.d.ts.map +1 -0
- package/src/network/network-spec.js +115 -0
- package/src/network/prod-network.d.ts +4 -0
- package/src/network/prod-network.d.ts.map +1 -0
- package/src/network/prod-network.js +405 -0
- package/src/observation-messages.d.ts +209 -0
- package/src/observation-messages.d.ts.map +1 -0
- package/src/observation-messages.js +443 -0
- package/src/places.d.ts +471 -0
- package/src/places.d.ts.map +1 -0
- package/src/places.js +360 -0
- package/src/portfolio-constants.d.ts +44 -0
- package/src/portfolio-constants.d.ts.map +1 -0
- package/src/portfolio-constants.js +80 -0
- package/src/portfolio-permissions.d.ts +87 -0
- package/src/portfolio-permissions.d.ts.map +1 -0
- package/src/portfolio-permissions.js +190 -0
- package/src/resolver.d.ts +139 -13
- package/src/resolver.d.ts.map +1 -1
- package/src/resolver.js +97 -17
- package/src/target-balances.d.ts +46 -0
- package/src/target-balances.d.ts.map +1 -0
- package/src/target-balances.js +412 -0
- package/src/type-guards.d.ts +38 -9
- package/src/type-guards.d.ts.map +1 -1
- package/src/type-guards.js +163 -0
- package/src/types-index.d.ts +3 -0
- package/src/types.d.ts +519 -17
- package/src/types.d.ts.map +1 -1
- package/src/types.js +759 -0
- package/src/type-guards.ts +0 -17
- package/src/types.ts +0 -167
package/README.md
CHANGED
|
@@ -1,3 +1,118 @@
|
|
|
1
1
|
# Portfolio management API
|
|
2
2
|
|
|
3
3
|
API shared between on-chain contract and external clients
|
|
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
|
+
|
|
82
|
+
## YDS Target Balances
|
|
83
|
+
|
|
84
|
+
The YMax Data Service (YDS) should import the shared target-balance helper and
|
|
85
|
+
production network data from this public package. `@agoric/portfolio-api`
|
|
86
|
+
participates in the repo's after-merge canary publish flow, so production
|
|
87
|
+
network changes can propagate without waiting for `@aglocal/portfolio-contract`
|
|
88
|
+
packaging.
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
import { computeTargetBalances } from '@agoric/portfolio-api/src/target-balances.js';
|
|
92
|
+
import { PROD_NETWORK } from '@agoric/portfolio-api/src/network/prod-network.js';
|
|
93
|
+
|
|
94
|
+
const changedTargets = computeTargetBalances({
|
|
95
|
+
brand: usdcBrand,
|
|
96
|
+
currentBalances,
|
|
97
|
+
balanceDelta,
|
|
98
|
+
targetAllocation,
|
|
99
|
+
network: PROD_NETWORK,
|
|
100
|
+
depositFromChain,
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`changedTargets` contains only balances that need to change. Use signed
|
|
105
|
+
minor-unit deltas: positive for deposits, negative for withdrawals, and `0n` for
|
|
106
|
+
rebalances.
|
|
107
|
+
|
|
108
|
+
Relevant explicit `package.json` subpath exports are:
|
|
109
|
+
|
|
110
|
+
- `./src/target-balances.js`
|
|
111
|
+
- `./src/network/prod-network.js`
|
|
112
|
+
- `./src/network/network-spec.js`
|
|
113
|
+
- `./src/places.js`
|
|
114
|
+
- `./src/type-guards.js`
|
|
115
|
+
- `./src/evm-wallet/eip712-messages.js`
|
|
116
|
+
- `./src/evm-wallet/message-handler-helpers.js`
|
|
117
|
+
|
|
118
|
+
Keep importing the `.js` subpaths so the same source works after packaging.
|
package/package.json
CHANGED
|
@@ -1,60 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/portfolio-api",
|
|
3
|
-
"version": "0.1.1-other-dev-
|
|
3
|
+
"version": "0.1.1-other-dev-ecf44df.0.ecf44df",
|
|
4
4
|
"description": "API for Portfolio management",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Agoric/agoric-sdk.git"
|
|
8
|
+
},
|
|
5
9
|
"type": "module",
|
|
6
10
|
"files": [
|
|
7
11
|
"src",
|
|
8
12
|
"tools"
|
|
9
13
|
],
|
|
10
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/observation-messages.js": "./src/observation-messages.js",
|
|
23
|
+
"./src/places.js": "./src/places.js",
|
|
24
|
+
"./src/portfolio-permissions.js": "./src/portfolio-permissions.js",
|
|
25
|
+
"./src/portfolio-constants.js": "./src/portfolio-constants.js",
|
|
26
|
+
"./src/resolver.js": "./src/resolver.js",
|
|
27
|
+
"./src/target-balances.js": "./src/target-balances.js",
|
|
28
|
+
"./src/type-guards.js": "./src/type-guards.js",
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
11
31
|
"bin": "./src/cli/bin.js",
|
|
12
32
|
"scripts": {
|
|
13
33
|
"build": "exit 0",
|
|
14
|
-
"prepack": "yarn run -T
|
|
15
|
-
"postpack": "
|
|
34
|
+
"prepack": "yarn run -T prepack-package",
|
|
35
|
+
"postpack": "yarn run -T postpack-package",
|
|
16
36
|
"test": "ava",
|
|
17
37
|
"test:c8": "c8 --all $C8_OPTIONS ava",
|
|
18
38
|
"test:xs": "exit 0",
|
|
19
39
|
"lint-fix": "yarn lint:eslint --fix",
|
|
20
40
|
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
21
|
-
"lint:eslint": "
|
|
22
|
-
"lint:types": "yarn run -T
|
|
41
|
+
"lint:eslint": "node ../../scripts/eslint-repo.mjs .",
|
|
42
|
+
"lint:types": "yarn run -T tsgo --tsBuildInfoFile tsconfig.tsgo.tsbuildinfo",
|
|
43
|
+
"lint:mermaid": "npx tsx scripts/gen-mermaid.mts --check",
|
|
44
|
+
"lint:ymax-diagram": "npx tsx scripts/lint-ymax-state-diagram.mts",
|
|
45
|
+
"lint:ymax-machine": "npx tsx scripts/gen-ymax-machine.mts --check",
|
|
46
|
+
"lint:visualizer-data": "npx tsx scripts/gen-visualizer-data.mts --check",
|
|
47
|
+
"generate:ymax-machine": "npx tsx scripts/gen-ymax-machine.mts"
|
|
23
48
|
},
|
|
24
49
|
"dependencies": {
|
|
25
|
-
"@agoric/
|
|
26
|
-
"@
|
|
50
|
+
"@agoric/internal": "0.3.3-other-dev-ecf44df.0.ecf44df",
|
|
51
|
+
"@agoric/orchestration": "0.1.1-other-dev-ecf44df.0.ecf44df",
|
|
52
|
+
"@endo/common": "^1.4.0",
|
|
53
|
+
"@endo/errors": "^1.3.1",
|
|
54
|
+
"@endo/patterns": "^1.9.1"
|
|
27
55
|
},
|
|
28
56
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
57
|
+
"@endo/far": "^1.1.14",
|
|
58
|
+
"@endo/init": "^1.1.13",
|
|
59
|
+
"@types/js-yaml": "^4",
|
|
60
|
+
"ajv": "^6.12.6",
|
|
61
|
+
"ava": "^8.0.1",
|
|
31
62
|
"c8": "^10.1.3",
|
|
63
|
+
"js-yaml": "^4.1.1",
|
|
32
64
|
"ts-blank-space": "^0.6.2",
|
|
33
65
|
"tsd": "^0.33.0"
|
|
34
66
|
},
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"js": true,
|
|
38
|
-
"ts": "module"
|
|
39
|
-
},
|
|
40
|
-
"files": [
|
|
41
|
-
"test/**/*.test.*"
|
|
42
|
-
],
|
|
43
|
-
"nodeArguments": [
|
|
44
|
-
"--import=ts-blank-space/register",
|
|
45
|
-
"--no-warnings"
|
|
46
|
-
],
|
|
47
|
-
"require": [
|
|
48
|
-
"@endo/init/debug.js"
|
|
49
|
-
],
|
|
50
|
-
"timeout": "20m"
|
|
67
|
+
"typeCoverage": {
|
|
68
|
+
"atLeast": 99.95
|
|
51
69
|
},
|
|
52
70
|
"license": "Apache-2.0",
|
|
53
71
|
"publishConfig": {
|
|
54
72
|
"access": "public"
|
|
55
73
|
},
|
|
56
74
|
"engines": {
|
|
57
|
-
"node": "^
|
|
75
|
+
"node": "^22.11 || ^24.14"
|
|
58
76
|
},
|
|
59
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "ecf44df5eadcc7a1d68745f056fca19155fb5231"
|
|
60
78
|
}
|
package/src/constants.d.ts
CHANGED
|
@@ -1,66 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {ClusterName, TypedPattern} from '@agoric/internal';
|
|
3
|
+
* @import {CaipChainId} from '@agoric/orchestration';
|
|
4
|
+
* @import {FlowConfig} from './types.js';
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Configuration arguments for newly-created portfolio flows.
|
|
8
|
+
*
|
|
9
|
+
* This is only a default so that existing flows continue to behave as before
|
|
10
|
+
* for replay fidelity.
|
|
11
|
+
*
|
|
12
|
+
* @type {FlowConfig | undefined}
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_FLOW_CONFIG: FlowConfig | undefined;
|
|
1
15
|
/**
|
|
2
16
|
* Yield protocols for Proof of Concept.
|
|
3
17
|
*/
|
|
4
18
|
export type YieldProtocol = (typeof YieldProtocol)[keyof typeof YieldProtocol];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Yield protocols for Proof of Concept.
|
|
21
|
+
*
|
|
22
|
+
* @typedef {(typeof YieldProtocol)[keyof typeof YieldProtocol]} YieldProtocol
|
|
23
|
+
*/
|
|
24
|
+
export const YieldProtocol: import("@agoric/internal").KeyMirrorResult<{
|
|
25
|
+
Aave: null;
|
|
26
|
+
Compound: null;
|
|
27
|
+
USDN: null;
|
|
28
|
+
Beefy: null;
|
|
29
|
+
ERC4626: null;
|
|
30
|
+
}>;
|
|
11
31
|
/**
|
|
12
32
|
* EVM chain wallet operations that incur different gas costs.
|
|
13
33
|
* Supply: user is supplying assets to a yield protocol on the target chain.
|
|
14
34
|
* Withdraw: user is withdrawing assets from a yield protocol on the target chain.
|
|
15
35
|
* DepositForBurn: user is transferring assets off the target chain via CCTP.
|
|
36
|
+
* Claim: user is claiming rewards from a yield protocol.
|
|
37
|
+
* Swap: user is swapping one token for another (e.g., a reward token to USDC).
|
|
16
38
|
*/
|
|
17
39
|
export type EvmWalletOperationType = (typeof EvmWalletOperationType)[keyof typeof EvmWalletOperationType];
|
|
18
40
|
export namespace EvmWalletOperationType {
|
|
19
41
|
let Supply: "supply";
|
|
20
42
|
let Withdraw: "withdraw";
|
|
21
43
|
let DepositForBurn: "depositforburn";
|
|
44
|
+
let Claim: "claim";
|
|
45
|
+
let Swap: "swap";
|
|
22
46
|
}
|
|
23
47
|
export type AxelarChain = (typeof AxelarChain)[keyof typeof AxelarChain];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @typedef {(typeof AxelarChain)[keyof typeof AxelarChain]} AxelarChain
|
|
50
|
+
*/
|
|
51
|
+
export const AxelarChain: import("@agoric/internal").KeyMirrorResult<{
|
|
52
|
+
Arbitrum: null;
|
|
53
|
+
Avalanche: null;
|
|
54
|
+
Base: null;
|
|
55
|
+
Ethereum: null;
|
|
56
|
+
Optimism: null;
|
|
57
|
+
}>;
|
|
31
58
|
/**
|
|
32
59
|
* cf. https://chainlist.org/
|
|
33
|
-
* XXX this probably belongs in @agoric/orchestration
|
|
60
|
+
* XXX this probably belongs in '@agoric/orchestration'
|
|
34
61
|
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<AxelarChain, bigint>>>>>}
|
|
35
62
|
*/
|
|
36
63
|
export const Eip155ChainIds: Readonly<Record<ClusterName, Readonly<Partial<Record<AxelarChain, bigint>>>>>;
|
|
37
64
|
export type SupportedChain = (typeof SupportedChain)[keyof typeof SupportedChain];
|
|
38
|
-
export namespace SupportedChain {
|
|
39
|
-
let Arbitrum_1: "Arbitrum";
|
|
40
|
-
export { Arbitrum_1 as Arbitrum };
|
|
41
|
-
let Avalanche_1: "Avalanche";
|
|
42
|
-
export { Avalanche_1 as Avalanche };
|
|
43
|
-
let Base_1: "Base";
|
|
44
|
-
export { Base_1 as Base };
|
|
45
|
-
let Ethereum_1: "Ethereum";
|
|
46
|
-
export { Ethereum_1 as Ethereum };
|
|
47
|
-
let Optimism_1: "Optimism";
|
|
48
|
-
export { Optimism_1 as Optimism };
|
|
49
|
-
export let agoric: "agoric";
|
|
50
|
-
export let noble: "noble";
|
|
51
|
-
}
|
|
52
65
|
/**
|
|
53
|
-
*
|
|
66
|
+
* @typedef {(typeof SupportedChain)[keyof typeof SupportedChain]} SupportedChain
|
|
67
|
+
*/
|
|
68
|
+
export const SupportedChain: import("@agoric/internal").KeyMirrorResult<{
|
|
69
|
+
Arbitrum: "Arbitrum";
|
|
70
|
+
Avalanche: "Avalanche";
|
|
71
|
+
Base: "Base";
|
|
72
|
+
Ethereum: "Ethereum";
|
|
73
|
+
Optimism: "Optimism";
|
|
74
|
+
agoric: "agoric";
|
|
75
|
+
noble: "noble";
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* cf. https://standards.chainagnostic.org/CAIPs/caip-2
|
|
54
79
|
* Please keep in sync with ../../../services/ymax-planner/src/support.ts `spectrumChainIds`
|
|
55
80
|
*
|
|
56
|
-
* XXX this probably belongs in @agoric/orchestration
|
|
81
|
+
* XXX this probably belongs in '@agoric/orchestration'
|
|
57
82
|
*
|
|
58
83
|
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, CaipChainId>>>>>}
|
|
59
84
|
*/
|
|
60
85
|
export const CaipChainIds: Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, CaipChainId>>>>>;
|
|
61
86
|
/**
|
|
62
87
|
* cf. https://developers.circle.com/stablecoins/usdc-contract-addresses
|
|
63
|
-
* XXX this might belong in @agoric/orchestration
|
|
88
|
+
* XXX this might belong in '@agoric/orchestration'
|
|
64
89
|
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, string>>>>>}
|
|
65
90
|
*/
|
|
66
91
|
export const UsdcTokenIds: Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, string>>>>>;
|
|
@@ -77,6 +102,24 @@ export namespace RebalanceStrategy {
|
|
|
77
102
|
* This corresponds to 100 uusdc, i.e., $0.0001 for USDC.
|
|
78
103
|
*/
|
|
79
104
|
export const ACCOUNT_DUST_EPSILON: 100n;
|
|
105
|
+
export const ExperimentalSwapShape: import("@endo/patterns").MatcherOf<"kind", "boolean">;
|
|
106
|
+
/**
|
|
107
|
+
* Feature flags to handle contract upgrade flow compatibility.
|
|
108
|
+
* @type {TypedPattern<FlowConfig['features']>}
|
|
109
|
+
*/
|
|
110
|
+
export const FlowFeaturesShape: TypedPattern<FlowConfig["features"]>;
|
|
111
|
+
/**
|
|
112
|
+
* Configuration options for flows.
|
|
113
|
+
* @type {TypedPattern<FlowConfig>}
|
|
114
|
+
*/
|
|
115
|
+
export const FlowConfigShape: TypedPattern<FlowConfig>;
|
|
116
|
+
/**
|
|
117
|
+
* Special string to designate the planner as a grantee.
|
|
118
|
+
* Includes a special & character to avoid potential collision with any CAIP-10 account address.
|
|
119
|
+
*/
|
|
120
|
+
export const PortfolioPlannerAgent: "&planner";
|
|
121
|
+
import type { FlowConfig } from './types.js';
|
|
80
122
|
import type { ClusterName } from '@agoric/internal';
|
|
81
123
|
import type { CaipChainId } from '@agoric/orchestration';
|
|
124
|
+
import type { TypedPattern } from '@agoric/internal';
|
|
82
125
|
//# sourceMappingURL=constants.d.ts.map
|
package/src/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["constants.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["constants.js"],"names":[],"mappings":"AAOA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,kCAFU,UAAU,GAAG,SAAS,CAO9B;;;;4BAMW,CAAC,OAAO,aAAa,EAAE,MAAM,OAAO,aAAa,CAAC;AAH/D;;;;GAIG;AACH;;;;;;GAMG;;;;;;;;;qCAWU,CAAC,OAAO,sBAAsB,EAAE,MAAM,OAAO,sBAAsB,CAAC;;;;;;;;0BAYpE,CAAC,OAAO,WAAW,EAAE,MAAM,OAAO,WAAW,CAAC;AAD3D;;GAEG;AACH;;;;;;GAMG;AAGH;;;;GAIG;AACH,6BAFU,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAkBrF;6BAIW,CAAC,OAAO,cAAc,EAAE,MAAM,OAAO,cAAc,CAAC;AADjE;;GAEG;AACH;;;;;;;;GAWG;AAMH;;;;;;;GAOG;AACH,2BAFU,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAgB7F;AAGF;;;;GAIG;AACH,2BAFU,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAwBxF;;;;gCAMW,CAAC,OAAO,iBAAiB,EAAE,MAAM,OAAO,iBAAiB,CAAC;;;;;AAgBvE;;;GAGG;AACH,mCAAoC,IAAI,CAAC;AAEzC,0FAAiD;AAEjD;;;GAGG;AACH,gCAFU,aAAa,UAAU,CAAC,UAAU,CAAC,CAAC,CAQ5C;AAEF;;;GAGG;AACH,8BAFU,aAAa,UAAU,CAAC,CAOhC;AAEF;;;GAGG;AACH,oCAAqC,UAAU,CAAC;gCAzNnB,YAAY;iCAFG,kBAAkB;iCAChC,uBAAuB;kCADT,kBAAkB"}
|
package/src/constants.js
CHANGED
|
@@ -2,21 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
/// <reference types="ses" />
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { keyMirror } from '@agoric/internal';
|
|
6
|
+
import { M, objectMap } from '@endo/patterns';
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @import {ClusterName, TypedPattern} from '@agoric/internal';
|
|
10
|
+
* @import {CaipChainId} from '@agoric/orchestration';
|
|
11
|
+
* @import {FlowConfig} from './types.js';
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Configuration arguments for newly-created portfolio flows.
|
|
16
|
+
*
|
|
17
|
+
* This is only a default so that existing flows continue to behave as before
|
|
18
|
+
* for replay fidelity.
|
|
19
|
+
*
|
|
20
|
+
* @type {FlowConfig | undefined}
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_FLOW_CONFIG = {
|
|
23
|
+
features: {
|
|
24
|
+
/** Enable ProgressTracker support in new flows. */
|
|
25
|
+
useProgressTracker: true,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
harden(DEFAULT_FLOW_CONFIG);
|
|
9
29
|
|
|
10
30
|
/**
|
|
11
31
|
* Yield protocols for Proof of Concept.
|
|
12
32
|
*
|
|
13
|
-
* @
|
|
33
|
+
* @typedef {(typeof YieldProtocol)[keyof typeof YieldProtocol]} YieldProtocol
|
|
14
34
|
*/
|
|
15
|
-
export const YieldProtocol =
|
|
16
|
-
Aave:
|
|
17
|
-
Compound:
|
|
18
|
-
USDN:
|
|
19
|
-
Beefy:
|
|
35
|
+
export const YieldProtocol = keyMirror({
|
|
36
|
+
Aave: null,
|
|
37
|
+
Compound: null,
|
|
38
|
+
USDN: null,
|
|
39
|
+
Beefy: null,
|
|
40
|
+
ERC4626: null,
|
|
20
41
|
});
|
|
21
42
|
harden(YieldProtocol);
|
|
22
43
|
|
|
@@ -25,31 +46,35 @@ harden(YieldProtocol);
|
|
|
25
46
|
* Supply: user is supplying assets to a yield protocol on the target chain.
|
|
26
47
|
* Withdraw: user is withdrawing assets from a yield protocol on the target chain.
|
|
27
48
|
* DepositForBurn: user is transferring assets off the target chain via CCTP.
|
|
49
|
+
* Claim: user is claiming rewards from a yield protocol.
|
|
50
|
+
* Swap: user is swapping one token for another (e.g., a reward token to USDC).
|
|
28
51
|
*
|
|
29
|
-
* @
|
|
52
|
+
* @typedef {(typeof EvmWalletOperationType)[keyof typeof EvmWalletOperationType]} EvmWalletOperationType
|
|
30
53
|
*/
|
|
31
54
|
export const EvmWalletOperationType = /** @type {const} */ ({
|
|
32
55
|
Supply: 'supply',
|
|
33
56
|
Withdraw: 'withdraw',
|
|
34
57
|
DepositForBurn: 'depositforburn',
|
|
58
|
+
Claim: 'claim',
|
|
59
|
+
Swap: 'swap',
|
|
35
60
|
});
|
|
36
61
|
harden(EvmWalletOperationType);
|
|
37
62
|
|
|
38
63
|
/**
|
|
39
|
-
* @
|
|
64
|
+
* @typedef {(typeof AxelarChain)[keyof typeof AxelarChain]} AxelarChain
|
|
40
65
|
*/
|
|
41
|
-
export const AxelarChain =
|
|
42
|
-
Arbitrum:
|
|
43
|
-
Avalanche:
|
|
44
|
-
Base:
|
|
45
|
-
Ethereum:
|
|
46
|
-
Optimism:
|
|
66
|
+
export const AxelarChain = keyMirror({
|
|
67
|
+
Arbitrum: null,
|
|
68
|
+
Avalanche: null,
|
|
69
|
+
Base: null,
|
|
70
|
+
Ethereum: null,
|
|
71
|
+
Optimism: null,
|
|
47
72
|
});
|
|
48
73
|
harden(AxelarChain);
|
|
49
74
|
|
|
50
75
|
/**
|
|
51
76
|
* cf. https://chainlist.org/
|
|
52
|
-
* XXX this probably belongs in @agoric/orchestration
|
|
77
|
+
* XXX this probably belongs in '@agoric/orchestration'
|
|
53
78
|
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<AxelarChain, bigint>>>>>}
|
|
54
79
|
*/
|
|
55
80
|
export const Eip155ChainIds = {
|
|
@@ -72,9 +97,9 @@ export const Eip155ChainIds = {
|
|
|
72
97
|
harden(Eip155ChainIds);
|
|
73
98
|
|
|
74
99
|
/**
|
|
75
|
-
* @
|
|
100
|
+
* @typedef {(typeof SupportedChain)[keyof typeof SupportedChain]} SupportedChain
|
|
76
101
|
*/
|
|
77
|
-
export const SupportedChain =
|
|
102
|
+
export const SupportedChain = keyMirror({
|
|
78
103
|
// ...AxelarChain works locally but gets lost in .d.ts generation
|
|
79
104
|
Arbitrum: 'Arbitrum',
|
|
80
105
|
Avalanche: 'Avalanche',
|
|
@@ -92,10 +117,10 @@ harden(SupportedChain);
|
|
|
92
117
|
const caipChainIdFromEip155 = chainId => `eip155:${chainId}`;
|
|
93
118
|
|
|
94
119
|
/**
|
|
95
|
-
* cf. https://chainagnostic.org/CAIPs/caip-2
|
|
120
|
+
* cf. https://standards.chainagnostic.org/CAIPs/caip-2
|
|
96
121
|
* Please keep in sync with ../../../services/ymax-planner/src/support.ts `spectrumChainIds`
|
|
97
122
|
*
|
|
98
|
-
* XXX this probably belongs in @agoric/orchestration
|
|
123
|
+
* XXX this probably belongs in '@agoric/orchestration'
|
|
99
124
|
*
|
|
100
125
|
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, CaipChainId>>>>>}
|
|
101
126
|
*/
|
|
@@ -118,7 +143,7 @@ harden(CaipChainIds);
|
|
|
118
143
|
|
|
119
144
|
/**
|
|
120
145
|
* cf. https://developers.circle.com/stablecoins/usdc-contract-addresses
|
|
121
|
-
* XXX this might belong in @agoric/orchestration
|
|
146
|
+
* XXX this might belong in '@agoric/orchestration'
|
|
122
147
|
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, string>>>>>}
|
|
123
148
|
*/
|
|
124
149
|
export const UsdcTokenIds = {
|
|
@@ -130,7 +155,7 @@ export const UsdcTokenIds = {
|
|
|
130
155
|
Optimism: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',
|
|
131
156
|
agoric:
|
|
132
157
|
'ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9',
|
|
133
|
-
noble: '
|
|
158
|
+
noble: 'uusdc',
|
|
134
159
|
},
|
|
135
160
|
testnet: {
|
|
136
161
|
Arbitrum: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d', // Sepolia
|
|
@@ -140,7 +165,7 @@ export const UsdcTokenIds = {
|
|
|
140
165
|
Optimism: '0x5fd84259d66Cd46123540766Be93DFE6D43130D7', // Sepolia
|
|
141
166
|
agoric:
|
|
142
167
|
'ibc/75F84596DDE9EE93010620701FFED959F3FFA1D0979F6773DE994FFEEA7D32F3',
|
|
143
|
-
noble: '
|
|
168
|
+
noble: 'uusdc',
|
|
144
169
|
},
|
|
145
170
|
local: {},
|
|
146
171
|
};
|
|
@@ -149,7 +174,7 @@ harden(UsdcTokenIds);
|
|
|
149
174
|
/**
|
|
150
175
|
* Strategies for portfolio rebalancing of bulk deposits.
|
|
151
176
|
*
|
|
152
|
-
* @
|
|
177
|
+
* @typedef {(typeof RebalanceStrategy)[keyof typeof RebalanceStrategy]} RebalanceStrategy
|
|
153
178
|
*/
|
|
154
179
|
export const RebalanceStrategy = /** @type {const} */ ({
|
|
155
180
|
/**
|
|
@@ -170,3 +195,34 @@ harden(RebalanceStrategy);
|
|
|
170
195
|
* This corresponds to 100 uusdc, i.e., $0.0001 for USDC.
|
|
171
196
|
*/
|
|
172
197
|
export const ACCOUNT_DUST_EPSILON = 100n;
|
|
198
|
+
|
|
199
|
+
export const ExperimentalSwapShape = M.boolean();
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Feature flags to handle contract upgrade flow compatibility.
|
|
203
|
+
* @type {TypedPattern<FlowConfig['features']>}
|
|
204
|
+
*/
|
|
205
|
+
export const FlowFeaturesShape = M.splitRecord(
|
|
206
|
+
{},
|
|
207
|
+
{
|
|
208
|
+
useProgressTracker: M.boolean(),
|
|
209
|
+
experimentalSwap: ExperimentalSwapShape,
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Configuration options for flows.
|
|
215
|
+
* @type {TypedPattern<FlowConfig>}
|
|
216
|
+
*/
|
|
217
|
+
export const FlowConfigShape = M.splitRecord(
|
|
218
|
+
{},
|
|
219
|
+
{
|
|
220
|
+
features: FlowFeaturesShape,
|
|
221
|
+
},
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Special string to designate the planner as a grantee.
|
|
226
|
+
* Includes a special & character to avoid potential collision with any CAIP-10 account address.
|
|
227
|
+
*/
|
|
228
|
+
export const PortfolioPlannerAgent = '&planner';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PureData } from '@endo/pass-style';
|
|
2
|
+
export type PortfolioPath = `published.ymax${0 | 1}.portfolios.portfolio${number}`;
|
|
3
|
+
type EIPCommonMessageUpdate = {
|
|
4
|
+
updated: 'messageUpdate';
|
|
5
|
+
nonce: bigint;
|
|
6
|
+
deadline: bigint;
|
|
7
|
+
};
|
|
8
|
+
export type EIPMessageUpdate = EIPCommonMessageUpdate & ({
|
|
9
|
+
status: 'pending';
|
|
10
|
+
} | {
|
|
11
|
+
status: 'error';
|
|
12
|
+
error: string;
|
|
13
|
+
} | {
|
|
14
|
+
status: 'ok';
|
|
15
|
+
result: PureData;
|
|
16
|
+
});
|
|
17
|
+
export type EVMWalletUpdate = EIPMessageUpdate | never;
|
|
18
|
+
export {};
|
|
19
|
+
//# 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,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,aAAa,GACvB,iBAAiB,CAAC,GAAG,CAAC,wBAAwB,MAAM,EAAE,CAAC;AAEzD,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,eAAe,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,GACnD,CACI;IACE,MAAM,EAAE,SAAS,CAAC;CACnB,GACD;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC;CAClB,CACJ,CAAC;AAEJ,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,KAAK,CAAC"}
|