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

chore: parameterize price feed replacement (check liquidation) #9827

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
84fb4f5
refactor: rename e:upgrade-next to n:upgrade-next
Chris-Hibbert Aug 22, 2024
4eb168b
chore: setup f:replace-price-feeds
Chris-Hibbert Aug 29, 2024
b88c330
feat: start of a proposal for replacing priceFeeds
Chris-Hibbert Aug 29, 2024
089bbfd
test: PriceFeedDriver.refreshInvitations()
dckc Sep 9, 2024
45c9927
test: export ATOM oracleAddresses from liquidation support
dckc Sep 9, 2024
739c806
test: thread $SLOGFILE thru liquidation setup
dckc Sep 9, 2024
bbc08f2
feat: makeProposalExtractor supports cliArgs
dckc Sep 9, 2024
51c1516
chore: add parameterized builder to priceFeedSupport
dckc Sep 9, 2024
95059af
test: liquidation works with new price feeds, vaults, auctions
dckc Sep 9, 2024
5e55342
chore(vats): include priceAggregator in WellKnownContracts
dckc Sep 9, 2024
20f82af
refactor: sanitizePathSegment
dckc Sep 10, 2024
3f2a983
chore: deploy-price-feeds core-eval script
dckc Sep 10, 2024
e618b56
chore: integrated price feed proposal
dckc Sep 10, 2024
5269856
test: use updatePriceFeeds
dckc Sep 10, 2024
13843eb
fixup! feat: makeProposalExtractor supports cliArgs
dckc Sep 10, 2024
3e5378d
test: use integrated updatePriceFeeds with config
dckc Sep 10, 2024
a9117e9
chore: align options between deploy-price-feed and scaled...
dckc Sep 10, 2024
6f6c56b
chore: prune priceFeedSupport.js
dckc Sep 10, 2024
710695b
fixup! test: use integrated updatePriceFeeds with config
dckc Sep 10, 2024
3dc7a9e
feat: produce priceAuthority8400 signal when price feeds are updated
dckc Sep 10, 2024
3d6c4e7
chore: wait for "price feeds all repaird" signal
dckc Sep 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

10 changes: 10 additions & 0 deletions a3p-integration/proposals/f:replace-price-feeds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CoreEvalProposal to replace existing price_feed and scaledPriceAuthority vats
# with new contracts. Auctions will need to be replaced, and Vaults will need to
# get at least a null upgrade in order to make use of the new prices. Oracle
# operators will need to accept new invitations, and sync to the roundId (0) of
# the new contracts in order to feed the new pipelines.

The `submission` for this proposal is automatically generated during `yarn build`
in [a3p-integration](../..) using the code in agoric-sdk through
[build-all-submissions.sh](../../scripts/build-all-submissions.sh) and
[build-submission.sh](../../scripts/build-submission.sh).
34 changes: 34 additions & 0 deletions a3p-integration/proposals/f:replace-price-feeds/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"agoricProposal": {
"releaseNotes": false,
"sdkImageTag": "unreleased",
"planName": "UNRELEASED_A3P_INTEGRATION",
"upgradeInfo": {
"coreProposals": []
},
"sdk-generate": [
"vats/replacePriceFeeds.js",
"vats/replace-scaledPriceAuthorities.js",
"vats/add-auction.js",
"vats/upgradeVaults.js"
],
"type": "Software Upgrade Proposal"
},
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "^0.1.0",
"ava": "^5.3.1"
},
"ava": {
"concurrency": 1,
"timeout": "2m",
"files": [
"!submission"
]
},
"scripts": {
"agops": "yarn --cwd /usr/src/agoric-sdk/ --silent agops"
},
"packageManager": "[email protected]"
}
6 changes: 6 additions & 0 deletions a3p-integration/proposals/f:replace-price-feeds/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Place here any test that should be executed using the proposal.
# The effects of this step are not persisted in further layers.

