@agoric/fast-usdc 0.1.1-dev-252b405.0 → 0.1.1-dev-4e588de.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/package.json +15 -15
- package/src/exos/advancer.js +15 -11
- package/src/exos/settler.js +12 -11
- package/src/fast-usdc.contract.js +1 -1
- package/src/types.ts +15 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/fast-usdc",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-4e588de.0+4e588de",
|
|
4
4
|
"description": "CLI and library for Fast USDC product",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"lint:eslint": "eslint ."
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
27
|
-
"@agoric/vats": "0.15.2-dev-
|
|
28
|
-
"@agoric/zone": "0.2.3-dev-
|
|
26
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-4e588de.0+4e588de",
|
|
27
|
+
"@agoric/vats": "0.15.2-dev-4e588de.0+4e588de",
|
|
28
|
+
"@agoric/zone": "0.2.3-dev-4e588de.0+4e588de",
|
|
29
29
|
"@fast-check/ava": "^2.0.1",
|
|
30
30
|
"ava": "^5.3.0",
|
|
31
31
|
"c8": "^10.1.2",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"ts-blank-space": "^0.4.4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@agoric/client-utils": "0.1.1-dev-
|
|
37
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
38
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
39
|
-
"@agoric/internal": "0.3.3-dev-
|
|
40
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
41
|
-
"@agoric/orchestration": "0.1.1-dev-
|
|
42
|
-
"@agoric/store": "0.9.3-dev-
|
|
43
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
44
|
-
"@agoric/vow": "0.1.1-dev-
|
|
45
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
36
|
+
"@agoric/client-utils": "0.1.1-dev-4e588de.0+4e588de",
|
|
37
|
+
"@agoric/cosmic-proto": "0.4.1-dev-4e588de.0+4e588de",
|
|
38
|
+
"@agoric/ertp": "0.16.3-dev-4e588de.0+4e588de",
|
|
39
|
+
"@agoric/internal": "0.3.3-dev-4e588de.0+4e588de",
|
|
40
|
+
"@agoric/notifier": "0.6.3-dev-4e588de.0+4e588de",
|
|
41
|
+
"@agoric/orchestration": "0.1.1-dev-4e588de.0+4e588de",
|
|
42
|
+
"@agoric/store": "0.9.3-dev-4e588de.0+4e588de",
|
|
43
|
+
"@agoric/vat-data": "0.5.3-dev-4e588de.0+4e588de",
|
|
44
|
+
"@agoric/vow": "0.1.1-dev-4e588de.0+4e588de",
|
|
45
|
+
"@agoric/zoe": "0.26.3-dev-4e588de.0+4e588de",
|
|
46
46
|
"@cosmjs/proto-signing": "^0.32.4",
|
|
47
47
|
"@cosmjs/stargate": "^0.32.4",
|
|
48
48
|
"@endo/base64": "^1.0.9",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "4e588deeeee83704a5de69f3914ded0605dc1dc0"
|
|
86
86
|
}
|
package/src/exos/advancer.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { decodeAddressHook } from '@agoric/cosmic-proto/address-hooks.js';
|
|
2
2
|
import { AmountMath } from '@agoric/ertp';
|
|
3
3
|
import { assertAllDefined, makeTracer } from '@agoric/internal';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AnyNatAmountShape,
|
|
6
|
+
CosmosChainAddressShape,
|
|
7
|
+
} from '@agoric/orchestration';
|
|
5
8
|
import { pickFacet } from '@agoric/vat-data';
|
|
6
9
|
import { VowShape } from '@agoric/vow';
|
|
7
10
|
import { E } from '@endo/far';
|
|
@@ -19,7 +22,7 @@ import { makeFeeTools } from '../utils/fees.js';
|
|
|
19
22
|
* @import {Amount, Brand} from '@agoric/ertp';
|
|
20
23
|
* @import {TypedPattern} from '@agoric/internal'
|
|
21
24
|
* @import {NatAmount} from '@agoric/ertp';
|
|
22
|
-
* @import {
|
|
25
|
+
* @import {CosmosChainAddress, ChainHub, Denom, OrchestrationAccount} from '@agoric/orchestration';
|
|
23
26
|
* @import {ZoeTools} from '@agoric/orchestration/src/utils/zoe-tools.js';
|
|
24
27
|
* @import {VowTools} from '@agoric/vow';
|
|
25
28
|
* @import {Zone} from '@agoric/zone';
|
|
@@ -46,7 +49,7 @@ const AdvancerVowCtxShape = M.splitRecord(
|
|
|
46
49
|
{
|
|
47
50
|
fullAmount: AnyNatAmountShape,
|
|
48
51
|
advanceAmount: AnyNatAmountShape,
|
|
49
|
-
destination:
|
|
52
|
+
destination: CosmosChainAddressShape,
|
|
50
53
|
forwardingAddress: M.string(),
|
|
51
54
|
txHash: EvmHashShape,
|
|
52
55
|
},
|
|
@@ -57,7 +60,7 @@ const AdvancerVowCtxShape = M.splitRecord(
|
|
|
57
60
|
const AdvancerKitI = harden({
|
|
58
61
|
advancer: M.interface('AdvancerI', {
|
|
59
62
|
handleTransactionEvent: M.callWhen(EvidenceWithRiskShape).returns(),
|
|
60
|
-
setIntermediateRecipient: M.call(
|
|
63
|
+
setIntermediateRecipient: M.call(CosmosChainAddressShape).returns(),
|
|
61
64
|
}),
|
|
62
65
|
depositHandler: M.interface('DepositHandlerI', {
|
|
63
66
|
onFulfilled: M.call(M.undefined(), AdvancerVowCtxShape).returns(VowShape),
|
|
@@ -85,7 +88,7 @@ const AdvancerKitI = harden({
|
|
|
85
88
|
* @typedef {{
|
|
86
89
|
* fullAmount: NatAmount;
|
|
87
90
|
* advanceAmount: NatAmount;
|
|
88
|
-
* destination:
|
|
91
|
+
* destination: CosmosChainAddress;
|
|
89
92
|
* forwardingAddress: NobleAddress;
|
|
90
93
|
* txHash: EvmHash;
|
|
91
94
|
* }} AdvancerVowCtx
|
|
@@ -95,8 +98,8 @@ export const stateShape = harden({
|
|
|
95
98
|
notifier: M.remotable(),
|
|
96
99
|
borrower: M.remotable(),
|
|
97
100
|
poolAccount: M.remotable(),
|
|
98
|
-
intermediateRecipient: M.opt(
|
|
99
|
-
settlementAddress: M.opt(
|
|
101
|
+
intermediateRecipient: M.opt(CosmosChainAddressShape),
|
|
102
|
+
settlementAddress: M.opt(CosmosChainAddressShape),
|
|
100
103
|
});
|
|
101
104
|
|
|
102
105
|
/**
|
|
@@ -135,8 +138,8 @@ export const prepareAdvancerKit = (
|
|
|
135
138
|
* notifier: import('./settler.js').SettlerKit['notifier'];
|
|
136
139
|
* borrower: LiquidityPoolKit['borrower'];
|
|
137
140
|
* poolAccount: HostInterface<OrchestrationAccount<{chainId: 'agoric'}>>;
|
|
138
|
-
* settlementAddress:
|
|
139
|
-
* intermediateRecipient?:
|
|
141
|
+
* settlementAddress: CosmosChainAddress;
|
|
142
|
+
* intermediateRecipient?: CosmosChainAddress;
|
|
140
143
|
* }} config
|
|
141
144
|
*/
|
|
142
145
|
config =>
|
|
@@ -177,8 +180,9 @@ export const prepareAdvancerKit = (
|
|
|
177
180
|
if (decoded.baseAddress !== settlementAddress.value) {
|
|
178
181
|
throw Fail`⚠️ baseAddress of address hook ${q(decoded.baseAddress)} does not match the expected address ${q(settlementAddress.value)}`;
|
|
179
182
|
}
|
|
180
|
-
const { EUD } =
|
|
183
|
+
const { EUD } = decoded.query;
|
|
181
184
|
log(`decoded EUD: ${EUD}`);
|
|
185
|
+
assert.typeof(EUD, 'string');
|
|
182
186
|
// throws if the bech32 prefix is not found
|
|
183
187
|
const destination = chainHub.makeChainAddress(EUD);
|
|
184
188
|
|
|
@@ -220,7 +224,7 @@ export const prepareAdvancerKit = (
|
|
|
220
224
|
statusManager.skipAdvance(evidence, [error.message]);
|
|
221
225
|
}
|
|
222
226
|
},
|
|
223
|
-
/** @param {
|
|
227
|
+
/** @param {CosmosChainAddress} intermediateRecipient */
|
|
224
228
|
setIntermediateRecipient(intermediateRecipient) {
|
|
225
229
|
this.state.intermediateRecipient = intermediateRecipient;
|
|
226
230
|
},
|
package/src/exos/settler.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AmountMath } from '@agoric/ertp';
|
|
2
2
|
import { assertAllDefined, makeTracer } from '@agoric/internal';
|
|
3
|
-
import {
|
|
3
|
+
import { CosmosChainAddressShape } from '@agoric/orchestration';
|
|
4
4
|
import { atob } from '@endo/base64';
|
|
5
5
|
import { E } from '@endo/far';
|
|
6
6
|
import { M } from '@endo/patterns';
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
/**
|
|
18
18
|
* @import {FungibleTokenPacketData} from '@agoric/cosmic-proto/ibc/applications/transfer/v2/packet.js';
|
|
19
19
|
* @import {Amount, Brand, NatValue, Payment} from '@agoric/ertp';
|
|
20
|
-
* @import {Denom, OrchestrationAccount, ChainHub,
|
|
20
|
+
* @import {AccountId, Denom, OrchestrationAccount, ChainHub, CosmosChainAddress} from '@agoric/orchestration';
|
|
21
21
|
* @import {WithdrawToSeat} from '@agoric/orchestration/src/utils/zoe-tools'
|
|
22
22
|
* @import {IBCChannelID, IBCPacket, VTransferIBCEvent} from '@agoric/vats';
|
|
23
23
|
* @import {Zone} from '@agoric/zone';
|
|
@@ -86,7 +86,7 @@ const makeMintedEarlyKey = (addr, amount) =>
|
|
|
86
86
|
/** @param {Brand<'nat'>} USDC */
|
|
87
87
|
export const makeAdvanceDetailsShape = USDC =>
|
|
88
88
|
harden({
|
|
89
|
-
destination:
|
|
89
|
+
destination: CosmosChainAddressShape,
|
|
90
90
|
forwardingAddress: M.string(),
|
|
91
91
|
fullAmount: makeNatAmountShape(USDC),
|
|
92
92
|
txHash: EvmHashShape,
|
|
@@ -99,7 +99,7 @@ export const stateShape = harden({
|
|
|
99
99
|
sourceChannel: M.string(),
|
|
100
100
|
remoteDenom: M.string(),
|
|
101
101
|
mintedEarly: M.remotable('mintedEarly'),
|
|
102
|
-
intermediateRecipient: M.opt(
|
|
102
|
+
intermediateRecipient: M.opt(CosmosChainAddressShape),
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
/**
|
|
@@ -133,7 +133,7 @@ export const prepareSettler = (
|
|
|
133
133
|
{
|
|
134
134
|
creator: M.interface('SettlerCreatorI', {
|
|
135
135
|
monitorMintingDeposits: M.callWhen().returns(M.any()),
|
|
136
|
-
setIntermediateRecipient: M.call(
|
|
136
|
+
setIntermediateRecipient: M.call(CosmosChainAddressShape).returns(),
|
|
137
137
|
}),
|
|
138
138
|
tap: M.interface('SettlerTapI', {
|
|
139
139
|
receiveUpcall: M.call(M.record()).returns(M.promise()),
|
|
@@ -145,7 +145,7 @@ export const prepareSettler = (
|
|
|
145
145
|
).returns(),
|
|
146
146
|
checkMintedEarly: M.call(
|
|
147
147
|
CctpTxEvidenceShape,
|
|
148
|
-
|
|
148
|
+
CosmosChainAddressShape,
|
|
149
149
|
).returns(M.boolean()),
|
|
150
150
|
}),
|
|
151
151
|
self: M.interface('SettlerSelfI', {
|
|
@@ -163,7 +163,7 @@ export const prepareSettler = (
|
|
|
163
163
|
* remoteDenom: Denom;
|
|
164
164
|
* repayer: LiquidityPoolKit['repayer'];
|
|
165
165
|
* settlementAccount: HostInterface<OrchestrationAccount<{ chainId: 'agoric' }>>
|
|
166
|
-
* intermediateRecipient?:
|
|
166
|
+
* intermediateRecipient?: CosmosChainAddress;
|
|
167
167
|
* }} config
|
|
168
168
|
*/
|
|
169
169
|
config => {
|
|
@@ -188,7 +188,7 @@ export const prepareSettler = (
|
|
|
188
188
|
assert.typeof(registration, 'object');
|
|
189
189
|
this.state.registration = registration;
|
|
190
190
|
},
|
|
191
|
-
/** @param {
|
|
191
|
+
/** @param {CosmosChainAddress} intermediateRecipient */
|
|
192
192
|
setIntermediateRecipient(intermediateRecipient) {
|
|
193
193
|
this.state.intermediateRecipient = intermediateRecipient;
|
|
194
194
|
},
|
|
@@ -244,7 +244,7 @@ export const prepareSettler = (
|
|
|
244
244
|
* @param {EvmHash} ctx.txHash
|
|
245
245
|
* @param {NobleAddress} ctx.forwardingAddress
|
|
246
246
|
* @param {Amount<'nat'>} ctx.fullAmount
|
|
247
|
-
* @param {
|
|
247
|
+
* @param {CosmosChainAddress} ctx.destination
|
|
248
248
|
* @param {boolean} success
|
|
249
249
|
* @returns {void}
|
|
250
250
|
*/
|
|
@@ -273,7 +273,7 @@ export const prepareSettler = (
|
|
|
273
273
|
},
|
|
274
274
|
/**
|
|
275
275
|
* @param {CctpTxEvidence} evidence
|
|
276
|
-
* @param {
|
|
276
|
+
* @param {CosmosChainAddress} destination
|
|
277
277
|
* @returns {boolean}
|
|
278
278
|
* @throws {Error} if minted early, so advancer doesn't advance
|
|
279
279
|
*/
|
|
@@ -340,9 +340,10 @@ export const prepareSettler = (
|
|
|
340
340
|
forward(txHash, fullValue, EUD) {
|
|
341
341
|
const { settlementAccount, intermediateRecipient } = this.state;
|
|
342
342
|
|
|
343
|
+
/** @type {AccountId | null} */
|
|
343
344
|
const dest = (() => {
|
|
344
345
|
try {
|
|
345
|
-
return chainHub.
|
|
346
|
+
return chainHub.resolveAccountId(EUD);
|
|
346
347
|
} catch (e) {
|
|
347
348
|
log('⚠️ forward transfer failed!', e, txHash);
|
|
348
349
|
statusManager.forwarded(txHash, false);
|
|
@@ -31,7 +31,7 @@ const ADDRESSES_BAGGAGE_KEY = 'addresses';
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* @import {HostInterface} from '@agoric/async-flow';
|
|
34
|
-
* @import {
|
|
34
|
+
* @import {CosmosChainAddress, CosmosChainInfo, Denom, DenomDetail, OrchestrationAccount} from '@agoric/orchestration';
|
|
35
35
|
* @import {OrchestrationPowers, OrchestrationTools} from '@agoric/orchestration/src/utils/start-helper.js';
|
|
36
36
|
* @import {Remote} from '@agoric/internal';
|
|
37
37
|
* @import {Marshaller, StorageNode} from '@agoric/internal/src/lib-chainStorage.js'
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
AccountId,
|
|
3
|
+
CosmosChainAddress,
|
|
4
|
+
Bech32Address,
|
|
3
5
|
CosmosChainInfo,
|
|
4
6
|
Denom,
|
|
5
7
|
DenomDetail,
|
|
@@ -11,7 +13,15 @@ import type { PendingTxStatus, TxStatus } from './constants.js';
|
|
|
11
13
|
import type { FastUsdcTerms } from './fast-usdc.contract.js';
|
|
12
14
|
import type { RepayAmountKWR } from './exos/liquidity-pool.js';
|
|
13
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Block hash is calculated using the keccak256 algorithm that always results
|
|
18
|
+
* in 32 bytes (64 hex characters prepended by 0x) no matter the input length.
|
|
19
|
+
*/
|
|
14
20
|
export type EvmHash = `0x${string}`;
|
|
21
|
+
/**
|
|
22
|
+
* An address is always the last 20 bytes (40 hex charaters prepended by 0x) of
|
|
23
|
+
* the public key hash.
|
|
24
|
+
*/
|
|
15
25
|
export type EvmAddress = `0x${string & { length: 40 }}`;
|
|
16
26
|
export type NobleAddress = `noble1${string}`;
|
|
17
27
|
export type EvmChainID = number;
|
|
@@ -25,7 +35,7 @@ export interface CctpTxEvidence {
|
|
|
25
35
|
/** from Noble RPC */
|
|
26
36
|
aux: {
|
|
27
37
|
forwardingChannel: IBCChannelID;
|
|
28
|
-
recipientAddress:
|
|
38
|
+
recipientAddress: CosmosChainAddress['value'];
|
|
29
39
|
};
|
|
30
40
|
/** on the source chain (e.g. L1 Ethereum and L2s Arbitrum, Base) */
|
|
31
41
|
blockHash: EvmHash;
|
|
@@ -70,8 +80,8 @@ export interface TransactionRecord extends CopyRecord {
|
|
|
70
80
|
|
|
71
81
|
/** the record in vstorage at the path of the contract's node */
|
|
72
82
|
export interface ContractRecord extends CopyRecord {
|
|
73
|
-
poolAccount:
|
|
74
|
-
settlementAccount:
|
|
83
|
+
poolAccount: CosmosChainAddress['value'];
|
|
84
|
+
settlementAccount: CosmosChainAddress['value'];
|
|
75
85
|
}
|
|
76
86
|
|
|
77
87
|
export type LogFn = (...args: unknown[]) => void;
|
|
@@ -142,7 +152,7 @@ export type AddressHook = {
|
|
|
142
152
|
baseAddress: string;
|
|
143
153
|
query: {
|
|
144
154
|
/** end user destination address */
|
|
145
|
-
EUD:
|
|
155
|
+
EUD: Bech32Address;
|
|
146
156
|
};
|
|
147
157
|
};
|
|
148
158
|
|