@agoric/fast-usdc 0.1.1-dev-3cbd11f.0 → 0.1.1-dev-4b5dff2.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 +9 -16
- package/src/cli/operator-commands.js +1 -4
- package/src/operator-kit-interface.js +29 -0
- package/src/pool-share-math.js +1 -1
- package/src/type-guards.js +2 -2
- package/src/types.ts +5 -3
- package/src/utils/fees.js +16 -1
- package/tools/mock-evidence.ts +141 -0
- package/src/add-operators.core.js +0 -63
- package/src/distribute-fees.core.js +0 -93
- package/src/exos/advancer.js +0 -375
- package/src/exos/liquidity-pool.js +0 -404
- package/src/exos/operator-kit.js +0 -124
- package/src/exos/settler.js +0 -405
- package/src/exos/status-manager.js +0 -422
- package/src/exos/transaction-feed.js +0 -275
- package/src/fast-usdc-policy.core.js +0 -65
- package/src/fast-usdc.contract.js +0 -338
- package/src/fast-usdc.flows.js +0 -23
- package/src/start-fast-usdc.core.js +0 -253
- package/src/update-fee-config.core.js +0 -99
- package/src/update-noble-ica.core.js +0 -164
- package/src/update-settler-reference.core.js +0 -67
- package/src/utils/chain-policies.js +0 -151
- package/src/utils/config-marshal.js +0 -130
- package/src/utils/core-eval.js +0 -73
- package/src/utils/deploy-config.js +0 -123
- package/src/utils/store.js +0 -117
- package/src/utils/zoe.js +0 -28
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/fast-usdc",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-4b5dff2.0+4b5dff2",
|
|
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,9 +22,6 @@
|
|
|
23
22
|
"lint:eslint": "eslint ."
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-3cbd11f.0+3cbd11f",
|
|
27
|
-
"@agoric/vats": "0.15.2-dev-3cbd11f.0+3cbd11f",
|
|
28
|
-
"@agoric/zone": "0.2.3-dev-3cbd11f.0+3cbd11f",
|
|
29
25
|
"@fast-check/ava": "^2.0.1",
|
|
30
26
|
"ava": "^5.3.0",
|
|
31
27
|
"c8": "^10.1.2",
|
|
@@ -33,16 +29,13 @@
|
|
|
33
29
|
"ts-blank-space": "^0.4.4"
|
|
34
30
|
},
|
|
35
31
|
"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/
|
|
43
|
-
"@agoric/vat-data": "0.5.3-dev-3cbd11f.0+3cbd11f",
|
|
44
|
-
"@agoric/vow": "0.1.1-dev-3cbd11f.0+3cbd11f",
|
|
45
|
-
"@agoric/zoe": "0.26.3-dev-3cbd11f.0+3cbd11f",
|
|
32
|
+
"@agoric/client-utils": "0.1.1-dev-4b5dff2.0+4b5dff2",
|
|
33
|
+
"@agoric/cosmic-proto": "0.4.1-dev-4b5dff2.0+4b5dff2",
|
|
34
|
+
"@agoric/ertp": "0.16.3-dev-4b5dff2.0+4b5dff2",
|
|
35
|
+
"@agoric/internal": "0.3.3-dev-4b5dff2.0+4b5dff2",
|
|
36
|
+
"@agoric/notifier": "0.6.3-dev-4b5dff2.0+4b5dff2",
|
|
37
|
+
"@agoric/orchestration": "0.1.1-dev-4b5dff2.0+4b5dff2",
|
|
38
|
+
"@agoric/zoe": "0.26.3-dev-4b5dff2.0+4b5dff2",
|
|
46
39
|
"@cosmjs/proto-signing": "^0.33.0",
|
|
47
40
|
"@cosmjs/stargate": "^0.33.0",
|
|
48
41
|
"@endo/base64": "^1.0.9",
|
|
@@ -82,5 +75,5 @@
|
|
|
82
75
|
"publishConfig": {
|
|
83
76
|
"access": "public"
|
|
84
77
|
},
|
|
85
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "4b5dff2564e6765b7f6966a13256785710d1d841"
|
|
86
79
|
}
|
|
@@ -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 '../
|
|
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: {},
|
|
@@ -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
|
+
};
|
package/src/pool-share-math.js
CHANGED
|
@@ -14,7 +14,7 @@ const { add, isEmpty, isEqual, isGTE, make, makeEmpty, subtract } = AmountMath;
|
|
|
14
14
|
* @import {Amount, Brand, DepositFacet, NatValue, Payment, Ratio} from '@agoric/ertp';
|
|
15
15
|
* @import {Allocation} from '@agoric/zoe';
|
|
16
16
|
* @import {PoolStats} from './types.js';
|
|
17
|
-
* @import {RepayAmountKWR} from './
|
|
17
|
+
* @import {RepayAmountKWR} from './utils/fees.js';
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
/**
|
package/src/type-guards.js
CHANGED
|
@@ -10,9 +10,9 @@ import { PendingTxStatus } from './constants.js';
|
|
|
10
10
|
/**
|
|
11
11
|
* @import {Amount, Brand, NatValue, Payment} from '@agoric/ertp';
|
|
12
12
|
* @import {TypedPattern} from '@agoric/internal';
|
|
13
|
-
* @import {
|
|
13
|
+
* @import {CosmosChainInfo, Denom, DenomDetail, OrchestrationAccount, IBCConnectionInfo} from '@agoric/orchestration';
|
|
14
14
|
* @import {USDCProposalShapes} from './pool-share-math.js';
|
|
15
|
-
* @import {CctpTxEvidence, FastUSDCConfig, FeeConfig, PendingTx, PoolMetrics, ChainPolicy, FeedPolicy, AddressHook, EvmAddress, EvmHash, RiskAssessment, EvidenceWithRisk} from './types.js';
|
|
15
|
+
* @import {CctpTxEvidence, FastUSDCConfig, FastUsdcTerms, FeeConfig, PendingTx, PoolMetrics, ChainPolicy, FeedPolicy, AddressHook, EvmAddress, EvmHash, RiskAssessment, EvidenceWithRisk} from './types.js';
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
package/src/types.ts
CHANGED
|
@@ -10,8 +10,7 @@ import type { IBCChannelID } from '@agoric/vats';
|
|
|
10
10
|
import type { Amount } from '@agoric/ertp';
|
|
11
11
|
import type { CopyRecord, Passable } from '@endo/pass-style';
|
|
12
12
|
import type { PendingTxStatus, TxStatus } from './constants.js';
|
|
13
|
-
import type {
|
|
14
|
-
import type { RepayAmountKWR } from './exos/liquidity-pool.js';
|
|
13
|
+
import type { RepayAmountKWR } from './utils/fees.js';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Block hash is calculated using the keccak256 algorithm that always results
|
|
@@ -137,6 +136,10 @@ export type FeedPolicy = {
|
|
|
137
136
|
eventFilter?: string;
|
|
138
137
|
} & CopyRecord;
|
|
139
138
|
|
|
139
|
+
export type FastUsdcTerms = {
|
|
140
|
+
usdcDenom: Denom;
|
|
141
|
+
};
|
|
142
|
+
|
|
140
143
|
export type FastUSDCConfig = {
|
|
141
144
|
terms: FastUsdcTerms;
|
|
142
145
|
oracles: Record<string, string>;
|
|
@@ -157,4 +160,3 @@ export type AddressHook = {
|
|
|
157
160
|
};
|
|
158
161
|
|
|
159
162
|
export type * from './constants.js';
|
|
160
|
-
export type { LiquidityPoolKit } from './exos/liquidity-pool.js';
|
package/src/utils/fees.js
CHANGED
|
@@ -9,7 +9,22 @@ const { add, isGTE, subtract } = AmountMath;
|
|
|
9
9
|
/**
|
|
10
10
|
* @import {Amount} from '@agoric/ertp';
|
|
11
11
|
* @import {FeeConfig} from '../types.js';
|
|
12
|
-
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{
|
|
16
|
+
* Principal: Amount<'nat'>;
|
|
17
|
+
* PoolFee: Amount<'nat'>;
|
|
18
|
+
* ContractFee: Amount<'nat'>;
|
|
19
|
+
* }} RepayAmountKWR
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {{
|
|
24
|
+
* Principal: Payment<'nat'>;
|
|
25
|
+
* PoolFee: Payment<'nat'>;
|
|
26
|
+
* ContractFee: Payment<'nat'>;
|
|
27
|
+
* }} RepayPaymentKWR
|
|
13
28
|
*/
|
|
14
29
|
|
|
15
30
|
/** @param {FeeConfig} feeConfig */
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { encodeAddressHook } from '@agoric/cosmic-proto/address-hooks.js';
|
|
2
|
+
import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js';
|
|
3
|
+
import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js';
|
|
4
|
+
import type { CosmosChainAddress } from '@agoric/orchestration';
|
|
5
|
+
import type { VTransferIBCEvent } from '@agoric/vats';
|
|
6
|
+
import type { CctpTxEvidence, EvmAddress } from '../src/types.js';
|
|
7
|
+
|
|
8
|
+
const mockScenarios = [
|
|
9
|
+
'AGORIC_PLUS_OSMO',
|
|
10
|
+
'AGORIC_PLUS_DYDX',
|
|
11
|
+
'AGORIC_PLUS_AGORIC',
|
|
12
|
+
'AGORIC_NO_PARAMS',
|
|
13
|
+
'AGORIC_UNKNOWN_EUD',
|
|
14
|
+
] as const;
|
|
15
|
+
|
|
16
|
+
export type MockScenario = (typeof mockScenarios)[number];
|
|
17
|
+
|
|
18
|
+
export const Senders = {
|
|
19
|
+
default: '0xDefaultFakeEthereumAddress',
|
|
20
|
+
} as unknown as Record<string, EvmAddress>;
|
|
21
|
+
|
|
22
|
+
const blockTimestamp = 1632340000n;
|
|
23
|
+
|
|
24
|
+
export const MockCctpTxEvidences: Record<
|
|
25
|
+
MockScenario,
|
|
26
|
+
(receiverAddress?: string) => CctpTxEvidence
|
|
27
|
+
> = {
|
|
28
|
+
AGORIC_PLUS_OSMO: (receiverAddress?: string) => ({
|
|
29
|
+
blockHash:
|
|
30
|
+
'0x90d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee665',
|
|
31
|
+
blockNumber: 21037663n,
|
|
32
|
+
blockTimestamp,
|
|
33
|
+
txHash:
|
|
34
|
+
'0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761702',
|
|
35
|
+
tx: {
|
|
36
|
+
amount: 150000000n,
|
|
37
|
+
forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd',
|
|
38
|
+
sender: Senders.default,
|
|
39
|
+
},
|
|
40
|
+
aux: {
|
|
41
|
+
forwardingChannel: 'channel-21',
|
|
42
|
+
recipientAddress:
|
|
43
|
+
receiverAddress ||
|
|
44
|
+
encodeAddressHook(settlementAddress.value, {
|
|
45
|
+
EUD: 'osmo183dejcnmkka5dzcu9xw6mywq0p2m5peks28men',
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
chainId: 1,
|
|
49
|
+
}),
|
|
50
|
+
AGORIC_PLUS_DYDX: (receiverAddress?: string) => ({
|
|
51
|
+
blockHash:
|
|
52
|
+
'0x80d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee699',
|
|
53
|
+
blockNumber: 21037669n,
|
|
54
|
+
blockTimestamp,
|
|
55
|
+
txHash:
|
|
56
|
+
'0xd81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761799',
|
|
57
|
+
tx: {
|
|
58
|
+
amount: 300000000n,
|
|
59
|
+
forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelktz',
|
|
60
|
+
sender: Senders.default,
|
|
61
|
+
},
|
|
62
|
+
aux: {
|
|
63
|
+
forwardingChannel: 'channel-21',
|
|
64
|
+
recipientAddress:
|
|
65
|
+
receiverAddress ||
|
|
66
|
+
encodeAddressHook(settlementAddress.value, {
|
|
67
|
+
EUD: 'dydx183dejcnmkka5dzcu9xw6mywq0p2m5peks28men',
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
chainId: 1,
|
|
71
|
+
}),
|
|
72
|
+
AGORIC_PLUS_AGORIC: (receiverAddress?: string) => ({
|
|
73
|
+
blockHash:
|
|
74
|
+
'0x80d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee6z9',
|
|
75
|
+
blockNumber: 21037600n,
|
|
76
|
+
blockTimestamp,
|
|
77
|
+
txHash:
|
|
78
|
+
'0xd81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff3875527617z9',
|
|
79
|
+
tx: {
|
|
80
|
+
amount: 250000000n,
|
|
81
|
+
forwardingAddress: 'noble17ww3rfusv895d92c0ncgj0fl9trntn70jz7hd5',
|
|
82
|
+
sender: Senders.default,
|
|
83
|
+
},
|
|
84
|
+
aux: {
|
|
85
|
+
forwardingChannel: 'channel-21',
|
|
86
|
+
recipientAddress:
|
|
87
|
+
receiverAddress ||
|
|
88
|
+
encodeAddressHook(settlementAddress.value, {
|
|
89
|
+
EUD: 'agoric13rj0cc0hm5ac2nt0sdup2l7gvkx4v9tyvgq3h2',
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
chainId: 1,
|
|
93
|
+
}),
|
|
94
|
+
AGORIC_NO_PARAMS: (receiverAddress?: string) => ({
|
|
95
|
+
blockHash:
|
|
96
|
+
'0x70d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee699',
|
|
97
|
+
blockNumber: 21037669n,
|
|
98
|
+
blockTimestamp,
|
|
99
|
+
txHash:
|
|
100
|
+
'0xa81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761799',
|
|
101
|
+
tx: {
|
|
102
|
+
amount: 200000000n,
|
|
103
|
+
forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelyyy',
|
|
104
|
+
sender: Senders.default,
|
|
105
|
+
},
|
|
106
|
+
aux: {
|
|
107
|
+
forwardingChannel: 'channel-21',
|
|
108
|
+
recipientAddress: receiverAddress || settlementAddress.value,
|
|
109
|
+
},
|
|
110
|
+
chainId: 1,
|
|
111
|
+
}),
|
|
112
|
+
AGORIC_UNKNOWN_EUD: (receiverAddress?: string) => ({
|
|
113
|
+
blockHash:
|
|
114
|
+
'0x70d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee699',
|
|
115
|
+
blockNumber: 21037669n,
|
|
116
|
+
blockTimestamp,
|
|
117
|
+
txHash:
|
|
118
|
+
'0xa81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761799',
|
|
119
|
+
tx: {
|
|
120
|
+
amount: 200000000n,
|
|
121
|
+
forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelyyy',
|
|
122
|
+
sender: Senders.default,
|
|
123
|
+
},
|
|
124
|
+
aux: {
|
|
125
|
+
forwardingChannel: 'channel-21',
|
|
126
|
+
recipientAddress:
|
|
127
|
+
receiverAddress ||
|
|
128
|
+
encodeAddressHook(settlementAddress.value, {
|
|
129
|
+
EUD: 'random1addr',
|
|
130
|
+
}),
|
|
131
|
+
},
|
|
132
|
+
chainId: 1,
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const settlementAddress: CosmosChainAddress = harden({
|
|
137
|
+
chainId: 'agoric-3',
|
|
138
|
+
encoding: 'bech32' as const,
|
|
139
|
+
// Random value, copied from tests of address hooks
|
|
140
|
+
value: 'agoric16kv2g7snfc4q24vg3pjdlnnqgngtjpwtetd2h689nz09lcklvh5s8u37ek',
|
|
141
|
+
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { makeTracer } from '@agoric/internal';
|
|
2
|
-
import { inviteOracles } from './utils/core-eval.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @import {ManifestBundleRef} from '@agoric/deploy-script-support/src/externalTypes.js'
|
|
6
|
-
* @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js'
|
|
7
|
-
* @import {LegibleCapData} from './utils/config-marshal.js'
|
|
8
|
-
* @import {FastUSDCConfig} from './types.js'
|
|
9
|
-
* @import {FastUSDCCorePowers, FastUSDCKit} from './start-fast-usdc.core.js';
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const trace = makeTracer('FUSD-AddOperators', true);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @throws if oracle smart wallets are not yet provisioned
|
|
16
|
-
*
|
|
17
|
-
* @param {BootstrapPowers & FastUSDCCorePowers } powers
|
|
18
|
-
* @param {{ options: LegibleCapData<FastUSDCConfig> }} config
|
|
19
|
-
*/
|
|
20
|
-
export const addOperators = async (
|
|
21
|
-
{ consume: { namesByAddress, fastUsdcKit } },
|
|
22
|
-
config,
|
|
23
|
-
) => {
|
|
24
|
-
trace(addOperators.name);
|
|
25
|
-
|
|
26
|
-
const kit = await fastUsdcKit;
|
|
27
|
-
|
|
28
|
-
const { creatorFacet } = kit;
|
|
29
|
-
|
|
30
|
-
trace(config);
|
|
31
|
-
|
|
32
|
-
// @ts-expect-error XXX LegibleCapData typedef
|
|
33
|
-
const { oracles } = config.options.structure;
|
|
34
|
-
|
|
35
|
-
await inviteOracles({ creatorFacet, namesByAddress }, oracles);
|
|
36
|
-
};
|
|
37
|
-
harden(addOperators);
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @param {{
|
|
41
|
-
* restoreRef: (b: ERef<ManifestBundleRef>) => Promise<Installation>;
|
|
42
|
-
* }} utils
|
|
43
|
-
* @param {{
|
|
44
|
-
* options: LegibleCapData<FastUSDCConfig>;
|
|
45
|
-
* }} param1
|
|
46
|
-
*/
|
|
47
|
-
export const getManifestForAddOperators = ({ restoreRef: _ }, { options }) => {
|
|
48
|
-
return {
|
|
49
|
-
/** @type {BootstrapManifest} */
|
|
50
|
-
manifest: {
|
|
51
|
-
[addOperators.name]: {
|
|
52
|
-
consume: {
|
|
53
|
-
fastUsdcKit: true,
|
|
54
|
-
|
|
55
|
-
// widely shared: name services
|
|
56
|
-
agoricNames: true,
|
|
57
|
-
namesByAddress: true,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
options,
|
|
62
|
-
};
|
|
63
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/** @file core eval module to collect fees. */
|
|
2
|
-
import { AmountMath } from '@agoric/ertp';
|
|
3
|
-
import { floorMultiplyBy } from '@agoric/zoe/src/contractSupport/index.js';
|
|
4
|
-
import { E } from '@endo/far';
|
|
5
|
-
import { makeTracer } from '@agoric/internal';
|
|
6
|
-
import { fromExternalConfig } from './utils/config-marshal.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @import {Amount, Brand, DepositFacet, Ratio} from '@agoric/ertp';
|
|
10
|
-
* @import {FastUSDCCorePowers} from '@agoric/fast-usdc/src/start-fast-usdc.core.js';
|
|
11
|
-
* @import {CopyRecord} from '@endo/pass-style'
|
|
12
|
-
* @import {BootstrapManifestPermit} from '@agoric/vats/src/core/lib-boot.js'
|
|
13
|
-
* @import {LegibleCapData} from './utils/config-marshal.js'
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @typedef {{ destinationAddress: string } &
|
|
18
|
-
* ({ feePortion: Ratio} | {fixedFees: Amount<'nat'>}) &
|
|
19
|
-
* CopyRecord
|
|
20
|
-
* } FeeDistributionTerms
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
const kwUSDC = 'USDC'; // keyword in AmountKeywordRecord
|
|
24
|
-
const issUSDC = 'USDC'; // issuer name
|
|
25
|
-
|
|
26
|
-
const trace = makeTracer('FUCF', true);
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {BootstrapPowers & FastUSDCCorePowers } permittedPowers
|
|
30
|
-
* @param {{ options: LegibleCapData<{ feeTerms: FeeDistributionTerms}> }} config
|
|
31
|
-
*/
|
|
32
|
-
export const distributeFees = async (permittedPowers, config) => {
|
|
33
|
-
trace('distributeFees...', config.options);
|
|
34
|
-
|
|
35
|
-
const { agoricNames, namesByAddress, zoe } = permittedPowers.consume;
|
|
36
|
-
/** @type {Brand<'nat'>} */
|
|
37
|
-
const usdcBrand = await E(agoricNames).lookup('brand', issUSDC);
|
|
38
|
-
/** @type {{ feeTerms: FeeDistributionTerms}} */
|
|
39
|
-
const { feeTerms: terms } = fromExternalConfig(config.options, {
|
|
40
|
-
USDC: usdcBrand,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const { creatorFacet } = await permittedPowers.consume.fastUsdcKit;
|
|
44
|
-
const want = {
|
|
45
|
-
[kwUSDC]: await ('fixedFees' in terms
|
|
46
|
-
? terms.fixedFees
|
|
47
|
-
: E(creatorFacet)
|
|
48
|
-
.getContractFeeBalance()
|
|
49
|
-
.then(balance => floorMultiplyBy(balance, terms.feePortion))),
|
|
50
|
-
};
|
|
51
|
-
const proposal = harden({ want });
|
|
52
|
-
|
|
53
|
-
/** @type {DepositFacet} */
|
|
54
|
-
const depositFacet = await E(namesByAddress).lookup(
|
|
55
|
-
terms.destinationAddress,
|
|
56
|
-
'depositFacet',
|
|
57
|
-
);
|
|
58
|
-
trace('to:', terms.destinationAddress, depositFacet);
|
|
59
|
-
|
|
60
|
-
const toWithdraw = await E(creatorFacet).makeWithdrawFeesInvitation();
|
|
61
|
-
trace('invitation:', toWithdraw, 'proposal:', proposal);
|
|
62
|
-
const seat = E(zoe).offer(toWithdraw, proposal);
|
|
63
|
-
const result = await E(seat).getOfferResult();
|
|
64
|
-
trace('offer result', result);
|
|
65
|
-
const payout = await E(seat).getPayout(kwUSDC);
|
|
66
|
-
/** @type {Amount<'nat'>} */
|
|
67
|
-
// @ts-expect-error USDC is a nat brand
|
|
68
|
-
const rxd = await E(depositFacet).receive(payout);
|
|
69
|
-
trace('received', rxd);
|
|
70
|
-
if (!AmountMath.isGTE(rxd, proposal.want[kwUSDC])) {
|
|
71
|
-
trace('🚨 expected', proposal.want[kwUSDC], 'got', rxd);
|
|
72
|
-
}
|
|
73
|
-
trace('done');
|
|
74
|
-
};
|
|
75
|
-
harden(distributeFees);
|
|
76
|
-
|
|
77
|
-
/** @satisfies {BootstrapManifestPermit} */
|
|
78
|
-
const permit = {
|
|
79
|
-
consume: {
|
|
80
|
-
fastUsdcKit: true,
|
|
81
|
-
agoricNames: true,
|
|
82
|
-
namesByAddress: true,
|
|
83
|
-
zoe: true,
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @param {unknown} _utils
|
|
89
|
-
* @param {Parameters<typeof distributeFees>[1]} config
|
|
90
|
-
*/
|
|
91
|
-
export const getManifestForDistributeFees = (_utils, { options }) => {
|
|
92
|
-
return { manifest: { [distributeFees.name]: permit }, options };
|
|
93
|
-
};
|