@agoric/portfolio-api 0.1.1-other-dev-fbe72e7.0.fbe72e7 → 0.1.1-other-dev-d15096d.0.d15096d
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 +11 -26
- package/src/constants.d.ts +82 -0
- package/src/constants.d.ts.map +1 -0
- package/src/constants.js +118 -4
- package/src/instruments.d.ts +28 -0
- package/src/instruments.d.ts.map +1 -0
- package/src/instruments.js +29 -0
- package/src/main.d.ts +5 -0
- package/src/main.d.ts.map +1 -0
- package/src/main.js +5 -1
- package/src/resolver.d.ts +43 -0
- package/src/resolver.d.ts.map +1 -0
- package/src/resolver.js +39 -0
- package/src/type-guards.d.ts +10 -0
- package/src/type-guards.d.ts.map +1 -0
- package/src/type-guards.ts +17 -0
- package/src/types.d.ts +162 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +167 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/portfolio-api",
|
|
3
|
-
"version": "0.1.1-other-dev-
|
|
3
|
+
"version": "0.1.1-other-dev-d15096d.0.d15096d",
|
|
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",
|
|
@@ -19,33 +21,16 @@
|
|
|
19
21
|
"lint:eslint": "yarn run -T eslint .",
|
|
20
22
|
"lint:types": "yarn run -T tsc"
|
|
21
23
|
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@agoric/orchestration": "0.1.1-other-dev-d15096d.0.d15096d",
|
|
26
|
+
"@endo/common": "^1.2.13"
|
|
27
|
+
},
|
|
22
28
|
"devDependencies": {
|
|
23
|
-
"@
|
|
29
|
+
"@agoric/internal": "0.3.3-other-dev-d15096d.0.d15096d",
|
|
24
30
|
"ava": "^5.3.0",
|
|
25
31
|
"c8": "^10.1.3",
|
|
26
|
-
"ts-blank-space": "^0.6.2"
|
|
27
|
-
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@agoric/client-utils": "0.1.1-other-dev-fbe72e7.0.fbe72e7",
|
|
30
|
-
"@agoric/cosmic-proto": "0.4.1-other-dev-fbe72e7.0.fbe72e7",
|
|
31
|
-
"@agoric/ertp": "0.16.3-other-dev-fbe72e7.0.fbe72e7",
|
|
32
|
-
"@agoric/internal": "0.3.3-other-dev-fbe72e7.0.fbe72e7",
|
|
33
|
-
"@agoric/notifier": "0.6.3-other-dev-fbe72e7.0.fbe72e7",
|
|
34
|
-
"@agoric/orchestration": "0.1.1-other-dev-fbe72e7.0.fbe72e7",
|
|
35
|
-
"@agoric/zoe": "0.26.3-other-dev-fbe72e7.0.fbe72e7",
|
|
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"
|
|
32
|
+
"ts-blank-space": "^0.6.2",
|
|
33
|
+
"tsd": "^0.33.0"
|
|
49
34
|
},
|
|
50
35
|
"ava": {
|
|
51
36
|
"extensions": {
|
|
@@ -71,5 +56,5 @@
|
|
|
71
56
|
"engines": {
|
|
72
57
|
"node": "^20.9 || ^22.11"
|
|
73
58
|
},
|
|
74
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "d15096dc4ff8b96e9b6cd11954c20d3a9efbb393"
|
|
75
60
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
/**
|
|
32
|
+
* cf. https://chainlist.org/
|
|
33
|
+
* XXX this probably belongs in @agoric/orchestration
|
|
34
|
+
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<AxelarChain, bigint>>>>>}
|
|
35
|
+
*/
|
|
36
|
+
export const Eip155ChainIds: Readonly<Record<ClusterName, Readonly<Partial<Record<AxelarChain, bigint>>>>>;
|
|
37
|
+
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
|
+
/**
|
|
53
|
+
* cf. https://chainagnostic.org/CAIPs/caip-2
|
|
54
|
+
* Please keep in sync with ../../../services/ymax-planner/src/support.ts `spectrumChainIds`
|
|
55
|
+
*
|
|
56
|
+
* XXX this probably belongs in @agoric/orchestration
|
|
57
|
+
*
|
|
58
|
+
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, CaipChainId>>>>>}
|
|
59
|
+
*/
|
|
60
|
+
export const CaipChainIds: Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, CaipChainId>>>>>;
|
|
61
|
+
/**
|
|
62
|
+
* cf. https://developers.circle.com/stablecoins/usdc-contract-addresses
|
|
63
|
+
* XXX this might belong in @agoric/orchestration
|
|
64
|
+
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, string>>>>>}
|
|
65
|
+
*/
|
|
66
|
+
export const UsdcTokenIds: Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, string>>>>>;
|
|
67
|
+
/**
|
|
68
|
+
* Strategies for portfolio rebalancing of bulk deposits.
|
|
69
|
+
*/
|
|
70
|
+
export type RebalanceStrategy = (typeof RebalanceStrategy)[keyof typeof RebalanceStrategy];
|
|
71
|
+
export namespace RebalanceStrategy {
|
|
72
|
+
let Preset: "preset";
|
|
73
|
+
let PreserveExistingProportions: "pep";
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Treat account deltas smaller than this value (in micro-units) as dust.
|
|
77
|
+
* This corresponds to 100 uusdc, i.e., $0.0001 for USDC.
|
|
78
|
+
*/
|
|
79
|
+
export const ACCOUNT_DUST_EPSILON: 100n;
|
|
80
|
+
import type { ClusterName } from '@agoric/internal';
|
|
81
|
+
import type { CaipChainId } from '@agoric/orchestration';
|
|
82
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["constants.js"],"names":[],"mappings":";;;4BAYU,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;;;;;;;;AAWxD;;;;GAIG;AACH,6BAFU,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAkBrF;6BAIQ,CAAC,OAAO,cAAc,EAAE,MAAM,OAAO,cAAc,CAAC;;;;;;;;;;;;;;;AAmB9D;;;;;;;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;;;;gCAMQ,CAAC,OAAO,iBAAiB,EAAE,MAAM,OAAO,iBAAiB,CAAC;;;;;AAgBpE;;;GAGG;AACH,mCAAoC,IAAI,CAAC;iCArKV,kBAAkB;iCAClB,uBAAuB"}
|
package/src/constants.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
/// <reference types="ses" />
|
|
4
4
|
|
|
5
|
+
import { objectMap } from '@endo/common/object-map.js';
|
|
6
|
+
|
|
7
|
+
/** @import {ClusterName} from '@agoric/internal'; */
|
|
8
|
+
/** @import {CaipChainId} from '@agoric/orchestration'; */
|
|
9
|
+
|
|
5
10
|
/**
|
|
6
11
|
* Yield protocols for Proof of Concept.
|
|
7
12
|
*
|
|
@@ -15,29 +20,132 @@ export const YieldProtocol = /** @type {const} */ ({
|
|
|
15
20
|
});
|
|
16
21
|
harden(YieldProtocol);
|
|
17
22
|
|
|
23
|
+
/**
|
|
24
|
+
* EVM chain wallet operations that incur different gas costs.
|
|
25
|
+
* Supply: user is supplying assets to a yield protocol on the target chain.
|
|
26
|
+
* Withdraw: user is withdrawing assets from a yield protocol on the target chain.
|
|
27
|
+
* DepositForBurn: user is transferring assets off the target chain via CCTP.
|
|
28
|
+
*
|
|
29
|
+
* @enum {(typeof EvmWalletOperationType)[keyof typeof EvmWalletOperationType]}
|
|
30
|
+
*/
|
|
31
|
+
export const EvmWalletOperationType = /** @type {const} */ ({
|
|
32
|
+
Supply: 'supply',
|
|
33
|
+
Withdraw: 'withdraw',
|
|
34
|
+
DepositForBurn: 'depositforburn',
|
|
35
|
+
});
|
|
36
|
+
harden(EvmWalletOperationType);
|
|
37
|
+
|
|
18
38
|
/**
|
|
19
39
|
* @enum {(typeof AxelarChain)[keyof typeof AxelarChain]}
|
|
20
40
|
*/
|
|
21
41
|
export const AxelarChain = /** @type {const} */ ({
|
|
22
|
-
Avalanche: 'Avalanche',
|
|
23
42
|
Arbitrum: 'Arbitrum',
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
Avalanche: 'Avalanche',
|
|
44
|
+
Base: 'Base',
|
|
26
45
|
Ethereum: 'Ethereum',
|
|
46
|
+
Optimism: 'Optimism',
|
|
27
47
|
});
|
|
28
48
|
harden(AxelarChain);
|
|
29
49
|
|
|
50
|
+
/**
|
|
51
|
+
* cf. https://chainlist.org/
|
|
52
|
+
* XXX this probably belongs in @agoric/orchestration
|
|
53
|
+
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<AxelarChain, bigint>>>>>}
|
|
54
|
+
*/
|
|
55
|
+
export const Eip155ChainIds = {
|
|
56
|
+
mainnet: {
|
|
57
|
+
Arbitrum: 42161n,
|
|
58
|
+
Avalanche: 43114n,
|
|
59
|
+
Base: 8453n,
|
|
60
|
+
Ethereum: 1n,
|
|
61
|
+
Optimism: 10n,
|
|
62
|
+
},
|
|
63
|
+
testnet: {
|
|
64
|
+
Arbitrum: 421614n, // Sepolia
|
|
65
|
+
Avalanche: 43113n, // Fuji
|
|
66
|
+
Base: 84532n, // Sepolia
|
|
67
|
+
Ethereum: 11155111n, // Sepolia
|
|
68
|
+
Optimism: 11155420n, // Sepolia
|
|
69
|
+
},
|
|
70
|
+
local: {},
|
|
71
|
+
};
|
|
72
|
+
harden(Eip155ChainIds);
|
|
73
|
+
|
|
30
74
|
/**
|
|
31
75
|
* @enum {(typeof SupportedChain)[keyof typeof SupportedChain]}
|
|
32
76
|
*/
|
|
33
77
|
export const SupportedChain = /** @type {const} */ ({
|
|
34
|
-
...AxelarChain
|
|
78
|
+
// ...AxelarChain works locally but gets lost in .d.ts generation
|
|
79
|
+
Arbitrum: 'Arbitrum',
|
|
80
|
+
Avalanche: 'Avalanche',
|
|
81
|
+
Base: 'Base',
|
|
82
|
+
Ethereum: 'Ethereum',
|
|
83
|
+
Optimism: 'Optimism',
|
|
84
|
+
// Unique to this object
|
|
35
85
|
agoric: 'agoric',
|
|
36
86
|
noble: 'noble',
|
|
37
87
|
// XXX: check privateArgs for chainInfo for all of these
|
|
38
88
|
});
|
|
39
89
|
harden(SupportedChain);
|
|
40
90
|
|
|
91
|
+
/** @type {(eip155ChainId: bigint) => CaipChainId} */
|
|
92
|
+
const caipChainIdFromEip155 = chainId => `eip155:${chainId}`;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* cf. https://chainagnostic.org/CAIPs/caip-2
|
|
96
|
+
* Please keep in sync with ../../../services/ymax-planner/src/support.ts `spectrumChainIds`
|
|
97
|
+
*
|
|
98
|
+
* XXX this probably belongs in @agoric/orchestration
|
|
99
|
+
*
|
|
100
|
+
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, CaipChainId>>>>>}
|
|
101
|
+
*/
|
|
102
|
+
export const CaipChainIds = {
|
|
103
|
+
mainnet: {
|
|
104
|
+
...objectMap(Eip155ChainIds.mainnet, caipChainIdFromEip155),
|
|
105
|
+
agoric: 'cosmos:agoric-3',
|
|
106
|
+
noble: 'cosmos:noble-1',
|
|
107
|
+
},
|
|
108
|
+
testnet: {
|
|
109
|
+
...objectMap(Eip155ChainIds.testnet, caipChainIdFromEip155),
|
|
110
|
+
agoric: 'cosmos:agoricdev-25',
|
|
111
|
+
noble: 'cosmos:grand-1',
|
|
112
|
+
},
|
|
113
|
+
local: {
|
|
114
|
+
...objectMap(Eip155ChainIds.local, caipChainIdFromEip155),
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
harden(CaipChainIds);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* cf. https://developers.circle.com/stablecoins/usdc-contract-addresses
|
|
121
|
+
* XXX this might belong in @agoric/orchestration
|
|
122
|
+
* @type {Readonly<Record<ClusterName, Readonly<Partial<Record<SupportedChain, string>>>>>}
|
|
123
|
+
*/
|
|
124
|
+
export const UsdcTokenIds = {
|
|
125
|
+
mainnet: {
|
|
126
|
+
Arbitrum: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
127
|
+
Avalanche: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E',
|
|
128
|
+
Base: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
129
|
+
Ethereum: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
130
|
+
Optimism: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',
|
|
131
|
+
agoric:
|
|
132
|
+
'ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9',
|
|
133
|
+
noble: 'usdc',
|
|
134
|
+
},
|
|
135
|
+
testnet: {
|
|
136
|
+
Arbitrum: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d', // Sepolia
|
|
137
|
+
Avalanche: '0x5425890298aed601595a70AB815c96711a31Bc65', // Fuji
|
|
138
|
+
Base: '0x036CbD53842c5426634e7929541eC2318f3dCF7e', // Sepolia
|
|
139
|
+
Ethereum: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // Sepolia
|
|
140
|
+
Optimism: '0x5fd84259d66Cd46123540766Be93DFE6D43130D7', // Sepolia
|
|
141
|
+
agoric:
|
|
142
|
+
'ibc/75F84596DDE9EE93010620701FFED959F3FFA1D0979F6773DE994FFEEA7D32F3',
|
|
143
|
+
noble: 'usdc',
|
|
144
|
+
},
|
|
145
|
+
local: {},
|
|
146
|
+
};
|
|
147
|
+
harden(UsdcTokenIds);
|
|
148
|
+
|
|
41
149
|
/**
|
|
42
150
|
* Strategies for portfolio rebalancing of bulk deposits.
|
|
43
151
|
*
|
|
@@ -56,3 +164,9 @@ export const RebalanceStrategy = /** @type {const} */ ({
|
|
|
56
164
|
PreserveExistingProportions: 'pep',
|
|
57
165
|
});
|
|
58
166
|
harden(RebalanceStrategy);
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Treat account deltas smaller than this value (in micro-units) as dust.
|
|
170
|
+
* This corresponds to 100 uusdc, i.e., $0.0001 for USDC.
|
|
171
|
+
*/
|
|
172
|
+
export const ACCOUNT_DUST_EPSILON = 100n;
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.js"],"names":[],"mappings":""}
|
package/src/main.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Represents a published transaction with its type, optional amount, destination, and status.
|
|
23
|
+
*/
|
|
24
|
+
export type PublishedTx = {
|
|
25
|
+
/**
|
|
26
|
+
* - The type of transaction (CCTP_TO_EVM, GMP or CCTP_TO_AGORIC)
|
|
27
|
+
*/
|
|
28
|
+
type: TxType;
|
|
29
|
+
/**
|
|
30
|
+
* - Optional transaction amount as a bigint
|
|
31
|
+
*/
|
|
32
|
+
amount?: bigint | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* - The destination account identifier for the transaction
|
|
35
|
+
*/
|
|
36
|
+
destinationAddress: AccountId;
|
|
37
|
+
/**
|
|
38
|
+
* - Current status of the transaction (pending, success, or failed)
|
|
39
|
+
*/
|
|
40
|
+
status: TxStatus;
|
|
41
|
+
};
|
|
42
|
+
import type { AccountId } from '@agoric/orchestration';
|
|
43
|
+
//# 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"}
|
package/src/resolver.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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 or CCTP_TO_AGORIC)
|
|
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
|
+
});
|
|
39
|
+
harden(TxType);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InterChainAccountRef, LocalChainAccountRef } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Does it match the pattern, without regard to supported chains.
|
|
4
|
+
*/
|
|
5
|
+
export declare const isLocalChainAccountRef: (ref: string) => ref is LocalChainAccountRef;
|
|
6
|
+
/**
|
|
7
|
+
* Does it match the pattern, without regard to supported chains.
|
|
8
|
+
*/
|
|
9
|
+
export declare const isInterChainAccountRef: (ref: string) => ref is InterChainAccountRef;
|
|
10
|
+
//# sourceMappingURL=type-guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["type-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,MAAM,KACV,GAAG,IAAI,oBAA2C,CAAC;AAGtD;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,MAAM,KACV,GAAG,IAAI,oBAA2C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { InterChainAccountRef, LocalChainAccountRef } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Does it match the pattern, without regard to supported chains.
|
|
5
|
+
*/
|
|
6
|
+
export const isLocalChainAccountRef = (
|
|
7
|
+
ref: string,
|
|
8
|
+
): ref is LocalChainAccountRef => ref.startsWith('+');
|
|
9
|
+
harden(isLocalChainAccountRef);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Does it match the pattern, without regard to supported chains.
|
|
13
|
+
*/
|
|
14
|
+
export const isInterChainAccountRef = (
|
|
15
|
+
ref: string,
|
|
16
|
+
): ref is InterChainAccountRef => ref.startsWith('@');
|
|
17
|
+
harden(isInterChainAccountRef);
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Reference to a local chain accounts (LCA).
|
|
9
|
+
* '+agoric' is published as `depositAddress`
|
|
10
|
+
*/
|
|
11
|
+
export type LocalChainAccountRef = '+agoric';
|
|
12
|
+
export type InterChainAccountRef = `@${SupportedChain}`;
|
|
13
|
+
export type AssetPlaceRef = `<${SeatKeyword}>` | LocalChainAccountRef | InterChainAccountRef | InstrumentId;
|
|
14
|
+
type Empty = Record<never, NatAmount>;
|
|
15
|
+
/**
|
|
16
|
+
* Proposal shapes for portfolio operations.
|
|
17
|
+
*
|
|
18
|
+
* **openPortfolio**: Create portfolio with initial funding across protocols
|
|
19
|
+
* **rebalance**: Add funds (give) or withdraw funds (want) from protocols
|
|
20
|
+
*/
|
|
21
|
+
export type ProposalType = {
|
|
22
|
+
openPortfolio: {
|
|
23
|
+
give: {
|
|
24
|
+
/** required iff the contract was started with an Access issuer */
|
|
25
|
+
Access?: NatAmount;
|
|
26
|
+
Deposit?: NatAmount;
|
|
27
|
+
};
|
|
28
|
+
want?: Empty;
|
|
29
|
+
};
|
|
30
|
+
rebalance: {
|
|
31
|
+
give: {
|
|
32
|
+
Deposit?: NatAmount;
|
|
33
|
+
};
|
|
34
|
+
want: Empty;
|
|
35
|
+
} | {
|
|
36
|
+
want: {
|
|
37
|
+
Cash: NatAmount;
|
|
38
|
+
};
|
|
39
|
+
give: Empty;
|
|
40
|
+
};
|
|
41
|
+
withdraw: {
|
|
42
|
+
want: {
|
|
43
|
+
Cash: NatAmount;
|
|
44
|
+
};
|
|
45
|
+
give: Empty;
|
|
46
|
+
};
|
|
47
|
+
deposit: {
|
|
48
|
+
give: {
|
|
49
|
+
Deposit: NatAmount;
|
|
50
|
+
};
|
|
51
|
+
want: Empty;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Target allocation mapping from PoolKey to numerator (typically in basis points).
|
|
56
|
+
* Denominator is implicitly the sum of all numerators.
|
|
57
|
+
*/
|
|
58
|
+
export type TargetAllocation = Partial<Record<InstrumentId, bigint>>;
|
|
59
|
+
export type FlowDetail = {
|
|
60
|
+
type: 'withdraw';
|
|
61
|
+
amount: NatAmount;
|
|
62
|
+
} | {
|
|
63
|
+
type: 'deposit';
|
|
64
|
+
amount: NatAmount;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'rebalance';
|
|
67
|
+
};
|
|
68
|
+
/** linked list of concurrent failures, including dependencies */
|
|
69
|
+
export type FlowErrors = {
|
|
70
|
+
step: number;
|
|
71
|
+
how: string;
|
|
72
|
+
error: string;
|
|
73
|
+
next?: FlowErrors;
|
|
74
|
+
};
|
|
75
|
+
export type FlowStatus = {
|
|
76
|
+
state: 'run';
|
|
77
|
+
/** minimum currently running step */
|
|
78
|
+
step: number;
|
|
79
|
+
how: string;
|
|
80
|
+
/** currently running steps, when executing concurrently */
|
|
81
|
+
steps?: number[];
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated - contract no longer does automatic recovery */
|
|
84
|
+
| {
|
|
85
|
+
state: 'undo';
|
|
86
|
+
step: number;
|
|
87
|
+
how: string;
|
|
88
|
+
} | {
|
|
89
|
+
state: 'done';
|
|
90
|
+
} | ({
|
|
91
|
+
state: 'fail';
|
|
92
|
+
} & FlowErrors);
|
|
93
|
+
export type MovementDesc = {
|
|
94
|
+
amount: NatAmount;
|
|
95
|
+
src: AssetPlaceRef;
|
|
96
|
+
dest: AssetPlaceRef;
|
|
97
|
+
/** for example: GMP fee */
|
|
98
|
+
fee?: NatAmount;
|
|
99
|
+
/** for example: { usdnOut: 98n } */
|
|
100
|
+
detail?: Record<string, bigint>;
|
|
101
|
+
claim?: boolean;
|
|
102
|
+
};
|
|
103
|
+
export type FlowStep = {
|
|
104
|
+
how: string;
|
|
105
|
+
amount: NatAmount;
|
|
106
|
+
src: AssetPlaceRef;
|
|
107
|
+
dest: AssetPlaceRef;
|
|
108
|
+
};
|
|
109
|
+
export type FundsFlowPlan = {
|
|
110
|
+
flow: MovementDesc[];
|
|
111
|
+
/** default to full order */
|
|
112
|
+
order?: [target: number, prereqs: number[]][];
|
|
113
|
+
};
|
|
114
|
+
export type PortfolioKey = `portfolio${number}`;
|
|
115
|
+
export type FlowKey = `flow${number}`;
|
|
116
|
+
export type StatusFor = {
|
|
117
|
+
contract: {
|
|
118
|
+
contractAccount: CosmosChainAddress['value'];
|
|
119
|
+
};
|
|
120
|
+
pendingTx: PublishedTx;
|
|
121
|
+
portfolios: {
|
|
122
|
+
addPortfolio: PortfolioKey;
|
|
123
|
+
};
|
|
124
|
+
portfolio: {
|
|
125
|
+
positionKeys: InstrumentId[];
|
|
126
|
+
accountIdByChain: Partial<Record<SupportedChain, AccountId>>;
|
|
127
|
+
accountsPending?: SupportedChain[];
|
|
128
|
+
depositAddress?: Bech32Address;
|
|
129
|
+
/** Noble Forwarding Address (NFA) registered by the contract for the `@agoric` address */
|
|
130
|
+
nobleForwardingAddress?: Bech32Address;
|
|
131
|
+
targetAllocation?: TargetAllocation;
|
|
132
|
+
/** incremented by the contract every time the user sends a transaction that the planner should respond to */
|
|
133
|
+
policyVersion: number;
|
|
134
|
+
/** the count of acknowledged submissions [from the planner] associated with the current policyVersion */
|
|
135
|
+
rebalanceCount: number;
|
|
136
|
+
/** @deprecated in favor of flowsRunning */
|
|
137
|
+
flowCount: number;
|
|
138
|
+
flowsRunning?: Record<FlowKey, FlowDetail>;
|
|
139
|
+
};
|
|
140
|
+
position: {
|
|
141
|
+
protocol: YieldProtocol;
|
|
142
|
+
accountId: AccountId;
|
|
143
|
+
totalIn: NatAmount;
|
|
144
|
+
totalOut: NatAmount;
|
|
145
|
+
};
|
|
146
|
+
flow: FlowStatus & FlowDetail;
|
|
147
|
+
flowSteps: FlowStep[];
|
|
148
|
+
flowOrder: FundsFlowPlan['order'];
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Names suitable for use as `publicInvitationMaker` in {@link ContractInvitationSpec}.
|
|
152
|
+
*/
|
|
153
|
+
export type PortfolioPublicInvitationMaker = 'makeOpenPortfolioInvitation';
|
|
154
|
+
/**
|
|
155
|
+
* Names suitable for use as `invitationMakerName` in {@link ContinuingInvitationSpec}.
|
|
156
|
+
*
|
|
157
|
+
* These continuing invitation makers are returned from portfolio creation and enable
|
|
158
|
+
* ongoing operations like rebalancing between yield protocols.
|
|
159
|
+
*/
|
|
160
|
+
export type PortfolioContinuingInvitationMaker = 'Deposit' | 'Withdraw' | 'Rebalance' | 'SimpleRebalance';
|
|
161
|
+
export {};
|
|
162
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,k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E;QACR,QAAQ,EAAE,aAAa,CAAC;QACxB,SAAS,EAAE,SAAS,CAAC;QACrB,OAAO,EAAE,SAAS,CAAC;QACnB,QAAQ,EAAE,SAAS,CAAC;KACrB,CAAC;IACF,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IAC9B,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,6BAA6B,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAC1C,SAAS,GACT,UAAU,GACV,WAAW,GACX,iBAAiB,CAAC"}
|
package/src/types.ts
CHANGED
|
@@ -1 +1,167 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars -- doesn't see type usage in JSDoc */
|
|
2
|
+
import type { NatAmount } from '@agoric/ertp';
|
|
3
|
+
import {
|
|
4
|
+
type AccountId,
|
|
5
|
+
type Bech32Address,
|
|
6
|
+
type CosmosChainAddress,
|
|
7
|
+
} from '@agoric/orchestration';
|
|
8
|
+
import type {
|
|
9
|
+
ContinuingInvitationSpec,
|
|
10
|
+
ContractInvitationSpec,
|
|
11
|
+
} from '@agoric/smart-wallet/src/invitations.js';
|
|
12
|
+
import type { SupportedChain, YieldProtocol } from './constants.js';
|
|
13
|
+
import type { InstrumentId } from './instruments.js';
|
|
14
|
+
import type { PublishedTx } from './resolver.js';
|
|
15
|
+
|
|
16
|
+
export type SeatKeyword = 'Cash' | 'Deposit';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Reference to a local chain accounts (LCA).
|
|
20
|
+
* '+agoric' is published as `depositAddress`
|
|
21
|
+
*/
|
|
22
|
+
export type LocalChainAccountRef = '+agoric';
|
|
23
|
+
|
|
24
|
+
export type InterChainAccountRef = `@${SupportedChain}`;
|
|
25
|
+
|
|
26
|
+
export type AssetPlaceRef =
|
|
27
|
+
| `<${SeatKeyword}>`
|
|
28
|
+
| LocalChainAccountRef
|
|
29
|
+
| InterChainAccountRef
|
|
30
|
+
| InstrumentId;
|
|
31
|
+
|
|
32
|
+
type Empty = Record<never, NatAmount>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Proposal shapes for portfolio operations.
|
|
36
|
+
*
|
|
37
|
+
* **openPortfolio**: Create portfolio with initial funding across protocols
|
|
38
|
+
* **rebalance**: Add funds (give) or withdraw funds (want) from protocols
|
|
39
|
+
*/
|
|
40
|
+
export type ProposalType = {
|
|
41
|
+
openPortfolio: {
|
|
42
|
+
give: {
|
|
43
|
+
/** required iff the contract was started with an Access issuer */
|
|
44
|
+
Access?: NatAmount;
|
|
45
|
+
Deposit?: NatAmount;
|
|
46
|
+
};
|
|
47
|
+
want?: Empty;
|
|
48
|
+
};
|
|
49
|
+
rebalance:
|
|
50
|
+
| { give: { Deposit?: NatAmount }; want: Empty }
|
|
51
|
+
| { want: { Cash: NatAmount }; give: Empty };
|
|
52
|
+
withdraw: { want: { Cash: NatAmount }; give: Empty };
|
|
53
|
+
deposit: { give: { Deposit: NatAmount }; want: Empty };
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Target allocation mapping from PoolKey to numerator (typically in basis points).
|
|
58
|
+
* Denominator is implicitly the sum of all numerators.
|
|
59
|
+
*/
|
|
60
|
+
export type TargetAllocation = Partial<Record<InstrumentId, bigint>>;
|
|
61
|
+
|
|
62
|
+
export type FlowDetail =
|
|
63
|
+
| { type: 'withdraw'; amount: NatAmount }
|
|
64
|
+
| { type: 'deposit'; amount: NatAmount }
|
|
65
|
+
| { type: 'rebalance' }; // aka simpleRebalance
|
|
66
|
+
|
|
67
|
+
/** linked list of concurrent failures, including dependencies */
|
|
68
|
+
export type FlowErrors = {
|
|
69
|
+
step: number;
|
|
70
|
+
how: string;
|
|
71
|
+
error: string;
|
|
72
|
+
next?: FlowErrors;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type FlowStatus =
|
|
76
|
+
| {
|
|
77
|
+
state: 'run';
|
|
78
|
+
/** minimum currently running step */
|
|
79
|
+
step: number;
|
|
80
|
+
how: string;
|
|
81
|
+
/** currently running steps, when executing concurrently */
|
|
82
|
+
steps?: number[];
|
|
83
|
+
}
|
|
84
|
+
/** @deprecated - contract no longer does automatic recovery */
|
|
85
|
+
| { state: 'undo'; step: number; how: string }
|
|
86
|
+
| { state: 'done' }
|
|
87
|
+
| ({ state: 'fail' } & FlowErrors);
|
|
88
|
+
|
|
89
|
+
export type MovementDesc = {
|
|
90
|
+
amount: NatAmount;
|
|
91
|
+
src: AssetPlaceRef;
|
|
92
|
+
dest: AssetPlaceRef;
|
|
93
|
+
/** for example: GMP fee */
|
|
94
|
+
fee?: NatAmount;
|
|
95
|
+
/** for example: { usdnOut: 98n } */
|
|
96
|
+
detail?: Record<string, bigint>;
|
|
97
|
+
claim?: boolean;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type FlowStep = {
|
|
101
|
+
how: string;
|
|
102
|
+
amount: NatAmount;
|
|
103
|
+
src: AssetPlaceRef;
|
|
104
|
+
dest: AssetPlaceRef;
|
|
105
|
+
// XXX all parts: fee etc.
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export type FundsFlowPlan = {
|
|
109
|
+
flow: MovementDesc[];
|
|
110
|
+
/** default to full order */
|
|
111
|
+
order?: [target: number, prereqs: number[]][];
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export type PortfolioKey = `portfolio${number}`;
|
|
115
|
+
export type FlowKey = `flow${number}`;
|
|
116
|
+
|
|
117
|
+
export type StatusFor = {
|
|
118
|
+
contract: {
|
|
119
|
+
contractAccount: CosmosChainAddress['value'];
|
|
120
|
+
};
|
|
121
|
+
pendingTx: PublishedTx;
|
|
122
|
+
portfolios: {
|
|
123
|
+
addPortfolio: PortfolioKey;
|
|
124
|
+
};
|
|
125
|
+
portfolio: {
|
|
126
|
+
positionKeys: InstrumentId[];
|
|
127
|
+
accountIdByChain: Partial<Record<SupportedChain, AccountId>>;
|
|
128
|
+
accountsPending?: SupportedChain[];
|
|
129
|
+
depositAddress?: Bech32Address;
|
|
130
|
+
/** Noble Forwarding Address (NFA) registered by the contract for the `@agoric` address */
|
|
131
|
+
nobleForwardingAddress?: Bech32Address;
|
|
132
|
+
targetAllocation?: TargetAllocation;
|
|
133
|
+
/** incremented by the contract every time the user sends a transaction that the planner should respond to */
|
|
134
|
+
policyVersion: number;
|
|
135
|
+
/** the count of acknowledged submissions [from the planner] associated with the current policyVersion */
|
|
136
|
+
rebalanceCount: number;
|
|
137
|
+
/** @deprecated in favor of flowsRunning */
|
|
138
|
+
flowCount: number;
|
|
139
|
+
flowsRunning?: Record<FlowKey, FlowDetail>;
|
|
140
|
+
};
|
|
141
|
+
position: {
|
|
142
|
+
protocol: YieldProtocol;
|
|
143
|
+
accountId: AccountId;
|
|
144
|
+
totalIn: NatAmount;
|
|
145
|
+
totalOut: NatAmount;
|
|
146
|
+
};
|
|
147
|
+
flow: FlowStatus & FlowDetail;
|
|
148
|
+
flowSteps: FlowStep[];
|
|
149
|
+
flowOrder: FundsFlowPlan['order'];
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Names suitable for use as `publicInvitationMaker` in {@link ContractInvitationSpec}.
|
|
154
|
+
*/
|
|
155
|
+
export type PortfolioPublicInvitationMaker = 'makeOpenPortfolioInvitation';
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Names suitable for use as `invitationMakerName` in {@link ContinuingInvitationSpec}.
|
|
159
|
+
*
|
|
160
|
+
* These continuing invitation makers are returned from portfolio creation and enable
|
|
161
|
+
* ongoing operations like rebalancing between yield protocols.
|
|
162
|
+
*/
|
|
163
|
+
export type PortfolioContinuingInvitationMaker =
|
|
164
|
+
| 'Deposit'
|
|
165
|
+
| 'Withdraw'
|
|
166
|
+
| 'Rebalance'
|
|
167
|
+
| 'SimpleRebalance';
|