Skip to content

Commit 980defa

Browse files
chrismareenicholaspai
authored andcommitted
fix[N08] Propose fixes to some naming issues (#105)
* fix[N02} Move all structs to the same place Signed-off-by: chrismaree <christopher.maree@gmail.com> * fix[N03] Fixed inconsistant token metadata versioning Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * nit Signed-off-by: chrismaree <christopher.maree@gmail.com> * fix[N08] Propose fixes to some naming issues Signed-off-by: chrismaree <christopher.maree@gmail.com>
1 parent 954b022 commit 980defa

17 files changed

+117
-113
lines changed

contracts/HubPool.sol

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable {
149149
bool depositsEnabled
150150
);
151151
event ProposeRootBundle(
152-
uint32 requestExpirationTimestamp,
153-
uint64 unclaimedPoolRebalanceLeafCount,
152+
uint32 challengePeriodEndTimestamp,
153+
uint64 poolRebalanceLeafCount,
154154
uint256[] bundleEvaluationBlockNumbers,
155155
bytes32 indexed poolRebalanceRoot,
156156
bytes32 indexed relayerRefundRoot,
@@ -161,10 +161,10 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable {
161161
uint256 groupIndex,
162162
uint256 indexed leafId,
163163
uint256 indexed chainId,
164-
address[] l1Token,
164+
address[] l1Tokens,
165165
uint256[] bundleLpFees,
166-
int256[] netSendAmount,
167-
int256[] runningBalance,
166+
int256[] netSendAmounts,
167+
int256[] runningBalances,
168168
address indexed caller
169169
);
170170
event SpokePoolAdminFunctionTriggered(uint256 indexed chainId, bytes message);
@@ -560,11 +560,11 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable {
560560
// technically valid but not useful. This could also potentially be enforced at the UMIP-level.
561561
require(poolRebalanceLeafCount > 0, "Bundle must have at least 1 leaf");
562562

563-
uint32 requestExpirationTimestamp = uint32(getCurrentTime()) + liveness;
563+
uint32 challengePeriodEndTimestamp = uint32(getCurrentTime()) + liveness;
564564

565565
delete rootBundleProposal; // Only one bundle of roots can be executed at a time. Delete the previous bundle.
566566

567-
rootBundleProposal.requestExpirationTimestamp = requestExpirationTimestamp;
567+
rootBundleProposal.challengePeriodEndTimestamp = challengePeriodEndTimestamp;
568568
rootBundleProposal.unclaimedPoolRebalanceLeafCount = poolRebalanceLeafCount;
569569
rootBundleProposal.poolRebalanceRoot = poolRebalanceRoot;
570570
rootBundleProposal.relayerRefundRoot = relayerRefundRoot;
@@ -575,7 +575,7 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable {
575575
bondToken.safeTransferFrom(msg.sender, address(this), bondAmount);
576576

577577
emit ProposeRootBundle(
578-
requestExpirationTimestamp,
578+
challengePeriodEndTimestamp,
579579
poolRebalanceLeafCount,
580580
bundleEvaluationBlockNumbers,
581581
poolRebalanceRoot,
@@ -611,7 +611,7 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable {
611611
address[] memory l1Tokens,
612612
bytes32[] memory proof
613613
) public nonReentrant unpaused {
614-
require(getCurrentTime() > rootBundleProposal.requestExpirationTimestamp, "Not passed liveness");
614+
require(getCurrentTime() > rootBundleProposal.challengePeriodEndTimestamp, "Not passed liveness");
615615

616616
// Verify the leafId in the poolRebalanceLeaf has not yet been claimed.
617617
require(!MerkleLib.isClaimed1D(rootBundleProposal.claimedBitMap, leafId), "Already claimed");
@@ -703,7 +703,7 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable {
703703
*/
704704
function disputeRootBundle() public nonReentrant zeroOptimisticOracleApproval {
705705
uint32 currentTime = uint32(getCurrentTime());
706-
require(currentTime <= rootBundleProposal.requestExpirationTimestamp, "Request passed liveness");
706+
require(currentTime <= rootBundleProposal.challengePeriodEndTimestamp, "Request passed liveness");
707707

708708
// Request price from OO and dispute it.
709709
uint256 finalFee = _getBondTokenFinalFee();
@@ -949,10 +949,12 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable {
949949
// that will flow from L2 to L1. In this case, we can use it normally in the equation. However, if it is
950950
// negative, then it is already counted in liquidReserves. This occurs if tokens are transferred directly to the
951951
// contract. In this case, ignore it as it is captured in liquid reserves and has no meaning in the numerator.
952-
PooledToken memory pooledToken = pooledTokens[l1Token]; // Note this is storage so the state can be modified.
953-
uint256 flooredUtilizedReserves = pooledToken.utilizedReserves > 0 ? uint256(pooledToken.utilizedReserves) : 0;
952+
PooledToken memory pooledL1Token = pooledTokens[l1Token];
953+
uint256 flooredUtilizedReserves = pooledL1Token.utilizedReserves > 0
954+
? uint256(pooledL1Token.utilizedReserves) // If positive: take the uint256 cast utilizedReserves.
955+
: 0; // Else, if negative, then the is already captured in liquidReserves and should be ignored.
954956
uint256 numerator = relayedAmount + flooredUtilizedReserves;
955-
uint256 denominator = pooledToken.liquidReserves + flooredUtilizedReserves;
957+
uint256 denominator = pooledL1Token.liquidReserves + flooredUtilizedReserves;
956958

957959
// If the denominator equals zero, return 1e18 (max utilization).
958960
if (denominator == 0) return 1e18;

contracts/HubPoolInterface.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface HubPoolInterface {
4848
// - Send funds from a SpokePool to Relayer as a refund for a relayed deposit
4949
// - Send funds from a SpokePool to a deposit recipient to fulfill a "slow" relay
5050
// Anyone can dispute this struct if the merkle roots contain invalid leaves before the
51-
// requestExpirationTimestamp. Once the expiration timestamp is passed, executeRootBundle to execute a leaf
51+
// challengePeriodEndTimestamp. Once the expiration timestamp is passed, executeRootBundle to execute a leaf
5252
// from the poolRebalanceRoot on this contract and it will simultaneously publish the relayerRefundRoot and
5353
// slowRelayRoot to a SpokePool. The latter two roots, once published to the SpokePool, contain
5454
// leaves that can be executed on the SpokePool to pay relayers or recipients.
@@ -67,7 +67,7 @@ interface HubPoolInterface {
6767
// of leaves are executed, a new root bundle can be proposed
6868
uint8 unclaimedPoolRebalanceLeafCount;
6969
// When root bundle challenge period passes and this root bundle becomes executable.
70-
uint32 requestExpirationTimestamp;
70+
uint32 challengePeriodEndTimestamp;
7171
}
7272

7373
// Each whitelisted L1 token has an associated pooledToken struct that contains all information used to track the
@@ -130,7 +130,7 @@ interface HubPoolInterface {
130130

131131
function liquidityUtilizationCurrent(address l1Token) external returns (uint256);
132132

133-
function liquidityUtilizationPostRelay(address token, uint256 relayedAmount) external returns (uint256);
133+
function liquidityUtilizationPostRelay(address l1Token, uint256 relayedAmount) external returns (uint256);
134134

135135
function sync(address l1Token) external;
136136

contracts/LpTokenFactory.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ contract LpTokenFactory is LpTokenFactoryInterface {
1717
*/
1818
function createLpToken(address l1Token) public returns (address) {
1919
ExpandedERC20 lpToken = new ExpandedERC20(
20-
_append("Across V2 ", IERC20Metadata(l1Token).name(), " LP Token"), // LP Token Name
21-
_append("Av2-", IERC20Metadata(l1Token).symbol(), "-LP"), // LP Token Symbol
20+
_concatenate("Across V2 ", IERC20Metadata(l1Token).name(), " LP Token"), // LP Token Name
21+
_concatenate("Av2-", IERC20Metadata(l1Token).symbol(), "-LP"), // LP Token Symbol
2222
IERC20Metadata(l1Token).decimals() // LP Token Decimals
2323
);
24+
2425
lpToken.addMinter(msg.sender); // Set the caller as the LP Token's minter.
2526
lpToken.addBurner(msg.sender); // Set the caller as the LP Token's burner.
2627
lpToken.resetOwner(msg.sender); // Set the caller as the LP Token's owner.
2728

2829
return address(lpToken);
2930
}
3031

31-
function _append(
32+
function _concatenate(
3233
string memory a,
3334
string memory b,
3435
string memory c

contracts/Optimism_SpokePool.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ contract Optimism_SpokePool is CrossDomainEnabled, SpokePool {
7474
* ETH over the canonical token bridge instead of WETH.
7575
* @inheritdoc SpokePool
7676
*/
77-
function executeSlowRelayRoot(
77+
function executeSlowRelayLeaf(
7878
address depositor,
7979
address recipient,
8080
address destinationToken,
@@ -86,9 +86,9 @@ contract Optimism_SpokePool is CrossDomainEnabled, SpokePool {
8686
uint32 rootBundleId,
8787
bytes32[] memory proof
8888
) public override(SpokePool) nonReentrant {
89-
if (destinationToken == address(weth)) _depositEthToWeth();
89+
if (destinationToken == address(wrappedNativeToken)) _depositEthToWeth();
9090

91-
_executeSlowRelayRoot(
91+
_executeSlowRelayLeaf(
9292
depositor,
9393
recipient,
9494
destinationToken,
@@ -108,14 +108,14 @@ contract Optimism_SpokePool is CrossDomainEnabled, SpokePool {
108108
* ETH over the canonical token bridge instead of WETH.
109109
* @inheritdoc SpokePool
110110
*/
111-
function executeRelayerRefundRoot(
111+
function executeRelayerRefundLeaf(
112112
uint32 rootBundleId,
113113
SpokePoolInterface.RelayerRefundLeaf memory relayerRefundLeaf,
114114
bytes32[] memory proof
115115
) public override(SpokePool) nonReentrant {
116-
if (relayerRefundLeaf.l2TokenAddress == address(weth)) _depositEthToWeth();
116+
if (relayerRefundLeaf.l2TokenAddress == address(wrappedNativeToken)) _depositEthToWeth();
117117

118-
_executeRelayerRefundRoot(rootBundleId, relayerRefundLeaf, proof);
118+
_executeRelayerRefundLeaf(rootBundleId, relayerRefundLeaf, proof);
119119
}
120120

121121
/**************************************
@@ -127,13 +127,13 @@ contract Optimism_SpokePool is CrossDomainEnabled, SpokePool {
127127
// this logic inside a fallback method that executes when this contract receives ETH because ETH is an ERC20
128128
// on the OVM.
129129
function _depositEthToWeth() internal {
130-
if (address(this).balance > 0) weth.deposit{ value: address(this).balance }();
130+
if (address(this).balance > 0) wrappedNativeToken.deposit{ value: address(this).balance }();
131131
}
132132

133133
function _bridgeTokensToHubPool(RelayerRefundLeaf memory relayerRefundLeaf) internal override {
134134
// If the token being bridged is WETH then we need to first unwrap it to ETH and then send ETH over the
135135
// canonical bridge. On Optimism, this is address 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000.
136-
if (relayerRefundLeaf.l2TokenAddress == address(weth)) {
136+
if (relayerRefundLeaf.l2TokenAddress == address(wrappedNativeToken)) {
137137
WETH9(relayerRefundLeaf.l2TokenAddress).withdraw(relayerRefundLeaf.amountToReturn); // Unwrap into ETH.
138138
relayerRefundLeaf.l2TokenAddress = l2Eth; // Set the l2TokenAddress to ETH.
139139
}

contracts/Polygon_SpokePool.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool {
6565
* @param _polygonTokenBridger Token routing contract that sends tokens from here to HubPool. Changeable by Admin.
6666
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
6767
* @param _hubPool Hub pool address to set. Can be changed by admin.
68-
* @param _wmaticAddress Replaces _wethAddress for this network since MATIC is the gas token and sent via msg.value
69-
* on Polygon.
68+
* @param _wmaticAddress Replaces wrappedNativeToken for this network since MATIC is the native currency on polygon.
7069
* @param _fxChild FxChild contract, changeable by Admin.
7170
* @param timerAddress Timer address to set.
7271
*/
@@ -83,7 +82,7 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool {
8382
}
8483

8584
/********************************************************
86-
* ARBITRUM-SPECIFIC CROSS-CHAIN ADMIN FUNCTIONS *
85+
* POLYGON-SPECIFIC CROSS-CHAIN ADMIN FUNCTIONS *
8786
********************************************************/
8887

8988
/**
@@ -138,11 +137,11 @@ contract Polygon_SpokePool is IFxMessageProcessor, SpokePool {
138137
relayerRefundLeaf.amountToReturn
139138
);
140139

141-
// Note: WETH is WMATIC on matic, so this tells the tokenbridger that this is an unwrappable native token.
140+
// Note: WrappedNativeToken is WMATIC on matic, so this tells the tokenbridger that this is an unwrappable native token.
142141
polygonTokenBridger.send(
143142
PolygonIERC20(relayerRefundLeaf.l2TokenAddress),
144143
relayerRefundLeaf.amountToReturn,
145-
address(weth) == relayerRefundLeaf.l2TokenAddress
144+
address(wrappedNativeToken) == relayerRefundLeaf.l2TokenAddress
146145
);
147146

148147
emit PolygonTokensBridged(relayerRefundLeaf.l2TokenAddress, address(this), relayerRefundLeaf.amountToReturn);

0 commit comments

Comments
 (0)