@agoric/fast-usdc 0.2.0-u19.1 → 0.2.0-u20.0

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,101 +1,27 @@
1
1
  # Fast USDC
2
2
 
3
- Development package for the Fast USDC product.
4
- Here in agoric-sdk as a convenience for integration testing and iterating on the SDK affordances required for the product.
3
+ Development package for the Fast USDC product. Here in agoric-sdk as a
4
+ convenience for integration testing and iterating on the SDK affordances
5
+ required for the product.
5
6
 
6
7
  # Factoring
7
8
 
8
- This package is meant to contain all the code for the Fast USDC product. However there are some constraints:
9
+ This package is meant to contain all the code for the Fast USDC product.
10
+ However, there are some constraints:
9
11
 
10
- - a3p integration tests are in the `a3p-integration` top-level package, separate from this workspace
11
- - the proposal builders are in `@agoric/builders` to work with the a3p-integration `build:submissions` script
12
- - the RunUtils tests are in `@agoric/boot` to test running them atop a fresh bootstrapped environment
12
+ - a3p integration tests are in the `a3p-integration` top-level package, separate
13
+ from this workspace
14
+ - the proposal builders are in `@agoric/builders` to work with the
15
+ a3p-integration `build:submissions` script
16
+ - the RunUtils tests are in `@aglocal/boot` to test running them atop a fresh
17
+ bootstrapped environment
13
18
 
14
19
  Over time we can update our tooling to decouple this more from the `packages` directory.
15
20
 
16
- 1. Make a3p-integration `build:submissions` script work with arbitrary builder paths, allowing this to be above `@agoric/builders` in the package graph
17
- 2. Export bootstrap testing utilities from `@agoric/boot`, allowing this to be above `@agoric/boot` in the package graph
18
- 3. Update CI to support packages that aren't under `packages/`, eg. a top-level `dapps` directory
21
+ 1. Make a3p-integration `build:submissions` script work with arbitrary builder
22
+ paths, allowing this to be above `@agoric/builders` in the package graph
23
+ 2. Export bootstrap testing utilities from `@aglocal/boot`, allowing this to be
24
+ above `@aglocal/boot` in the package graph
25
+ 3. Update CI to support packages that aren't under `packages/`, eg. a top-level
26
+ `dapps` directory
19
27
  4. Move this package out of agoric-sdk
20
-
21
- # Transaction feed
22
-
23
- ## Oracles interface
24
-
25
- Oracles run off-chain and interact with the contract via an Agoric smart wallet bridge.
26
- ```mermaid
27
- sequenceDiagram
28
- title Becoming an oracle operator
29
- participant OW as Operator N<br/>Smart Wallet
30
- participant FUC as Fast USDC<br/>Contract Exo
31
- participant CE as Core Eval
32
-
33
- CE->>FUC: makeOperatorInvitation()
34
- FUC-->>CE: operatorInvitation
35
- CE->>+OW: deposit(operatorInvitation)
36
-
37
- Note left of FUC: Off-chain wallet accepts the operator invitation
38
-
39
- OW->>+FUC: offer(operatorInvitation)
40
- FUC-->>OW: operator invitationMakers: {SubmitEvidence}
41
-
42
- Note left of FUC: Off-chain watcher detects evidence
43
- OW->>+FUC: offer(SubmitEvidence, evidence)
44
- ```
45
-
46
- ```mermaid
47
- sequenceDiagram
48
- title Receiving evidence
49
- participant W as Operator N<br/>Smart Wallet
50
- participant A as Operator N<br/>Admin Oexo
51
- participant TF as Transaction<br/>Feed
52
-
53
- W->>A: offer(SubmitEvidence, evidence)
54
-
55
- Note left of A: Once 3 operators push the same…
56
-
57
- A->>TF: notify(evidence)
58
- ```
59
-
60
- # Status Manager
61
-
62
- ### Pending Advance State Diagram
63
-
64
- *Transactions are qualified by the OCW and EventFeed before arriving to the Advancer.*
65
-
66
- ```mermaid
67
- stateDiagram-v2
68
- [*] --> Observed: observe()
69
- [*] --> Advancing: advancing()
70
-
71
- Advancing --> Advanced: advanceOutcome(...true)
72
- Advancing --> AdvanceFailed: advanceOutcome(...false)
73
-
74
- Observed --> [*]: dequeueStatus()
75
- Advanced --> [*]: dequeueStatus()
76
- AdvanceFailed --> [*]: dequeueStatus()
77
-
78
- note right of [*]
79
- After dequeueStatus():
80
- Transaction is removed
81
- from pendingTxs store.
82
- Settler will .disburse()
83
- or .forward()
84
- end note
85
- ```
86
-
87
- ### Complete state diagram (starting from Transaction Feed into Advancer)
88
-
89
- ```mermaid
90
- stateDiagram-v2
91
- Observed --> AdvanceSkipped : Risks identified
92
- Observed --> Advancing : No risks, can advance
93
- Observed --> Forwarding : No risks, Mint deposited before advance
94
- Forwarding --> Forwarded
95
- Advancing --> Advanced
96
- Advanced --> Disbursed
97
- AdvanceSkipped --> Forwarding : Mint deposited
98
- AdvanceFailed --> Forwarding : Mint deposited
99
- Advancing --> AdvanceFailed
100
- Forwarding --> ForwardFailed
101
- ```
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@agoric/fast-usdc",
3
- "version": "0.2.0-u19.1",
3
+ "version": "0.2.0-u20.0",
4
4
  "description": "CLI and library for Fast USDC product",
