Skip to content

Commit

Permalink
feat: polymer deployment of generalised incentives
Browse files Browse the repository at this point in the history
  • Loading branch information
reednaa committed Dec 19, 2023
1 parent 457ddf7 commit e20c176
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
12 changes: 11 additions & 1 deletion evm/script/BaseMultiChainDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ contract BaseMultiChainDeployer is Script {
BSCTestnet,
MantleTestnet,
OmniTestnet,
INEVMDevnet
INEVMDevnet,
BaseSepolia,
OptimismSepolia
}

mapping(Chains => string) public rpc;
Expand Down Expand Up @@ -81,6 +83,14 @@ contract BaseMultiChainDeployer is Script {
rpc[Chains.INEVMDevnet] = "inevmdevnet";
wrapped_gas[Chains.INEVMDevnet] = "WINJ";
chain_list.push(Chains.INEVMDevnet);

rpc[Chains.BaseSepolia] = "basesepolia";
wrapped_gas[Chains.BaseSepolia] = "WOMNI";
chain_list.push(Chains.BaseSepolia);

rpc[Chains.OptimismSepolia] = "optimismsepolia";
wrapped_gas[Chains.OptimismSepolia] = "WINJ";
chain_list.push(Chains.OptimismSepolia);
}

uint256 pk;
Expand Down
24 changes: 21 additions & 3 deletions evm/script/DeployInterfaces.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { BaseMultiChainDeployer} from "./BaseMultiChainDeployer.s.sol";
import { IncentivizedMockEscrow } from "GeneralisedIncentives/src/apps/mock/IncentivizedMockEscrow.sol";
import { IncentivizedWormholeEscrow } from "GeneralisedIncentives/src/apps/wormhole/IncentivizedWormholeEscrow.sol";

import { IncentivizedPolymerEscrow } from "GeneralisedIncentives/src/apps/polymer/IncentivizedPolymerEscrow.sol";

import { JsonContracts } from "./DeployContracts.s.sol";

