Skip to content

Commit d212017

Browse files
committed
feat: add proposal 92
1 parent 3464d48 commit d212017

9 files changed

+163
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CoreEval proposal to reset MintLimit for USDC, USDT PSMs
2+
3+
Files under `submission` are taken from the relevant [release](https://github.com/Agoric/agoric-sdk/releases/tag/psm-param-fix).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"agoricProposal": {
3+
"type": "/agoric.swingset.CoreEvalProposal",
4+
"releaseNotes": "https://github.com/Agoric/agoric-sdk/releases/tag/psm-param-fix"
5+
},
6+
"type": "module",
7+
"license": "Apache-2.0",
8+
"scripts": {
9+
"agops": "yarn --cwd /usr/src/agoric-sdk/ --silent agops"
10+
},
11+
"packageManager": "[email protected]"
12+
}

proposals/92:reset-psm-mintlimit/submission/b1-29e7a47537e6fedccb75dd2c01e28a4bfdf787c6c3c7d7e06156627ed5b31ba80aa05727d10350fa776af0d13eacf15af586da7a8468e9fa0a3f9d41727fc67a.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"consume": {
3+
"economicCommitteeCreatorFacet": true,
4+
"instancePrivateArgs": true,
5+
"psmKit": true,
6+
"zoe": true
7+
},
8+
"brand": {
9+
"consume": {
10+
"IST": true
11+
}
12+
}
13+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/* global E */
2+
/**
3+
* @import {EconomyBootstrapPowers} from './econ-behaviors'
4+
*/
5+
6+
const ISTUnit = 1_000_000n;
7+
const MintLimitValue = 500_000n * ISTUnit;
8+
9+
let tick = 0;
10+
const trace = (...args) => console.log('--- PGRe', (tick += 1), ...args);
11+
12+
trace('script started');
13+
14+
const { entries, fromEntries } = Object;
15+
16+
/**
17+
* Given an object whose properties may be promise-valued, return a promise for
18+
* an analogous object in which each such value has been replaced with its
19+
* fulfillment. This is a non-recursive form of endo `deeplyFulfilled`.
20+
*
21+
* @template T
22+
* @param {{ [K in keyof T]: T[K] | Promise<T[K]> }} obj
23+
* @returns {Promise<T>}
24+
*/
25+
const shallowlyFulfilled = async obj => {
26+
if (!obj) {
27+
return obj;
28+
}
29+
const awaitedEntries = await Promise.all(
30+
entries(obj).map(async ([key, valueP]) => {
31+
const value = await valueP;
32+
return [key, value];
33+
}),
34+
);
35+
return fromEntries(awaitedEntries);
36+
};
37+
38+
/**
39+
* null case is vestigial
40+
*
41+
* @typedef {{
42+
* consume: { chainStorage: Promise<StorageNode> };
43+
* }} ChainStorageNonNull
44+
*/
45+
46+
/**
47+
* Reset MintLimit on all PSMs to 50K IST.
48+
*
49+
* parts adapted from packages/vats/src/proposals/upgrade-psm-proposal.js
50+
*
51+
* @param {EconomyBootstrapPowers & ChainStorageNonNull} powers
52+
* @param {object} [opts]
53+
* @param {string} opts.bundleID
54+
*/
55+
const resetPSMMintLimits = async (
56+
powers,
57+
opts = {
58+
// see psm-bundle-check.test.js
59+
bundleID:
60+
'b1-29e7a47537e6fedccb75dd2c01e28a4bfdf787c6c3c7d7e06156627ed5b31ba80aa05727d10350fa776af0d13eacf15af586da7a8468e9fa0a3f9d41727fc67a',
61+
},
62+
) => {
63+
trace('resetPSMMintLimits', opts);
64+
const { economicCommitteeCreatorFacet, instancePrivateArgs, psmKit, zoe } =
65+
powers.consume;
66+
const { bundleID } = opts;
67+
68+
const ISTbrand = await powers.brand.consume.IST;
69+
const MintLimit = harden({ brand: ISTbrand, value: MintLimitValue });
70+
trace({ MintLimit });
71+
72+
const psmKitMap = await psmKit;
73+
for (const kit of psmKitMap.values()) {
74+
// const instanceKey = `psm-${Stable.symbol}-${keyword}`;
75+
const [_psm, _ist, keyword] = kit.label.split('-');
76+
trace('PSM name(s)', kit.label, keyword);
77+
assert(keyword, kit.label);
78+
if (!['USDC', 'USDT'].includes(keyword)) {
79+
trace('out of scope:', keyword);
80+
continue;
81+
}
82+
83+
const privateArgsPre = await shallowlyFulfilled(
84+
// @ts-expect-error instancePrivateArgs is a mixed bag
85+
await E(instancePrivateArgs).get(kit.psm),
86+
);
87+
const toPose = await E(economicCommitteeCreatorFacet).getPoserInvitation();
88+
const privateArgs = {
89+
...privateArgsPre,
90+
paramUpdates: { MintLimit },
91+
initialPoserInvitation: toPose,
92+
};
93+
trace(keyword, 'privateArgs', privateArgs);
94+
const it = await E(kit.psmAdminFacet).upgradeContract(
95+
bundleID,
96+
privateArgs,
97+
);
98+
trace('upgraded', keyword, it);
99+
}
100+
};
101+
harden(resetPSMMintLimits);
102+
103+
trace('"export" using completion value', resetPSMMintLimits);
104+
resetPSMMintLimits;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/bash
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Exit when any command fails
4+
set -e
5+
6+
source /usr/src/upgrade-test-scripts/env_setup.sh
7+
8+
PSM_USDC_PAIR="IST.USDC"
9+
PSM_USDT_PAIR="IST.USDT"
10+
11+
echo DEBUG test mint limit was adjusted
12+
agd query vstorage data published.psm.${pair}.governance
13+
14+
# there are two instances in governance vstorage path, use latest
15+
test_val $(agd query vstorage data published.psm.${PSM_USDC_PAIR}.governance | sed "s/^value: '//" | sed "s/'$//" | tr -d '\n' | jq -r '.values[-1] | fromjson | .body | sub("^#";"") | fromjson | .current.MintLimit.value.value | ltrimstr("+")') "500000000000" "PSM MintLimit was reset to 500K"
16+
test_val $(agd query vstorage data published.psm.${PSM_USDT_PAIR}.governance | sed "s/^value: '//" | sed "s/'$//" | tr -d '\n' | jq -r '.values[-1] | fromjson | .body | sub("^#";"") | fromjson | .current.MintLimit.value.value | ltrimstr("+")') "500000000000" "PSM MintLimit was reset to 500K"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is generated by running "yarn install" inside your project.
2+
# Manual changes might be lost - proceed with caution!
3+
4+
__metadata:
5+
version: 8
6+
cacheKey: 10c0
7+
8+
"root-workspace-0b6124@workspace:.":
9+
version: 0.0.0-use.local
10+
resolution: "root-workspace-0b6124@workspace:."
11+
languageName: unknown
12+
linkType: soft

0 commit comments

Comments
 (0)