Skip to content

Commit

Permalink
feat(contracts): refactor into two tokens model
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickGT committed May 30, 2024
1 parent cf3111a commit 67b4f26
Show file tree
Hide file tree
Showing 11 changed files with 650 additions and 453 deletions.
44 changes: 44 additions & 0 deletions script/DeployBase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.23;

import { ContractHelper } from "../lib/common/src/ContractHelper.sol";

import { WM } from "../src/WM.sol";
import { YM } from "../src/YM.sol";

contract DeployBase {
/**
* @dev Deploys YM and YM.
* @param deployer_ The address of the account deploying the contracts.
* @param deployerNonce_ The current nonce of the deployer.
* @param mToken_ The address of the M token.
* @param ttgRegistrar_ The address of the TTG Registrar.
*/
function deploy(
address deployer_,
uint256 deployerNonce_,
address mToken_,
address ttgRegistrar_
) public virtual returns (address wMToken_, address yMToken_) {
// YM token needs `mToken_` and YM token needs `yMToken_`.
wMToken_ = address(new WM(mToken_, _getExpectedYMToken(deployer_, deployerNonce_), ttgRegistrar_));
yMToken_ = address(new YM(mToken_, wMToken_, ttgRegistrar_));
}

function getExpectedWMToken(address deployer_, uint256 deployerNonce_) public pure virtual returns (address) {
return _getExpectedWMToken(deployer_, deployerNonce_);
}

function getExpectedYMToken(address deployer_, uint256 deployerNonce_) public pure virtual returns (address) {
return _getExpectedYMToken(deployer_, deployerNonce_);
}

function _getExpectedWMToken(address deployer_, uint256 deployerNonce_) internal pure returns (address) {
return ContractHelper.getContractFrom(deployer_, deployerNonce_);
}

function _getExpectedYMToken(address deployer_, uint256 deployerNonce_) internal pure returns (address) {
return ContractHelper.getContractFrom(deployer_, deployerNonce_ + 1);
}
}
Loading

0 comments on commit 67b4f26

Please sign in to comment.