contract DeployInterfaces is BaseMultiChainDeployer {
Expand All @@ -33,22 +35,27 @@ contract DeployInterfaces is BaseMultiChainDeployer {

mapping(Chains => address) wormholeBridge;

mapping(Chains => address) polymerContract;

constructor() {
interfaceSalt[0x00000001a9818a7807998dbc243b05F2B3CfF6f4] = bytes32(uint256(1));

interfaceSalt[0x000000ED80503e3A7EA614FFB5507FD52584a1f2] = bytes32(uint256(1));

wormholeBridge[Chains.Sepolia] = 0x4a8bc80Ed5a4067f1CCf107057b8270E0cC11A78;

wormholeBridge[Chains.Mumbai] = 0x0CBE91CF822c73C2315FB05100C2F714765d5c20;

polymerContract[Chains.BaseSepolia] = 0xfcef85E0F0Afd1Acd73fAF1648266DF923d4521d;
polymerContract[Chains.OptimismSepolia] = 0x3001b73254EB715799EB93E8413EdCE4721090Ab;
}

function deployGeneralisedIncentives(string memory version) internal returns(address incentive) {
// Here is the map of id to version:
// id == 0: Mock (POA)
// id == 1: Wormhole
bytes32 chainIdentifier = abi.decode(config_chain.parseRaw(string.concat(".", version, ".", rpc[chain], ".", rpc[chain])), (bytes32));
if (keccak256(abi.encodePacked(version)) == keccak256(abi.encodePacked("MOCK"))) {
bytes32 chainIdentifier = abi.decode(config_chain.parseRaw(string.concat(".", version, ".", rpc[chain], ".", rpc[chain])), (bytes32));

address signer = vm.envAddress("MOCK_SIGNER");

vm.stopBroadcast();
Expand All @@ -67,6 +74,15 @@ contract DeployInterfaces is BaseMultiChainDeployer {

incentive = address(new IncentivizedWormholeEscrow(vm.envAddress("CATALYST_ADDRESS"), wormholeBridge[chain]));

vm.stopBroadcast();
vm.startBroadcast(pk);
} else if (keccak256(abi.encodePacked(version)) == keccak256(abi.encodePacked("POLYMER"))) {
vm.stopBroadcast();
uint256 pv_key = vm.envUint("POLYMER_DEPLOYER");
vm.startBroadcast(pv_key);

incentive = address(new IncentivizedPolymerEscrow(vm.envAddress("CATALYST_ADDRESS"), wormholeBridge[chain]));

vm.stopBroadcast();
vm.startBroadcast(pk);
} else {
Expand Down Expand Up @@ -109,6 +125,7 @@ contract DeployInterfaces is BaseMultiChainDeployer {
return;
}
address newlyDeployedIncentiveAddress = deployGeneralisedIncentives(incentiveVersion);
console.log("Deploying new base incentive");
console.logAddress(newlyDeployedIncentiveAddress);
require(newlyDeployedIncentiveAddress == incentiveAddress, "Newly deployed incentive address isn't expected address");
}
Expand All @@ -129,6 +146,7 @@ contract DeployInterfaces is BaseMultiChainDeployer {
new CatalystChainInterface{salt: salt}(incentiveAddress, admin)
);

console.log("Deploying new base interface");
console.logAddress(newlyDeployedInterfaceAddress);

require(newlyDeployedInterfaceAddress == interfaceAddress, "Newly deployed interface address isn't expected address");
Expand All @@ -138,7 +156,7 @@ contract DeployInterfaces is BaseMultiChainDeployer {
function _deploy() internal {
address admin = address(0x0000007aAAC54131e031b3C0D6557723f9365A5B);

fund(vm.envAddress("INCENTIVE_DEPLOYER_ADDRESS"), 0.05*10**18);
// fund(vm.envAddress("INCENTIVE_DEPLOYER_ADDRESS"), 0.05*10**18);

deployBaseIncentive();

Expand Down
9 changes: 8 additions & 1 deletion evm/script/config/config_chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,12 @@
}
},
"HYPERLANE": {},
"POLYMER": {}
"POLYMER": {
"basesepolia": {
"optimismsepolia": 44963396551096171397160558726282299286140034337171331191205222918429706551296
},
"optimismsepolia": {
"basesepolia": 44963396551096171397185078654936153507873767889605736138143122744384644186112
}
}
}
12 changes: 12 additions & 0 deletions evm/script/config/config_interfaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
"interface": "0x307737d19238D3E07CC3E0167cEd991a32D21dD9"
}
},
"basesepolia": {
"POLYMER": {
"incentive": "0x000000d76e7F74E60cFAA1a885E01a8770C9E580",
"interface": "0xe5cFD130edbC99bd38e0B7A2E0A0Ac10dDE30B5F"
}
},
"mantletestnet" : {
"MOCK": {
"incentive": "0x00000001a9818a7807998dbc243b05F2B3CfF6f4",
Expand Down Expand Up @@ -55,6 +61,12 @@
"interface": "0x307737d19238D3E07CC3E0167cEd991a32D21dD9"
}
},
"optimismsepolia": {
"POLYMER": {
"incentive": "0x000000d76e7F74E60cFAA1a885E01a8770C9E580",
"interface": "0xe5cFD130edbC99bd38e0B7A2E0A0Ac10dDE30B5F"
}
},
"bsctestnet": {
"MOCK": {
"incentive": "0x00000001a9818a7807998dbc243b05F2B3CfF6f4",
Expand Down
6 changes: 6 additions & 0 deletions evm/script/config/config_tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,11 @@
},
"inevmdevnet": {
"WINJ": "0x0000005eff5E63a9B4C4505Af65F701354d0Bef7"
},
"basesepolia": {
"WETH": "0xb54d11Bc9Aadf9D66C20B977D4aA84dfaaDAD631"
},
"optimismsepolia": {
"WETH": "0x74A4A85C611679B73F402B36c0F84A7D2CcdFDa3"
}
}

0 comments on commit e20c176

Please sign in to comment.