Skip to content

Commit

Permalink
feat: WIP deploy EUR transmuter on Base (#118)
Browse files Browse the repository at this point in the history
* feat: WIP deploy EUR transmuter on Base

* tests done

* feat: deployed
  • Loading branch information
GuillaumeNervoXS authored Nov 5, 2024
1 parent 689aa30 commit 3ea9f59
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 82 deletions.
52 changes: 30 additions & 22 deletions contracts/transmuter/configs/ProductionSidechain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,35 @@ contract ProductionSidechain {
address _agToken,
// USDC like tokens
address liquidStablecoin,
address oracleLiquidStablecoin,
address[] memory oracleLiquidStablecoin,
uint8[] memory oracleIsMultiplied,
uint256 hardCap,
address dummyImplementation
) external {
// Set Collaterals
CollateralSetupProd[] memory collaterals = new CollateralSetupProd[](1);
// Liquid stablecoin
{
uint64[] memory xMintFee = new uint64[](1);
xMintFee[0] = uint64(0);

int64[] memory yMintFee = new int64[](1);
yMintFee[0] = int64(0);

uint64[] memory xBurnFee = new uint64[](1);
xBurnFee[0] = uint64(BASE_9);

int64[] memory yBurnFee = new int64[](1);
yBurnFee[0] = int64(0);

bytes memory oracleConfig;
{
bytes memory readData;
{
AggregatorV3Interface[] memory circuitChainlink = new AggregatorV3Interface[](1);
uint32[] memory stalePeriods = new uint32[](1);
uint8[] memory circuitChainIsMultiplied = new uint8[](1);
uint8[] memory chainlinkDecimals = new uint8[](1);
uint256 oracleLength = oracleLiquidStablecoin.length;
if (oracleLength != oracleIsMultiplied.length) {
revert("ProductionSidechain: oracles length not equal");

Check warning on line 29 in contracts/transmuter/configs/ProductionSidechain.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of revert statements

Check warning on line 29 in contracts/transmuter/configs/ProductionSidechain.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of revert statements

Check warning on line 29 in contracts/transmuter/configs/ProductionSidechain.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of revert statements
}
AggregatorV3Interface[] memory circuitChainlink = new AggregatorV3Interface[](oracleLength);
uint32[] memory stalePeriods = new uint32[](oracleLength);
uint8[] memory circuitChainIsMultiplied = new uint8[](oracleLength);
uint8[] memory chainlinkDecimals = new uint8[](oracleLength);

// Oracle between liquid stablecoin and the fiat it is peg to
circuitChainlink[0] = AggregatorV3Interface(oracleLiquidStablecoin);
stalePeriods[0] = 1 days;
circuitChainIsMultiplied[0] = 1;
chainlinkDecimals[0] = 8;
for (uint256 i; i < oracleLiquidStablecoin.length; i++) {
circuitChainlink[i] = AggregatorV3Interface(oracleLiquidStablecoin[i]);
stalePeriods[i] = 1 days;
circuitChainIsMultiplied[i] = oracleIsMultiplied[i];
chainlinkDecimals[i] = 8;
}
OracleQuoteType quoteType = OracleQuoteType.UNIT;
readData = abi.encode(
circuitChainlink,
Expand All @@ -60,9 +55,22 @@ contract ProductionSidechain {
Storage.OracleReadType.STABLE,
readData,
targetData,
abi.encode(uint128(0), uint128(50 * BPS))
abi.encode(uint128(30 * BPS), uint128(0))
);
}

uint64[] memory xMintFee = new uint64[](1);
xMintFee[0] = uint64(0);

int64[] memory yMintFee = new int64[](1);
yMintFee[0] = int64(0);

uint64[] memory xBurnFee = new uint64[](1);
xBurnFee[0] = uint64(BASE_9);

int64[] memory yBurnFee = new int64[](1);
yBurnFee[0] = int64(0);

collaterals[0] = CollateralSetupProd(
liquidStablecoin,
oracleConfig,
Expand Down
15 changes: 12 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ via_ir = true
sizes = true
optimizer = true
optimizer_runs=1000
solc_version = '0.8.23'
solc_version = '0.8.26'
ffi = true
fs_permissions = [
{ access = "read-write", path = "./scripts/selectors.json"},
Expand Down Expand Up @@ -42,10 +42,19 @@ base = "${ETH_NODE_URI_BASE}"
linea = "${ETH_NODE_URI_LINEA}"

[etherscan]

arbitrum = { key = "${ARBITRUM_ETHERSCAN_API_KEY}" }
gnosis = { key = "${GNOSIS_ETHERSCAN_API_KEY}" , url = "https://api.gnosisscan.io/api"}
mainnet = { key = "${MAINNET_ETHERSCAN_API_KEY}" }
optimism = { key = "${OPTIMISM_ETHERSCAN_API_KEY}" }
polygon = { key = "${POLYGON_ETHERSCAN_API_KEY}" }
avalanche = { key = "${AVALANCHE_ETHERSCAN_API_KEY}" }
celo = { key = "${CELO_ETHERSCAN_API_KEY}", url = "https://api.celoscan.io/api" }
base = { key = "${BASE_ETHERSCAN_API_KEY}", url = "https://api.basescan.org/api" }
polygon-zkevm = { key = "${POLYGONZKEVM_ETHERSCAN_API_KEY}", url = "https://api-zkevm.polygonscan.com/api" }
bsc = { key = "${BSC_ETHERSCAN_API_KEY}"}
linea = { key = "${LINEA_ETHERSCAN_API_KEY}"}

[profile.dev]
optimizer = true
via_ir = false
src = 'contracts'
gas_reports = ["*"]
Expand Down
2 changes: 1 addition & 1 deletion lib/utils
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"coverage": "FOUNDRY_PROFILE=dev forge coverage --report lcov && yarn lcov:clean && yarn lcov:generate-html",
"compile": "forge build",
"compile:dev": "FOUNDRY_PROFILE=dev forge build",
"deploy": "forge script --skip test --broadcast --verify --slow -vvvv --rpc-url",
"deploy:fork": "forge script --skip test --slow --fork-url fork --broadcast -vvvv",
"deploy": "FOUNDRY_PROFILE=dev forge script --skip test --broadcast --verify --slow -vvvv --rpc-url",
"deploy:fork": "FOUNDRY_PROFILE=dev forge script --skip test --slow --fork-url fork --broadcast -vvvv",
"generate": "FOUNDRY_PROFILE=dev forge script scripts/utils/GenerateSelectors.s.sol",
"deploy:check": "FOUNDRY_PROFILE=dev forge script --fork-url fork scripts/test/CheckTransmuter.s.sol",
"gas": "FOUNDRY_PROFILE=dev yarn test --gas-report",
Expand Down
18 changes: 14 additions & 4 deletions scripts/DeployTransmuterSidechain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,25 @@ contract DeployTransmuterSidechain is TransmuterDeploymentHelper, Helpers {

// TODO
uint256 chain = CHAIN_BASE;
uint256 hardCap = 1000 ether;
uint256 hardCap = 2_000_000 ether;
address core = _chainToContract(chain, ContractType.CoreBorrow);
address agToken = _chainToContract(chain, ContractType.AgUSD);
StablecoinType fiat = StablecoinType.USD;
address agToken = _chainToContract(chain, ContractType.AgEUR);
address liquidStablecoin;
address[] memory oracleLiquidStablecoin;
uint8[] memory oracleIsMultiplied;
{
StablecoinType fiat = StablecoinType.EUR;
(liquidStablecoin, oracleLiquidStablecoin, oracleIsMultiplied) = _chainToLiquidStablecoinAndOracle(
chain,
fiat
);
}

// Config
config = address(new ProductionSidechain());

address dummyImplementation = address(new DummyDiamondImplementation());
(address liquidStablecoin, address oracleLiquidStablecoin) = _chainToLiquidStablecoinAndOracle(chain, fiat);

ITransmuter transmuter = _deployTransmuter(
config,
abi.encodeWithSelector(
Expand All @@ -51,6 +60,7 @@ contract DeployTransmuterSidechain is TransmuterDeploymentHelper, Helpers {
agToken,
liquidStablecoin,
oracleLiquidStablecoin,
oracleIsMultiplied,
hardCap,
dummyImplementation
)
Expand Down
128 changes: 81 additions & 47 deletions scripts/Helpers.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,89 +26,123 @@ contract Helpers is Utils {
function _chainToLiquidStablecoinAndOracle(
uint256 chain,
StablecoinType fiat
) internal pure returns (address, address) {
)
internal
pure
returns (address liquidStablecoin, address[] memory oracleAddresses, uint8[] memory oracleIsMultiplied)
{
oracleAddresses = new address[](1);
oracleIsMultiplied = new uint8[](1);
if (chain == CHAIN_ARBITRUM) {
if (fiat == StablecoinType.USD)
return (
address(0xaf88d065e77c8cC2239327C5EDb3A432268e5831),
address(0x50834F3163758fcC1Df9973b6e91f0F0F0434aD3)
);
else revert("chain not supported");
if (fiat == StablecoinType.USD) {
liquidStablecoin = address(0xaf88d065e77c8cC2239327C5EDb3A432268e5831);
oracleAddresses[0] = address(0x50834F3163758fcC1Df9973b6e91f0F0F0434aD3);
oracleIsMultiplied[0] = 1;
} else revert("chain not supported");
}
if (chain == CHAIN_AVALANCHE) {
// USDC
if (fiat == StablecoinType.USD)
return (
address(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E),
address(0xF096872672F44d6EBA71458D74fe67F9a77a23B9)
);
// EURC
else return (address(0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD), address(0));
if (fiat == StablecoinType.USD) {
liquidStablecoin = address(0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E);
oracleAddresses[0] = address(0xF096872672F44d6EBA71458D74fe67F9a77a23B9);
oracleIsMultiplied[0] = 1;
// EURC
} else {
liquidStablecoin = address(0xC891EB4cbdEFf6e073e859e987815Ed1505c2ACD);
oracleAddresses[0] = address(0);
oracleIsMultiplied[0] = 1;
}
}
if (chain == CHAIN_BASE) {
// USDC
if (fiat == StablecoinType.USD)
return (
address(0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913),
address(0x7e860098F58bBFC8648a4311b374B1D669a2bc6B)
);
else revert("chain not supported");
if (fiat == StablecoinType.USD) {
liquidStablecoin = address(0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913);
oracleAddresses[0] = address(0x7e860098F58bBFC8648a4311b374B1D669a2bc6B);
oracleIsMultiplied[0] = 1;
} else {
address[] memory oracleAddressesSize2 = new address[](2);
uint8[] memory oracleIsMultipliedSize2 = new uint8[](2);

liquidStablecoin = address(0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42);
oracleAddressesSize2[0] = address(0xDAe398520e2B67cd3f27aeF9Cf14D93D927f8250);
oracleIsMultipliedSize2[0] = 1;

oracleAddressesSize2[1] = address(0xc91D87E81faB8f93699ECf7Ee9B44D11e1D53F0F);
oracleIsMultipliedSize2[1] = 0;

return (liquidStablecoin, oracleAddressesSize2, oracleIsMultipliedSize2);
}
}
if (chain == CHAIN_BNB) {
if (fiat == StablecoinType.USD) revert("chain not supported");
else revert("chain not supported");
}
if (chain == CHAIN_CELO) {
// USDC
if (fiat == StablecoinType.USD)
return (
address(0xcebA9300f2b948710d2653dD7B07f33A8B32118C),
address(0xc7A353BaE210aed958a1A2928b654938EC59DaB2)
);
else revert("chain not supported");
if (fiat == StablecoinType.USD) {
liquidStablecoin = address(0xcebA9300f2b948710d2653dD7B07f33A8B32118C);
oracleAddresses[0] = address(0xc7A353BaE210aed958a1A2928b654938EC59DaB2);
oracleIsMultiplied[0] = 1;
} else revert("chain not supported");
}
if (chain == CHAIN_ETHEREUM) {
// USDC
if (fiat == StablecoinType.USD)
return (
address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48),
address(0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6)
);
if (fiat == StablecoinType.USD) {
liquidStablecoin = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
oracleAddresses[0] = address(0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6);
oracleIsMultiplied[0] = 1;
}
// EURC
else return (address(0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c), address(0));
else {
liquidStablecoin = address(0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c);
oracleAddresses[0] = address(0);
oracleIsMultiplied[0] = 1;
}
}
if (chain == CHAIN_LINEA) {
if (fiat == StablecoinType.USD) revert("chain not supported");
else revert("chain not supported");
}
if (chain == CHAIN_GNOSIS) {
if (fiat == StablecoinType.USD)
return (0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83, 0x26C31ac71010aF62E6B486D1132E266D6298857D);
if (fiat == StablecoinType.USD) {
liquidStablecoin = address(0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83);
oracleAddresses[0] = address(0x26C31ac71010aF62E6B486D1132E266D6298857D);
oracleIsMultiplied[0] = 1;
}
// EURe
else return (address(0xcB444e90D8198415266c6a2724b7900fb12FC56E), address(0));
else {
liquidStablecoin = address(0xcB444e90D8198415266c6a2724b7900fb12FC56E);
oracleAddresses[0] = address(0);
oracleIsMultiplied[0] = 1;
}
}
if (chain == CHAIN_OPTIMISM) {
// USDC
if (fiat == StablecoinType.USD)
return (
address(0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85),
address(0x16a9FA2FDa030272Ce99B29CF780dFA30361E0f3)
);
else revert("chain not supported");
if (fiat == StablecoinType.USD) {
liquidStablecoin = address(0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85);
oracleAddresses[0] = address(0x16a9FA2FDa030272Ce99B29CF780dFA30361E0f3);
oracleIsMultiplied[0] = 1;
} else revert("chain not supported");
}
if (chain == CHAIN_POLYGON) {
// USDC
if (fiat == StablecoinType.USD)
return (
address(0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359),
address(0xfE4A8cc5b5B2366C1B58Bea3858e81843581b2F7)
);
if (fiat == StablecoinType.USD) {
liquidStablecoin = address(0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359);
oracleAddresses[0] = address(0xfE4A8cc5b5B2366C1B58Bea3858e81843581b2F7);
oracleIsMultiplied[0] = 1;
}
// EURe
else return (address(0x18ec0A6E18E5bc3784fDd3a3634b31245ab704F6), address(0));
else {
liquidStablecoin = address(0x18ec0A6E18E5bc3784fDd3a3634b31245ab704F6);
oracleAddresses[0] = address(0);
oracleIsMultiplied[0] = 1;
}
}
if (chain == CHAIN_POLYGONZKEVM) {
if (fiat == StablecoinType.USD) revert("chain not supported");
else revert("chain not supported");
} else revert("chain not supported");

return (liquidStablecoin, oracleAddresses, oracleIsMultiplied);
}
}
2 changes: 1 addition & 1 deletion scripts/interaction/transmuter/Swap.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract SwapTransmuter is Utils, Helpers {
uint256 chain = CHAIN_GNOSIS;
StablecoinType fiat = StablecoinType.USD;
address agToken = _chainToContract(chain, ContractType.AgUSD);
(address liquidStablecoin, ) = _chainToLiquidStablecoinAndOracle(chain, fiat);
(address liquidStablecoin, , ) = _chainToLiquidStablecoinAndOracle(chain, fiat);
transmuter = ITransmuter(_chainToContract(chain, ContractType.TransmuterAgUSD));
tokenIn = agToken;
decimalsIn = IERC20Metadata(agToken).decimals();
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/TransmuterDeploymentHelper.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ contract TransmuterDeploymentHelper is Utils {

address computedAddress = create2Factory.findCreate2Address(salt, initCode);
console.log("Supposed to deploy: %s", address(computedAddress));
if (computedAddress != 0x222222880e079445Df703c0604706E71a538Fd4f) revert InvalidVanityAddress();
// if (computedAddress != 0x222222880e079445Df703c0604706E71a538Fd4f) revert InvalidVanityAddress();

transmuter = ITransmuter(create2Factory.safeCreate2(salt, initCode));
}
Expand Down
Loading

0 comments on commit 3ea9f59

Please sign in to comment.