5
5
  "type": "module",
6
6
  "files": [
7
- "contract",
8
7
  "src",
9
8
  "tools"
10
9
  ],
@@ -23,39 +22,33 @@
23
22
  "lint:eslint": "eslint ."
24
23
  },
25
24
  "devDependencies": {
26
- "@agoric/swingset-liveslots": "^0.10.3-u19.1",
27
- "@agoric/vats": "^0.16.0-u19.1",
28
- "@agoric/zone": "^0.3.0-u19.1",
29
25
  "@fast-check/ava": "^2.0.1",
30
26
  "ava": "^5.3.0",
31
27
  "c8": "^10.1.2",
32
- "execa": "9.1.0",
28
+ "nano-spawn": "^0.2.0",
33
29
  "ts-blank-space": "^0.4.4"
34
30
  },
35
31
  "dependencies": {
36
- "@agoric/client-utils": "^0.2.0-u19.1",
37
- "@agoric/cosmic-proto": "^0.5.0-u19.1",
38
- "@agoric/ertp": "^0.16.3-u19.1",
39
- "@agoric/internal": "^0.4.0-u19.1",
40
- "@agoric/notifier": "^0.7.0-u19.1",
41
- "@agoric/orchestration": "^0.2.0-u19.1",
42
- "@agoric/store": "^0.9.3-u19.0",
43
- "@agoric/vat-data": "^0.5.3-u19.1",
44
- "@agoric/vow": "^0.2.0-u19.1",
45
- "@agoric/zoe": "^0.27.0-u19.1",
46
- "@cosmjs/proto-signing": "^0.32.4",
47
- "@cosmjs/stargate": "^0.32.4",
32
+ "@agoric/client-utils": "^0.2.0-u20.0",
33
+ "@agoric/cosmic-proto": "^0.5.0-u20.0",
34
+ "@agoric/ertp": "^0.16.3-u20.0",
35
+ "@agoric/internal": "^0.4.0-u20.0",
36
+ "@agoric/notifier": "^0.7.0-u20.0",
37
+ "@agoric/orchestration": "^0.2.0-u20.0",
38
+ "@agoric/zoe": "^0.27.0-u20.0",
39
+ "@cosmjs/proto-signing": "^0.33.0",
40
+ "@cosmjs/stargate": "^0.33.0",
48
41
  "@endo/base64": "^1.0.9",
49
- "@endo/common": "^1.2.9",
50
- "@endo/errors": "^1.2.9",
51
- "@endo/eventual-send": "^1.3.0",
52
- "@endo/far": "^1.1.10",
53
- "@endo/init": "^1.1.8",
54
- "@endo/marshal": "^1.6.3",
55
- "@endo/nat": "^5.0.14",
56
- "@endo/pass-style": "^1.4.8",
57
- "@endo/patterns": "^1.4.8",
58
- "@endo/promise-kit": "^1.1.9",
42
+ "@endo/common": "^1.2.10",
43
+ "@endo/errors": "^1.2.10",
44
+ "@endo/eventual-send": "^1.3.1",
45
+ "@endo/far": "^1.1.11",
46
+ "@endo/init": "^1.1.9",
47
+ "@endo/marshal": "^1.6.4",
48
+ "@endo/nat": "^5.1.0",
49
+ "@endo/pass-style": "^1.5.0",
50
+ "@endo/patterns": "^1.5.0",
51
+ "@endo/promise-kit": "^1.1.10",
59
52
  "@nick134-bit/noblejs": "0.0.2",
60
53
  "bech32": "^2.0.0",
61
54
  "commander": "^12.1.0",
@@ -82,5 +75,5 @@
82
75
  "publishConfig": {
83
76
  "access": "public"
84
77
  },
85
- "gitHead": "a04d2bf43a9753d123954b52c6ba8d35083a3c8f"
78
+ "gitHead": "8e4207fa19dabf76c1f91f8779b5b5b93570ecea"
86
79
  }
