Skip to content

Commit

Permalink
feat(init): add bundles and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Aug 2, 2023
0 parents commit 1aa1b70
Show file tree
Hide file tree
Showing 9 changed files with 567 additions and 0 deletions.
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
## Preqrequisites

### 1. Use Proposal Builder to generate Core Eval files

See [inter-protocol/scripts/add-STARS.js](https://github.com/Agoric/agoric-sdk/blob/5a00ae14aedb7d4a5f1e60c4bc9d79814089c99b/packages/inter-protocol/scripts/add-STARS.js) and this npm [script](https://github.com/Agoric/agoric-sdk/blob/5a00ae14aedb7d4a5f1e60c4bc9d79814089c99b/packages/inter-protocol/package.json#L13) for more details.

I have checked in the generated files here for reference.

### 2. Setup wallet

```zsh
# list current keys
agd keys list
# add a new key, with auto-generated mnemonic
agd keys add [dev-local]
# add a new key, with custom mnemonic
agd keys add [dev-local] --interactive
# prints address
agd keys show [dev-local] -a
```

### 3. Request faucet funds

Setup a smart-wallet and request funds here: https://devnet.faucet.agoric.net/, using the address from the previous step.

## Proposal Steps

### 1. Deploy bundles

```zsh
NODE=https://devnet.rpc.agoric.net:443
WALLET=dev-local
CHAIN_ID=agoricdev-20
B1=bundles/b1-3cf6f8499883ff9edc294bf784cb0a93af68829da3b469b6c4a53f33c785c416cdb398169a757cf448a1635a3a6b21ac7881d07f9dd184ff3d6579905f44cb5e.json
B2=bundles/b1-5da781b83f8a3e4e173184e0641a9b95f66aad7c4225a364ef081fd1c124e3c33fc4a04a3dd59eebcf537b3e7944f38429fdbe3713c660b9d272ff4532cf540a.json
B3=bundles/b1-5e23d485ee30dadc1cc78c4df6009466e710bf53d63204f99da96decc50a2997d6afc25df3c0a479e41c7ff46aaa806eb0aaf94c9509c9f4860640ce8b271774.json
B4=bundles/b1-0571491fc026ed1e3ed4346c0a8f6b2d818e5614b8bfe6b4ed6ce9caa5eb9729d21cd7f10f4638c9f3b07ebe8d077678afe023a9e6e4f762dd6159b076310e63.json
agd tx swingset install-bundle $B1 --node $NODE --from $WALLET --chain-id $CHAIN_ID
agd tx swingset install-bundle $B2 --node $NODE --from $WALLET --chain-id $CHAIN_ID
agd tx swingset install-bundle $B3 --node $NODE --from $WALLET --chain-id $CHAIN_ID
agd tx swingset install-bundle $B4 --node $NODE --from $WALLET --chain-id $CHAIN_ID
```

### 2. Submit Vault / Asset Proposal

```zsh
NODE=https://devnet.rpc.agoric.net:443
WALLET=dev-local
CHAIN_ID=agoricdev-20
agd tx gov submit-proposal swingset-core-eval add-stATOM-permit.json add-stATOM.js \
--title="Enable stATOM Vault" --description="Evaluate add-stATOM.js" --deposit=1000000ubld \
--gas=auto --gas-adjustment=1.2 \
--node $NODE --from $WALLET --chain-id $CHAIN_ID
```

### 3. Submit Oracle Proposal

```zsh
NODE=https://devnet.rpc.agoric.net:443
WALLET=dev-local
CHAIN_ID=agoricdev-20
agd tx gov submit-proposal swingset-core-eval add-stATOM-oracles-permit.json add-stATOM-oracles.js \
--title="Enable stATOM Oracle" --description="Evaluate add-stATOM-oracles.js" --deposit=1000000ubld \
--gas=auto --gas-adjustment=1.2 \
--node $NODE --from $WALLET --chain-id $CHAIN_ID
```

### 4. Query Gov Proposals

```zsh
NODE=https://devnet.rpc.agoric.net:443
WALLET=dev-local
CHAIN_ID=agoricdev-20
agd query gov proposals --node $NODE --chain-id $CHAIN_ID --output json | \
jq -c '.proposals[] | [.proposal_id,.voting_end_time,.status]';
```

### 5. Vote on Gov Proposals

```zsh
NODE=https://devnet.rpc.agoric.net:443
WALLET=dev-local
CHAIN_ID=agoricdev-20
agd tx gov vote 1 yes --node $NODE --from $WALLET --chain-id $CHAIN_ID
agd tx gov vote 2 yes --node $NODE --from $WALLET --chain-id $CHAIN_ID
```
39 changes: 39 additions & 0 deletions add-stATOM-oracles-permit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"consume": {
"agoricNamesAdmin": "priceFeed",
"board": "priceFeed",
"chainStorage": "priceFeed",
"chainTimerService": "priceFeed",
"client": "priceFeed",
"contractGovernor": "priceFeed",
"econCharterKit": "priceFeed",
"economicCommitteeCreatorFacet": "priceFeed",
"highPrioritySendersManager": "priceFeed",
"namesByAddressAdmin": "priceFeed",
"priceAuthority": "priceFeed",
"priceAuthorityAdmin": "priceFeed",
"startGovernedUpgradable": "priceFeed",
"vatAdminSvc": "makeCoreProposalBehavior",
"zoe": "makeCoreProposalBehavior"
},
"instance": {
"produce": "priceFeed"
},
"namedVat": {
"consume": {
"agoricNames": "agoricNames"
}
},
"oracleBrand": {
"produce": "priceFeed"
},
"evaluateBundleCap": "makeCoreProposalBehavior",
"installation": {
"produce": "makeCoreProposalBehavior"
},
"modules": {
"utils": {
"runModuleBehaviors": "makeCoreProposalBehavior"
}
}
}
190 changes: 190 additions & 0 deletions add-stATOM-oracles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
// This is generated by writeCoreProposal; please edit!
/* eslint-disable */

