@agoric/inter-protocol 0.16.2-dev-fed2b5e.0 → 0.16.2-dev-35e67be.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,43 +0,0 @@
1
- import { makeHelpers } from '@agoric/deploy-script-support';
2
- import { defaultProposalBuilder as vaultProposalBuilder } from './add-collateral-core.js';
3
- import { defaultProposalBuilder as oraclesProposalBuilder } from './price-feed-core.js';
4
-
5
- /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
6
- export const starsVaultProposalBuilder = async powers => {
7
- return vaultProposalBuilder(powers, {
8
- interchainAssetOptions: {
9
- // Values for the Stargaze token on Osmosis
10
- denom:
11
- 'ibc/987C17B11ABC2B20019178ACE62929FE9840202CE79498E29FE8E5CB02B7C0A4',
12
- decimalPlaces: 6,
13
- keyword: 'STARS',
14
- oracleBrand: 'STARS',
15
- proposedName: 'STARS',
16
- },
17
- });
18
- };
19
-
20
- /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
21
- export const starsOraclesProposalBuilder = async powers => {
22
- return oraclesProposalBuilder(powers, {
23
- AGORIC_INSTANCE_NAME: `STARS-USD price feed`,
24
- IN_BRAND_LOOKUP: ['agoricNames', 'oracleBrand', 'STARS'],
25
- IN_BRAND_DECIMALS: 6,
26
- OUT_BRAND_LOOKUP: ['agoricNames', 'oracleBrand', 'USD'],
27
- OUT_BRAND_DECIMALS: 4,
28
- oracleAddresses: [
29
- // copied from decentral-main-vaults-config.json
30
- 'agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr',
31
- 'agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8',
32
- 'agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78',
33
- 'agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p',
34
- 'agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj',
35
- ],
36
- });
37
- };
38
-
39
- export default async (homeP, endowments) => {
40
- const { writeCoreProposal } = await makeHelpers(homeP, endowments);
41
- await writeCoreProposal('add-STARS', starsVaultProposalBuilder);
42
- await writeCoreProposal('add-STARS-oracles', starsOraclesProposalBuilder);
43
- };
@@ -1,112 +0,0 @@
1
- /* global process */
2
- import { makeHelpers } from '@agoric/deploy-script-support';
3
-
4
- import { getManifestForAddAssetToVault } from '../src/proposals/addAssetToVault.js';
5
- import { getManifestForPsm } from '../src/proposals/startPSM.js';
6
- import { makeInstallCache } from '../src/proposals/utils.js';
7
-
8
- /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
9
- export const defaultProposalBuilder = async (
10
- { publishRef, install: install0, wrapInstall },
11
- {
12
- debtLimitValue = undefined,
13
- interestRateValue = undefined,
14
- interchainAssetOptions = /** @type {object} */ ({}),
15
- } = {},
16
- { env = process.env } = {},
17
- ) => {
18
- /** @type {import('../src/proposals/addAssetToVault.js').InterchainAssetOptions} */
19
- const {
20
- issuerBoardId = env.INTERCHAIN_ISSUER_BOARD_ID,
21
- denom = env.INTERCHAIN_DENOM,
22
- oracleBrand = 'ATOM',
23
- decimalPlaces = 6,
24
- keyword = 'ATOM',
25
- proposedName = oracleBrand,
26
- initialPrice = undefined,
27
- } = interchainAssetOptions;
28
-
29
- if (!denom) {
30
- assert(issuerBoardId, 'INTERCHAIN_ISSUER_BOARD_ID is required');
31
- }
32
-
33
- const install = wrapInstall ? wrapInstall(install0) : install0;
34
-
35
- return harden({
36
- sourceSpec: '../src/proposals/addAssetToVault.js',
37
- getManifestCall: [
38
- getManifestForAddAssetToVault.name,
39
- {
40
- debtLimitValue: debtLimitValue && BigInt(debtLimitValue),
41
- interestRateValue: interestRateValue && BigInt(interestRateValue),
42
- interchainAssetOptions: {
43
- denom,
44
- issuerBoardId,
45
- decimalPlaces,
46
- initialPrice,
47
- keyword,
48
- proposedName,
49
- oracleBrand,
50
- },
51
- scaledPriceAuthorityRef: publishRef(
52
- install(
53
- '@agoric/zoe/src/contracts/scaledPriceAuthority.js',
54
- '../bundles/bundle-scaledPriceAuthority.js',
55
- { persist: true },
56
- ),
57
- ),
58
- },
59
- ],
60
- });
61
- };
62
-
63
- /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
64
- export const psmProposalBuilder = async (
65
- { publishRef, install: install0, wrapInstall },
66
- { anchorOptions = /** @type {object} */ ({}) } = {},
67
- { env = process.env } = {},
68
- ) => {
69
- const { denom = env.ANCHOR_DENOM, decimalPlaces = 6 } = anchorOptions;
70
-
71
- assert(denom, 'ANCHOR_DENOM is required');
72
-
73
- const install = wrapInstall ? wrapInstall(install0) : install0;
74
-
75
- return harden({
76
- sourceSpec: '../src/proposals/startPSM.js',
77
- getManifestCall: [
78
- getManifestForPsm.name,
79
- {
80
- anchorOptions: {
81
- ...anchorOptions,
82
- denom,
83
- decimalPlaces,
84
- },
85
- installKeys: {
86
- psm: publishRef(
87
- install('../src/psm/psm.js', '../bundles/bundle-psm.js'),
88
- ),
89
- mintHolder: publishRef(
90
- install(
91
- '@agoric/vats/src/mintHolder.js',
92
- '../../vats/bundles/bundle-mintHolder.js',
93
- ),
94
- ),
95
- },
96
- },
97
- ],
98
- });
99
- };
100
-
101
- export default async (homeP, endowments) => {
102
- const { writeCoreProposal } = await makeHelpers(homeP, endowments);
103
-
104
- const tool = await makeInstallCache(homeP, {
105
- loadBundle: spec => import(spec),
106
- });
107
-
108
- await writeCoreProposal('gov-add-collateral', defaultProposalBuilder);
109
- await writeCoreProposal('gov-start-psm', opts =>
110
- psmProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
111
- );
112
- };
@@ -1,110 +0,0 @@
1
- #!/usr/bin/env node
2
- import url from 'url';
3
- import { makeHelpers } from '@agoric/deploy-script-support';
4
- import { E } from '@endo/eventual-send';
5
- import { getCopyMapEntries, makeCopyMap } from '@agoric/store';
6
-
7
- // TODO: CLI options to choose contracts
8
- const contractRefs = [
9
- '../../governance/bundles/bundle-contractGovernor.js',
10
- '../../governance/bundles/bundle-committee.js',
11
- '../../governance/bundles/bundle-binaryVoteCounter.js',
12
- '../bundles/bundle-vaultFactory.js',
13
- '../bundles/bundle-reserve.js',
14
- '../bundles/bundle-psm.js',
15
- '../bundles/bundle-auctioneer.js',
16
- '../../vats/bundles/bundle-mintHolder.js',
17
- ];
18
- const contractRoots = contractRefs.map(ref =>
19
- url.fileURLToPath(new URL(ref, import.meta.url)),
20
- );
21
-
22
- /** @type {<T>(store: any, key: string, make: () => T) => Promise<T>} */
23
- const provideWhen = async (store, key, make) => {
24
- const found = await E(store).get(key);
25
- if (found) {
26
- return found;
27
- }
28
- const value = make();
29
- await E(store).set(key, value);
30
- return value;
31
- };
32
-
33
- export default async (homeP, endowments) => {
34
- const home = await homeP;
35
- const { zoe, scratch, board } = home;
36
-
37
- const { installInPieces, getBundlerMaker } = await makeHelpers(
38
- homeP,
39
- endowments,
40
- );
41
- const bundler = E(getBundlerMaker({ log: console.log })).makeBundler({
42
- zoe,
43
- });
44
-
45
- console.log('getting installCache...');
46
- /**
47
- * @type {CopyMap<
48
- * string,
49
- * { installation: Installation; boardId: string; path?: string }
50
- * >}
51
- */
52
- const initial = await provideWhen(scratch, 'installCache', () =>
53
- makeCopyMap([]),
54
- );
55
- console.log('initially:', initial.payload.keys.length, 'entries');
56
-
57
- // ISSUE: getCopyMapEntries of CopyMap<K, V> loses K, V.
58
- /**
59
- * @type {Map<
60
- * string,
61
- * { installation: Installation; boardId: string; path?: string }
62
- * >}
63
- */
64
- const working = new Map(getCopyMapEntries(initial));
65
-
66
- let added = 0;
67
-
68
- /** @type {EndoZipBase64Bundle[]} */
69
- const bundles = await Promise.all(
70
- contractRoots.map(path => import(path).then(m => m.default)),
71
- );
72
-
73
- let ix = 0;
74
- for await (const bundle of bundles) {
75
- const sha512 = bundle.endoZipBase64Sha512;
76
- if (working.has(bundle.endoZipBase64Sha512)) {
77
- console.log('hit:', { path: contractRefs[ix], sha512 });
78
- } else {
79
- console.log('miss:', {
80
- path: contractRefs[ix],
81
- length: bundle.endoZipBase64.length,
82
- sha512,
83
- });
84
- const installation = await installInPieces(bundle, bundler, {
85
- persist: true,
86
- });
87
- const boardId = await E(board).getId(installation);
88
- working.set(sha512, { installation, boardId, path: contractRefs[ix] });
89
- added += 1;
90
- }
91
- ix += 1;
92
- }
93
-
94
- const final = makeCopyMap(working);
95
- assert.equal(final.payload.keys.length, working.size);
96
- await (added > 0 && E(home.scratch).set('installCache', final));
97
- console.log({
98
- initial: initial.payload.keys.length,
99
- added,
100
- total: working.size,
101
- });
102
-
103
- const items = [...working.entries()]
104
- .map(([sha512, { boardId, path }]) => ({ sha512, boardId, path }))
105
- .sort();
106
- const boardId = await E(board).getId(JSON.stringify(items));
107
- console.log({
108
- boardId,
109
- });
110
- };
@@ -1,197 +0,0 @@
1
- /* global process */
2
- /**
3
- * @file can be run with `agoric deploy` after a chain is running (depends on
4
- * chain state) Only works with "local" chain and not sim-chain b/c it needs
5
- * governance votes (n/a on sim-chain).
6
- */
7
- import { makeHelpers } from '@agoric/deploy-script-support';
8
- import { objectMap } from '@agoric/internal';
9
-
10
- import {
11
- getManifestForInterProtocol,
12
- getManifestForEconCommittee,
13
- getManifestForMain,
14
- } from '../src/proposals/core-proposal.js';
15
- import { makeInstallCache } from '../src/proposals/utils.js';
16
-
17
- /** @type {Record<string, Record<string, [string, string]>>} */
18
- const installKeyGroups = {
19
- econCommittee: {
20
- contractGovernor: [
21
- '@agoric/governance/src/contractGovernor.js',
22
- '../../governance/bundles/bundle-contractGovernor.js',
23
- ],
24
- committee: [
25
- '@agoric/governance/src/committee.js',
26
- '../../governance/bundles/bundle-committee.js',
27
- ],
28
- binaryVoteCounter: [
29
- '@agoric/governance/src/binaryVoteCounter.js',
30
- '../../governance/bundles/bundle-binaryVoteCounter.js',
31
- ],
32
- },
33
- main: {
34
- auctioneer: [
35
- '../src/auction/auctioneer.js',
36
- '../bundles/bundle-auctioneer.js',
37
- ],
38
- vaultFactory: [
39
- '../src/vaultFactory/vaultFactory.js',
40
- '../bundles/bundle-vaultFactory.js',
41
- ],
42
- feeDistributor: [
43
- '../src/feeDistributor.js',
44
- '../bundles/bundle-feeDistributor.js',
45
- ],
46
- reserve: ['../src/reserve/assetReserve.js', '../bundles/bundle-reserve.js'],
47
- },
48
- };
49
-
50
- /**
51
- * @template I
52
- * @template R
53
- * @param {object} opts
54
- * @param {(i: I) => R} opts.publishRef
55
- * @param {(m: string, b: string, opts?: any) => I} opts.install
56
- * @param {<T>(f: T) => T} [opts.wrapInstall]
57
- * @param {object} [options]
58
- * @param {{ committeeName?: string; committeeSize?: number }} [options.econCommitteeOptions]
59
- */
60
- export const committeeProposalBuilder = async (
61
- { publishRef, install: install0, wrapInstall },
62
- { econCommitteeOptions } = {},
63
- ) => {
64
- const install = wrapInstall ? wrapInstall(install0) : install0;
65
-
66
- /** @param {Record<string, [string, string]>} group */
67
- const publishGroup = group =>
68
- objectMap(group, ([mod, bundle]) =>
69
- publishRef(install(mod, bundle, { persist: true })),
70
- );
71
- return harden({
72
- sourceSpec: '../src/proposals/core-proposal.js',
73
- getManifestCall: [
74
- getManifestForEconCommittee.name,
75
- {
76
- econCommitteeOptions,
77
- installKeys: {
78
- ...publishGroup(installKeyGroups.econCommittee),
79
- },
80
- },
81
- ],
82
- });
83
- };
84
-
85
- /**
86
- * @template I
87
- * @template R
88
- * @param {object} opts
89
- * @param {(i: I) => R} opts.publishRef
90
- * @param {(m: string, b: string, opts?: any) => I} opts.install
91
- * @param {<T>(f: T) => T} [opts.wrapInstall]
92
- */
93
- export const mainProposalBuilder = async ({
94
- publishRef,
95
- install: install0,
96
- wrapInstall,
97
- }) => {
98
- const { VAULT_FACTORY_CONTROLLER_ADDR } = process.env;
99
-
100
- const install = wrapInstall ? wrapInstall(install0) : install0;
101
-
102
- const persist = true;
103
- /** @param {Record<string, [string, string]>} group */
104
- const publishGroup = group =>
105
- objectMap(group, ([mod, bundle]) =>
106
- publishRef(install(mod, bundle, { persist })),
107
- );
108
- return harden({
109
- sourceSpec: '../src/proposals/core-proposal.js',
110
- getManifestCall: [
111
- getManifestForMain.name,
112
- {
113
- vaultFactoryControllerAddress: VAULT_FACTORY_CONTROLLER_ADDR,
114
- installKeys: {
115
- ...publishGroup(installKeyGroups.main),
116
- },
117
- },
118
- ],
119
- });
120
- };
121
-
122
- // Build proposal for sim-chain etc.
123
- /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
124
- export const defaultProposalBuilder = async (
125
- { publishRef, install },
126
- options = {},
127
- { env = process.env } = {},
128
- ) => {
129
- /** @param {string | undefined} s */
130
- const optBigInt = s => s && BigInt(s);
131
- const {
132
- vaultFactoryControllerAddress = env.VAULT_FACTORY_CONTROLLER_ADDR,
133
- minInitialPoolLiquidity = env.MIN_INITIAL_POOL_LIQUIDITY,
134
- referencedUi,
135
- anchorOptions: {
136
- anchorDenom = env.ANCHOR_DENOM,
137
- anchorDecimalPlaces = '6',
138
- anchorKeyword = 'AUSD',
139
- anchorProposedName = anchorKeyword,
140
- initialPrice = undefined,
141
- } = {},
142
- econCommitteeOptions: {
143
- committeeSize: econCommitteeSize = env.ECON_COMMITTEE_SIZE || '3',
144
- } = {},
145
- } = options;
146
-
147
- /** @param {Record<string, [string, string]>} group */
148
- const publishGroup = group =>
149
- objectMap(group, ([mod, bundle]) => publishRef(install(mod, bundle)));
150
-
151
- const anchorOptions = anchorDenom && {
152
- denom: anchorDenom,
153
- decimalPlaces: parseInt(anchorDecimalPlaces, 10),
154
- initialPrice,
155
- keyword: anchorKeyword,
156
- proposedName: anchorProposedName,
157
- };
158
-
159
- const econCommitteeOptions = {
160
- committeeSize: parseInt(econCommitteeSize, 10),
161
- };
162
-
163
- return harden({
164
- sourceSpec: '../src/proposals/core-proposal.js',
165
- getManifestCall: [
166
- getManifestForInterProtocol.name,
167
- {
168
- vaultFactoryControllerAddress,
169
- minInitialPoolLiquidity: optBigInt(minInitialPoolLiquidity),
170
- referencedUi,
171
- anchorOptions,
172
- econCommitteeOptions,
173
- installKeys: {
174
- ...publishGroup(installKeyGroups.econCommittee),
175
- ...publishGroup(installKeyGroups.main),
176
- },
177
- },
178
- ],
179
- });
180
- };
181
-
182
- export default async (homeP, endowments) => {
183
- const { writeCoreProposal } = await makeHelpers(homeP, endowments);
184
-
185
- const tool = await makeInstallCache(homeP, {
186
- loadBundle: spec => import(spec),
187
- });
188
- await Promise.all([
189
- writeCoreProposal('gov-econ-committee', opts =>
190
- committeeProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
191
- ),
192
- writeCoreProposal('gov-amm-vaults-etc', opts =>
193
- mainProposalBuilder({ ...opts, wrapInstall: tool.wrapInstall }),
194
- ),
195
- ]);
196
- await tool.saveCache();
197
- };
@@ -1,42 +0,0 @@
1
- /* global process */
2
- import { makeHelpers } from '@agoric/deploy-script-support';
3
-
4
- import { getManifestForInviteCommittee } from '../src/proposals/committee-proposal.js';
5
-
6
- // Build proposal for sim-chain etc.
7
- /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
8
- export const defaultProposalBuilder = async (
9
- { publishRef, install },
10
- options = {},
11
- ) => {
12
- const {
13
- ECON_COMMITTEE_ADDRESSES = process.env.ECON_COMMITTEE_ADDRESSES,
14
- voterAddresses = JSON.parse(ECON_COMMITTEE_ADDRESSES),
15
- } = options;
16
-
17
- assert(voterAddresses, 'ECON_COMMITTEE_ADDRESSES is required');
18
-
19
- return harden({
20
- sourceSpec: '../src/proposals/committee-proposal.js',
21
- getManifestCall: [
22
- getManifestForInviteCommittee.name,
23
- {
24
- voterAddresses,
25
- econCommitteeCharterRef: publishRef(
26
- install(
27
- '../src/econCommitteeCharter.js',
28
- '../bundles/bundle-econCommitteeCharter.js',
29
- {
30
- persist: true,
31
- },
32
- ),
33
- ),
34
- },
35
- ],
36
- });
37
- };
38
-
39
- export default async (homeP, endowments) => {
40
- const { writeCoreProposal } = await makeHelpers(homeP, endowments);
41
- await writeCoreProposal('gov-invite-committee', defaultProposalBuilder);
42
- };
@@ -1,122 +0,0 @@
1
- import { E } from '@endo/far';
2
- import { deeplyFulfilled } from '@endo/marshal';
3
- import { makeNotifierFromAsyncIterable } from '@agoric/notifier';
4
-
5
- import process from 'process';
6
-
7
- /**
8
- * After extracting the oracleAdmins to entries in home.scratch, you can use one
9
- * from the REPL like:
10
- *
11
- * lookup('agoricNames', 'oracleBrand', 'ATOM').then(brand => atom = brand)
12
- * -> [Object Alleged: ATOM brand]{}
13
- * lookup('agoricNames', 'oracleBrand', 'USD').then(brand => usd = brand)
14
- * -> [Object Alleged: USD brand]{}
15
- * pa = home.priceAuthority
16
- * -> [Object Alleged: PriceAuthority]{}
17
- * qn = E(pa).makeQuoteNotifier({ value: 1n * 10n ** 6n, brand: atom }, usd)
18
- * -> [Object Alleged: QuoteNotifier]{}
19
- * oa = E(home.scratch).get("offerResult unknown#1652669688625")
20
- * -> [Object Alleged: OracleAdmin]{}
21
- * E(oa).pushResult('19.37')
22
- * E(qn).getUpdateSince()
23
- *
24
- * @typedef {{
25
- * board: import('@agoric/vats').Board;
26
- * chainTimerService;
27
- * scratch;
28
- * zoe;
29
- * }} Home
30
- * @param {Promise<Home>} homePromise
31
- * @param {object} root0
32
- * @param {(...path: string[]) => Promise<any>} root0.lookup A promise for the
33
- * references available from REPL home
34
- */
35
- export default async function priceAuthorityFromNotifier(
36
- homePromise,
37
- { lookup },
38
- ) {
39
- const { AGGREGATOR_INSTANCE_LOOKUP } = process.env;
40
-
41
- // Let's wait for the promise to resolve.
42
- const home = await deeplyFulfilled(homePromise);
43
-
44
- let aggregatorInstance;
45
- if (AGGREGATOR_INSTANCE_LOOKUP) {
46
- aggregatorInstance = await lookup(JSON.parse(AGGREGATOR_INSTANCE_LOOKUP));
47
- }
48
-
49
- if (!aggregatorInstance) {
50
- console.log('Autodetecting aggregator instance...');
51
- const purse = E(home.wallet).getPurse('Default Zoe invite purse');
52
- const { value } = await E(purse).getCurrentAmount();
53
- const invitations = value.filter(
54
- ({ description }) => description === 'oracle invitation',
55
- );
56
- if (invitations.length > 1) {
57
- console.error('Multiple oracle invitations found', invitations);
58
- throw Error('You need an AGGREGATOR_INSTANCE_LOOKUP to disambiguate');
59
- }
60
- if (invitations.length === 0) {
61
- console.error(
62
- 'No oracle invitations found; you may need an AGGREGATOR_INSTANCE_LOOKUP',
63
- );
64
- } else {
65
- console.log('Found oracle invitation', invitations);
66
- aggregatorInstance = invitations[0].instance;
67
- }
68
- }
69
-
70
- if (!aggregatorInstance) {
71
- return;
72
- }
73
-
74
- const offer = {
75
- id: Date.now(),
76
- proposalTemplate: {},
77
- invitationQuery: {
78
- description: 'oracle invitation',
79
- instance: aggregatorInstance,
80
- },
81
- };
82
-
83
- console.log('Getting wallet bridge...');
84
- const bridge = await E(home.wallet).getBridge();
85
-
86
- // Consume an aggregator invitation for this instance.
87
- await E(bridge)
88
- .addOffer(offer)
89
- .then(
90
- () =>
91
- console.log(
92
- `Please approve your wallet's proposal to connect the aggregator ${aggregatorInstance}...`,
93
- ),
94
- () => {},
95
- );
96
-
97
- const walletAdmin = E(home.wallet).getAdminFacet();
98
-
99
- console.log('=====================================================');
100
- console.log('=== Extracting oracleAdmins from price feed offers...');
101
- console.log('=== Control-C to cancel');
102
- const offerIt = E(walletAdmin).getOffersNotifier();
103
- for await (const offers of makeNotifierFromAsyncIterable(offerIt)) {
104
- // console.log(offers);
105
- offers
106
- .filter(
107
- ({ status, invitationQuery: { instance } }) =>
108
- status === 'complete' && instance === aggregatorInstance,
109
- )
110
- .forEach(async ({ id }) => {
111
- const orKey = `offerResult ${id}`;
112
- await E(home.scratch).set(
113
- orKey,
114
- E(home.wallet).lookup('offerResult', id),
115
- );
116
- console.log(
117
- 'Use this oracleAdmin:',
118
- `E(home.scratch).get(${JSON.stringify(orKey)})`,
119
- );
120
- });
121
- }
122
- }