Skip to content

Commit

Permalink
feat(agoric-cli): proposeChangeMintLimit (#6278)
Browse files Browse the repository at this point in the history
* feat(agoric-cli): proposeChangeMintLimit

* docs(agoric-cli): doc/test for changing PSM MintLimit

* fixup! feat(agoric-cli): proposeChangeMintLimit

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
dckc and mergify[bot] authored Sep 20, 2022
1 parent a369ec3 commit 7165dea
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
63 changes: 63 additions & 0 deletions packages/agoric-cli/src/commands/psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,69 @@ export const makePsmCommand = async logger => {
console.warn('Now execute the prepared offer');
});

psm
.command('proposeChangeMintLimit')
.description('propose to change the MintLimit parameter')
.option(
'--offerId [number]',
'id of this offer (optional)',
Number,
Date.now(),
)
.requiredOption(
'--pair [Minted.Anchor]',
'token pair (Minted.Anchor)',
s => s.split('.'),
['IST', 'AUSD'],
)
.requiredOption(
'--previousOfferId [number]',
'offer using psm charter invitation',
Number,
)
.requiredOption('--limit [number]', 'new mint limit (in IST)', Number)
.option(
'--deadline [minutes]',
'minutes from now to close the vote',
Number,
1,
)
.action(async function () {
const opts = this.opts();

const psmInstance = lookupPsmInstance(opts.pair);

/** @type {Brand} */
// @ts-expect-error yes, it is a brand
const istBrand = agoricNames.brand.IST;
const scaledAmount = harden({
brand: istBrand,
value: BigInt(opts.limit * 1_000_000),
});
/** @type {import('../lib/psm.js').OfferSpec} */
const offer = {
id: Number(opts.offerId),
invitationSpec: {
source: 'continuing',
previousOffer: opts.previousOfferId,
invitationMakerName: 'VoteOnParamChange',
},
proposal: {},
offerArgs: {
instance: psmInstance,
params: { MintLimit: scaledAmount },
deadline: BigInt(opts.deadline * 60 + Math.round(Date.now() / 1000)),
},
};

outputAction({
method: 'executeOffer',
offer,
});

console.warn('Now execute the prepared offer');
});

psm
.command('vote')
.description('vote on a question (hard-coded for now))')
Expand Down
21 changes: 21 additions & 0 deletions packages/agoric-cli/test/agops-governance-smoketest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,24 @@ agoric wallet send --from "$KEY" --offer "$SWAP_OFFER"
# ls: v6: Logging sent error stack (Error#1)
# ls: v6: Error#1: not accepting offer with description wantMinted
# ls: v6: Error: not accepting offer with description "wantMinted"

# Propose a vote to raise the mint limit
PROPOSAL_OFFER=$(mktemp -t agops.XXX)
bin/agops psm proposeChangeMintLimit --limit 10000 --previousOfferId "$CHARTER_OFFER_ID" >|"$PROPOSAL_OFFER"
jq ".body | fromjson" <"$PROPOSAL_OFFER"
agoric wallet send --from "$KEY" --offer "$PROPOSAL_OFFER"

# to verify that the question was proposed, you can use
# agoric follow published.committees.Initial_Economic_Committee.latestQuestion
# for a local net or
# agoric -B $networkConfig follow published.committees.Initial_Economic_Committee.latestQuestion

# vote on the question that was made
VOTE_OFFER=$(mktemp -t agops.XXX)
bin/agops psm vote --forPosition 0 --previousOfferId "$COMMITTEE_OFFER_ID" >|"$VOTE_OFFER"
jq ".body | fromjson" <"$VOTE_OFFER"
agoric wallet send --from "$KEY" --offer "$VOTE_OFFER"
## wait for the election to be resolved (1m default in commands/psm.js)

# to see the new MintLimit
bin/agops psm info

0 comments on commit 7165dea

Please sign in to comment.