yarn ava ./*.test.js
208 changes: 208 additions & 0 deletions a3p-integration/proposals/n:upgrade-next/agd-tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import {
agd,
agops,
agopsLocation,
CHAINID,
executeCommand,
executeOffer,
GOV1ADDR,
GOV2ADDR,
GOV3ADDR,
newOfferId,
VALIDATORADDR,
} from '@agoric/synthetic-chain';

const ORACLE_ADDRESSES = [GOV1ADDR, GOV2ADDR, GOV3ADDR];

export const BID_OFFER_ID = 'bid-vaultUpgrade-test3';

const queryVstorage = path =>
agd.query('vstorage', 'data', '--output', 'json', path);

// XXX use endo/marshal?
const getQuoteBody = async path => {
const queryOut = await queryVstorage(path);

const body = JSON.parse(JSON.parse(queryOut.value).values[0]);
return JSON.parse(body.body.substring(1));
};

export const getOracleInstance = async price => {
const instanceRec = await queryVstorage(`published.agoricNames.instance`);

const value = JSON.parse(instanceRec.value);
const body = JSON.parse(value.values.at(-1));

const feeds = JSON.parse(body.body.substring(1));
const feedName = `${price}-USD price feed`;

const key = Object.keys(feeds).find(k => feeds[k][0] === feedName);
if (key) {
return body.slots[key];
}
return null;
};

export const checkForOracle = async (t, name) => {
const instance = await getOracleInstance(name);
t.truthy(instance);
};

export const registerOraclesForBrand = async (brandIn, oraclesByBrand) => {
await null;
const promiseArray = [];

const oraclesWithID = oraclesByBrand.get(brandIn);
for (const oracle of oraclesWithID) {
const { address, offerId } = oracle;
promiseArray.push(
executeOffer(
address,
agops.oracle('accept', '--offerId', offerId, `--pair ${brandIn}.USD`),
),
);
}

return Promise.all(promiseArray);
};

/**
* Generate a consistent map of oracleIDs for a brand that can be used to
* register oracles or to push prices. The baseID changes each time new
* invitations are sent/accepted, and need to be maintained as constants in
* scripts that use the oracles. Each oracleAddress and brand needs a unique
* offerId, so we create recoverable IDs using the brandName and oracle id,
* mixed with the upgrade at which the invitations were accepted.
*
* @param {string} baseId
* @param {string} brandName
*/
const addOraclesForBrand = (baseId, brandName) => {
const oraclesWithID = [];
for (let i = 0; i < ORACLE_ADDRESSES.length; i += 1) {
const oracleAddress = ORACLE_ADDRESSES[i];
const offerId = `${brandName}.${baseId}.${i}`;
oraclesWithID.push({ address: oracleAddress, offerId });
}
return oraclesWithID;
};

export const addPreexistingOracles = async (brandIn, oraclesByBrand) => {
await null;

const oraclesWithID = [];
for (let i = 0; i < ORACLE_ADDRESSES.length; i += 1) {
const oracleAddress = ORACLE_ADDRESSES[i];

const path = `published.wallet.${oracleAddress}.current`;
const wallet = await getQuoteBody(path);
const idToInvitation = wallet.offerToUsedInvitation.find(([k]) => {
return !isNaN(k[0]);
});
if (idToInvitation) {
oraclesWithID.push({
address: oracleAddress,
offerId: idToInvitation[0],
});
} else {
console.log('AGD addO skip', oraclesWithID);
}
}

oraclesByBrand.set(brandIn, oraclesWithID);
};

/**
* Generate a consistent map of oracleIDs and brands that can be used to
* register oracles or to push prices. The baseID changes each time new
* invitations are sent/accepted, and need to be maintained as constants in
* scripts that use these records to push prices.
*
* @param {string} baseId
* @param {string[]} brandNames
*/
export const generateOracleMap = (baseId, brandNames) => {
const oraclesByBrand = new Map();
for (const brandName of brandNames) {
const oraclesWithID = addOraclesForBrand(baseId, brandName);
oraclesByBrand.set(brandName, oraclesWithID);
}
return oraclesByBrand;
};

export const pushPrices = (price, brandIn, oraclesByBrand) => {
const promiseArray = [];

for (const oracle of oraclesByBrand.get(brandIn)) {
promiseArray.push(
executeOffer(
oracle.address,
agops.oracle(
'pushPriceRound',
'--price',
price,
'--oracleAdminAcceptOfferId',
oracle.offerId,
),
),
);
}

return Promise.all(promiseArray);
};

export const getPriceQuote = async price => {
const path = `published.priceFeed.${price}-USD_price_feed`;
const body = await getQuoteBody(path);
return body.amountOut.value;
};

export const agopsInter = (...params) => {
const newParams = ['inter', ...params];
return executeCommand(agopsLocation, newParams);
};

export const createBid = (price, addr, offerId) => {
return agopsInter(
'bid',
'by-price',
`--price ${price}`,
`--give 1.0IST`,
'--from',
addr,
'--keyring-backend test',
`--offer-id ${offerId}`,
);
};

export const getLiveOffers = async addr => {
const path = `published.wallet.${addr}.current`;
const body = await getQuoteBody(path);
return body.liveOffers;
};

export const getAuctionCollateral = async index => {
const path = `published.auction.book${index}`;
const body = await getQuoteBody(path);
return body.collateralAvailable.value;
};

export const getVaultPrices = async index => {
const path = `published.vaultFactory.managers.manager${index}.quotes`;
const body = await getQuoteBody(path);
return body.quoteAmount;
};

export const bankSend = (addr, wanted) => {
const chain = ['--chain-id', CHAINID];
const from = ['--from', VALIDATORADDR];
const testKeyring = ['--keyring-backend', 'test'];
const noise = [...from, ...chain, ...testKeyring, '--yes'];

return agd.tx('bank', 'send', VALIDATORADDR, addr, wanted, ...noise);
};

export const getProvisionPoolMetrics = async () => {
const path = `published.provisionPool.metrics`;
return getQuoteBody(path);
};
Loading