@agoric/inter-protocol 0.16.2-dev-5dc325b.0 → 0.16.2-getting-started-dev-d127d1d.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/CHANGELOG.md +1057 -0
- package/package.json +30 -37
- package/scripts/add-collateral-core.js +112 -0
- package/scripts/build-bundles.js +21 -5
- package/scripts/deploy-contracts.js +100 -0
- package/scripts/init-core.js +198 -0
- package/scripts/invite-committee-core.js +42 -0
- package/scripts/manual-price-feed.js +117 -0
- package/scripts/price-feed-core.js +104 -0
- package/scripts/start-local-chain.sh +84 -0
- package/src/auction/auctionBook.js +59 -74
- package/src/auction/auctioneer.js +44 -56
- package/src/auction/offerBook.js +11 -12
- package/src/auction/params.js +5 -3
- package/src/auction/scheduleMath.js +13 -13
- package/src/auction/scheduler.js +39 -47
- package/src/auction/sortedOffers.js +7 -8
- package/src/auction/util.js +4 -4
- package/src/clientSupport.js +96 -154
- package/src/contractSupport.js +5 -5
- package/src/econCommitteeCharter.js +17 -18
- package/src/feeDistributor.js +33 -34
- package/src/interest.js +14 -20
- package/src/price/README.md +0 -13
- package/src/price/fluxAggregatorContract.js +53 -59
- package/src/price/fluxAggregatorKit.js +33 -48
- package/src/price/priceOracleKit.js +13 -11
- package/src/price/roundsManager.js +64 -52
- package/src/proposals/addAssetToVault.js +36 -170
- package/src/proposals/committee-proposal.js +27 -21
- package/src/proposals/core-proposal.js +7 -7
- package/src/proposals/econ-behaviors.js +32 -57
- package/src/proposals/price-feed-proposal.js +36 -71
- package/src/proposals/startEconCommittee.js +1 -1
- package/src/proposals/startPSM.js +22 -32
- package/src/proposals/utils.js +7 -32
- package/src/psm/psm.js +63 -69
- package/src/reserve/assetReserve.js +18 -27
- package/src/reserve/assetReserveKit.js +22 -14
- package/src/typeGuards.js +13 -0
- package/src/vaultFactory/liquidation.js +17 -30
- package/src/vaultFactory/math.js +9 -8
- package/src/vaultFactory/orderedVaultStore.js +9 -6
- package/src/vaultFactory/params.js +19 -25
- package/src/vaultFactory/prioritizedVaults.js +2 -2
- package/src/vaultFactory/proceeds.js +18 -24
- package/src/vaultFactory/storeUtils.js +12 -8
- package/src/vaultFactory/type-imports.js +1 -1
- package/src/vaultFactory/types.js +28 -38
- package/src/vaultFactory/vault.js +89 -88
- package/src/vaultFactory/vaultDirector.js +44 -35
- package/src/vaultFactory/vaultFactory.js +26 -33
- package/src/vaultFactory/vaultHolder.js +13 -8
- package/src/vaultFactory/vaultKit.js +2 -3
- package/src/vaultFactory/vaultManager.js +120 -138
- package/src/auction/auctionBook.d.ts +0 -83
- package/src/auction/auctionBook.d.ts.map +0 -1
- package/src/auction/auctioneer.d.ts +0 -75
- package/src/auction/auctioneer.d.ts.map +0 -1
- package/src/auction/offerBook.d.ts +0 -72
- package/src/auction/offerBook.d.ts.map +0 -1
- package/src/auction/params.d.ts +0 -142
- package/src/auction/params.d.ts.map +0 -1
- package/src/auction/scheduleMath.d.ts +0 -4
- package/src/auction/scheduleMath.d.ts.map +0 -1
- package/src/auction/scheduler.d.ts +0 -49
- package/src/auction/scheduler.d.ts.map +0 -1
- package/src/auction/sortedOffers.d.ts +0 -8
- package/src/auction/sortedOffers.d.ts.map +0 -1
- package/src/auction/util.d.ts +0 -30
- package/src/auction/util.d.ts.map +0 -1
- package/src/clientSupport.d.ts +0 -167
- package/src/clientSupport.d.ts.map +0 -1
- package/src/collectFees.d.ts +0 -2
- package/src/collectFees.d.ts.map +0 -1
- package/src/contractSupport.d.ts +0 -33
- package/src/contractSupport.d.ts.map +0 -1
- package/src/econCommitteeCharter.d.ts +0 -41
- package/src/econCommitteeCharter.d.ts.map +0 -1
- package/src/feeDistributor.d.ts +0 -212
- package/src/feeDistributor.d.ts.map +0 -1
- package/src/index.d.ts +0 -2
- package/src/index.d.ts.map +0 -1
- package/src/interest-math.d.ts +0 -3
- package/src/interest-math.d.ts.map +0 -1
- package/src/interest.d.ts +0 -29
- package/src/interest.d.ts.map +0 -1
- package/src/price/fluxAggregatorContract.d.ts +0 -112
- package/src/price/fluxAggregatorContract.d.ts.map +0 -1
- package/src/price/fluxAggregatorKit.d.ts +0 -155
- package/src/price/fluxAggregatorKit.d.ts.map +0 -1
- package/src/price/priceOracleKit.d.ts +0 -52
- package/src/price/priceOracleKit.d.ts.map +0 -1
- package/src/price/roundsManager.d.ts +0 -330
- package/src/price/roundsManager.d.ts.map +0 -1
- package/src/proposals/addAssetToVault.d.ts +0 -160
- package/src/proposals/addAssetToVault.d.ts.map +0 -1
- package/src/proposals/committee-proposal.d.ts +0 -113
- package/src/proposals/committee-proposal.d.ts.map +0 -1
- package/src/proposals/core-proposal.d.ts +0 -149
- package/src/proposals/core-proposal.d.ts.map +0 -1
- package/src/proposals/econ-behaviors.d.ts +0 -201
- package/src/proposals/econ-behaviors.d.ts.map +0 -1
- package/src/proposals/price-feed-proposal.d.ts +0 -82
- package/src/proposals/price-feed-proposal.d.ts.map +0 -1
- package/src/proposals/startEconCommittee.d.ts +0 -34
- package/src/proposals/startEconCommittee.d.ts.map +0 -1
- package/src/proposals/startPSM.d.ts +0 -61
- package/src/proposals/startPSM.d.ts.map +0 -1
- package/src/proposals/utils.d.ts +0 -17
- package/src/proposals/utils.d.ts.map +0 -1
- package/src/provisionPool.d.ts +0 -165
- package/src/provisionPool.d.ts.map +0 -1
- package/src/provisionPool.js +0 -119
- package/src/provisionPoolKit.d.ts +0 -379
- package/src/provisionPoolKit.d.ts.map +0 -1
- package/src/provisionPoolKit.js +0 -461
- package/src/psm/psm.d.ts +0 -178
- package/src/psm/psm.d.ts.map +0 -1
- package/src/psm/types.d.ts +0 -2
- package/src/psm/types.d.ts.map +0 -1
- package/src/reserve/assetReserve.d.ts +0 -44
- package/src/reserve/assetReserve.d.ts.map +0 -1
- package/src/reserve/assetReserveKit.d.ts +0 -114
- package/src/reserve/assetReserveKit.d.ts.map +0 -1
- package/src/reserve/params.d.ts +0 -10
- package/src/reserve/params.d.ts.map +0 -1
- package/src/tokens.d.ts +0 -3
- package/src/tokens.d.ts.map +0 -1
- package/src/tokens.js +0 -5
- package/src/vaultFactory/burn.d.ts +0 -2
- package/src/vaultFactory/burn.d.ts.map +0 -1
- package/src/vaultFactory/liquidation.d.ts +0 -24
- package/src/vaultFactory/liquidation.d.ts.map +0 -1
- package/src/vaultFactory/math.d.ts +0 -10
- package/src/vaultFactory/math.d.ts.map +0 -1
- package/src/vaultFactory/orderedVaultStore.d.ts +0 -94
- package/src/vaultFactory/orderedVaultStore.d.ts.map +0 -1
- package/src/vaultFactory/params.d.ts +0 -159
- package/src/vaultFactory/params.d.ts.map +0 -1
- package/src/vaultFactory/prioritizedVaults.d.ts +0 -279
- package/src/vaultFactory/prioritizedVaults.d.ts.map +0 -1
- package/src/vaultFactory/proceeds.d.ts +0 -34
- package/src/vaultFactory/proceeds.d.ts.map +0 -1
- package/src/vaultFactory/storeUtils.d.ts +0 -25
- package/src/vaultFactory/storeUtils.d.ts.map +0 -1
- package/src/vaultFactory/type-imports.d.ts +0 -2
- package/src/vaultFactory/type-imports.d.ts.map +0 -1
- package/src/vaultFactory/types.d.ts +0 -137
- package/src/vaultFactory/types.d.ts.map +0 -1
- package/src/vaultFactory/vault.d.ts +0 -529
- package/src/vaultFactory/vault.d.ts.map +0 -1
- package/src/vaultFactory/vaultDirector.d.ts +0 -560
- package/src/vaultFactory/vaultDirector.d.ts.map +0 -1
- package/src/vaultFactory/vaultFactory.d.ts +0 -162
- package/src/vaultFactory/vaultFactory.d.ts.map +0 -1
- package/src/vaultFactory/vaultHolder.d.ts +0 -201
- package/src/vaultFactory/vaultHolder.d.ts.map +0 -1
- package/src/vaultFactory/vaultKit.d.ts +0 -32
- package/src/vaultFactory/vaultKit.d.ts.map +0 -1
- package/src/vaultFactory/vaultManager.d.ts +0 -554
- package/src/vaultFactory/vaultManager.d.ts.map +0 -1
|
@@ -4,14 +4,14 @@ import { reserveThenDeposit } from './utils.js';
|
|
|
4
4
|
|
|
5
5
|
const { values } = Object;
|
|
6
6
|
|
|
7
|
-
/** @type {<X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
|
|
7
|
+
/** @type { <X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
|
|
8
8
|
const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]);
|
|
9
9
|
|
|
10
10
|
const EC_HIGH_PRIORITY_SENDERS_NAMESPACE = 'economicCommittee';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
14
|
-
* @param {{ options: { voterAddresses: Record<string, string> }
|
|
14
|
+
* @param {{ options: { voterAddresses: Record<string, string> }}} param1
|
|
15
15
|
*/
|
|
16
16
|
export const inviteCommitteeMembers = async (
|
|
17
17
|
{
|
|
@@ -26,14 +26,18 @@ export const inviteCommitteeMembers = async (
|
|
|
26
26
|
|
|
27
27
|
const highPrioritySendersManager = await consume.highPrioritySendersManager;
|
|
28
28
|
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* @param {[string, Promise<Invitation>][]} addrInvitations
|
|
31
|
+
*/
|
|
30
32
|
const distributeInvitations = async addrInvitations => {
|
|
31
33
|
await Promise.all(
|
|
32
34
|
addrInvitations.map(async ([addr, invitationP]) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
await reserveThenDeposit(
|
|
36
|
+
`econ committee member ${addr}`,
|
|
37
|
+
namesByAddressAdmin,
|
|
38
|
+
addr,
|
|
39
|
+
[invitationP],
|
|
40
|
+
);
|
|
37
41
|
if (highPrioritySendersManager) {
|
|
38
42
|
await E(highPrioritySendersManager).add(
|
|
39
43
|
EC_HIGH_PRIORITY_SENDERS_NAMESPACE,
|
|
@@ -44,14 +48,14 @@ export const inviteCommitteeMembers = async (
|
|
|
44
48
|
);
|
|
45
49
|
};
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
// Don't block bootstrap on it.
|
|
49
|
-
void distributeInvitations(zip(values(voterAddresses), invitations));
|
|
51
|
+
await distributeInvitations(zip(values(voterAddresses), invitations));
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
harden(inviteCommitteeMembers);
|
|
53
55
|
|
|
54
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
58
|
+
*/
|
|
55
59
|
export const startEconCharter = async ({
|
|
56
60
|
consume: { zoe },
|
|
57
61
|
produce: { econCharterKit },
|
|
@@ -127,7 +131,7 @@ harden(addGovernorsToEconCharter);
|
|
|
127
131
|
|
|
128
132
|
/**
|
|
129
133
|
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
130
|
-
* @param {{ options: { voterAddresses: Record<string, string> }
|
|
134
|
+
* @param {{ options: { voterAddresses: Record<string, string> }}} param1
|
|
131
135
|
*/
|
|
132
136
|
export const inviteToEconCharter = async (
|
|
133
137
|
{ consume: { namesByAddressAdmin, econCharterKit } },
|
|
@@ -135,15 +139,15 @@ export const inviteToEconCharter = async (
|
|
|
135
139
|
) => {
|
|
136
140
|
const { creatorFacet } = E.get(econCharterKit);
|
|
137
141
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
E(creatorFacet).makeCharterMemberInvitation(),
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
await Promise.all(
|
|
143
|
+
values(voterAddresses).map(async addr =>
|
|
144
|
+
reserveThenDeposit(
|
|
145
|
+
`econ charter member ${addr}`,
|
|
146
|
+
namesByAddressAdmin,
|
|
147
|
+
addr,
|
|
148
|
+
[E(creatorFacet).makeCharterMemberInvitation()],
|
|
149
|
+
),
|
|
150
|
+
),
|
|
147
151
|
);
|
|
148
152
|
};
|
|
149
153
|
|
|
@@ -176,6 +180,8 @@ export const getManifestForInviteCommittee = async (
|
|
|
176
180
|
[addGovernorsToEconCharter.name]: {
|
|
177
181
|
consume: {
|
|
178
182
|
auctioneerKit: t,
|
|
183
|
+
reserveGovernorCreatorFacet: t,
|
|
184
|
+
vaultFactoryGovernorCreator: t,
|
|
179
185
|
econCharterKit: t,
|
|
180
186
|
zoe: t,
|
|
181
187
|
agoricNames: t,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
-
import { Stable } from '@agoric/
|
|
3
|
+
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
4
4
|
import * as econBehaviors from './econ-behaviors.js';
|
|
5
5
|
import { ECON_COMMITTEE_MANIFEST } from './startEconCommittee.js';
|
|
6
6
|
|
|
@@ -15,7 +15,9 @@ export * from './startEconCommittee.js'; // eslint-disable-line import/export
|
|
|
15
15
|
// require updating a lot of tests. So for now, we just
|
|
16
16
|
// grab the kits afterward and store them.
|
|
17
17
|
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* @param {import('./econ-behaviors.js').EconomyBootstrapPowers} powers
|
|
20
|
+
*/
|
|
19
21
|
export const storeInterContractStartKits = async ({
|
|
20
22
|
consume: {
|
|
21
23
|
contractKits,
|
|
@@ -29,15 +31,13 @@ export const storeInterContractStartKits = async ({
|
|
|
29
31
|
},
|
|
30
32
|
}) => {
|
|
31
33
|
/**
|
|
32
|
-
* @param {Promise<MapStore<string, {
|
|
33
|
-
* @param {Promise<{
|
|
34
|
+
* @param {Promise<MapStore<string, {instance: Instance}>>} storeP
|
|
35
|
+
* @param {Promise<{instance: Instance}>[]} kitPs
|
|
34
36
|
*/
|
|
35
37
|
const storeAll = async (storeP, kitPs) => {
|
|
36
38
|
const store = await storeP;
|
|
37
39
|
const kits = await Promise.all(kitPs);
|
|
38
|
-
|
|
39
|
-
store.init(kit.instance, kit);
|
|
40
|
-
}
|
|
40
|
+
kits.forEach(kit => store.init(kit.instance, kit));
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
await storeAll(contractKits, [
|
|
@@ -6,9 +6,11 @@ import { AmountMath } from '@agoric/ertp';
|
|
|
6
6
|
import '@agoric/governance/exported.js';
|
|
7
7
|
import { deeplyFulfilledObject, makeTracer } from '@agoric/internal';
|
|
8
8
|
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
|
|
9
|
+
import '@agoric/vats/exported.js';
|
|
10
|
+
import '@agoric/vats/src/core/types.js';
|
|
11
|
+
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
9
12
|
import { E } from '@endo/far';
|
|
10
13
|
import { makeScalarBigMapStore } from '@agoric/vat-data';
|
|
11
|
-
import { Stable } from '@agoric/internal/src/tokens.js';
|
|
12
14
|
import { makeGovernedTerms as makeGovernedATerms } from '../auction/params.js';
|
|
13
15
|
import { makeReserveTerms } from '../reserve/params.js';
|
|
14
16
|
import { makeGovernedTerms as makeGovernedVFTerms } from '../vaultFactory/params.js';
|
|
@@ -22,9 +24,7 @@ export const SECONDS_PER_WEEK = 7n * SECONDS_PER_DAY;
|
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* @typedef {import('../vaultFactory/vaultFactory.js').VaultFactoryContract['publicFacet']} VaultFactoryPublicFacet
|
|
25
|
-
*
|
|
26
27
|
* @typedef {import('../auction/auctioneer.js').AuctioneerPublicFacet} AuctioneerPublicFacet
|
|
27
|
-
*
|
|
28
28
|
* @typedef {import('../auction/auctioneer.js').AuctioneerCreatorFacet} AuctioneerCreatorFacet
|
|
29
29
|
*/
|
|
30
30
|
|
|
@@ -33,65 +33,43 @@ export const SECONDS_PER_WEEK = 7n * SECONDS_PER_DAY;
|
|
|
33
33
|
* @property {string} label
|
|
34
34
|
* @property {Instance} psm
|
|
35
35
|
* @property {Instance} psmGovernor
|
|
36
|
-
* @property {Awaited<
|
|
37
|
-
*
|
|
38
|
-
* Awaited<
|
|
39
|
-
* ReturnType<import('../psm/psm.js')['start']>
|
|
40
|
-
* >['creatorFacet']['getLimitedCreatorFacet']
|
|
41
|
-
* >
|
|
42
|
-
* >} psmCreatorFacet
|
|
43
|
-
* @property {GovernorCreatorFacet<import('../../src/psm/psm.js')['start']>} psmGovernorCreatorFacet
|
|
36
|
+
* @property {Awaited<ReturnType<Awaited<ReturnType<import('../psm/psm.js')['prepare']>>['creatorFacet']['getLimitedCreatorFacet']>>} psmCreatorFacet
|
|
37
|
+
* @property {GovernorCreatorFacet<import('../../src/psm/psm.js')['prepare']>} psmGovernorCreatorFacet
|
|
44
38
|
* @property {AdminFacet} psmAdminFacet
|
|
45
39
|
*/
|
|
46
40
|
|
|
47
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {GovernanceFacetKit<import('../auction/auctioneer.js').start>} AuctioneerKit
|
|
43
|
+
*/
|
|
48
44
|
|
|
49
45
|
/**
|
|
50
|
-
* @typedef {WellKnownSpaces & ChainBootstrapSpace & EconomyBootstrapSpace
|
|
51
|
-
*
|
|
46
|
+
* @typedef { WellKnownSpaces & ChainBootstrapSpace & EconomyBootstrapSpace
|
|
47
|
+
* } EconomyBootstrapPowers
|
|
52
48
|
* @typedef {PromiseSpaceOf<{
|
|
53
|
-
* economicCommitteeKit: CommitteeStartResult
|
|
54
|
-
* economicCommitteeCreatorFacet: import('@agoric/governance/src/committee.js').CommitteeElectorateCreatorFacet
|
|
55
|
-
* feeDistributorKit: StartedInstanceKit<
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* econCharterKit: EconCharterStartResult;
|
|
65
|
-
* reserveKit: GovernanceFacetKit<
|
|
66
|
-
* import('../reserve/assetReserve.js')['start']
|
|
67
|
-
* >;
|
|
68
|
-
* vaultFactoryKit: GovernanceFacetKit<
|
|
69
|
-
* import('../vaultFactory/vaultFactory.js')['start']
|
|
70
|
-
* >;
|
|
71
|
-
* auctioneerKit: AuctioneerKit;
|
|
72
|
-
* minInitialDebt: NatValue;
|
|
49
|
+
* economicCommitteeKit: CommitteeStartResult,
|
|
50
|
+
* economicCommitteeCreatorFacet: import('@agoric/governance/src/committee.js').CommitteeElectorateCreatorFacet,
|
|
51
|
+
* feeDistributorKit: StartedInstanceKit<typeof import('../feeDistributor.js').start>,
|
|
52
|
+
* periodicFeeCollectors: MapStore<number, import('../feeDistributor.js').PeriodicFeeCollector>,
|
|
53
|
+
* psmKit: MapStore<Brand, PSMKit>,
|
|
54
|
+
* anchorBalancePayments: MapStore<Brand, Payment<'nat'>>,
|
|
55
|
+
* econCharterKit: EconCharterStartResult,
|
|
56
|
+
* reserveKit: GovernanceFacetKit<import('../reserve/assetReserve.js')['prepare']>,
|
|
57
|
+
* vaultFactoryKit: GovernanceFacetKit<import('../vaultFactory/vaultFactory.js')['prepare']>,
|
|
58
|
+
* auctioneerKit: AuctioneerKit,
|
|
59
|
+
* minInitialDebt: NatValue,
|
|
73
60
|
* }>} EconomyBootstrapSpace
|
|
74
61
|
*/
|
|
75
62
|
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
* import('../econCommitteeCharter')['start']
|
|
79
|
-
* >} EconCharterStartResult
|
|
80
|
-
*/
|
|
81
|
-
/**
|
|
82
|
-
* @typedef {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<
|
|
83
|
-
* import('@agoric/governance/src/committee.js')['start']
|
|
84
|
-
* >} CommitteeStartResult
|
|
85
|
-
*/
|
|
63
|
+
/** @typedef {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<import('../econCommitteeCharter')['prepare']>} EconCharterStartResult */
|
|
64
|
+
/** @typedef {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<import('@agoric/governance/src/committee.js')['prepare']>} CommitteeStartResult */
|
|
86
65
|
|
|
87
66
|
/**
|
|
88
67
|
* @file A collection of productions, each of which declares inputs and outputs.
|
|
89
|
-
*
|
|
90
|
-
* vat config.
|
|
68
|
+
* Each function is passed a set of powers for reading from and writing to the vat config.
|
|
91
69
|
*
|
|
92
|
-
*
|
|
70
|
+
* Each of the things they produce they're responsible for resolving or setting.
|
|
93
71
|
*
|
|
94
|
-
*
|
|
72
|
+
* In production called by @agoric/vats to bootstrap.
|
|
95
73
|
*/
|
|
96
74
|
|
|
97
75
|
/** @param {EconomyBootstrapPowers} powers */
|
|
@@ -323,11 +301,7 @@ export const startVaultFactory = async (
|
|
|
323
301
|
}),
|
|
324
302
|
);
|
|
325
303
|
|
|
326
|
-
/**
|
|
327
|
-
* @type {GovernorStartedInstallationKit<
|
|
328
|
-
* typeof vaultFactoryInstallation
|
|
329
|
-
* >}
|
|
330
|
-
*/
|
|
304
|
+
/** @type {GovernorStartedInstallationKit<typeof vaultFactoryInstallation>} */
|
|
331
305
|
const g = await E(consume.zoe).startInstance(
|
|
332
306
|
contractGovernorInstallation,
|
|
333
307
|
undefined,
|
|
@@ -376,8 +350,8 @@ export const startVaultFactory = async (
|
|
|
376
350
|
};
|
|
377
351
|
|
|
378
352
|
/**
|
|
379
|
-
* Grant access to the VaultFactory creatorFacet
|
|
380
|
-
* address.
|
|
353
|
+
* Grant access to the VaultFactory creatorFacet
|
|
354
|
+
* to up to one user based on address.
|
|
381
355
|
*
|
|
382
356
|
* @param {EconomyBootstrapPowers} powers
|
|
383
357
|
* @param {object} [root0]
|
|
@@ -463,8 +437,9 @@ export const startRewardDistributor = async ({
|
|
|
463
437
|
|
|
464
438
|
/**
|
|
465
439
|
* @type {Awaited<
|
|
466
|
-
* ReturnType<typeof import('../feeDistributor.js').makeFeeDistributor
|
|
467
|
-
*
|
|
440
|
+
* ReturnType<typeof import('../feeDistributor.js').makeFeeDistributor>>
|
|
441
|
+
* & { adminFacet: AdminFacet, instance: Instance }
|
|
442
|
+
* }
|
|
468
443
|
*/
|
|
469
444
|
const instanceKit = await E(zoe).startInstance(
|
|
470
445
|
feeDistributor,
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
// @ts-nocheck -- lots of type errors. low prio b/c proposals are like scripts
|
|
2
|
-
import {
|
|
2
|
+
import { E } from '@endo/far';
|
|
3
3
|
import {
|
|
4
|
-
assertPathSegment,
|
|
5
4
|
makeStorageNodeChild,
|
|
5
|
+
assertPathSegment,
|
|
6
6
|
} from '@agoric/internal/src/lib-chainStorage.js';
|
|
7
|
-
import {
|
|
7
|
+
import { makeTracer } from '@agoric/internal';
|
|
8
8
|
|
|
9
9
|
import { unitAmount } from '@agoric/zoe/src/contractSupport/priceQuote.js';
|
|
10
|
-
import {
|
|
11
|
-
oracleBrandFeedName,
|
|
12
|
-
reserveThenDeposit,
|
|
13
|
-
reserveThenGetNames,
|
|
14
|
-
} from './utils.js';
|
|
15
|
-
|
|
16
|
-
// backwards compatibility
|
|
17
|
-
export { oracleBrandFeedName as instanceNameFor };
|
|
10
|
+
import { reserveThenDeposit, reserveThenGetNames } from './utils.js';
|
|
18
11
|
|
|
19
12
|
const trace = makeTracer('RunPriceFeed', true);
|
|
20
13
|
|
|
@@ -27,12 +20,12 @@ const sanitizePathSegment = name => {
|
|
|
27
20
|
|
|
28
21
|
/**
|
|
29
22
|
* @typedef {{
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
23
|
+
* brandIn?: ERef<Brand<'nat'> | undefined>,
|
|
24
|
+
* brandOut?: ERef<Brand<'nat'> | undefined>,
|
|
25
|
+
* IN_BRAND_NAME: string,
|
|
26
|
+
* IN_BRAND_DECIMALS: string,
|
|
27
|
+
* OUT_BRAND_NAME: string,
|
|
28
|
+
* OUT_BRAND_DECIMALS: string,
|
|
36
29
|
* }} PriceFeedOptions
|
|
37
30
|
*/
|
|
38
31
|
|
|
@@ -40,7 +33,7 @@ const sanitizePathSegment = name => {
|
|
|
40
33
|
* Create inert brands (no mint or issuer) referred to by price oracles.
|
|
41
34
|
*
|
|
42
35
|
* @param {ChainBootstrapSpace & NamedVatPowers} space
|
|
43
|
-
* @param {{
|
|
36
|
+
* @param {{options: {priceFeedOptions: PriceFeedOptions}}} opt
|
|
44
37
|
* @returns {Promise<[Brand<'nat'>, Brand<'nat'>]>}
|
|
45
38
|
*/
|
|
46
39
|
export const ensureOracleBrands = async (
|
|
@@ -69,6 +62,7 @@ export const ensureOracleBrands = async (
|
|
|
69
62
|
let b = await brand;
|
|
70
63
|
if (!b) {
|
|
71
64
|
// not 1st await
|
|
65
|
+
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
72
66
|
b = await E(agoricNames).provideInertBrand(
|
|
73
67
|
name,
|
|
74
68
|
harden({ decimalPlaces: parseInt(decimals, 10) }),
|
|
@@ -85,17 +79,7 @@ export const ensureOracleBrands = async (
|
|
|
85
79
|
|
|
86
80
|
/**
|
|
87
81
|
* @param {ChainBootstrapSpace} powers
|
|
88
|
-
* @param {{
|
|
89
|
-
* options: {
|
|
90
|
-
* priceFeedOptions: {
|
|
91
|
-
* AGORIC_INSTANCE_NAME: string;
|
|
92
|
-
* oracleAddresses: string[];
|
|
93
|
-
* contractTerms: import('@agoric/inter-protocol/src/price/fluxAggregatorKit.js').ChainlinkConfig;
|
|
94
|
-
* IN_BRAND_NAME: string;
|
|
95
|
-
* OUT_BRAND_NAME: string;
|
|
96
|
-
* };
|
|
97
|
-
* };
|
|
98
|
-
* }} config
|
|
82
|
+
* @param {{options: {priceFeedOptions: {AGORIC_INSTANCE_NAME: string, oracleAddresses: string[], contractTerms: import('@agoric/inter-protocol/src/price/fluxAggregatorKit.js').ChainlinkConfig, IN_BRAND_NAME: string, OUT_BRAND_NAME: string}}}} config
|
|
99
83
|
*/
|
|
100
84
|
export const createPriceFeed = async (
|
|
101
85
|
{
|
|
@@ -112,7 +96,6 @@ export const createPriceFeed = async (
|
|
|
112
96
|
priceAuthorityAdmin,
|
|
113
97
|
startGovernedUpgradable,
|
|
114
98
|
},
|
|
115
|
-
instance: { produce: produceInstance },
|
|
116
99
|
},
|
|
117
100
|
{
|
|
118
101
|
options: {
|
|
@@ -134,17 +117,9 @@ export const createPriceFeed = async (
|
|
|
134
117
|
const timer = await chainTimerService;
|
|
135
118
|
|
|
136
119
|
/**
|
|
137
|
-
* Values come from economy-template.json, which at this writing had IN:ATOM,
|
|
138
|
-
* OUT:USD
|
|
120
|
+
* Values come from economy-template.json, which at this writing had IN:ATOM, OUT:USD
|
|
139
121
|
*
|
|
140
|
-
* @type {[
|
|
141
|
-
* [Brand<'nat'>, Brand<'nat'>],
|
|
142
|
-
* [
|
|
143
|
-
* Installation<
|
|
144
|
-
* import('@agoric/inter-protocol/src/price/fluxAggregatorContract.js')['start]
|
|
145
|
-
* >,
|
|
146
|
-
* ],
|
|
147
|
-
* ]}
|
|
122
|
+
* @type {[[Brand<'nat'>, Brand<'nat'>], [Installation<import('@agoric/inter-protocol/src/price/fluxAggregatorContract.js').prepare>]]}
|
|
148
123
|
*/
|
|
149
124
|
const [[brandIn, brandOut], [priceAggregator]] = await Promise.all([
|
|
150
125
|
reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('oracleBrand'), [
|
|
@@ -186,27 +161,11 @@ export const createPriceFeed = async (
|
|
|
186
161
|
installation: priceAggregator,
|
|
187
162
|
});
|
|
188
163
|
|
|
189
|
-
|
|
190
|
-
const forceReplace = true;
|
|
191
|
-
// Make sure this PA is registered before sharing the instance in agoricNames,
|
|
192
|
-
// which allows contracts that depend on the registry value to wait for it and
|
|
193
|
-
// prevent a race.
|
|
194
|
-
await E(priceAuthorityAdmin).registerPriceAuthority(
|
|
195
|
-
E(faKit.publicFacet).getPriceAuthority(),
|
|
196
|
-
brandIn,
|
|
197
|
-
brandOut,
|
|
198
|
-
forceReplace,
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
await E(E(agoricNamesAdmin).lookupAdmin('instance'))
|
|
164
|
+
E(E(agoricNamesAdmin).lookupAdmin('instance'))
|
|
202
165
|
.update(AGORIC_INSTANCE_NAME, faKit.instance)
|
|
203
166
|
.catch(err =>
|
|
204
167
|
console.error(`🚨 failed to update ${AGORIC_INSTANCE_NAME}`, err),
|
|
205
168
|
);
|
|
206
|
-
// being after the above awaits means that when this resolves, the consumer
|
|
207
|
-
// gets notified that the authority is in the registry and its instance is in
|
|
208
|
-
// agoricNames.
|
|
209
|
-
produceInstance[AGORIC_INSTANCE_NAME].resolve(faKit.instance);
|
|
210
169
|
|
|
211
170
|
E(E.get(econCharterKit).creatorFacet).addInstance(
|
|
212
171
|
faKit.instance,
|
|
@@ -215,6 +174,15 @@ export const createPriceFeed = async (
|
|
|
215
174
|
);
|
|
216
175
|
trace('registered', AGORIC_INSTANCE_NAME, faKit.instance);
|
|
217
176
|
|
|
177
|
+
// Publish price feed in home.priceAuthority.
|
|
178
|
+
const forceReplace = true;
|
|
179
|
+
void E(priceAuthorityAdmin).registerPriceAuthority(
|
|
180
|
+
E(faKit.publicFacet).getPriceAuthority(),
|
|
181
|
+
brandIn,
|
|
182
|
+
brandOut,
|
|
183
|
+
forceReplace,
|
|
184
|
+
);
|
|
185
|
+
|
|
218
186
|
/**
|
|
219
187
|
* Initialize a new oracle and send an invitation to administer it.
|
|
220
188
|
*
|
|
@@ -222,23 +190,22 @@ export const createPriceFeed = async (
|
|
|
222
190
|
*/
|
|
223
191
|
const addOracle = async addr => {
|
|
224
192
|
const invitation = await E(faKit.creatorFacet).makeOracleInvitation(addr);
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
193
|
+
await reserveThenDeposit(
|
|
194
|
+
`${AGORIC_INSTANCE_NAME} member ${addr}`,
|
|
195
|
+
namesByAddressAdmin,
|
|
196
|
+
addr,
|
|
197
|
+
[invitation],
|
|
198
|
+
);
|
|
229
199
|
};
|
|
230
200
|
|
|
231
201
|
trace('distributing invitations', oracleAddresses);
|
|
232
|
-
|
|
233
|
-
// Don't block bootstrap on it.
|
|
234
|
-
void Promise.all(oracleAddresses.map(addOracle));
|
|
202
|
+
await Promise.all(oracleAddresses.map(addOracle));
|
|
235
203
|
trace('createPriceFeed complete');
|
|
236
204
|
};
|
|
237
205
|
|
|
238
206
|
const t = 'priceFeed';
|
|
239
207
|
/**
|
|
240
|
-
* Add a price feed to a running chain, returning the manifest, installations,
|
|
241
|
-
* and options.
|
|
208
|
+
* Add a price feed to a running chain, returning the manifest, installations, and options.
|
|
242
209
|
*
|
|
243
210
|
* @param {object} utils
|
|
244
211
|
* @param {(ref: unknown) => Promise<unknown>} [utils.restoreRef]
|
|
@@ -256,16 +223,15 @@ export const getManifestForPriceFeed = async (
|
|
|
256
223
|
chainStorage: t,
|
|
257
224
|
chainTimerService: t,
|
|
258
225
|
client: t,
|
|
226
|
+
contractGovernor: t,
|
|
259
227
|
econCharterKit: t,
|
|
228
|
+
economicCommitteeCreatorFacet: t,
|
|
260
229
|
highPrioritySendersManager: t,
|
|
261
230
|
namesByAddressAdmin: t,
|
|
262
231
|
priceAuthority: t,
|
|
263
232
|
priceAuthorityAdmin: t,
|
|
264
233
|
startGovernedUpgradable: t,
|
|
265
234
|
},
|
|
266
|
-
instance: {
|
|
267
|
-
produce: t,
|
|
268
|
-
},
|
|
269
235
|
},
|
|
270
236
|
[ensureOracleBrands.name]: {
|
|
271
237
|
namedVat: {
|
|
@@ -277,7 +243,6 @@ export const getManifestForPriceFeed = async (
|
|
|
277
243
|
},
|
|
278
244
|
},
|
|
279
245
|
installations: {
|
|
280
|
-
// ??? will every eval of price-feed-proposal install priceAggregator ?
|
|
281
246
|
priceAggregator: restoreRef(priceFeedOptions.priceAggregatorRef),
|
|
282
247
|
},
|
|
283
248
|
options: {
|
|
@@ -338,7 +303,7 @@ export const startPriceFeeds = async (
|
|
|
338
303
|
{
|
|
339
304
|
options: {
|
|
340
305
|
priceFeedOptions: {
|
|
341
|
-
AGORIC_INSTANCE_NAME:
|
|
306
|
+
AGORIC_INSTANCE_NAME: `${inBrandName}-${outBrandName} price feed`,
|
|
342
307
|
contractTerms: {
|
|
343
308
|
minSubmissionCount: 2,
|
|
344
309
|
minSubmissionValue: 1,
|
|
@@ -22,7 +22,7 @@ const sanitizePathSegment = name => {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @param {import('./econ-behaviors').EconomyBootstrapPowers} powers
|
|
25
|
-
* @param {object} config
|
|
25
|
+
* @param {object} [config]
|
|
26
26
|
* @param {object} [config.options]
|
|
27
27
|
* @param {EconCommitteeOptions} [config.options.econCommitteeOptions]
|
|
28
28
|
*/
|
|
@@ -6,14 +6,14 @@ import { CONTRACT_ELECTORATE, ParamTypes } from '@agoric/governance';
|
|
|
6
6
|
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
|
|
7
7
|
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
|
|
8
8
|
import { E } from '@endo/far';
|
|
9
|
+
import { Stable } from '@agoric/vats/src/tokens.js';
|
|
9
10
|
import {
|
|
10
11
|
makeHistoryReviver,
|
|
11
12
|
makeBoardRemote,
|
|
12
13
|
slotToBoardRemote,
|
|
13
|
-
} from '@agoric/
|
|
14
|
+
} from '@agoric/vats/tools/board-utils.js';
|
|
14
15
|
import { deeplyFulfilledObject } from '@agoric/internal';
|
|
15
16
|
import { makeScalarBigMapStore } from '@agoric/vat-data';
|
|
16
|
-
import { Stable } from '@agoric/internal/src/tokens.js';
|
|
17
17
|
|
|
18
18
|
import { reserveThenGetNamePaths } from './utils.js';
|
|
19
19
|
|
|
@@ -35,13 +35,10 @@ export { inviteCommitteeMembers, startEconCharter, inviteToEconCharter };
|
|
|
35
35
|
const stablePsmKey = `published.psm.${Stable.symbol}`;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* @param {[key: string, value: string]
|
|
38
|
+
* @param {Array<[key: string, value: string]>} chainStorageEntries
|
|
39
39
|
* @param {string} keyword
|
|
40
|
-
* @param {{ minted: Brand<'nat'
|
|
41
|
-
* @returns {{
|
|
42
|
-
* metrics?: MetricsNotification;
|
|
43
|
-
* governance?: GovernanceSubscriptionState;
|
|
44
|
-
* }}
|
|
40
|
+
* @param {{ minted: Brand<'nat'>, anchor: Brand<'nat'> }} brands
|
|
41
|
+
* @returns {{ metrics?: MetricsNotification, governance?: GovernanceSubscriptionState }}
|
|
45
42
|
*/
|
|
46
43
|
const findOldPSMState = (chainStorageEntries, keyword, brands) => {
|
|
47
44
|
// In this reviver, object references are revived as boardIDs
|
|
@@ -83,7 +80,7 @@ const findOldPSMState = (chainStorageEntries, keyword, brands) => {
|
|
|
83
80
|
* @param {bigint} [config.WantMintedFeeBP]
|
|
84
81
|
* @param {bigint} [config.GiveMintedFeeBP]
|
|
85
82
|
* @param {bigint} [config.MINT_LIMIT]
|
|
86
|
-
* @param {{ anchorOptions?: AnchorOptions }} [config.options]
|
|
83
|
+
* @param {{ anchorOptions?: AnchorOptions } } [config.options]
|
|
87
84
|
*/
|
|
88
85
|
export const startPSM = async (
|
|
89
86
|
{
|
|
@@ -294,16 +291,16 @@ harden(startPSM);
|
|
|
294
291
|
*/
|
|
295
292
|
|
|
296
293
|
/**
|
|
297
|
-
* Make anchor issuer out of a Cosmos asset; presumably
|
|
298
|
-
* BankManager.
|
|
294
|
+
* Make anchor issuer out of a Cosmos asset; presumably
|
|
295
|
+
* USDC over IBC. Add it to BankManager.
|
|
299
296
|
*
|
|
300
|
-
* Also, if vatParameters shows an anchorPoolBalance for this asset,
|
|
301
|
-
* payment for that balance.
|
|
297
|
+
* Also, if vatParameters shows an anchorPoolBalance for this asset,
|
|
298
|
+
* mint a payment for that balance.
|
|
302
299
|
*
|
|
303
300
|
* TODO: address redundancy with publishInterchainAssetFromBank
|
|
304
301
|
*
|
|
305
302
|
* @param {EconomyBootstrapPowers & WellKnownSpaces & ChainStorageVatParams} powers
|
|
306
|
-
* @param {{
|
|
303
|
+
* @param {{options?: { anchorOptions?: AnchorOptions } }} [config]
|
|
307
304
|
*/
|
|
308
305
|
export const makeAnchorAsset = async (
|
|
309
306
|
{
|
|
@@ -348,18 +345,13 @@ export const makeAnchorAsset = async (
|
|
|
348
345
|
}),
|
|
349
346
|
);
|
|
350
347
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
installation: mintHolder,
|
|
359
|
-
label: keyword,
|
|
360
|
-
terms,
|
|
361
|
-
})
|
|
362
|
-
);
|
|
348
|
+
/** @type {{ creatorFacet: ERef<Mint<'nat'>>, publicFacet: ERef<Issuer<'nat'>> }} */
|
|
349
|
+
// @ts-expect-error cast
|
|
350
|
+
const { creatorFacet: mint, publicFacet: issuer } = await E(startUpgradable)({
|
|
351
|
+
installation: mintHolder,
|
|
352
|
+
label: keyword,
|
|
353
|
+
terms,
|
|
354
|
+
});
|
|
363
355
|
|
|
364
356
|
const brand = await E(issuer).getBrand();
|
|
365
357
|
const kit = harden({ mint, issuer, brand });
|
|
@@ -371,25 +363,23 @@ export const makeAnchorAsset = async (
|
|
|
371
363
|
slotToBoardRemote,
|
|
372
364
|
);
|
|
373
365
|
const metricsKey = `${stablePsmKey}.${keyword}.metrics`;
|
|
374
|
-
|
|
375
|
-
if (!toSlotReviver.has(metricsKey)) {
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
366
|
+
if (toSlotReviver.has(metricsKey)) {
|
|
378
367
|
const metrics = toSlotReviver.getItem(metricsKey);
|
|
379
368
|
produceAnchorBalancePayments.resolve(
|
|
380
369
|
makeScalarBigMapStore('Anchor balance payments', { durable: true }),
|
|
381
370
|
);
|
|
382
371
|
// XXX this rule should only apply to the 1st await
|
|
372
|
+
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
383
373
|
const anchorPaymentMap = await anchorBalancePayments;
|
|
384
374
|
|
|
385
375
|
// TODO: validate that `metrics.anchorPoolBalance.value` is
|
|
386
376
|
// pass-by-copy PureData (e.g., contains no remotables).
|
|
377
|
+
// eslint-disable-next-line @jessie.js/no-nested-await
|
|
387
378
|
const pmt = await E(mint).mintPayment(
|
|
388
379
|
AmountMath.make(brand, metrics.anchorPoolBalance.value),
|
|
389
380
|
);
|
|
390
381
|
anchorPaymentMap.init(brand, pmt);
|
|
391
|
-
}
|
|
392
|
-
await maybeReviveMetrics();
|
|
382
|
+
}
|
|
393
383
|
|
|
394
384
|
await Promise.all([
|
|
395
385
|
E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, kit.issuer),
|