Skip to content

Commit

Permalink
Merge pull request #11 from 0xpatrickdev/feat/statom1
Browse files Browse the repository at this point in the history
vault addCollateral proposal updates
  • Loading branch information
0xpatrickdev authored Aug 18, 2023
2 parents 1aa1b70 + e4ea938 commit 7bd1601
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 61 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*-clean.js
136 changes: 111 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ I have checked in the generated files here for reference.

### 2. Setup wallet

One wallet is needed for submitting governance proposals, and two* wallets are required for submitting oracle prices.

```zsh
# list current keys
agd keys list
Expand All @@ -19,10 +21,23 @@ agd keys add [dev-local] --interactive
agd keys show [dev-local] -a
```

### 3. Request faucet funds
* two if `minSubmissionCount` in `decentral-devnet-config.json` is set to `2`

### 3. Request faucet funds + Provision Wallet

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

In a local environment, the following `cosmic-swingset` Makefile commands will help achieve the same:
```zsh
cd ~/agoric-sdk/packages/cosmic-swingset
# fund provision pool
make fund-provision-pool
# create a smart wallet
ACCT_ADDR=your-address make provision-acct
# add faucet tokens to wallet
ACCT_ADDR=your-address FUNDS=80000000ubld,80000000uist,80000000ibc/toyatom,80000000ibc/toystatom1 make fund-acct
```

## Proposal Steps

### 1. Deploy bundles
Expand All @@ -31,56 +46,127 @@ Setup a smart-wallet and request funds here: https://devnet.faucet.agoric.net/,
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
B1=bundles/b1-1c8e93cc80b28b2cf6b1252e9b6edb0253a1f962889f8a255397b43984950a263dd9c9efd82aee5744b46e7bd57ff1c733030e9f4dc8da9b355b185a59687862.json
B2=bundles/b1-8fb229296073327ed26d2a1ac56eda2bdc70c99d68621895a88f6cc09bce2defa3bd0894e97950e5a0696388193279c8f6b9399809611f8fec3ef5aeed355ba5.json
B3=bundles/b1-938304530ab413804ba64aa99a73cccb6f2068c285631463f5bd7e6e42dda81bc27fc81a6976ab7907d19d5d0e31ee5a1eaa05bc7234c7d102cc0a0f3a34ff60.json
B4=bundles/b1-e4ba9cb60b5b59d4d4618710991fe8a503dd4a07c7f17029a342ccb41893bc961ae63bcb0e2c20e4bc2415c9755f090f7761751cdd00b85762902b357a48c5cf.json
agd tx swingset install-bundle $B1 --node $NODE --from $WALLET --chain-id $CHAIN_ID -y
agd tx swingset install-bundle $B2 --node $NODE --from $WALLET --chain-id $CHAIN_ID -y
agd tx swingset install-bundle $B3 --node $NODE --from $WALLET --chain-id $CHAIN_ID -y
agd tx swingset install-bundle $B4 --node $NODE --from $WALLET --chain-id $CHAIN_ID -y
```

### 2. Submit Vault / Asset Proposal
### 2. Submit Governance Proposals

```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 \
agd tx gov submit-proposal swingset-core-eval \
add-stATOM-permit.json add-stATOM.js \
add-stATOM-oracles-permit.json add-stATOM-oracles.js \
--title="Enable stATOM1 Vault" --description="Evaluate add-stATOM.js add-stATOM-oracles" --deposit=1000000ubld \
--gas=auto --gas-adjustment=1.2 \
--node $NODE --from $WALLET --chain-id $CHAIN_ID
```

### 3. Submit Oracle Proposal
### 3. Query Gov Proposals

```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
agd query gov proposals --node $NODE --chain-id $CHAIN_ID --output json | \
jq -c '.proposals[] | [.proposal_id,.voting_end_time,.status]';
```

### 4. Query Gov Proposals
### 4. Vote on Gov Proposal

```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]';
agd tx gov vote 1 yes --node $NODE --from $WALLET --chain-id $CHAIN_ID
```

### 5. Vote on Gov Proposals

## Oracle Steps

Before, ensure at least two addresses you control is listed in `oracleAddresses`. You may also want to adjust `minSubmissionCount` from `3` to `2` in `decentral-devnet-config.json`.

```zsh
NODE=https://devnet.rpc.agoric.net:443
cd ~/agoric-sdk
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
NODE=https://localhost:26657
WALLET=dev-local
WALLET_2=dev-local-2
CHAIN_ID=agoriclocal
alias oracle="yarn run --silent agops oracle"

