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

add vortex multi-network deployment config #166

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ pnpm deploy:prepare && pnpm deploy:network

The deployment artifacts are going to be in `deployments/{network_name}`.

If deploying a licensed deployment on a network, it's recommended to fork the carbon-contracts repo and push the deployment artifacts into the fork after deployment.
If deploying a licensed deployment on a network, it's recommended to fork the carbon-contracts repo and push the deployment artifacts into the fork after deployment.

You can make changes to the deployment scripts by modifying them in `deploy/scripts/network` and you can add specific network data in `data/named-accounts.ts` (Relevant to Carbon Vortex)

If you want to verify the contracts after deployment, please set up the `VERIFY_API_KEY` environmental variable to the etherscan api key.

Expand Down
2 changes: 2 additions & 0 deletions contracts/vortex/CarbonVortex.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { PPM_RESOLUTION, MAX_GAP } from "../utility/Constants.sol";
* half-life parameter sets the price decay rate -
* - this is the time in seconds it takes for the price to halve
* - this parameter can be configured so that tokens reach the market rate faster or slower
* target token is the token to which all other tokens are traded to (can be native token for example)
* final target token is an additional token to which the target token is traded to (optional)
*/
contract CarbonVortex is ICarbonVortex, Upgradeable, ReentrancyGuardUpgradeable, Utils {
using Address for address payable;
Expand Down
103 changes: 101 additions & 2 deletions data/named-accounts.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NATIVE_TOKEN_ADDRESS } from '../utils/TokenData';
import { DeploymentNetwork, ZERO_ADDRESS } from '../utils/Constants';
import chainIds from '../utils/chainIds.json';

Expand Down Expand Up @@ -74,6 +75,84 @@ const mantle = (address: string) => {
};
};

const blast = (address: string) => {
if (TENDERLY_NETWORK_ID === chainIds[DeploymentNetwork.Blast]) {
return {
[DeploymentNetwork.Blast]: address,
[DeploymentNetwork.Tenderly]: address,
[DeploymentNetwork.TenderlyTestnet]: address
};
}
return {
[DeploymentNetwork.Blast]: address
};
}

const celo = (address: string) => {
if (TENDERLY_NETWORK_ID === chainIds[DeploymentNetwork.Celo]) {
return {
[DeploymentNetwork.Celo]: address,
[DeploymentNetwork.Tenderly]: address,
[DeploymentNetwork.TenderlyTestnet]: address
};
}
return {
[DeploymentNetwork.Celo]: address
};
}

const sei = (address: string) => {
if (TENDERLY_NETWORK_ID === chainIds[DeploymentNetwork.Sei]) {
return {
[DeploymentNetwork.Sei]: address,
[DeploymentNetwork.Tenderly]: address,
[DeploymentNetwork.TenderlyTestnet]: address
};
}
return {
[DeploymentNetwork.Sei]: address
};
}

const fantom = (address: string) => {
if (TENDERLY_NETWORK_ID === chainIds[DeploymentNetwork.Fantom]) {
return {
[DeploymentNetwork.Fantom]: address,
[DeploymentNetwork.Tenderly]: address,
[DeploymentNetwork.TenderlyTestnet]: address
};
}
return {
[DeploymentNetwork.Fantom]: address
};
}

const linea = (address: string) => {
if (TENDERLY_NETWORK_ID === chainIds[DeploymentNetwork.Linea]) {
return {
[DeploymentNetwork.Linea]: address,
[DeploymentNetwork.Tenderly]: address,
[DeploymentNetwork.TenderlyTestnet]: address
};
}
return {
[DeploymentNetwork.Linea]: address
};
}

const telos = (address: string) => {
if (TENDERLY_NETWORK_ID === chainIds[DeploymentNetwork.Telos]) {
return {
[DeploymentNetwork.Telos]: address,
[DeploymentNetwork.Tenderly]: address,
[DeploymentNetwork.TenderlyTestnet]: address
};
}
return {
[DeploymentNetwork.Telos]: address
};
}

