Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap core: AMM, VaultFactory bootstrap with governance committee #4437

Merged
merged 62 commits into from
Feb 3, 2022

Conversation

dckc
Copy link
Member

@dckc dckc commented Feb 2, 2022

refs: #4165

@dckc dckc force-pushed the bootstrap-core branch 3 times, most recently from d99c7e3 to a23ce62 Compare February 3, 2022 02:20
@dckc dckc marked this pull request as ready for review February 3, 2022 02:38
@dckc
Copy link
Member Author

dckc commented Feb 3, 2022

@michaelfig this is another chunk of work on #4165 . It might be a little unwieldy, but... what do you think?

Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Wowza! Let's get this in!

(Just a few minor style questions, not necessarily blockers.)

packages/governance/src/contractHelper.js Show resolved Hide resolved
@@ -53,16 +53,21 @@
* @property {() => Allocation} getRewardAllocation,
* @property {() => ERef<Payment>} getBootstrapPayment
* @property {() => Instance} getContractGovernor
* @property {() => Invitation} makeCollectFeesInvitation
* @property {() => ERef<Invitation>} makeCollectFeesInvitation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally avoid using ERef in a return value, preferring instead Promise<Invitation>. Just curious why you chose this way.

@@ -173,6 +173,7 @@ test('amm with valid offers', async t => {
const bobSwapInvitation1 = await E(amm.ammPublicFacet).makeSwapInInvitation();

const { value } = await E(invitationIssuer).getAmountOf(bobSwapInvitation1);
assert(Array.isArray(value)); // non-fungible
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a t.assert(...)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, t.assert doesn't convince tsc that value is an array

const contractFilename = `${dirname}/../src/contractFacet/vatRoot.js`;
const outputPath = `${dirname}/../bundles/bundle-contractFacet.js`;
await writeSourceBundle(contractFilename, outputPath);
for await (const { src, bundle } of [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a for await...of when the iterable is not an AsyncIterable?

dckc added 22 commits February 3, 2022 16:06
 - feat: export bundled attestion contract
 - style: types tweak in tools
 - docs: fix optional arg decl in registerPriceAuthority
 - chore: prune attestation install-on-chain
 - test: first steps toward borrowing RUN against BLD
 - test: prepare real attestation
 - docs: types for FP utilities
 - feat: terms are controlled by governance
 - fix: prevent forged attestation
   - test: forging an attestion should fail
 - replace getInvitation with makeLoanInvitation
   patterned after vault.js
   - HIGH_FEE, LONG_EXP
   - return uiNotifier, invitationMakers, vault
   - factor out makeLineOfCreditKit
     - add close OfferHandler
     - track debtAmount, vaultState
     - keep attestation in vaultSeat
   - stub adjustBalances
 - factor out makeCreditPolicy
 - document close()
 - refactor: push more down into startAttestation

test(runLoC): run tests from spreadsheet

 - ava tests have to be created synchronously, so
   turn the CSV data into a string constant
 - fix parsing of empty leading fields in CSV
 - add types to CSV parsing

test(runLoC): test close

  10 tests passed
  15 tests skipped

hush some logging
  10 tests passed
  15 tests skipped

 - adjust offer need not have want: Attestation
 - provide limited runMint access to makeLineOfCreditKit (WIP)
 - provide type for notifier (RunLoCUIState)
 - factor out creditPolicy.checkBorrow()
 - refactor test bootstrap
   - each part installs its own bundles
   - bootstrapAttestation caller provides bld brand, issuer, reporter
     - one reporter for many accounts / balances
     - add the reporter in bootstrap
     - factor out home.attMaker
   - bootstrapRunLoC caller provides timer
 - add testAdjust
  12 tests passed
  13 tests skipped

 - clarify close() offer handler a bit
 - test: clarify todo filter
 - never mind attenuating runMint
 - never mind burnSeat

feat(getRUN): vault-compatible naming

 - match invitationMakers labels
 - disregard address; attMaker handles it

test(getRUN): refactor stake reporter as mockBridge

feat(getRUN): only RUN balance can be adjusted, for now

 - clean up test logging a bit
 - style: organize imports

test(getRUN): misc refactor / clean-up

 - move contractRoots near imports;
   move test.before() bundle loading up
   - subordinate collection utilities in Collect
   - factor out theBundles type handling
 - move contract start types near usage
   - break lines in long type annotations
 - mockBridge: rename uBrand (underlying?) to stakingBrand

feat(getRUN): align types with vaults

 - makeLineOfCreditKit: move creditPolicy check inside
   in order to make documentation / design simpler.
   - document connection between debtAmount and minted RUN
   - use return value from creditPolicy.checkBorrow
     to clarify adjustBalances (up)
   - burn before updating debtAmount
   - never mind zeroRun
 - factor BaseUIState out of UIState;
   liened -> locked
   - vaultState doesn't seem to be part of UIState, so
     reduce it to a boolean
     - never mind assertVaultIsOpen; didn't carry its weight
   - makeAdjustBalancesInvitation on vault wasn't exposed; skip it
 - document CreditTerms
 - annotate types for minAmt()
 - extract from test-runLoC.js
 - declare StakingAuthority type
caller provides installations rather than bundles
Comment on lines 54 to 55
// @ts-expect-error bounded polymorphism doesn't fit well in JSDoc
const wrapPublicFacet = (originalPublicFacet = {}) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually used an inline cast for fixing these, but I know we frown upon them

Suggested change
// @ts-expect-error bounded polymorphism doesn't fit well in JSDoc
const wrapPublicFacet = (originalPublicFacet = {}) => {
const wrapPublicFacet = (originalPublicFacet = /** @type {T} */ ({})) => {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. In looking at the context, @michaelfig and I discovered a good type that's a bit more involved.

* @returns {GovernedCreatorFacet}
* @template T
*/
// @ts-expect-error bounded polymorphism doesn't fit well in JSDoc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I a little worried this may overrule different errors

@dckc dckc added the automerge:squash Automatically squash merge label Feb 3, 2022
@mergify mergify bot merged commit 241ac92 into master Feb 3, 2022
@mergify mergify bot deleted the bootstrap-core branch February 3, 2022 23:45
dtribble pushed a commit that referenced this pull request Feb 4, 2022
…#4437)

* feat(agoric-cli): start with 1B BLD

* chore(wallet): prune feePurse

* docs(governance): try to thread types for wrapped governed facets

* chore(governance): include README in package files

* chore(vats): Revert postpone getRUN bootstrap to later PR"

This reverts commit 42b96fa.

* chore(zoe): prune expiring / voting attestation usage

 - feat: export bundled attestion contract
 - style: types tweak in tools
 - docs: fix optional arg decl in registerPriceAuthority
 - chore: prune attestation install-on-chain

* feat(getRUN): borrow RUN with collateral price, ratio

 - test: first steps toward borrowing RUN against BLD
 - test: prepare real attestation
 - docs: types for FP utilities
 - feat: terms are controlled by governance
 - fix: prevent forged attestation
   - test: forging an attestion should fail

* test(getRUN): Test Cases spreadsheet, driver

* feat(getRUN): close, uiNotifier, invitation fee + expiry

 - replace getInvitation with makeLoanInvitation
   patterned after vault.js
   - HIGH_FEE, LONG_EXP
   - return uiNotifier, invitationMakers, vault
   - factor out makeLineOfCreditKit
     - add close OfferHandler
     - track debtAmount, vaultState
     - keep attestation in vaultSeat
   - stub adjustBalances
 - factor out makeCreditPolicy
 - document close()
 - refactor: push more down into startAttestation

test(runLoC): run tests from spreadsheet

 - ava tests have to be created synchronously, so
   turn the CSV data into a string constant
 - fix parsing of empty leading fields in CSV
 - add types to CSV parsing

test(runLoC): test close

  10 tests passed
  15 tests skipped

hush some logging

* feat(getRUN): borrow more against the same lien

  10 tests passed
  15 tests skipped

 - adjust offer need not have want: Attestation
 - provide limited runMint access to makeLineOfCreditKit (WIP)
 - provide type for notifier (RunLoCUIState)
 - factor out creditPolicy.checkBorrow()
 - refactor test bootstrap
   - each part installs its own bundles
   - bootstrapAttestation caller provides bld brand, issuer, reporter
     - one reporter for many accounts / balances
     - add the reporter in bootstrap
     - factor out home.attMaker
   - bootstrapRunLoC caller provides timer
 - add testAdjust

* feat(getRUN): partial payoff

  12 tests passed
  13 tests skipped

 - clarify close() offer handler a bit
 - test: clarify todo filter
 - never mind attenuating runMint
 - never mind burnSeat

feat(getRUN): vault-compatible naming

 - match invitationMakers labels
 - disregard address; attMaker handles it

test(getRUN): refactor stake reporter as mockBridge

feat(getRUN): only RUN balance can be adjusted, for now

 - clean up test logging a bit
 - style: organize imports

test(getRUN): misc refactor / clean-up

 - move contractRoots near imports;
   move test.before() bundle loading up
   - subordinate collection utilities in Collect
   - factor out theBundles type handling
 - move contract start types near usage
   - break lines in long type annotations
 - mockBridge: rename uBrand (underlying?) to stakingBrand

feat(getRUN): align types with vaults

 - makeLineOfCreditKit: move creditPolicy check inside
   in order to make documentation / design simpler.
   - document connection between debtAmount and minted RUN
   - use return value from creditPolicy.checkBorrow
     to clarify adjustBalances (up)
   - burn before updating debtAmount
   - never mind zeroRun
 - factor BaseUIState out of UIState;
   liened -> locked
   - vaultState doesn't seem to be part of UIState, so
     reduce it to a boolean
     - never mind assertVaultIsOpen; didn't carry its weight
   - makeAdjustBalancesInvitation on vault wasn't exposed; skip it
 - document CreditTerms
 - annotate types for minAmt()

* feat(zoe): bootstrapAttestation

 - extract from test-runLoC.js
 - declare StakingAuthority type

* refactor(treasury): factor bootstrapRunLoC out of test-runLoC

* chore: move runLoC (getRUN) from treasury/ to run-protocol/

* docs(treasury): arg types for makeMakeCollectFeesInvitation

* chore: rename runLoC -> getRUN

* chore(run-protocol): build getRUN bundle; tweak bootstrap

caller provides installations rather than bundles

* chore(getRUN): subsume attestation in getRUN contract vat

* chore(getRUN): update governance API; more renaming

* chore(zoe): prune bootstrapAttestation.js

* refactor(vats): factor BoostrapPowers out of startGetRun

* chore(vat): sort deps

* build(vats): add dependency on @agoric/governance

* feat(vats): startEconomicCommittee

* refactor(vats): start vault factory without install-on-chain

* refactor(vats): move extract, makePromiseSpace from boot to utils

* chore(run-protocol): move econ-behaviors from vats

... to facilitate unit testing

* chore(vats): export types

* refactor(vats): factor out makeNameAdmins

 - spell binaryVoteCounter consistently

* refactor(vats): push more down into EconomyBootstrapPowers

* feat(run-protocol): startEconomicCommittee using bootstrap style

* feat(vats): support behavior config via boostrap vatParameters

* feat(vats): reserve necessary governor instances

* chore(run-protocol): fix, test AMM bootstrap

* chore(vats): VaultFactory is capitalized in agoricNames

 - move board out of EconomyBootstrapPowers (postpone uiConfig)

* test(run-protocol): `voteOnParamChange` type requires `key`

* feat(run-protocol): export static contract bundles

* test(run-protcol): unit test startVaultFactory

 - test-vaultFactory.js: subsume makePriceAuthority(),
   setupVaultFactory(), bundleInstalls() using produce / consume space
   - manage bundles, installations as records with
     Collect.allValues
   - provide param types for setupServices() etc.
 - add config.loanParams to startVaultFactory
 - split consume.economyBundles into consume.ammBundle,
   consume.vaultBundles
 - factor out configureVaultFactoryUI so that board
   is not needed for unit testing
 - get centralIssuer from agoricNames so it doesn't
   have to be created by zoe.
 - spell VaultFactory, liquidate consistently
 - use export const x = () => { ... }; harden(X)

* refactor(run-protocol): move Collect out of bootstrapRunLoc.js

* refactor(run-protocol): move getRUN bootstrap into econ-behaviors

 - prune bootstrapRunLoC.js

* docs(run-protocol): deprecate install-on-chain

* docs(run-protocol): econ-behaviors TODOs

* chore(vats): update GOVERNANCE_ACTIONS_MANIFEST

 - shareEconomyBundles
 - EconomyBootstrapPowers type tweaks

* chore(vats): clean up bankManager ERef / optional

* docs(run-protocol): timer await is for legibility of terms

 - govIssuer / govBrand are unused. prune

* docs(run-protocol): optional args in AMM test setup

* chore(vats): postpone startGetRun

* chore(run-protocol): postpone startGetRun

* test(run-protocol): postpone test-getRUN

* chore(run-protocol): postpone bundle-getRUN

* chore(run-protocol): postpone getRUN contract

* chore(run-protocol): merge fix

* chore(zoe): prune more attestation/expiringNFT tests

* chore(run-protocol): postpone bundle-getRUN.js

* docs(vats): type of consume.ammCreatorFacet

* docs(governance): tidy up types a bit

* chore(run-protocol): postpone getRUN some more

* docs(run-protocol): polish off AMM types

* style: types, async style in run-protocol, zoe

* chore: sort out governance vs. vault types

* style(governance): fix types of wrapper functions

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:squash Automatically squash merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants