@agoric/fast-usdc 0.1.1-dev-1d5cb99.0 → 0.1.1-dev-8a52ddd.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 +14 -14
- package/src/exos/advancer.js +42 -55
- package/src/exos/settler.js +63 -37
- package/src/fast-usdc.contract.js +22 -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-8a52ddd.0+8a52ddd",
|
|
4
4
|
"description": "CLI and library for Fast USDC product",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"lint:eslint": "eslint ."
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
25
|
-
"@agoric/vats": "0.15.2-dev-
|
|
26
|
-
"@agoric/zone": "0.2.3-dev-
|
|
24
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-8a52ddd.0+8a52ddd",
|
|
25
|
+
"@agoric/vats": "0.15.2-dev-8a52ddd.0+8a52ddd",
|
|
26
|
+
"@agoric/zone": "0.2.3-dev-8a52ddd.0+8a52ddd",
|
|
27
27
|
"@fast-check/ava": "^2.0.1",
|
|
28
28
|
"ava": "^5.3.0",
|
|
29
29
|
"c8": "^10.1.2",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"ts-blank-space": "^0.4.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@agoric/client-utils": "0.1.1-dev-
|
|
35
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
36
|
-
"@agoric/internal": "0.3.3-dev-
|
|
37
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
38
|
-
"@agoric/orchestration": "0.1.1-dev-
|
|
39
|
-
"@agoric/store": "0.9.3-dev-
|
|
40
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
41
|
-
"@agoric/vow": "0.1.1-dev-
|
|
42
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
34
|
+
"@agoric/client-utils": "0.1.1-dev-8a52ddd.0+8a52ddd",
|
|
35
|
+
"@agoric/ertp": "0.16.3-dev-8a52ddd.0+8a52ddd",
|
|
36
|
+
"@agoric/internal": "0.3.3-dev-8a52ddd.0+8a52ddd",
|
|
37
|
+
"@agoric/notifier": "0.6.3-dev-8a52ddd.0+8a52ddd",
|
|
38
|
+
"@agoric/orchestration": "0.1.1-dev-8a52ddd.0+8a52ddd",
|
|
39
|
+
"@agoric/store": "0.9.3-dev-8a52ddd.0+8a52ddd",
|
|
40
|
+
"@agoric/vat-data": "0.5.3-dev-8a52ddd.0+8a52ddd",
|
|
41
|
+
"@agoric/vow": "0.1.1-dev-8a52ddd.0+8a52ddd",
|
|
42
|
+
"@agoric/zoe": "0.26.3-dev-8a52ddd.0+8a52ddd",
|
|
43
43
|
"@cosmjs/proto-signing": "^0.32.4",
|
|
44
44
|
"@cosmjs/stargate": "^0.32.4",
|
|
45
45
|
"@endo/base64": "^1.0.9",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "8a52dddcda0af5eaedeca94bebcffd88bb8eebae"
|
|
82
82
|
}
|
package/src/exos/advancer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AmountMath
|
|
1
|
+
import { AmountMath } from '@agoric/ertp';
|
|
2
2
|
import { assertAllDefined, makeTracer } from '@agoric/internal';
|
|
3
|
-
import { ChainAddressShape } from '@agoric/orchestration';
|
|
3
|
+
import { AnyNatAmountShape, ChainAddressShape } from '@agoric/orchestration';
|
|
4
4
|
import { pickFacet } from '@agoric/vat-data';
|
|
5
5
|
import { VowShape } from '@agoric/vow';
|
|
6
6
|
import { q } from '@endo/errors';
|
|
@@ -16,6 +16,7 @@ import { makeFeeTools } from '../utils/fees.js';
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @import {HostInterface} from '@agoric/async-flow';
|
|
19
|
+
* @import {TypedPattern} from '@agoric/internal'
|
|
19
20
|
* @import {NatAmount} from '@agoric/ertp';
|
|
20
21
|
* @import {ChainAddress, ChainHub, Denom, OrchestrationAccount} from '@agoric/orchestration';
|
|
21
22
|
* @import {ZoeTools} from '@agoric/orchestration/src/utils/zoe-tools.js';
|
|
@@ -39,47 +40,40 @@ import { makeFeeTools } from '../utils/fees.js';
|
|
|
39
40
|
* }} AdvancerKitPowers
|
|
40
41
|
*/
|
|
41
42
|
|
|
43
|
+
/** @type {TypedPattern<AdvancerVowCtx>} */
|
|
44
|
+
const AdvancerVowCtxShape = M.splitRecord(
|
|
45
|
+
{
|
|
46
|
+
fullAmount: AnyNatAmountShape,
|
|
47
|
+
advanceAmount: AnyNatAmountShape,
|
|
48
|
+
destination: ChainAddressShape,
|
|
49
|
+
forwardingAddress: M.string(),
|
|
50
|
+
txHash: EvmHashShape,
|
|
51
|
+
},
|
|
52
|
+
{ tmpSeat: M.remotable() },
|
|
53
|
+
);
|
|
54
|
+
|
|
42
55
|
/** type guards internal to the AdvancerKit */
|
|
43
56
|
const AdvancerKitI = harden({
|
|
44
57
|
advancer: M.interface('AdvancerI', {
|
|
45
58
|
handleTransactionEvent: M.callWhen(CctpTxEvidenceShape).returns(),
|
|
46
59
|
}),
|
|
47
60
|
depositHandler: M.interface('DepositHandlerI', {
|
|
48
|
-
onFulfilled: M.call(M.undefined(),
|
|
49
|
-
|
|
50
|
-
destination: ChainAddressShape,
|
|
51
|
-
forwardingAddress: M.string(),
|
|
52
|
-
tmpSeat: M.remotable(),
|
|
53
|
-
txHash: EvmHashShape,
|
|
54
|
-
}).returns(VowShape),
|
|
55
|
-
onRejected: M.call(M.error(), {
|
|
56
|
-
amount: AmountShape,
|
|
57
|
-
destination: ChainAddressShape,
|
|
58
|
-
forwardingAddress: M.string(),
|
|
59
|
-
tmpSeat: M.remotable(),
|
|
60
|
-
txHash: EvmHashShape,
|
|
61
|
-
}).returns(),
|
|
61
|
+
onFulfilled: M.call(M.undefined(), AdvancerVowCtxShape).returns(VowShape),
|
|
62
|
+
onRejected: M.call(M.error(), AdvancerVowCtxShape).returns(),
|
|
62
63
|
}),
|
|
63
64
|
transferHandler: M.interface('TransferHandlerI', {
|
|
64
65
|
// TODO confirm undefined, and not bigint (sequence)
|
|
65
|
-
onFulfilled: M.call(M.undefined(),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
txHash: EvmHashShape,
|
|
70
|
-
}).returns(M.undefined()),
|
|
71
|
-
onRejected: M.call(M.error(), {
|
|
72
|
-
amount: AmountShape,
|
|
73
|
-
destination: ChainAddressShape,
|
|
74
|
-
forwardingAddress: M.string(),
|
|
75
|
-
txHash: EvmHashShape,
|
|
76
|
-
}).returns(M.undefined()),
|
|
66
|
+
onFulfilled: M.call(M.undefined(), AdvancerVowCtxShape).returns(
|
|
67
|
+
M.undefined(),
|
|
68
|
+
),
|
|
69
|
+
onRejected: M.call(M.error(), AdvancerVowCtxShape).returns(M.undefined()),
|
|
77
70
|
}),
|
|
78
71
|
});
|
|
79
72
|
|
|
80
73
|
/**
|
|
81
74
|
* @typedef {{
|
|
82
|
-
*
|
|
75
|
+
* fullAmount: NatAmount;
|
|
76
|
+
* advanceAmount: NatAmount;
|
|
83
77
|
* destination: ChainAddress;
|
|
84
78
|
* forwardingAddress: NobleAddress;
|
|
85
79
|
* txHash: EvmHash;
|
|
@@ -155,9 +149,9 @@ export const prepareAdvancerKit = (
|
|
|
155
149
|
// throws if the bech32 prefix is not found
|
|
156
150
|
const destination = chainHub.makeChainAddress(EUD);
|
|
157
151
|
|
|
158
|
-
const
|
|
152
|
+
const fullAmount = toAmount(evidence.tx.amount);
|
|
159
153
|
// throws if requested does not exceed fees
|
|
160
|
-
const advanceAmount = feeTools.calculateAdvance(
|
|
154
|
+
const advanceAmount = feeTools.calculateAdvance(fullAmount);
|
|
161
155
|
|
|
162
156
|
const { zcfSeat: tmpSeat } = zcf.makeEmptySeatKit();
|
|
163
157
|
const amountKWR = harden({ USDC: advanceAmount });
|
|
@@ -174,7 +168,8 @@ export const prepareAdvancerKit = (
|
|
|
174
168
|
amountKWR,
|
|
175
169
|
);
|
|
176
170
|
void watch(depositV, this.facets.depositHandler, {
|
|
177
|
-
|
|
171
|
+
fullAmount,
|
|
172
|
+
advanceAmount,
|
|
178
173
|
destination,
|
|
179
174
|
forwardingAddress: evidence.tx.forwardingAddress,
|
|
180
175
|
tmpSeat,
|
|
@@ -193,16 +188,15 @@ export const prepareAdvancerKit = (
|
|
|
193
188
|
*/
|
|
194
189
|
onFulfilled(result, ctx) {
|
|
195
190
|
const { poolAccount } = this.state;
|
|
196
|
-
const {
|
|
191
|
+
const { destination, advanceAmount, ...detail } = ctx;
|
|
197
192
|
const transferV = E(poolAccount).transfer(destination, {
|
|
198
193
|
denom: usdc.denom,
|
|
199
|
-
value:
|
|
194
|
+
value: advanceAmount.value,
|
|
200
195
|
});
|
|
201
196
|
return watch(transferV, this.facets.transferHandler, {
|
|
202
197
|
destination,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
txHash,
|
|
198
|
+
advanceAmount,
|
|
199
|
+
...detail,
|
|
206
200
|
});
|
|
207
201
|
},
|
|
208
202
|
/**
|
|
@@ -222,23 +216,23 @@ export const prepareAdvancerKit = (
|
|
|
222
216
|
},
|
|
223
217
|
transferHandler: {
|
|
224
218
|
/**
|
|
225
|
-
* @param {
|
|
219
|
+
* @param {unknown} result TODO confirm this is not a bigint (sequence)
|
|
226
220
|
* @param {AdvancerVowCtx} ctx
|
|
227
221
|
*/
|
|
228
222
|
onFulfilled(result, ctx) {
|
|
229
223
|
const { notifyFacet } = this.state;
|
|
230
|
-
const {
|
|
224
|
+
const { advanceAmount, destination, ...detail } = ctx;
|
|
231
225
|
log(
|
|
232
226
|
'Advance transfer fulfilled',
|
|
233
|
-
q({
|
|
234
|
-
);
|
|
235
|
-
notifyFacet.notifyAdvancingResult(
|
|
236
|
-
txHash,
|
|
237
|
-
forwardingAddress,
|
|
238
|
-
amount.value,
|
|
239
|
-
destination.value,
|
|
240
|
-
true,
|
|
227
|
+
q({ advanceAmount, destination, result }).toString(),
|
|
241
228
|
);
|
|
229
|
+
// During development, due to a bug, this call threw.
|
|
230
|
+
// The failure was silent (no diagnostics) due to:
|
|
231
|
+
// - #10576 Vows do not report unhandled rejections
|
|
232
|
+
// For now, the advancer kit relies on consistency between
|
|
233
|
+
// notifyFacet, statusManager, and callers of handleTransactionEvent().
|
|
234
|
+
// TODO: revisit #10576 during #10510
|
|
235
|
+
notifyFacet.notifyAdvancingResult({ destination, ...detail }, true);
|
|
242
236
|
},
|
|
243
237
|
/**
|
|
244
238
|
* @param {Error} error
|
|
@@ -246,15 +240,8 @@ export const prepareAdvancerKit = (
|
|
|
246
240
|
*/
|
|
247
241
|
onRejected(error, ctx) {
|
|
248
242
|
const { notifyFacet } = this.state;
|
|
249
|
-
const { amount, destination, forwardingAddress, txHash } = ctx;
|
|
250
243
|
log('Advance transfer rejected', q(error).toString());
|
|
251
|
-
notifyFacet.notifyAdvancingResult(
|
|
252
|
-
txHash,
|
|
253
|
-
forwardingAddress,
|
|
254
|
-
amount.value,
|
|
255
|
-
destination.value,
|
|
256
|
-
false,
|
|
257
|
-
);
|
|
244
|
+
notifyFacet.notifyAdvancingResult(ctx, false);
|
|
258
245
|
},
|
|
259
246
|
},
|
|
260
247
|
},
|
package/src/exos/settler.js
CHANGED
|
@@ -11,18 +11,16 @@ import { EvmHashShape } from '../type-guards.js';
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @import {FungibleTokenPacketData} from '@agoric/cosmic-proto/ibc/applications/transfer/v2/packet.js';
|
|
14
|
-
* @import {Denom, OrchestrationAccount, ChainHub} from '@agoric/orchestration';
|
|
14
|
+
* @import {Denom, OrchestrationAccount, ChainHub, ChainAddress} from '@agoric/orchestration';
|
|
15
15
|
* @import {WithdrawToSeat} from '@agoric/orchestration/src/utils/zoe-tools'
|
|
16
16
|
* @import {IBCChannelID, VTransferIBCEvent} from '@agoric/vats';
|
|
17
17
|
* @import {Zone} from '@agoric/zone';
|
|
18
18
|
* @import {HostOf, HostInterface} from '@agoric/async-flow';
|
|
19
19
|
* @import {TargetRegistration} from '@agoric/vats/src/bridge-target.js';
|
|
20
|
-
* @import {NobleAddress, LiquidityPoolKit, FeeConfig, EvmHash} from '../types.js';
|
|
20
|
+
* @import {NobleAddress, LiquidityPoolKit, FeeConfig, EvmHash, LogFn} from '../types.js';
|
|
21
21
|
* @import {StatusManager} from './status-manager.js';
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
const trace = makeTracer('Settler');
|
|
25
|
-
|
|
26
24
|
/**
|
|
27
25
|
* NOTE: not meant to be parsable.
|
|
28
26
|
*
|
|
@@ -42,10 +40,20 @@ const makeMintedEarlyKey = (addr, amount) =>
|
|
|
42
40
|
* @param {HostOf<WithdrawToSeat>} caps.withdrawToSeat
|
|
43
41
|
* @param {import('@agoric/vow').VowTools} caps.vowTools
|
|
44
42
|
* @param {ChainHub} caps.chainHub
|
|
43
|
+
* @param {LogFn} [caps.log]
|
|
45
44
|
*/
|
|
46
45
|
export const prepareSettler = (
|
|
47
46
|
zone,
|
|
48
|
-
{
|
|
47
|
+
{
|
|
48
|
+
chainHub,
|
|
49
|
+
feeConfig,
|
|
50
|
+
log = makeTracer('Settler', true),
|
|
51
|
+
statusManager,
|
|
52
|
+
USDC,
|
|
53
|
+
vowTools,
|
|
54
|
+
withdrawToSeat,
|
|
55
|
+
zcf,
|
|
56
|
+
},
|
|
49
57
|
) => {
|
|
50
58
|
assertAllDefined({ statusManager });
|
|
51
59
|
return zone.exoClassKit(
|
|
@@ -59,8 +67,7 @@ export const prepareSettler = (
|
|
|
59
67
|
}),
|
|
60
68
|
notify: M.interface('SettlerNotifyI', {
|
|
61
69
|
notifyAdvancingResult: M.call(
|
|
62
|
-
M.
|
|
63
|
-
M.nat(),
|
|
70
|
+
M.record(), // XXX fill in details TODO
|
|
64
71
|
M.boolean(),
|
|
65
72
|
).returns(),
|
|
66
73
|
}),
|
|
@@ -89,6 +96,7 @@ export const prepareSettler = (
|
|
|
89
96
|
* }} config
|
|
90
97
|
*/
|
|
91
98
|
config => {
|
|
99
|
+
log('config', config);
|
|
92
100
|
return {
|
|
93
101
|
...config,
|
|
94
102
|
/** @type {HostInterface<TargetRegistration>|undefined} */
|
|
@@ -111,11 +119,12 @@ export const prepareSettler = (
|
|
|
111
119
|
tap: {
|
|
112
120
|
/** @param {VTransferIBCEvent} event */
|
|
113
121
|
async receiveUpcall(event) {
|
|
122
|
+
log('upcall event', event.packet.sequence, event.blockTime);
|
|
114
123
|
const { sourceChannel, remoteDenom } = this.state;
|
|
115
124
|
const { packet } = event;
|
|
116
125
|
if (packet.source_channel !== sourceChannel) {
|
|
117
126
|
const { source_channel: actual } = packet;
|
|
118
|
-
|
|
127
|
+
log('unexpected channel', { actual, expected: sourceChannel });
|
|
119
128
|
return;
|
|
120
129
|
}
|
|
121
130
|
|
|
@@ -129,7 +138,7 @@ export const prepareSettler = (
|
|
|
129
138
|
|
|
130
139
|
if (tx.denom !== remoteDenom) {
|
|
131
140
|
const { denom: actual } = tx;
|
|
132
|
-
|
|
141
|
+
log('unexpected denom', { actual, expected: remoteDenom });
|
|
133
142
|
return;
|
|
134
143
|
}
|
|
135
144
|
|
|
@@ -148,7 +157,7 @@ export const prepareSettler = (
|
|
|
148
157
|
|
|
149
158
|
const { self } = this.facets;
|
|
150
159
|
const found = statusManager.dequeueStatus(sender, amount);
|
|
151
|
-
|
|
160
|
+
log('dequeued', found, 'for', sender, amount);
|
|
152
161
|
switch (found?.status) {
|
|
153
162
|
case PendingTxStatus.Advanced:
|
|
154
163
|
return self.disburse(found.txHash, sender, amount);
|
|
@@ -157,35 +166,51 @@ export const prepareSettler = (
|
|
|
157
166
|
this.state.mintedEarly.add(makeMintedEarlyKey(sender, amount));
|
|
158
167
|
return;
|
|
159
168
|
|
|
160
|
-
case undefined:
|
|
161
169
|
case PendingTxStatus.Observed:
|
|
162
170
|
case PendingTxStatus.AdvanceFailed:
|
|
171
|
+
return self.forward(found.txHash, sender, amount, EUD);
|
|
172
|
+
|
|
173
|
+
case undefined:
|
|
163
174
|
default:
|
|
164
|
-
|
|
175
|
+
log('⚠️ tap: no status for ', sender, amount);
|
|
165
176
|
}
|
|
166
177
|
},
|
|
167
178
|
},
|
|
168
179
|
notify: {
|
|
169
180
|
/**
|
|
170
|
-
* @param {
|
|
171
|
-
* @param {
|
|
172
|
-
* @param {
|
|
173
|
-
* @param {
|
|
181
|
+
* @param {object} ctx
|
|
182
|
+
* @param {EvmHash} ctx.txHash
|
|
183
|
+
* @param {NobleAddress} ctx.forwardingAddress
|
|
184
|
+
* @param {Amount<'nat'>} ctx.fullAmount
|
|
185
|
+
* @param {ChainAddress} ctx.destination
|
|
174
186
|
* @param {boolean} success
|
|
175
187
|
* @returns {void}
|
|
176
188
|
*/
|
|
177
|
-
notifyAdvancingResult(
|
|
189
|
+
notifyAdvancingResult(
|
|
190
|
+
{ txHash, forwardingAddress, fullAmount, destination },
|
|
191
|
+
success,
|
|
192
|
+
) {
|
|
178
193
|
const { mintedEarly } = this.state;
|
|
179
|
-
const
|
|
194
|
+
const { value: fullValue } = fullAmount;
|
|
195
|
+
const key = makeMintedEarlyKey(forwardingAddress, fullValue);
|
|
180
196
|
if (mintedEarly.has(key)) {
|
|
181
197
|
mintedEarly.delete(key);
|
|
182
198
|
if (success) {
|
|
183
|
-
void this.facets.self.disburse(
|
|
199
|
+
void this.facets.self.disburse(
|
|
200
|
+
txHash,
|
|
201
|
+
forwardingAddress,
|
|
202
|
+
fullValue,
|
|
203
|
+
);
|
|
184
204
|
} else {
|
|
185
|
-
void this.facets.self.forward(
|
|
205
|
+
void this.facets.self.forward(
|
|
206
|
+
txHash,
|
|
207
|
+
forwardingAddress,
|
|
208
|
+
fullValue,
|
|
209
|
+
destination.value,
|
|
210
|
+
);
|
|
186
211
|
}
|
|
187
212
|
} else {
|
|
188
|
-
statusManager.advanceOutcome(
|
|
213
|
+
statusManager.advanceOutcome(forwardingAddress, fullValue, success);
|
|
189
214
|
}
|
|
190
215
|
},
|
|
191
216
|
},
|
|
@@ -193,15 +218,15 @@ export const prepareSettler = (
|
|
|
193
218
|
/**
|
|
194
219
|
* @param {EvmHash} txHash
|
|
195
220
|
* @param {NobleAddress} sender
|
|
196
|
-
* @param {NatValue}
|
|
221
|
+
* @param {NatValue} fullValue
|
|
197
222
|
*/
|
|
198
|
-
async disburse(txHash, sender,
|
|
223
|
+
async disburse(txHash, sender, fullValue) {
|
|
199
224
|
const { repayer, settlementAccount } = this.state;
|
|
200
|
-
const received = AmountMath.make(USDC,
|
|
225
|
+
const received = AmountMath.make(USDC, fullValue);
|
|
201
226
|
const { zcfSeat: settlingSeat } = zcf.makeEmptySeatKit();
|
|
202
227
|
const { calculateSplit } = makeFeeTools(feeConfig);
|
|
203
228
|
const split = calculateSplit(received);
|
|
204
|
-
|
|
229
|
+
log('disbursing', split);
|
|
205
230
|
|
|
206
231
|
// TODO: what if this throws?
|
|
207
232
|
// arguably, it cannot. Even if deposits
|
|
@@ -224,12 +249,12 @@ export const prepareSettler = (
|
|
|
224
249
|
statusManager.disbursed(txHash);
|
|
225
250
|
},
|
|
226
251
|
/**
|
|
227
|
-
* @param {EvmHash
|
|
252
|
+
* @param {EvmHash} txHash
|
|
228
253
|
* @param {NobleAddress} sender
|
|
229
|
-
* @param {NatValue}
|
|
254
|
+
* @param {NatValue} fullValue
|
|
230
255
|
* @param {string} EUD
|
|
231
256
|
*/
|
|
232
|
-
forward(txHash, sender,
|
|
257
|
+
forward(txHash, sender, fullValue, EUD) {
|
|
233
258
|
const { settlementAccount } = this.state;
|
|
234
259
|
|
|
235
260
|
const dest = chainHub.makeChainAddress(EUD);
|
|
@@ -237,12 +262,12 @@ export const prepareSettler = (
|
|
|
237
262
|
// TODO? statusManager.forwarding(txHash, sender, amount);
|
|
238
263
|
const txfrV = E(settlementAccount).transfer(
|
|
239
264
|
dest,
|
|
240
|
-
AmountMath.make(USDC,
|
|
265
|
+
AmountMath.make(USDC, fullValue),
|
|
241
266
|
);
|
|
242
267
|
void vowTools.watch(txfrV, this.facets.transferHandler, {
|
|
243
268
|
txHash,
|
|
244
269
|
sender,
|
|
245
|
-
|
|
270
|
+
fullValue,
|
|
246
271
|
});
|
|
247
272
|
},
|
|
248
273
|
},
|
|
@@ -254,20 +279,21 @@ export const prepareSettler = (
|
|
|
254
279
|
* @typedef {{
|
|
255
280
|
* txHash: EvmHash;
|
|
256
281
|
* sender: NobleAddress;
|
|
257
|
-
*
|
|
282
|
+
* fullValue: NatValue;
|
|
258
283
|
* }} SettlerTransferCtx
|
|
259
284
|
*/
|
|
260
285
|
onFulfilled(_result, ctx) {
|
|
261
|
-
const { txHash, sender,
|
|
262
|
-
statusManager.forwarded(txHash, sender,
|
|
286
|
+
const { txHash, sender, fullValue } = ctx;
|
|
287
|
+
statusManager.forwarded(txHash, sender, fullValue);
|
|
263
288
|
},
|
|
264
289
|
/**
|
|
265
|
-
* @param {unknown}
|
|
266
|
-
* @param {SettlerTransferCtx}
|
|
290
|
+
* @param {unknown} reason
|
|
291
|
+
* @param {SettlerTransferCtx} ctx
|
|
267
292
|
*/
|
|
268
|
-
onRejected(
|
|
293
|
+
onRejected(reason, ctx) {
|
|
294
|
+
log('⚠️ transfer rejected!', reason, ctx);
|
|
269
295
|
// const { txHash, sender, amount } = ctx;
|
|
270
|
-
// TODO: statusManager.forwardFailed(txHash, sender, amount);
|
|
296
|
+
// TODO(#10510): statusManager.forwardFailed(txHash, sender, amount);
|
|
271
297
|
},
|
|
272
298
|
},
|
|
273
299
|
},
|
|
@@ -30,12 +30,14 @@ import * as flows from './fast-usdc.flows.js';
|
|
|
30
30
|
const trace = makeTracer('FastUsdc');
|
|
31
31
|
|
|
32
32
|
const STATUS_NODE = 'status';
|
|
33
|
+
const FEE_NODE = 'feeConfig';
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* @import {HostInterface} from '@agoric/async-flow';
|
|
36
37
|
* @import {CosmosChainInfo, Denom, DenomDetail, OrchestrationAccount} from '@agoric/orchestration';
|
|
37
38
|
* @import {OrchestrationPowers, OrchestrationTools} from '@agoric/orchestration/src/utils/start-helper.js';
|
|
38
|
-
* @import {
|
|
39
|
+
* @import {Remote} from '@agoric/internal';
|
|
40
|
+
* @import {Marshaller, StorageNode} from '@agoric/internal/src/lib-chainStorage.js'
|
|
39
41
|
* @import {Zone} from '@agoric/zone';
|
|
40
42
|
* @import {OperatorKit} from './exos/operator-kit.js';
|
|
41
43
|
* @import {CctpTxEvidence, FeeConfig} from './types.js';
|
|
@@ -63,6 +65,17 @@ export const meta = {
|
|
|
63
65
|
};
|
|
64
66
|
harden(meta);
|
|
65
67
|
|
|
68
|
+
/**
|
|
69
|
+
* @param {Remote<StorageNode>} node
|
|
70
|
+
* @param {ERef<Marshaller>} marshaller
|
|
71
|
+
* @param {FeeConfig} feeConfig
|
|
72
|
+
*/
|
|
73
|
+
const publishFeeConfig = async (node, marshaller, feeConfig) => {
|
|
74
|
+
const feeNode = E(node).makeChildNode(FEE_NODE);
|
|
75
|
+
const value = await E(marshaller).toCapData(feeConfig);
|
|
76
|
+
return E(feeNode).setValue(JSON.stringify(value));
|
|
77
|
+
};
|
|
78
|
+
|
|
66
79
|
/**
|
|
67
80
|
* @param {ZCF<FastUsdcTerms>} zcf
|
|
68
81
|
* @param {OrchestrationPowers & {
|
|
@@ -80,14 +93,13 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
80
93
|
assert('USDC' in terms.brands, 'no USDC brand');
|
|
81
94
|
assert('usdcDenom' in terms, 'no usdcDenom');
|
|
82
95
|
|
|
83
|
-
const { feeConfig, marshaller } = privateArgs;
|
|
96
|
+
const { feeConfig, marshaller, storageNode } = privateArgs;
|
|
84
97
|
const { makeRecorderKit } = prepareRecorderKitMakers(
|
|
85
98
|
zone.mapStore('vstorage'),
|
|
86
99
|
marshaller,
|
|
87
100
|
);
|
|
88
101
|
|
|
89
|
-
const makeStatusNode = () =>
|
|
90
|
-
E(privateArgs.storageNode).makeChildNode(STATUS_NODE);
|
|
102
|
+
const makeStatusNode = () => E(storageNode).makeChildNode(STATUS_NODE);
|
|
91
103
|
const statusManager = prepareStatusManager(zone, makeStatusNode);
|
|
92
104
|
|
|
93
105
|
const { USDC } = terms.brands;
|
|
@@ -209,6 +221,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
209
221
|
// So we use zone.exoClassKit above to define the liquidity pool kind
|
|
210
222
|
// and pass the shareMint into the maker / init function.
|
|
211
223
|
|
|
224
|
+
void publishFeeConfig(storageNode, marshaller, feeConfig);
|
|
225
|
+
|
|
212
226
|
const shareMint = await provideSingleton(
|
|
213
227
|
zone.mapStore('mint'),
|
|
214
228
|
'PoolShare',
|
|
@@ -246,9 +260,12 @@ export const contract = async (zcf, privateArgs, zone, tools) => {
|
|
|
246
260
|
vowTools.all([poolAccountV, settleAccountV]),
|
|
247
261
|
);
|
|
248
262
|
|
|
263
|
+
const [_agoric, _noble, agToNoble] = await vowTools.when(
|
|
264
|
+
chainHub.getChainsAndConnection('agoric', 'noble'),
|
|
265
|
+
);
|
|
249
266
|
const settlerKit = makeSettler({
|
|
250
267
|
repayer: poolKit.repayer,
|
|
251
|
-
sourceChannel:
|
|
268
|
+
sourceChannel: agToNoble.transferChannel.counterPartyChannelId,
|
|
252
269
|
remoteDenom: 'uusdc',
|
|
253
270
|
settlementAccount,
|
|
254
271
|
});
|