Skip to content

Commit

Permalink
Config and deploy for manual feed on xdai
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-cardstack committed Aug 16, 2022
1 parent 9af5149 commit e3aaade
Show file tree
Hide file tree
Showing 6 changed files with 265 additions and 12 deletions.
12 changes: 8 additions & 4 deletions .openzeppelin/addresses-xdai.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@
"proxy": "0x36698BF676c40be119b0Fe4f964f4527943258F2",
"contractName": "ChainlinkFeedAdapter"
},
"CARDOracle": {
"proxy": "0xd570Ed8b313Fe6aEEA4064bd1713b5Cc6d41D3C5",
"contractName": "DIAOracleAdapter"
},
"VersionManager": {
"proxy": "0xd900133f96F85939335ADb9786ea9f2e07Bdf8c0",
"contractName": "VersionManager"
Expand Down Expand Up @@ -122,5 +118,13 @@
"AddPrepaidCardSKUHandler": {
"proxy": "0xBdcd28A153F615c23508C98112a7EC628f9ce38D",
"contractName": "AddPrepaidCardSKUHandler"
},
"CARDOracle": {
"proxy": "0x426558d0cA2f9ec45EbBe4A69Ef10323d5941446",
"contractName": "ChainlinkFeedAdapter"
},
"CARDUSDFeed": {
"proxy": "0xb62e47A584F9Db9fCbB3241966A12B24dF926261",
"contractName": "ManualFeed"
}
}
190 changes: 190 additions & 0 deletions .openzeppelin/unknown-100.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@
"address": "0x75Af6bcc2429681641f3fFb66C44F5d6Ba22e6D6",
"txHash": "0x2124a0d8196162c9707e317c2d666526b1420c906cae510d3ad9186e9f731d09",
"kind": "transparent"
},
{
"address": "0x426558d0cA2f9ec45EbBe4A69Ef10323d5941446",
"txHash": "0xee64be8310a1e99e59356791e4f04a1fc34b91f59ba15c56bb4c1b0457877238",
"kind": "transparent"
},
{
"address": "0xb62e47A584F9Db9fCbB3241966A12B24dF926261",
"txHash": "0x262fe94cc7058fa4ae06112d701f18c2b4d1b6c9d6e87817792861a63d0a8b66",
"kind": "transparent"
}
],
"impls": {
Expand Down Expand Up @@ -18091,6 +18101,186 @@
}
}
}
},
"148610ab53e8c537643f6df46ab7cb4fbdd507e388e297e631e7c0a8b7626ade": {
"address": "0x953FaDb2799635cdE76D128299c25895f5D8c8c4",
"txHash": "0x544c963d7201aeacc5ffdb168d6f12fc0621ca019b72e5e8324abe2255418f22",
"layout": {
"storage": [
{
"label": "_initialized",
"offset": 0,
"slot": "0",
"type": "t_bool",
"contract": "Initializable",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:39"
},
{
"label": "_initializing",
"offset": 1,
"slot": "0",
"type": "t_bool",
"contract": "Initializable",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:44"
},
{
"label": "__gap",
"offset": 0,
"slot": "1",
"type": "t_array(t_uint256)50_storage",
"contract": "ContextUpgradeable",
"src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:31"
},
{
"label": "_owner",
"offset": 0,
"slot": "51",
"type": "t_address",
"contract": "OwnableUpgradeable",
"src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22"
},
{
"label": "__gap",
"offset": 0,
"slot": "52",
"type": "t_array(t_uint256)49_storage",
"contract": "OwnableUpgradeable",
"src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:82"
},
{
"label": "____gap_Ownable",
"offset": 0,
"slot": "101",
"type": "t_array(t_uint256)1_storage",
"contract": "Ownable",
"src": "contracts/core/Ownable.sol:23"
},
{
"label": "____gap",
"offset": 0,
"slot": "102",
"type": "t_array(t_uint256)50_storage",
"contract": "Versionable",
"src": "contracts/core/Versionable.sol:10"
},
{
"label": "_description",
"offset": 0,
"slot": "152",
"type": "t_string_storage",
"contract": "ManualFeed",
"src": "contracts/oracles/ManualFeed.sol:18"
},
{
"label": "_decimals",
"offset": 0,
"slot": "153",
"type": "t_uint8",
"contract": "ManualFeed",
"src": "contracts/oracles/ManualFeed.sol:19"
},
{
"label": "_currentRound",
"offset": 1,
"slot": "153",
"type": "t_uint80",
"contract": "ManualFeed",
"src": "contracts/oracles/ManualFeed.sol:20"
},
{
"label": "rounds",
"offset": 0,
"slot": "154",
"type": "t_mapping(t_uint80,t_struct(RoundData)20804_storage)",
"contract": "ManualFeed",
"src": "contracts/oracles/ManualFeed.sol:22"
},
{
"label": "versionManager",
"offset": 0,
"slot": "155",
"type": "t_address",
"contract": "ManualFeed",
"src": "contracts/oracles/ManualFeed.sol:23"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_array(t_uint256)1_storage": {
"label": "uint256[1]",
"numberOfBytes": "32"
},
"t_array(t_uint256)49_storage": {
"label": "uint256[49]",
"numberOfBytes": "1568"
},
"t_array(t_uint256)50_storage": {
"label": "uint256[50]",
"numberOfBytes": "1600"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_int256": {
"label": "int256",
"numberOfBytes": "32"
},
"t_mapping(t_uint80,t_struct(RoundData)20804_storage)": {
"label": "mapping(uint80 => struct ManualFeed.RoundData)",
"numberOfBytes": "32"
},
"t_string_storage": {
"label": "string",
"numberOfBytes": "32"
},
"t_struct(RoundData)20804_storage": {
"label": "struct ManualFeed.RoundData",
"members": [
{
"label": "exists",
"type": "t_bool",
"offset": 0,
"slot": "0"
},
{
"label": "price",
"type": "t_int256",
"offset": 0,
"slot": "1"
},
{
"label": "startedAt",
"type": "t_uint256",
"offset": 0,
"slot": "2"
},
{
"label": "updatedAt",
"type": "t_uint256",
"offset": 0,
"slot": "3"
}
],
"numberOfBytes": "128"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
},
"t_uint8": {
"label": "uint8",
"numberOfBytes": "1"
},
"t_uint80": {
"label": "uint80",
"numberOfBytes": "10"
}
}
}
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"deploy:xdai:config-only": "env HARDHAT_NETWORK=xdai yarn deploy:config-only",
"deploy:xdai:upgrade-only:skip-verify": "env SKIP_VERIFY=true yarn deploy:xdai:upgrade-only",
"deploy:xdai:version": "env HARDHAT_NETWORK=xdai yarn deploy:config:version",
"deploy:xdai:update-card-price": "env HARDHAT_NETWORK=xdai ./node_modules/.bin/hardhat run scripts/deploy/updateCardPrice.ts",
"deploy:localhost": "yarn deploy:localhost:contracts && yarn deploy:localhost:config:manual-feeds && yarn deploy:localhost:config-only && yarn deploy:localhost:config:version",
"deploy:localhost:contracts": "env HARDHAT_NETWORK=localhost SKIP_VERIFY=true yarn deploy:contracts",
"deploy:localhost:config-only": "env HARDHAT_NETWORK=localhost yarn deploy:config-only",
Expand Down
7 changes: 4 additions & 3 deletions scripts/deploy/001_initialize_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,11 @@ async function main() {
init: [owner],
};
}
// only use mock DIA for private networks
// only use mock DIA for private networks, and as a temporary fix on xdai due to the DIA oracle being out of date
if (
["hardhat", "localhost"].includes(network) &&
!process.env.HARDHAT_FORKING
(["hardhat", "localhost"].includes(network) &&
!process.env.HARDHAT_FORKING) ||
network == "xdai"
) {
contracts["CARDOracle"] = {
contractName: "ChainlinkFeedAdapter",
Expand Down
23 changes: 18 additions & 5 deletions scripts/deploy/config/xdai/CARDOracle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {
chainlinkETHUSDAddress,
chainlinkDAIUSDAddress,
} from "../../xdai-oracles";

import { getAddress, AddressFile, ContractConfig } from "../../config-utils";
import { diaOracleAddress, chainlinkDAIUSDAddress } from "../../xdai-oracles";

export default async function (
proxyAddresses: AddressFile
Expand All @@ -10,17 +14,26 @@ export default async function (
return Promise.resolve({
setup: [
{
name: "oracle",
value: diaOracleAddress,
name: "tokenUsdFeed",
value: address("CARDUSDFeed"),
},
{
name: "tokenSymbol",
value: "CARD",
name: "ethUsdFeed",
value: chainlinkETHUSDAddress,
},
{
name: "daiUsdFeed",
value: chainlinkDAIUSDAddress,
},
{
name: "canSnapToUSD",
value: false,
},
{
name: "snapThreshold",
value: 0,
formatter: (v) => `${(Number(v) / 100000000).toFixed(4)}%`,
},
{
name: "versionManager",
value: address("VersionManager"),
Expand Down
44 changes: 44 additions & 0 deletions scripts/deploy/updateCardPrice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import retry from "async-retry";

import hre from "hardhat";
const { ethers } = hre;
import { patchNetworks, asyncMain, readAddressFile, getSigner } from "./util";
import { AddressFile, getAddress } from "./config-utils";
patchNetworks();

const {
network: { name: network },
} = hre;

async function main(proxyAddresses: AddressFile) {
proxyAddresses = proxyAddresses || readAddressFile(network);
let cardUsdFeedAddress = getAddress("CARDUSDFeed", proxyAddresses);

let signer = getSigner();

let price = process.env.CARD_USD_PRICE;

if (!price) {
throw new Error("Must provide env variable CARD_USD_PRICE");
}

let startedAt = Math.floor(Date.now() / 1000);
let updatedAt = startedAt;
await retry(
async () => {
console.log(
` adding round: price ${price}, startedAt(unix) ${startedAt}, updatedAt(unix) ${updatedAt}`
);

let instance = (
await ethers.getContractAt("ManualFeed", cardUsdFeedAddress)
).connect(signer);
await instance.addRound(price, startedAt, updatedAt);
},
{
retries: 3,
}
);
}

asyncMain(main);

0 comments on commit e3aaade

Please sign in to comment.