const manifestBundleRef = {bundleID:"b1-0571491fc026ed1e3ed4346c0a8f6b2d818e5614b8bfe6b4ed6ce9caa5eb9729d21cd7f10f4638c9f3b07ebe8d077678afe023a9e6e4f762dd6159b076310e63"};
const getManifestCall = harden([
"getManifestForPriceFeed",
{
AGORIC_INSTANCE_NAME: "STATOM-USD price feed",
IN_BRAND_DECIMALS: 6,
IN_BRAND_LOOKUP: [
"agoricNames",
"oracleBrand",
"STATOM",
],
IN_BRAND_NAME: "STATOM",
OUT_BRAND_DECIMALS: 4,
OUT_BRAND_LOOKUP: [
"agoricNames",
"oracleBrand",
"USD",
],
OUT_BRAND_NAME: "USD",
brandInRef: undefined,
brandOutRef: undefined,
contractTerms: {
POLL_INTERVAL: 30n,
maxSubmissionCount: 1000,
maxSubmissionValue: 115792089237316195423570985008687907853269984665640564039457584007913129639936n,
minSubmissionCount: 2,
minSubmissionValue: 1n,
restartDelay: 1,
timeout: 10,
},
oracleAddresses: [
"agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr",
"agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8",
"agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78",
"agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p",
"agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj",
],
priceAggregatorRef: {
bundleID: "b1-5e23d485ee30dadc1cc78c4df6009466e710bf53d63204f99da96decc50a2997d6afc25df3c0a479e41c7ff46aaa806eb0aaf94c9509c9f4860640ce8b271774",
},
},
]);
const overrideManifest = {
createPriceFeed: {
consume: {
agoricNamesAdmin: "priceFeed",
board: "priceFeed",
chainStorage: "priceFeed",
chainTimerService: "priceFeed",
client: "priceFeed",
contractGovernor: "priceFeed",
econCharterKit: "priceFeed",
economicCommitteeCreatorFacet: "priceFeed",
highPrioritySendersManager: "priceFeed",
namesByAddressAdmin: "priceFeed",
priceAuthority: "priceFeed",
priceAuthorityAdmin: "priceFeed",
startGovernedUpgradable: "priceFeed",
},
instance: {
produce: "priceFeed",
},
},
ensureOracleBrands: {
namedVat: {
consume: {
agoricNames: "agoricNames",
},
},
oracleBrand: {
produce: "priceFeed",
},
},
};