# accept the offer to submit a price
oracle accept --offerId 1 --pair STATOM1.USD > offer-1-w1.json
agoric wallet send --from $WALLET --offer offer-1-w1.json

# push a price
oracle pushPriceRound --price 10 --roundId 1 --oracleAdminAcceptOfferId 1 > price-offer-1-w1.json
agoric wallet send --from $WALLET --offer price-offer-1-w1.json

# verify price feed
agoric follow :published.priceFeed.STATOM1-USD_price_feed

# submit a price from wallet 2
oracle accept --offerId 1 --pair STATOM1.USD > offer-1-w2.json
agoric wallet send --from $WALLET_2 --offer offer-1-w2.json
oracle pushPriceRound --price 10 --roundId 1 --oracleAdminAcceptOfferId 1 > price-offer-1-w2.json
agoric wallet send --from $WALLET_2 --offer price-offer-1-w2.json
```


## REPL Validation

```js
// request a loan for 5m uist (the minimum)
E(E(home.agoricNames).lookup('issuer', 'IST')).getBrand()
istBrand = history[n]
fiveMillionUistAmount = { brand: istBrand, value: 5_000_000n}

// find the vault factory instance
E(home.agoricNames).lookup('instance', 'VaultFactory')
vfi = history[n]

// open an ATOM vault
E(E(home.agoricNames).lookup('issuer', 'ATOM')).getBrand()
atomBrand = history[n]
atomPurse = E(home.wallet).getPurse("ATOM")
oneMillionUatomAmount = { brand: atomBrand, value: 1_000_000n}
proposal = { give: { Collateral: oneMillionUatomAmount }, want: { Minted: fiveMillionUistAmount } }
E(atomPurse).withdraw(oneMillionUatomAmount)
pmt = { Collateral: history[n] }
E(E(E(home.zoe).getPublicFacet(vfi)).getCollateralManager(atomBrand)).makeVaultInvitation()
inv = history[n]
E(home.zoe).offer(inv, proposal, pmt)
E(history[n]).getOfferResult() // should provide a VaultSeatKit, or show an error