package/src/cli/config.js CHANGED
@@ -23,7 +23,7 @@ import { stdin as input, stdout as output } from 'node:process';
23
23
  }} ConfigOpts
24
24
  */
25
25
 
26
- /** @import { File } from './util/file' */
26
+ /** @import { File } from './util/file.js' */
27
27
 
28
28
  export const init = async (
29
29
  /** @type {File} */ configFile,
@@ -18,7 +18,7 @@ import {
18
18
  floorDivideBy,
19
19
  multiplyBy,
20
20
  parseRatio,
21
- } from '@agoric/zoe/src/contractSupport/ratio.js';
21
+ } from '@agoric/ertp/src/ratio.js';
22
22
  import { InvalidArgumentError } from 'commander';
23
23
  import { outputActionAndHint } from './bridge-action.js';
24
24
  import { Offers } from '../clientSupport.js';
@@ -38,7 +38,7 @@ const parseDecimal = arg => {
38
38
 
39
39
  /**
40
40
  * @param {string} amountString
41
- * @param {Brand} usdc
41
+ * @param {Brand<'nat'>} usdc
42
42
  */
43
43
  const parseUSDCAmount = (amountString, usdc) => {
44
44
  const USDC_DECIMALS = 6;
@@ -3,7 +3,6 @@
3
3
  * @import {Command} from 'commander';
4
4
  * @import {OfferSpec} from '@agoric/smart-wallet/src/offers.js';
5
5
  * @import {ExecuteOfferAction} from '@agoric/smart-wallet/src/smartWallet.js';
6
- * @import {OperatorKit} from '../exos/operator-kit.js';
7
6
  */
8
7
 
9
8
  import {
@@ -13,7 +12,7 @@ import {
13
12
  import { mustMatch } from '@agoric/internal';
14
13
  import { Nat } from '@endo/nat';
15
14
  import { InvalidArgumentError } from 'commander';
16
- import { INVITATION_MAKERS_DESC } from '../exos/transaction-feed.js';
15
+ import { INVITATION_MAKERS_DESC } from '../operator-kit-interface.js';
17
16
  import { CctpTxEvidenceShape } from '../type-guards.js';
18
17
  import { outputActionAndHint } from './bridge-action.js';
19
18
 
@@ -128,9 +127,7 @@ export const addOperatorCommands = (
128
127
  invitationSpec: {
129
128
  source: 'continuing',
130
129
  previousOffer: previousOfferId,
131
- /** @type {string & keyof OperatorKit['invitationMakers'] } */
132
130
  invitationMakerName: 'SubmitEvidence',
133
- /** @type {Parameters<OperatorKit['invitationMakers']['SubmitEvidence']> } */
134
131
  invitationArgs: [evidence],
135
132
  },
136
133
  proposal: {},
@@ -16,7 +16,7 @@ import {
16
16
  } from './util/noble.js';
17
17
  import { queryUSDCBalance } from './util/bank.js';
18
18
 
19
- /** @import { File } from './util/file' */
19
+ /** @import { File } from './util/file.js' */
20
20
  /** @import { VStorage } from '@agoric/client-utils' */
21
21
  /** @import { SigningStargateClient } from '@cosmjs/stargate' */
22
22
  /** @import { JsonRpcProvider as ethProvider } from 'ethers' */
@@ -34,7 +34,7 @@ const transfer = async (
34
34
  setTimeout = globalThis.setTimeout,
35
35
  ) => {
36
36
  const execute = async (
37
- /** @type {import('./config').ConfigOpts} */ config,
37
+ /** @type {import('./config.js').ConfigOpts} */ config,
38
38
  ) => {
39
39
  const netConfig = await fetchEnvNetworkConfig({ env, fetch });
40
40
  vstorage ||= makeVStorage(
package/src/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Status values for FastUSDC.
2
+ * Status values for FastUSDC. Includes states for advancing and settling.
3
3
  *
4
4
  * @enum {(typeof TxStatus)[keyof typeof TxStatus]}
5
5
  */
@@ -31,7 +31,7 @@ export const TerminalTxStatus = {
31
31
  };
32
32
 
33
33
  /**
34
- * Status values for the StatusManager.
34
+ * Status values for the StatusManager while an advance is being processed.
35
35
  *
36
36
  * @enum {(typeof PendingTxStatus)[keyof typeof PendingTxStatus]}
37
37
  */
@@ -0,0 +1,29 @@
1
+ import { M } from '@endo/patterns';
2
+ import { CctpTxEvidenceShape, RiskAssessmentShape } from './type-guards.js';
3
+
4
+ /**
5
+ * @import {Zone} from '@agoric/zone';
6
+ * @import {CctpTxEvidence, RiskAssessment} from '@agoric/fast-usdc/src/types.js';
7
+ */
8
+
9
+ /** Name in the invitation purse (keyed also by this contract instance) */
10
+ export const INVITATION_MAKERS_DESC = 'oracle operator invitation';
11
+
12
+ export const OperatorKitI = {
13
+ admin: M.interface('Admin', {
14
+ disable: M.call().returns(),
15
+ }),
16
+
17
+ invitationMakers: M.interface('InvitationMakers', {
18
+ SubmitEvidence: M.call(CctpTxEvidenceShape)
19
+ .optional(RiskAssessmentShape)
20
+ .returns(M.promise()),
21
+ }),
22
+
23
+ operator: M.interface('Operator', {
24
+ submitEvidence: M.call(CctpTxEvidenceShape)
25
+ .optional(RiskAssessmentShape)
26
+ .returns(),
27
+ getStatus: M.call().returns(M.record()),
28
+ }),
29
+ };
@@ -4,16 +4,17 @@ import {
4
4
  makeRatio,
5
5
  makeRatioFromAmounts,
6
6
  multiplyBy,
7
- } from '@agoric/zoe/src/contractSupport/ratio.js';
7
+ } from '@agoric/ertp/src/ratio.js';
8
8
  import { Fail, q } from '@endo/errors';
9
9
 
10
10
  const { keys } = Object;
11
11
  const { add, isEmpty, isEqual, isGTE, make, makeEmpty, subtract } = AmountMath;
12
12
 
13
13
  /**
14
- * @import {Amount, Brand, DepositFacet, NatValue, Payment} from '@agoric/ertp';
15
- * @import {PoolStats} from './types';
16
- * @import {RepayAmountKWR} from './exos/liquidity-pool';
14
+ * @import {Amount, Brand, DepositFacet, NatValue, Payment, Ratio} from '@agoric/ertp';
15
+ * @import {Allocation} from '@agoric/zoe';
16
+ * @import {PoolStats} from './types.js';
17
+ * @import {RepayAmountKWR} from './utils/fees.js';
17
18
  */
18
19
 
19
20
  /**
@@ -201,35 +202,26 @@ export const borrowCalc = (
201
202
 
202
203
  /**
203
204
  * @param {ShareWorth} shareWorth
204
- * @param {Allocation} fromSeatAllocation
205
- * @param {RepayAmountKWR} amounts
205
+ * @param {RepayAmountKWR} split
206
206
  * @param {Amount<'nat'>} encumberedBalance aka 'outstanding borrows'
207
207
  * @param {PoolStats} poolStats
208
- * @throws {Error} if allocations do not match amounts or Principal exceeds encumberedBalance
208
+ * @throws {Error} if Principal exceeds encumberedBalance
209
209
  */
210
- export const repayCalc = (
211
- shareWorth,
212
- fromSeatAllocation,
213
- amounts,
214
- encumberedBalance,
215
- poolStats,
216
- ) => {
217
- (isEqual(fromSeatAllocation.Principal, amounts.Principal) &&
218
- isEqual(fromSeatAllocation.PoolFee, amounts.PoolFee) &&
219
- isEqual(fromSeatAllocation.ContractFee, amounts.ContractFee)) ||
220
- Fail`Cannot repay. From seat allocation ${q(fromSeatAllocation)} does not equal amounts ${q(amounts)}.`;
221
-
222
- isGTE(encumberedBalance, amounts.Principal) ||
223
- Fail`Cannot repay. Principal ${q(amounts.Principal)} exceeds encumberedBalance ${q(encumberedBalance)}.`;
210
+ export const repayCalc = (shareWorth, split, encumberedBalance, poolStats) => {
211
+ isGTE(encumberedBalance, split.Principal) ||
212
+ Fail`Cannot repay. Principal ${q(split.Principal)} exceeds encumberedBalance ${q(encumberedBalance)}.`;
224
213
 
225
214
  return harden({
226
- shareWorth: withFees(shareWorth, amounts.PoolFee),
227
- encumberedBalance: subtract(encumberedBalance, amounts.Principal),
215
+ shareWorth: withFees(shareWorth, split.PoolFee),
216
+ encumberedBalance: subtract(encumberedBalance, split.Principal),
228
217
  poolStats: {
229
218
  ...poolStats,
230
- totalRepays: add(poolStats.totalRepays, amounts.Principal),
231
- totalPoolFees: add(poolStats.totalPoolFees, amounts.PoolFee),
232
- totalContractFees: add(poolStats.totalContractFees, amounts.ContractFee),
219
+ totalRepays: add(poolStats.totalRepays, split.Principal),
220
+ totalPoolFees: add(poolStats.totalPoolFees, split.PoolFee),
221
+ totalContractFees: add(
222
+ add(poolStats.totalContractFees, split.ContractFee),
223
+ split.RelayFee,
224
+ ),
233
225
  },
234
226
  });
235
227
  };
@@ -1,7 +1,6 @@
1
1
  import { AmountShape, BrandShape, RatioShape } from '@agoric/ertp';
2
2
  import { M } from '@endo/patterns';
3
3
  import {
4
- CosmosChainInfoShape,
5
4
  DenomDetailShape,
6
5
  DenomShape,
7
6
  } from '@agoric/orchestration/src/typeGuards.js';
@@ -10,13 +9,13 @@ import { PendingTxStatus } from './constants.js';
10
9
  /**
11
10
  * @import {Amount, Brand, NatValue, Payment} from '@agoric/ertp';
12
11
  * @import {TypedPattern} from '@agoric/internal';
13
- * @import {FastUsdcTerms} from './fast-usdc.contract.js';
12
+ * @import {CosmosChainInfo, Denom, DenomDetail, OrchestrationAccount, IBCConnectionInfo, CaipChainId} from '@agoric/orchestration';
14
13
  * @import {USDCProposalShapes} from './pool-share-math.js';
15
- * @import {CctpTxEvidence, FastUSDCConfig, FeeConfig, PendingTx, PoolMetrics, ChainPolicy, FeedPolicy, AddressHook, EvmAddress, EvmHash, RiskAssessment, EvidenceWithRisk} from './types.js';
14
+ * @import {CctpTxEvidence, FastUSDCConfig, FastUsdcTerms, FeeConfig, PendingTx, PoolMetrics, ChainPolicy, FeedPolicy, AddressHook, EvmAddress, EvmHash, RiskAssessment, EvidenceWithRisk} from './types.js';
16
15
  */
17
16
 
18
17
  /**
19
- * @param {Brand} brand must be a 'nat' brand, not checked
18
+ * @param {Brand<'nat'>} brand must be a 'nat' brand, not checked
20
19
  * @param {NatValue} [min]
21
20
  */
22
21
  export const makeNatAmountShape = (brand, min) =>
@@ -110,13 +109,33 @@ export const AddressHookShape = {
110
109
  harden(AddressHookShape);
111
110
 
112
111
  const NatAmountShape = { brand: BrandShape, value: M.nat() };
112
+
113
+ export const DestinationOverridesShape = M.recordOf(
114
+ M.string(),
115
+ M.splitRecord(
116
+ {},
117
+ {
118
+ flat: NatAmountShape,
119
+ variableRate: RatioShape,
120
+ contractRate: RatioShape,
121
+ relay: NatAmountShape,
122
+ },
123
+ ),
124
+ );
125
+
113
126
  /** @type {TypedPattern<FeeConfig>} */
114
- export const FeeConfigShape = {
115
- flat: NatAmountShape,
116
- variableRate: RatioShape,
117
- contractRate: RatioShape,
118
- };
119
- harden(FeeConfigShape);
127
+ export const FeeConfigShape = M.splitRecord(
128
+ {
129
+ flat: NatAmountShape,
130
+ variableRate: RatioShape,
131
+ contractRate: RatioShape,
132
+ },
133
+ {
134
+ relay: NatAmountShape,
135
+ destinationOverrides: DestinationOverridesShape,
136
+ },
137
+ {},
138
+ );
120
139
 
121
140
  /** @type {TypedPattern<PoolMetrics>} */
122
141
  export const PoolMetricsShape = {
@@ -150,8 +169,7 @@ harden(ChainPolicyShape);
150
169
  /**
151
170
  * @type {TypedPattern<FeedPolicy>}
152
171
  *
153
- * Should be JSON serializable so CLI can specify policy. E.g. no bigint,
154
- * undefined, remotable, etc.
172
+ * must be CopyData; no Brands or other Remotables
155
173
  */
156
174
  export const FeedPolicyShape = M.splitRecord(
157
175
  {
@@ -163,12 +181,30 @@ export const FeedPolicyShape = M.splitRecord(
163
181
  );
164
182
  harden(FeedPolicyShape);
165
183
 
184
+ /**
185
+ * The version of CosmosChainInfoShape that matches the `valueShape` used in FUSDC's ChainHub's `chainInfos` mapStore.
186
+ * @type {TypedPattern<CosmosChainInfo>}
187
+ */
188
+ export const CosmosChainInfoShapeV1 = M.splitRecord(
189
+ {
190
+ chainId: M.string(),
191
+ },
192
+ {
193
+ bech32Prefix: M.string(),
194
+ connections: M.record(),
195
+ stakingTokens: M.arrayOf({ denom: M.string() }),
196
+ // UNTIL https://github.com/Agoric/agoric-sdk/issues/9326
197
+ icqEnabled: M.boolean(),
198
+ pfmEnabled: M.boolean(),
199
+ },
200
+ );
201
+
166
202
  /** @type {TypedPattern<FastUSDCConfig>} */
167
203
  export const FastUSDCConfigShape = M.splitRecord({
168
204
  terms: FastUSDCTermsShape,
169
205
  oracles: M.recordOf(M.string(), M.string()),
170
206
  feeConfig: FeeConfigShape,
171
207
  feedPolicy: FeedPolicyShape,
172
- chainInfo: M.recordOf(M.string(), CosmosChainInfoShape),
208
+ chainInfo: M.recordOf(M.string(), CosmosChainInfoShapeV1),
173
209
  assetInfo: M.arrayOf([DenomShape, DenomDetailShape]),
174
210
  });
package/src/types.ts CHANGED
@@ -1,17 +1,35 @@
1
1
  import type {
2
- ChainAddress,
2
+ AccountId,
3
+ CosmosChainAddress,
4
+ Bech32Address,
3
5
  CosmosChainInfo,
4
6
  Denom,
5
7
  DenomDetail,
8
+ BaseChainInfo,
9
+ KnownNamespace,
10
+ CaipChainId,
6
11
  } from '@agoric/orchestration';
7
12
  import type { IBCChannelID } from '@agoric/vats';
8
13
  import type { Amount } from '@agoric/ertp';
9
14
  import type { CopyRecord, Passable } from '@endo/pass-style';
10
15
  import type { PendingTxStatus, TxStatus } from './constants.js';
11
- import type { FastUsdcTerms } from './fast-usdc.contract.js';
12
- import type { RepayAmountKWR } from './exos/liquidity-pool.js';
16
+ import type { RepayAmountKWR } from './utils/fees.js';
13
17
 
18
+ // XXX duped with Zoe contractSupport ambient types
19
+ type Ratio = {
20
+ numerator: Amount<'nat'>;
21
+ denominator: Amount<'nat'>;
22
+ };
23
+
24
+ /**
25
+ * Block hash is calculated using the keccak256 algorithm that always results
26
+ * in 32 bytes (64 hex characters prepended by 0x) no matter the input length.
27
+ */
14
28
  export type EvmHash = `0x${string}`;
29
+ /**
30
+ * An address is always the last 20 bytes (40 hex charaters prepended by 0x) of
31
+ * the public key hash.
32
+ */
15
33
  export type EvmAddress = `0x${string & { length: 40 }}`;
16
34
  export type NobleAddress = `noble1${string}`;
17
35
  export type EvmChainID = number;
@@ -25,7 +43,7 @@ export interface CctpTxEvidence {
25
43
  /** from Noble RPC */
26
44
  aux: {
27
45
  forwardingChannel: IBCChannelID;
28
- recipientAddress: ChainAddress['value'];
46
+ recipientAddress: CosmosChainAddress['value'] | AccountId;
29
47
  };
30
48
  /** on the source chain (e.g. L1 Ethereum and L2s Arbitrum, Base) */
31
49
  blockHash: EvmHash;
@@ -70,8 +88,9 @@ export interface TransactionRecord extends CopyRecord {
70
88
 
71
89
  /** the record in vstorage at the path of the contract's node */
72
90
  export interface ContractRecord extends CopyRecord {
73
- poolAccount: ChainAddress['value'];
74
- settlementAccount: ChainAddress['value'];
91
+ nobleICA?: CosmosChainAddress['value'];
92
+ poolAccount: CosmosChainAddress['value'];
93
+ settlementAccount: CosmosChainAddress['value'];
75
94
  }
76
95
 
77
96
  export type LogFn = (...args: unknown[]) => void;
@@ -81,12 +100,22 @@ export interface PendingTx extends CctpTxEvidence {
81
100
  }
82
101
 
83
102
  export type FeeConfig = {
84
- /** flat fee charged for every advance */
103
+ /** flat fee charged for every advance, eligible for LP disbursement */
85
104
  flat: Amount<'nat'>;
86
- /** proportion of advance kept as a fee */
105
+ /** proportion of advance kept as a fee, eligible for LP disbursement */
87
106
  variableRate: Ratio;
88
- /** proportion of fees that goes to the contract (remaining goes to LPs) */
107
+ /** proportion of `flat` and `variableRate` fees that goes to the contract (remaining goes to LPs) */
89
108
  contractRate: Ratio;
109
+ /**
110
+ * if present, a fee required to relay (e.g. CCTP to EVM/Solana). Not
111
+ * considered for LP disbursement - goes to `contractSeat`.
112
+ */
113
+ relay?: Amount<'nat'>;
114
+ /** Optional destination-specific overrides. If present, must supersede base values. */
115
+ destinationOverrides?: Record<
116
+ CaipChainId,
117
+ Partial<Omit<FeeConfig, 'destinationOverrides'>>
118
+ >;
90
119
  };
91
120
 
92
121
  export interface PoolStats {
@@ -127,13 +156,17 @@ export type FeedPolicy = {
127
156
  eventFilter?: string;
128
157
  } & CopyRecord;
129
158
 
159
+ export type FastUsdcTerms = {
160
+ usdcDenom: Denom;
161
+ };
162
+
130
163
  export type FastUSDCConfig = {
131
164
  terms: FastUsdcTerms;
132
165
  oracles: Record<string, string>;
133
166
  feeConfig: FeeConfig;
134
167
  feedPolicy: FeedPolicy;
135
168
  noNoble: boolean; // support a3p-integration, which has no noble chain
136
- chainInfo: Record<string, CosmosChainInfo & Passable>;
169
+ chainInfo: Record<string, ChainHubChainInfo>;
137
170
  assetInfo: [Denom, DenomDetail & { brandKey?: string }][];
138
171
  } & CopyRecord;
139
172
 
@@ -142,9 +175,22 @@ export type AddressHook = {
142
175
  baseAddress: string;
143
176
  query: {
144
177
  /** end user destination address */
145
- EUD: string;
178
+ EUD: Bech32Address;
146
179
  };
147
180
  };
148
181
 
182
+ /**
183
+ * The shape of ChainInfo ChainHub is expecting for FUSDC.
184
+ *
185
+ * Note: this diverges from `CosmosChainInfo` and `BaseChainInfo` in that:
186
+ * - BaseChainInfo includes chainId for backwards compatibility with `CosmosChainInfoShapeV1`
187
+ */
188
+ export type ChainHubChainInfo<N extends KnownNamespace = KnownNamespace> =
189
+ N extends 'cosmos' ? CosmosChainInfo : BaseChainInfoWithChainId<N>;
190
+
191
+ interface BaseChainInfoWithChainId<N extends KnownNamespace = KnownNamespace>
192
+ extends BaseChainInfo<N> {
193
+ chainId: string;
194
+ }
195
+
149
196
  export type * from './constants.js';
150
- export type { LiquidityPoolKit } from './exos/liquidity-pool.js';