// Make the behavior the completion value.
(({
manifestBundleRef,
getManifestCall,
overrideManifest,
E,
log = console.info,
restoreRef: overrideRestoreRef,
}) => {
const { entries, fromEntries } = Object;

// deeplyFulfilled is a bit overkill for what we need.
const shallowlyFulfilled = async obj => {
if (!obj) {
return obj;
}
const ents = await Promise.all(
entries(obj).map(async ([key, valueP]) => {
const value = await valueP;
return [key, value];
}),
);
return fromEntries(ents);
};

/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} allPowers */
const behavior = async allPowers => {
// NOTE: If updating any of these names extracted from `allPowers`, you must
// change `permits` above to reflect their accessibility.
const {
consume: { vatAdminSvc, zoe, agoricNamesAdmin },
evaluateBundleCap,
installation: { produce: produceInstallations },
modules: {
utils: { runModuleBehaviors },
},
} = allPowers;
const [exportedGetManifest, ...manifestArgs] = getManifestCall;

/** @type {(ref: import\('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
const defaultRestoreRef = async ref => {
// extract-proposal.js creates these records, and bundleName is
// the name under which the bundle was installed into
// config.bundles
const p =
'bundleName' in ref
? E(vatAdminSvc).getBundleIDByName(ref.bundleName)
: ref.bundleID;
const bundleID = await p;
const label = bundleID.slice(0, 8);
return E(zoe).installBundleID(bundleID, label);
};
const restoreRef = overrideRestoreRef || defaultRestoreRef;

// Get the on-chain installation containing the manifest and behaviors.
console.info('evaluateBundleCap', {
manifestBundleRef,
exportedGetManifest,
vatAdminSvc,
});
let bcapP;
if ('bundleName' in manifestBundleRef) {
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);
} else {
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);
}
const bundleCap = await bcapP;

const manifestNS = await evaluateBundleCap(bundleCap);

console.error('execute', {
exportedGetManifest,
behaviors: Object.keys(manifestNS),
});
const {
manifest,
options: rawOptions,
installations: rawInstallations,
} = await manifestNS[exportedGetManifest](
harden({ restoreRef }),
...manifestArgs,
);

// Await references in the options or installations.
const [options, installations] = await Promise.all(
[rawOptions, rawInstallations].map(shallowlyFulfilled),
);

// Publish the installations for behavior dependencies.
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
await Promise.all(
entries(installations || {}).map(([key, value]) => {
produceInstallations[key].resolve(value);
return E(installAdmin).update(key, value);
}),
);

// Evaluate the manifest for our behaviors.
return runModuleBehaviors({
allPowers,
behaviors: manifestNS,
manifest: overrideManifest || manifest,
makeConfig: (name, _permit) => {
log('coreProposal:', name);
return { options };
},
});
};

// Make the behavior the completion value.
return behavior;
})({ manifestBundleRef, getManifestCall, overrideManifest, E });
43 changes: 43 additions & 0 deletions add-stATOM-permit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"consume": {
"bankManager": true,
"agoricNamesAdmin": "makeCoreProposalBehavior",
"bankMints": true,
"reserveKit": true,
"vBankKits": true,
"startUpgradable": true,
"priceAuthorityAdmin": true,
"priceAuthority": true,
"scaledPriceAuthorityKits": true,
"auctioneerKit": "auctioneer",
"vaultFactoryKit": "vaultFactory",
"vatAdminSvc": "makeCoreProposalBehavior",
"zoe": "makeCoreProposalBehavior"
},
"produce": {
"bankMints": true,
"vBankKits": true,
"scaledPriceAuthorityKits": true
},
"installation": {
"consume": {
"mintHolder": true,
"scaledPriceAuthority": true
},
"produce": "makeCoreProposalBehavior"
},
"brand": {
"consume": {
"IST": true
}
},
"instance": {
"consume": true
},
"evaluateBundleCap": "makeCoreProposalBehavior",
"modules": {
"utils": {
"runModuleBehaviors": "makeCoreProposalBehavior"
}
}
}
Loading

0 comments on commit 1aa1b70

Please sign in to comment.