// open an stATOM vault
E(E(home.agoricNames).lookup('issuer', 'STATOM1')).getBrand()
stAtomBrand = history[n]
stAtomPurse = E(home.wallet).getPurse("stATOM1")
oneMillionUstAtomAmount = { brand: stAtomBrand, value: 1_000_000n}
proposal = { give: { Collateral: oneMillionUstAtomAmount }, want: { Minted: fiveMillionUistAmount } }
E(stAtomPurse).withdraw(oneMillionUstAtomAmount)
pmt = { Collateral: history[n] }
E(E(E(home.zoe).getPublicFacet(vfi)).getCollateralManager(stAtomBrand)).makeVaultInvitation()
inv = history[n]
E(home.zoe).offer(inv, proposal, pmt)
E(history[n]).getOfferResult() // should provide a VaultSeatKit, or show an error
```

## REPL Oracle Validation

```js
E(home.agoricNames).lookup('oracleBrand', 'STATOM1')
E(home.agoricNames).lookup('oracleBrand', 'USD')
stAtomOracleBrand = history[n]
E(home.priceAuthority).makeQuoteNotifier({ value: 10n * 10n ** 6n, brand: stAtomOracleBrand }, usdOracleBrand)
E(qn).getUpdateSince()
```
18 changes: 8 additions & 10 deletions add-stATOM-oracles.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// This is generated by writeCoreProposal; please edit!
/* eslint-disable */

const manifestBundleRef = {bundleID:"b1-0571491fc026ed1e3ed4346c0a8f6b2d818e5614b8bfe6b4ed6ce9caa5eb9729d21cd7f10f4638c9f3b07ebe8d077678afe023a9e6e4f762dd6159b076310e63"};
const manifestBundleRef = {bundleID:"b1-1c8e93cc80b28b2cf6b1252e9b6edb0253a1f962889f8a255397b43984950a263dd9c9efd82aee5744b46e7bd57ff1c733030e9f4dc8da9b355b185a59687862"};
const getManifestCall = harden([
"getManifestForPriceFeed",
{
AGORIC_INSTANCE_NAME: "STATOM-USD price feed",
AGORIC_INSTANCE_NAME: "STATOM1-USD price feed",
IN_BRAND_DECIMALS: 6,
IN_BRAND_LOOKUP: [
"agoricNames",
"oracleBrand",
"STATOM",
"STATOM1",
],
IN_BRAND_NAME: "STATOM",
IN_BRAND_NAME: "STATOM1",
OUT_BRAND_DECIMALS: 4,
OUT_BRAND_LOOKUP: [
"agoricNames",
Expand All @@ -32,14 +32,12 @@ const getManifestCall = harden([
timeout: 10,
},
oracleAddresses: [
"agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr",
"agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8",
"agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78",
"agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p",
"agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj",
"agoric1ldmtatp24qlllgxmrsjzcpe20fvlkp448zcuce",
"agoric140dmkrz2e42ergjj7gyvejhzmjzurvqeq82ang",
"agoric15xddzse9lq74cyt6ev9d7wywxerenxdgxsdc3m",
],
priceAggregatorRef: {
bundleID: "b1-5e23d485ee30dadc1cc78c4df6009466e710bf53d63204f99da96decc50a2997d6afc25df3c0a479e41c7ff46aaa806eb0aaf94c9509c9f4860640ce8b271774",
bundleID: "b1-8fb229296073327ed26d2a1ac56eda2bdc70c99d68621895a88f6cc09bce2defa3bd0894e97950e5a0696388193279c8f6b9399809611f8fec3ef5aeed355ba5",
},
},
]);
Expand Down
12 changes: 6 additions & 6 deletions add-stATOM.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// This is generated by writeCoreProposal; please edit!
/* eslint-disable */

const manifestBundleRef = {bundleID:"b1-3cf6f8499883ff9edc294bf784cb0a93af68829da3b469b6c4a53f33c785c416cdb398169a757cf448a1635a3a6b21ac7881d07f9dd184ff3d6579905f44cb5e"};
const manifestBundleRef = {bundleID:"b1-938304530ab413804ba64aa99a73cccb6f2068c285631463f5bd7e6e42dda81bc27fc81a6976ab7907d19d5d0e31ee5a1eaa05bc7234c7d102cc0a0f3a34ff60"};
const getManifestCall = harden([
"getManifestForAddAssetToVault",
{
debtLimitValue: undefined,
interchainAssetOptions: {
decimalPlaces: 6,
denom: "ibc/toystatom",
denom: "ibc/toystatom1",
initialPrice: undefined,
issuerBoardId: undefined,
keyword: "STATOM",
oracleBrand: "STATOM",
proposedName: "stATOM",
keyword: "STATOM1",
oracleBrand: "STATOM1",
proposedName: "stATOM1",
},
interestRateValue: undefined,
scaledPriceAuthorityRef: {
bundleID: "b1-5da781b83f8a3e4e173184e0641a9b95f66aad7c4225a364ef081fd1c124e3c33fc4a04a3dd59eebcf537b3e7944f38429fdbe3713c660b9d272ff4532cf540a",
bundleID: "b1-e4ba9cb60b5b59d4d4618710991fe8a503dd4a07c7f17029a342ccb41893bc961ae63bcb0e2c20e4bc2415c9755f090f7761751cdd00b85762902b357a48c5cf",
},
},
]);
Expand Down

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 7bd1601

Please sign in to comment.