@@ -142,6 +142,41 @@ async function deployERC20Contract(deployerWallet: Wallet, decimals: number): Pr
142142 return token . address ;
143143}
144144
145+ async function deployFeeTokenPricerContract ( deployerWallet : Wallet , exchangeRate : BigNumber ) : Promise < string > {
146+ //// Bytecode below is generated from this simple FeeTokenPricer contract
147+
148+ // pragma solidity ^0.8.16;
149+
150+ // interface IFeeTokenPricer {
151+ // /**
152+ // * @notice Get the number of child chain's fee tokens per 1 parent chain's native token. Exchange rate must be
153+ // * denominated in 18 decimals.
154+ // * @dev For example, parent chain's native token is ETH, fee token is DAI. If price of 1ETH = 2000DAI, then function should return 2000*1e18.
155+ // * If fee token is USDC instead and price of 1ETH = 2000USDC, function should still return 2000*1e18, no matter that USDC uses 6 decimals.
156+ // */
157+ // function getExchangeRate() external returns (uint256);
158+ // }
159+
160+ // contract ConstantFeeTokenPricer is IFeeTokenPricer {
161+ // uint256 immutable public constExchangeRate;
162+ // constructor(uint256 _constExchangeRate) {
163+ // constExchangeRate = _constExchangeRate;
164+ // }
165+
166+ // function getExchangeRate() external view returns (uint256) {
167+ // return constExchangeRate;
168+ // }
169+ // }
170+
171+ const feeTokenPricerBytecode = "0x60a0604052348015600e575f80fd5b506040516101c63803806101c68339818101604052810190602e9190606d565b8060808181525050506093565b5f80fd5b5f819050919050565b604f81603f565b81146058575f80fd5b50565b5f815190506067816048565b92915050565b5f60208284031215607f57607e603b565b5b5f608a84828501605b565b91505092915050565b6080516101166100b05f395f8181606a0152608f01526101165ff3fe6080604052348015600e575f80fd5b50600436106030575f3560e01c8063b8910a29146034578063e6aa216c14604e575b5f80fd5b603a6068565b6040516045919060c9565b60405180910390f35b6054608c565b604051605f919060c9565b60405180910390f35b7f000000000000000000000000000000000000000000000000000000000000000081565b5f7f0000000000000000000000000000000000000000000000000000000000000000905090565b5f819050919050565b60c38160b3565b82525050565b5f60208201905060da5f83018460bc565b9291505056fea2646970667358221220ee17f22614d853ccf8b3f854137f68f06ff92f9f71ba8b811d78b1313eead0c564736f6c634300081a0033" ;
172+ const abi = [ "constructor(uint256 exchangeRate)" ] ;
173+ const feeTokenPricerFactory = new ContractFactory ( abi , feeTokenPricerBytecode , deployerWallet ) ;
174+ const feeTokenPricer = await feeTokenPricerFactory . deploy ( exchangeRate ) ;
175+ await feeTokenPricer . deployTransaction . wait ( ) ;
176+
177+ return feeTokenPricer . address ;
178+ }
179+
145180async function deployWETHContract ( deployerWallet : Wallet ) : Promise < string > {
146181 const wethFactory = new ContractFactory ( TestWETH9 . abi , TestWETH9 . bytecode , deployerWallet ) ;
147182 const weth = await wethFactory . deploy ( "Wrapped Ether" , "WETH" ) ;
@@ -385,6 +420,30 @@ export const createERC20Command = {
385420 } ,
386421} ;
387422
423+ export const createFeeTokenPricerCommand = {
424+ command : "create-fee-token-pricer" ,
425+ describe : "creates Constant Fee Token Pricer on L2" ,
426+ builder : {
427+ deployer : {
428+ string : true ,
429+ describe : "account (see general help)"
430+ } ,
431+ } ,
432+ handler : async ( argv : any ) => {
433+ console . log ( "create-fee-token-pricer" ) ;
434+
435+ argv . provider = new ethers . providers . WebSocketProvider ( argv . l2url ) ;
436+ const deployerWallet = new Wallet (
437+ ethers . utils . sha256 ( ethers . utils . toUtf8Bytes ( argv . deployer ) ) ,
438+ argv . provider
439+ ) ;
440+ const feeTokenPricerAddress = await deployFeeTokenPricerContract ( deployerWallet , BigNumber . from ( "15000000000000000000" ) ) ;
441+ console . log ( "Contract deployed at address:" , feeTokenPricerAddress ) ;
442+
443+ argv . provider . destroy ( ) ;
444+ } ,
445+ } ;
446+
388447export const deployExpressLaneAuctionContractCommand = {
389448 command : "deploy-express-lane-auction" ,
390449 describe : "Deploy the ExpressLaneAuction contract" ,
0 commit comments