forked from axieinfinity/ronin-dpos-contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from axieinfinity/proposal/map-pixel-token-tes…
…tnet script: change pixel saigon token
- Loading branch information
Showing
5 changed files
with
559 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
script/20240201-maptoken-pixel-saigon/20240201-maptoken-pixel-mainchain.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { console2 } from "forge-std/console2.sol"; | ||
import { StdStyle } from "forge-std/StdStyle.sol"; | ||
import { BaseMigration } from "foundry-deployment-kit/BaseMigration.s.sol"; | ||
import { RoninBridgeManager } from "@ronin/contracts/ronin/gateway/RoninBridgeManager.sol"; | ||
import { IMainchainGatewayV3 } from "@ronin/contracts/interfaces/IMainchainGatewayV3.sol"; | ||
import { GlobalProposal } from "@ronin/contracts/libraries/GlobalProposal.sol"; | ||
import { Token } from "@ronin/contracts/libraries/Token.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import { BridgeMigration } from "../BridgeMigration.sol"; | ||
import { Network } from "../utils/Network.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import { IGeneralConfigExtended } from "../IGeneralConfigExtended.sol"; | ||
|
||
import "./maptoken-pixel-configs.s.sol"; | ||
|
||
contract Migration__20240201_MapTokenPixelMainchainTestnet is BridgeMigration, Migration__MapToken_Pixel_Config { | ||
RoninBridgeManager internal _roninBridgeManager; | ||
address internal _mainchainGatewayV3; | ||
address internal _mainchainBridgeManager; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
|
||
_roninBridgeManager = RoninBridgeManager(_config.getAddressFromCurrentNetwork(Contract.RoninBridgeManager.key())); | ||
_mainchainGatewayV3 = _config.getAddress( | ||
_config.getCompanionNetwork(_config.getNetworkByChainId(block.chainid)).key(), | ||
Contract.MainchainGatewayV3.key() | ||
); | ||
_mainchainBridgeManager = _config.getAddress( | ||
_config.getCompanionNetwork(_config.getNetworkByChainId(block.chainid)).key(), | ||
Contract.MainchainBridgeManager.key() | ||
); | ||
} | ||
|
||
function run() public { | ||
address[] memory mainchainTokens = new address[](1); | ||
address[] memory roninTokens = new address[](1); | ||
Token.Standard[] memory standards = new Token.Standard[](1); | ||
|
||
uint256 expiredTime = block.timestamp + 10 minutes; | ||
address[] memory targets = new address[](1); | ||
uint256[] memory values = new uint256[](1); | ||
bytes[] memory calldatas = new bytes[](1); | ||
uint256[] memory gasAmounts = new uint256[](1); | ||
|
||
// ================ PIXEL ERC-20 ====================== | ||
|
||
mainchainTokens[0] = _pixelMainchainToken; | ||
roninTokens[0] = _pixelNewRoninToken; | ||
standards[0] = Token.Standard.ERC20; | ||
|
||
// function mapTokens( | ||
// address[] calldata _mainchainTokens, | ||
// address[] calldata _roninTokens, | ||
// Token.Standard[] calldata _standards | ||
// ) | ||
|
||
bytes memory innerData = abi.encodeCall(IMainchainGatewayV3.mapTokens, ( | ||
mainchainTokens, | ||
roninTokens, | ||
standards | ||
)); | ||
|
||
bytes memory proxyData = abi.encodeWithSignature("functionDelegateCall(bytes)", innerData); | ||
|
||
targets[0] = _mainchainGatewayV3; | ||
values[0] = 0; | ||
calldatas[0] = proxyData; | ||
gasAmounts[0] = 1_000_000; | ||
|
||
// ================ VERIFY AND EXECUTE PROPOSAL =============== | ||
|
||
_verifyMainchainProposalGasAmount(targets, values, calldatas, gasAmounts); | ||
|
||
uint256 chainId = _config.getCompanionNetwork(_config.getNetworkByChainId(block.chainid)).chainId(); | ||
|
||
vm.broadcast(_governor); | ||
_roninBridgeManager.propose( | ||
chainId, | ||
expiredTime, | ||
targets, | ||
values, | ||
calldatas, | ||
gasAmounts | ||
); | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
script/20240201-maptoken-pixel-saigon/20240201-maptoken-pixel-roninchain.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { console2 } from "forge-std/console2.sol"; | ||
import { StdStyle } from "forge-std/StdStyle.sol"; | ||
import { BaseMigration } from "foundry-deployment-kit/BaseMigration.s.sol"; | ||
|
||
import { RoninBridgeManager } from "@ronin/contracts/ronin/gateway/RoninBridgeManager.sol"; | ||
import { IRoninGatewayV3 } from "@ronin/contracts/interfaces/IRoninGatewayV3.sol"; | ||
import { MinimumWithdrawal } from "@ronin/contracts/extensions/MinimumWithdrawal.sol"; | ||
import { Token } from "@ronin/contracts/libraries/Token.sol"; | ||
import { Ballot } from "@ronin/contracts/libraries/Ballot.sol"; | ||
import { GlobalProposal } from "@ronin/contracts/libraries/GlobalProposal.sol"; | ||
|
||
import { Contract } from "../utils/Contract.sol"; | ||
import { BridgeMigration } from "../BridgeMigration.sol"; | ||
import { Network } from "../utils/Network.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import { IGeneralConfigExtended } from "../IGeneralConfigExtended.sol"; | ||
|
||
import "forge-std/console2.sol"; | ||
|
||
import "./maptoken-pixel-configs.s.sol"; | ||
|
||
contract Migration__20240201_MapTokenPixelRoninchainTestnet is BridgeMigration, Migration__MapToken_Pixel_Config { | ||
RoninBridgeManager internal _roninBridgeManager; | ||
address internal _roninGatewayV3; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
_roninBridgeManager = RoninBridgeManager(_config.getAddressFromCurrentNetwork(Contract.RoninBridgeManager.key())); | ||
_roninGatewayV3 = _config.getAddressFromCurrentNetwork(Contract.RoninGatewayV3.key()); | ||
|
||
// _cheatWeightOperator(_governor); | ||
} | ||
|
||
function _cheatWeightOperator(address gov) internal { | ||
bytes32 $ = keccak256(abi.encode(gov, 0x88547008e60f5748911f2e59feb3093b7e4c2e87b2dd69d61f112fcc932de8e3)); | ||
bytes32 opAndWeight = vm.load(address(_roninBridgeManager), $); | ||
|
||
uint256 totalWeight = _roninBridgeManager.getTotalWeight(); | ||
bytes32 newOpAndWeight = bytes32((totalWeight << 160) + uint160(uint256(opAndWeight))); | ||
vm.store(address(_roninBridgeManager), $, newOpAndWeight); | ||
} | ||
|
||
function run() public { | ||
address[] memory roninTokens = new address[](2); | ||
address[] memory mainchainTokens = new address[](2); | ||
uint256[] memory chainIds = new uint256[](2); | ||
Token.Standard[] memory standards = new Token.Standard[](2); | ||
|
||
uint256 expiredTime = block.timestamp + 10 minutes; | ||
address[] memory targets = new address[](1); | ||
uint256[] memory values = new uint256[](1); | ||
bytes[] memory calldatas = new bytes[](1); | ||
uint256[] memory gasAmounts = new uint256[](1); | ||
|
||
|
||
|
||
// ============= DELETE OLD PIXEL TOKEN =========== | ||
|
||
roninTokens[0] = _pixelOldRoninToken; | ||
mainchainTokens[0] = address(0); | ||
chainIds[0] = _config.getCompanionNetwork(_config.getNetworkByChainId(block.chainid)).chainId(); | ||
standards[0] = Token.Standard.ERC20; | ||
|
||
// ============= MAP NEW PIXEL TOKEN =========== | ||
|
||
roninTokens[1] = _pixelNewRoninToken; | ||
mainchainTokens[1] = _pixelMainchainToken; | ||
chainIds[1] = _config.getCompanionNetwork(_config.getNetworkByChainId(block.chainid)).chainId(); | ||
standards[1] = Token.Standard.ERC20; | ||
|
||
// function mapTokens( | ||
// address[] calldata _roninTokens, | ||
// address[] calldata _mainchainTokens, | ||
// uint256[] calldata chainIds, | ||
// Token.Standard[] calldata _standards | ||
// ) | ||
bytes memory innerData = abi.encodeCall(IRoninGatewayV3.mapTokens, ( | ||
roninTokens, | ||
mainchainTokens, | ||
chainIds, | ||
standards | ||
)); | ||
bytes memory proxyData = abi.encodeWithSignature("functionDelegateCall(bytes)", innerData); | ||
|
||
targets[0] = _roninGatewayV3; | ||
values[0] = 0; | ||
calldatas[0] = proxyData; | ||
gasAmounts[0] = 1_000_000; | ||
|
||
// ================ VERIFY AND EXECUTE PROPOSAL =============== | ||
|
||
_verifyRoninProposalGasAmount(targets, values, calldatas, gasAmounts); | ||
|
||
vm.broadcast(_governor); | ||
_roninBridgeManager.propose( | ||
block.chainid, | ||
expiredTime, | ||
targets, | ||
values, | ||
calldatas, | ||
gasAmounts | ||
); | ||
} | ||
} | ||
|
||
// ./run.sh script/20240201-maptoken-pixel-saigon/20240201-maptoken-pixel-roninchain.s.sol -f ronin-testnet --fork-block-number 24353280 -vvvv |
19 changes: 19 additions & 0 deletions
19
script/20240201-maptoken-pixel-saigon/maptoken-pixel-configs.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
contract Migration__MapToken_Pixel_Config { | ||
address constant _pixelOldRoninToken = address(0xfBca6b939E2c4D86477a1E836372f9936ABB8245); | ||
address constant _pixelNewRoninToken = address(0x253eF7651433ca9cA5dE487e1661a27080E85A83); | ||
address constant _pixelMainchainToken = address(0x49337E7414F8B968EA5478B68F1b6D0A2706cba1); | ||
|
||
// The decimal of PIXEL token is 18 | ||
uint256 constant _highTierThreshold = 100_000_000 ether; | ||
uint256 constant _lockedThreshold = 400_000_000 ether; | ||
// The MAX_PERCENTAGE is 100_0000 | ||
uint256 constant _unlockFeePercentages = 10; // 0.001%. Max percentage is 1e6 so 10 is 0.001% (`10 / 1e6 = 0.001 * 100`) | ||
uint256 constant _dailyWithdrawalLimit = 300_000_000 ether; | ||
|
||
uint256 constant _pixelMinThreshold = 10 ether; | ||
|
||
address internal _governor = 0xd24D87DDc1917165435b306aAC68D99e0F49A3Fa; // TODO: replace by address of the SV governor | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters