@agoric/fast-usdc 0.2.0-upgrade-19-dev-0754752.0 → 0.2.0-upgrade-18a-dev-4ee0508.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.
@@ -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,98 +0,0 @@
1
- // @ts-check
2
- import { assertAllDefined } from '@agoric/internal';
3
-
4
- /**
5
- * @import {USDCProposalShapes} from './pool-share-math.js';
6
- */
7
-
8
- /**
9
- * @param {Pick<
10
- * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
11
- * 'brand'
12
- * >} agoricNames
13
- * @param {object} opts
14
- * @param {string} opts.offerId
15
- * @param {bigint} opts.fastLPAmount
16
- * @param {bigint} opts.usdcAmount
17
- * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec & {proposal: USDCProposalShapes['deposit']}}
18
- */
19
- const makeDepositOffer = ({ brand }, { offerId, fastLPAmount, usdcAmount }) => {
20
- assertAllDefined({ offerId, fastLPAmount, usdcAmount });
21
-
22
- return {
23
- id: offerId,
24
- invitationSpec: {
25
- source: 'agoricContract',
26
- instancePath: ['fastUsdc'],
27
- callPipe: [['makeDepositInvitation']],
28
- },
29
- /** @type {USDCProposalShapes['deposit']} */
30
- // @ts-expect-error https://github.com/Agoric/agoric-sdk/issues/10491
31
- proposal: {
32
- give: {
33
- USDC: {
34
- brand: brand.USDC,
35
- value: usdcAmount,
36
- },
37
- },
38
- want: {
39
- PoolShare: {
40
- brand: brand.FastLP,
41
- value: fastLPAmount,
42
- },
43
- },
44
- },
45
- };
46
- };
47
-
48
- /**
49
- * @param {Pick<
50
- * import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes,
51
- * 'brand'
52
- * >} agoricNames
53
- * @param {object} opts
54
- * @param {string} opts.offerId
55
- * @param {bigint} opts.fastLPAmount
56
- * @param {bigint} opts.usdcAmount
57
- * @returns {import('@agoric/smart-wallet/src/offers.js').OfferSpec}
58
- */
59
- const makeWithdrawOffer = (
60
- { brand },
61
- { offerId, fastLPAmount, usdcAmount },
62
- ) => ({
63
- id: offerId,
64
- invitationSpec: {
65
- source: 'agoricContract',
66
- instancePath: ['fastUsdc'],
67
- callPipe: [['makeWithdrawInvitation']],
68
- },
69
- proposal: {
70
- give: {
71
- PoolShare: {
72
- // @ts-expect-error https://github.com/Agoric/agoric-sdk/issues/10491
73
- brand: brand.FastLP,
74
- value: fastLPAmount,
75
- },
76
- },
77
- want: {
78
- USDC: {
79
- // @ts-expect-error https://github.com/Agoric/agoric-sdk/issues/10491
80
- brand: brand.USDC,
81
- value: usdcAmount,
82
- },
83
- },
84
- },
85
- });
86
-
87
- /**
88
- * @satisfies {Record<
89
- * string,
90
- * Record<string, import('@agoric/smart-wallet/src/types.js').OfferMaker>
91
- * >}
92
- */
93
- export const Offers = {
94
- fastUsdc: {
95
- Deposit: makeDepositOffer,
96
- Withdraw: makeWithdrawOffer,
97
- },
98
- };
@@ -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 {DepositFacet} 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
- };
package/src/main.js DELETED
@@ -1 +0,0 @@
1
- export * from './types.js';
@@ -1,140 +0,0 @@
1
- /** @import {ChainPolicy} from '../types.js'; */
2
-
3
- /** @satisfies {Record<'MAINNET'| 'TESTNET', Record<string, ChainPolicy>>} */
4
- export const ChainPolicies = /** @type {const} */ ({
5
- MAINNET: {
6
- Arbitrum: {
7
- attenuatedCttpBridgeAddresses: [
8
- '0xe298b93ffB5eA1FB628e0C0D55A43aeaC268e347',
9
- ],
10
- cctpTokenMessengerAddress: '0x19330d10D9Cc8751218eaf51E8885D058642E08A',
11
- chainId: 42161,
12
- // TODO confirm confirmations and rateLimits
13
- confirmations: 2,
14
- rateLimits: {
15
- blockWindow: 20_000_000_000n,
16
- blockWindowSize: 10,
17
- tx: 10_000_000_000n,
18
- },
19
- },
20
- Base: {
21
- attenuatedCttpBridgeAddresses: [
22
- '0xB6615B2662b35fc3533F8479002e62D0523341De',
23
- ],
24
- cctpTokenMessengerAddress: '0x1682Ae6375C4E4A97e4B583BC394c861A46D8962',
25
- chainId: 8453,
26
- // TODO confirm confirmations and rateLimits
27
- confirmations: 2,
28
- rateLimits: {
29
- blockWindow: 20_000_000_000n,
30
- blockWindowSize: 10,
31
- tx: 10_000_000_000n,
32
- },
33
- },
34
- Ethereum: {
35
- attenuatedCttpBridgeAddresses: [
36
- '0xBC8552339dA68EB65C8b88B414B5854E0E366cFc',
37
- ],
38
- cctpTokenMessengerAddress: '0xBd3fa81B58Ba92a82136038B25aDec7066af3155',
39
- chainId: 1,
40
- // TODO confirm confirmations and rateLimits
41
- confirmations: 2,
42
- rateLimits: {
43
- blockWindow: 20_000_000_000n,
44
- blockWindowSize: 10,
45
- tx: 10_000_000_000n,
46
- },
47
- },
48
- Optimism: {
49
- attenuatedCttpBridgeAddresses: [
50
- '0x48C5417ED570928eC85D5e3AD4e7E0EeD7dB1E2A',
51
- ],
52
- cctpTokenMessengerAddress: '0x2B4069517957735bE00ceE0fadAE88a26365528f',
53
- chainId: 10,
54
- // TODO confirm confirmations and rateLimits
55
- confirmations: 2,
56
- rateLimits: {
57
- blockWindow: 20_000_000_000n,
58
- blockWindowSize: 10,
59
- tx: 10_000_000_000n,
60
- },
61
- },
62
- Polygon: {
63
- attenuatedCttpBridgeAddresses: [
64
- '0x32cb9574650AFF312c80edc4B4343Ff5500767cA',
65
- ],
66
- cctpTokenMessengerAddress: '0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE',
67
- chainId: 137,
68
- // TODO confirm confirmations and rateLimits
69
- confirmations: 2,
70
- rateLimits: {
71
- blockWindow: 20_000_000_000n,
72
- blockWindowSize: 10,
73
- tx: 10_000_000_000n,
74
- },
75
- },
76
- },
77
- TESTNET: {
78
- // Arbitrum Sepolia
79
- Arbitrum: {
80
- attenuatedCttpBridgeAddresses: ['0xTODO'],
81
- cctpTokenMessengerAddress: '0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5',
82
- chainId: 421614,
83
- confirmations: 2,
84
- rateLimits: {
85
- blockWindow: 20_000_000_000n,
86
- blockWindowSize: 10,
87
- tx: 10_000_000_000n,
88
- },
89
- },
90
- // Base Sepolia
91
- Base: {
92
- attenuatedCttpBridgeAddresses: ['0xTODO'],
93
- cctpTokenMessengerAddress: '0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5',
94
- chainId: 84532,
95
- confirmations: 2,
96
- rateLimits: {
97
- blockWindow: 20_000_000_000n,
98
- blockWindowSize: 10,
99
- tx: 10_000_000_000n,
100
- },
101
- },
102
- // Ethereum Sepolia
103
- Ethereum: {
104
- attenuatedCttpBridgeAddresses: ['0xTODO'],
105
- cctpTokenMessengerAddress: '0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5',
106
- chainId: 11155111,
107
- confirmations: 2,
108
- rateLimits: {
109
- blockWindow: 20_000_000_000n,
110
- blockWindowSize: 10,
111
- tx: 10_000_000_000n,
112
- },
113
- },
114
- // OP Sepolia
115
- Optimism: {
116
- attenuatedCttpBridgeAddresses: ['0xTODO'],
117
- cctpTokenMessengerAddress: '0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5',
118
- chainId: 11155420,
119
- confirmations: 2,
120
- rateLimits: {
121
- blockWindow: 20_000_000_000n,
122
- blockWindowSize: 10,
123
- tx: 10_000_000_000n,
124
- },
125
- },
126
- // Polygon PoS Amoy
127
- Polygon: {
128
- attenuatedCttpBridgeAddresses: ['0xTODO'],
129
- cctpTokenMessengerAddress: '0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5',
130
- chainId: 80002,
131
- confirmations: 2,
132
- rateLimits: {
133
- blockWindow: 20_000_000_000n,
134
- blockWindowSize: 10,
135
- tx: 10_000_000_000n,
136
- },
137
- },
138
- },
139
- });
140
- harden(ChainPolicies);
@@ -1,73 +0,0 @@
1
- import { deeplyFulfilledObject, makeTracer, objectMap } from '@agoric/internal';
2
- import { Fail } from '@endo/errors';
3
- import { E } from '@endo/eventual-send';
4
- import { makeMarshal } from '@endo/marshal';
5
-
6
- const trace = makeTracer('FUCoreEval');
7
-
8
- /**
9
- * @import {Brand, DepositFacet} from '@agoric/ertp';
10
- * @import {FastUSDCKit} from '../start-fast-usdc.core.js'
11
- * @import {FeedPolicy} from '../types.js'
12
- */
13
-
14
- export const FEED_POLICY = 'feedPolicy';
15
- export const marshalData = makeMarshal(_val => Fail`data only`);
16
-
17
- /**
18
- * @param {ERef<StorageNode>} node
19
- * @param {FeedPolicy} policy
20
- */
21
- export const publishFeedPolicy = async (node, policy) => {
22
- const feedPolicy = E(node).makeChildNode(FEED_POLICY);
23
- const value = marshalData.toCapData(policy);
24
- await E(feedPolicy).setValue(JSON.stringify(value));
25
- };
26
-
27
- /**
28
- * @param {object} powers
29
- * @param {FastUSDCKit['creatorFacet']} powers.creatorFacet
30
- * @param {BootstrapPowers['consume']['namesByAddress']} powers.namesByAddress
31
- * @param {Record<string, string>} oracles
32
- */
33
- export const inviteOracles = async (
34
- { creatorFacet, namesByAddress },
35
- oracles,
36
- ) => {
37
- const oracleDepositFacets = await deeplyFulfilledObject(
38
- objectMap(
39
- oracles,
40
- /** @type {(address: string) => Promise<DepositFacet>} */
41
- address => E(namesByAddress).lookup(address, 'depositFacet'),
42
- ),
43
- );
44
- await Promise.all(
45
- Object.entries(oracleDepositFacets).map(async ([name, depositFacet]) => {
46
- const address = oracles[name];
47
- trace('making invitation for', name, address);
48
- const toWatch = await E(creatorFacet).makeOperatorInvitation(address);
49
-
50
- const amt = await E(depositFacet).receive(toWatch);
51
- trace('sent', amt, 'to', name);
52
- }),
53
- );
54
- };
55
-
56
- const BOARD_AUX = 'boardAux';
57
- /**
58
- * @param {Brand} brand
59
- * @param {Pick<BootstrapPowers['consume'], 'board' | 'chainStorage'>} powers
60
- */
61
- export const publishDisplayInfo = async (brand, { board, chainStorage }) => {
62
- // chainStorage type includes undefined, which doesn't apply here.
63
- // @ts-expect-error UNTIL https://github.com/Agoric/agoric-sdk/issues/8247
64
- const boardAux = E(chainStorage).makeChildNode(BOARD_AUX);
65
- const [id, displayInfo, allegedName] = await Promise.all([
66
- E(board).getId(brand),
67
- E(brand).getDisplayInfo(),
68
- E(brand).getAllegedName(),
69
- ]);
70
- const node = E(boardAux).makeChildNode(id);
71
- const aux = marshalData.toCapData(harden({ allegedName, displayInfo }));
72
- await E(node).setValue(JSON.stringify(aux));
73
- };
File without changes
File without changes
File without changes
File without changes
File without changes