const TestNamedAccounts = {
ethWhale: {
...getAddress(mainnet, '0xDA9dfA130Df4dE4673b89022EE50ff26f6EA73Cf'),
Expand Down Expand Up @@ -154,10 +233,29 @@ const BancorNamedAccounts = {
},
vault: {
...getAddress(mainnet, ZERO_ADDRESS),
...getAddress(base, '0xD2b2D272c30d9a0ff3DbaFe848DA7e2f194f697F')
...getAddress(base, '0xD2b2D272c30d9a0ff3DbaFe848DA7e2f194f697F'),
...getAddress(blast, '0x45d2e25C04F43A06f6C3e21e4f39B860D05a7aC8'),
...getAddress(celo, '0x8cE318919438982514F9f479FDfB40D32C6ab749'),
...getAddress(fantom, '0x4E017822E77e34842b71b8A24b09e6E490FACA13'),
...getAddress(mantle, '0x45d2e25C04F43A06f6C3e21e4f39B860D05a7aC8'),
...getAddress(linea, '0x45d2e25C04F43A06f6C3e21e4f39B860D05a7aC8'),
...getAddress(sei, '0x773B75CfB146bd5d1095fa9d6d45637f02B05119'),
...getAddress(telos, '0x8cE318919438982514F9f479FDfB40D32C6ab749')
}
};

const VortexNamedAccounts = {
targetToken: {
...getAddress(mainnet, NATIVE_TOKEN_ADDRESS)
},
finalTargetToken: {
...getAddress(mainnet, '0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C')
},
transferAddress: {
...getAddress(mainnet, '0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C')
}
}

function getAddress(func: (arg: string) => object | undefined, arg: string): object {
const result = func(arg);
return result || {};
Expand All @@ -179,5 +277,6 @@ export const NamedAccounts = {

...TokenNamedAccounts,
...TestNamedAccounts,
...BancorNamedAccounts
...BancorNamedAccounts,
...VortexNamedAccounts
};
38 changes: 38 additions & 0 deletions deploy/scripts/network/0004-CarbonVortex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ZERO_ADDRESS } from '../../../utils/Constants';
import { DeployedContracts, deployProxy, grantRole, InstanceName, setDeploymentMetadata } from '../../../utils/Deploy';
import { Roles } from '../../../utils/Roles';
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

/**
* deploy a new instance of carbon vortex v2.0 with the following configuration:
*
* 1. target token is *targetToken* - set address in named-accounts VortexNamedAccounts for the chain
* 2. final target token is *finalTargetToken* - set address in named-accounts VortexNamedAccounts for the chain (can be zero address)
* 3. transferAddress is *transferAddress* - set address in named-accounts VortexNamedAccounts for the chain
* 4. CarbonController is set as withdraw address (on execute, tokens will be withdrawn from it
* 5. For licensed deployments, vault should be address 0 (already configured)
*/
const func: DeployFunction = async ({ getNamedAccounts }: HardhatRuntimeEnvironment) => {
const { deployer, targetToken, finalTargetToken, transferAddress } = await getNamedAccounts();
const carbonController = await DeployedContracts.CarbonController.deployed();

await deployProxy({
name: InstanceName.CarbonVortex,
from: deployer,
args: [carbonController.address, ZERO_ADDRESS, transferAddress, targetToken, finalTargetToken]
});

const carbonVortex = await DeployedContracts.CarbonVortex.deployed();

await grantRole({
name: InstanceName.CarbonController,
id: Roles.CarbonController.ROLE_FEES_MANAGER,
member: carbonVortex.address,
from: deployer
});

return true;
};

export default setDeploymentMetadata(__filename, func);
File renamed without changes.
1 change: 1 addition & 0 deletions utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum MainnetNetwork {
Avalanche = 'avalanche',
Base = 'base',
BSC = 'bsc',
Blast = 'blast',
Canto = 'canto',
Celo = 'celo',
Cronos = 'cronos',
Expand Down
1 change: 1 addition & 0 deletions utils/chainIds.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"celo": 42220,
"avalanche": 43114,
"linea": 59144,
"blast": 81457,
"scroll": 534352,
"sepolia": 11155111,
"aurora": 1313161554
Expand Down
Loading