From 6ecadd8a0fb12e458b2761f37f44abdecc92952d Mon Sep 17 00:00:00 2001 From: chrismaree Date: Wed, 16 Mar 2022 10:07:16 +0200 Subject: [PATCH 1/6] fix[N13] Add more approval requirement comments Signed-off-by: chrismaree --- contracts/HubPool.sol | 3 +++ contracts/PolygonTokenBridger.sol | 1 + contracts/SpokePool.sol | 14 ++++++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/contracts/HubPool.sol b/contracts/HubPool.sol index c970e0fd2..bf97b1ef5 100644 --- a/contracts/HubPool.sol +++ b/contracts/HubPool.sol @@ -450,6 +450,7 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable { * and the caller, or "liquidity provider" earns a continuous fee for their credit that they are extending relayers. * @notice Caller will receive an LP token representing their share of this pool. The LP token's redemption value * increments from the time that they enter the pool to reflect their accrued fees. + * @notice The caller of this function must approve this contract to spend l1TokenAmount of l1Token. * @param l1Token Token to deposit into this contract. * @param l1TokenAmount Amount of liquidity to provide. */ @@ -552,6 +553,7 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable { * called; moreover, this method can't be called again until all leafs are executed. * @param bundleEvaluationBlockNumbers should contain the latest block number for all chains, even if there are no * relays contained on some of them. The usage of this variable should be defined in an off chain UMIP. + * @notice The caller of this function must approve this contract to spend bondAmount of bondToken. * @param poolRebalanceLeafCount Number of leaves contained in pool rebalance root. Max is the number of whitelisted chains. * @param poolRebalanceRoot Pool rebalance root containing leaves that will send tokens from this contract to a SpokePool. * @param relayerRefundRoot Relayer refund root to publish to SpokePool where a data worker can execute leaves to @@ -710,6 +712,7 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable { * @notice Caller stakes a bond to dispute the current root bundle proposal assuming it has not passed liveness * yet. The proposal is deleted, allowing a follow-up proposal to be submitted, and the dispute is sent to the * optimistic oracle to be adjudicated. Can only be called within the liveness period of the current proposal. + * @notice The caller of this function must approve this contract to spend l1TokenAmount of l1Token. */ function disputeRootBundle() public nonReentrant zeroOptimisticOracleApproval { uint32 currentTime = uint32(getCurrentTime()); diff --git a/contracts/PolygonTokenBridger.sol b/contracts/PolygonTokenBridger.sol index c8f3cbc3d..13ad42fce 100644 --- a/contracts/PolygonTokenBridger.sol +++ b/contracts/PolygonTokenBridger.sol @@ -52,6 +52,7 @@ contract PolygonTokenBridger is Lockable { /** * @notice Called by Polygon SpokePool to send tokens over bridge to contract with the same address as this. + * @notice The caller of this function must approve this contract to spend amount of token. * @param token Token to bridge. * @param amount Amount to bridge. * @param isWrappedMatic True if token is WMATIC. diff --git a/contracts/SpokePool.sol b/contracts/SpokePool.sol index c42cec6f8..b3f36b770 100644 --- a/contracts/SpokePool.sol +++ b/contracts/SpokePool.sol @@ -714,12 +714,14 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall } } - // @notice Caller specifies the max amount of tokens to send to user. Based on this amount and the amount of the - // relay remaining (as stored in the relayFills mapping), pull the amount of tokens from the caller ancillaryData - // and send to the caller. - // @dev relayFills keeps track of pre-fee fill amounts as a convenience to relayers who want to specify round - // numbers for the maxTokensToSend parameter or convenient numbers like 100 (i.e. relayers who will fully - // fill any relay up to 100 tokens, and partial fill with 100 tokens for larger relays). + /** + * @notice Caller specifies the max amount of tokens to send to user. Based on this amount and the amount of the + * relay remaining (as stored in the relayFills mapping), pull the amount of tokens from the caller ancillaryData + * and send to the caller. + * @dev relayFills keeps track of pre-fee fill amounts as a convenience to relayers who want to specify round + * numbers for the maxTokensToSend parameter or convenient numbers like 100 (i.e. relayers who will fully + * fill any relay up to 100 tokens, and partial fill with 100 tokens for larger relays). + */ function _fillRelay( bytes32 relayHash, RelayData memory relayData, From a3789670765eb6d463b1bfadaf9832966b0c9bf2 Mon Sep 17 00:00:00 2001 From: Chris Maree Date: Fri, 18 Mar 2022 07:29:17 +0200 Subject: [PATCH 2/6] Update contracts/HubPool.sol Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com> --- contracts/HubPool.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/HubPool.sol b/contracts/HubPool.sol index bf97b1ef5..0009af913 100644 --- a/contracts/HubPool.sol +++ b/contracts/HubPool.sol @@ -712,7 +712,7 @@ contract HubPool is HubPoolInterface, Testable, Lockable, MultiCaller, Ownable { * @notice Caller stakes a bond to dispute the current root bundle proposal assuming it has not passed liveness * yet. The proposal is deleted, allowing a follow-up proposal to be submitted, and the dispute is sent to the * optimistic oracle to be adjudicated. Can only be called within the liveness period of the current proposal. - * @notice The caller of this function must approve this contract to spend l1TokenAmount of l1Token. + * @notice The caller of this function must approve this contract to spend bondAmount of l1Token. */ function disputeRootBundle() public nonReentrant zeroOptimisticOracleApproval { uint32 currentTime = uint32(getCurrentTime()); From f45ff80c7ef6d43687c3fe0bb05b9a4f80c7afbd Mon Sep 17 00:00:00 2001 From: Chris Maree Date: Fri, 18 Mar 2022 07:29:22 +0200 Subject: [PATCH 3/6] Update contracts/SpokePool.sol Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com> --- contracts/SpokePool.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/SpokePool.sol b/contracts/SpokePool.sol index b3f36b770..e58a51258 100644 --- a/contracts/SpokePool.sol +++ b/contracts/SpokePool.sol @@ -716,7 +716,7 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall /** * @notice Caller specifies the max amount of tokens to send to user. Based on this amount and the amount of the - * relay remaining (as stored in the relayFills mapping), pull the amount of tokens from the caller ancillaryData + * relay remaining (as stored in the relayFills mapping), pull the amount of tokens from the caller * and send to the caller. * @dev relayFills keeps track of pre-fee fill amounts as a convenience to relayers who want to specify round * numbers for the maxTokensToSend parameter or convenient numbers like 100 (i.e. relayers who will fully From 430f68a509c213596c3fcc382b7c04f289128ef3 Mon Sep 17 00:00:00 2001 From: Chris Maree Date: Fri, 18 Mar 2022 07:29:27 +0200 Subject: [PATCH 4/6] Update contracts/SpokePool.sol Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com> --- contracts/SpokePool.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/SpokePool.sol b/contracts/SpokePool.sol index e58a51258..1188986a3 100644 --- a/contracts/SpokePool.sol +++ b/contracts/SpokePool.sol @@ -717,7 +717,7 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall /** * @notice Caller specifies the max amount of tokens to send to user. Based on this amount and the amount of the * relay remaining (as stored in the relayFills mapping), pull the amount of tokens from the caller - * and send to the caller. + * and send to the recipient. * @dev relayFills keeps track of pre-fee fill amounts as a convenience to relayers who want to specify round * numbers for the maxTokensToSend parameter or convenient numbers like 100 (i.e. relayers who will fully * fill any relay up to 100 tokens, and partial fill with 100 tokens for larger relays). From 91d8fd628d72f8f6a0dd029af202813a34efae29 Mon Sep 17 00:00:00 2001 From: Chris Maree Date: Fri, 18 Mar 2022 07:29:32 +0200 Subject: [PATCH 5/6] Update contracts/SpokePool.sol Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com> --- contracts/SpokePool.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/SpokePool.sol b/contracts/SpokePool.sol index 1188986a3..aafef8b2e 100644 --- a/contracts/SpokePool.sol +++ b/contracts/SpokePool.sol @@ -721,6 +721,8 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall * @dev relayFills keeps track of pre-fee fill amounts as a convenience to relayers who want to specify round * numbers for the maxTokensToSend parameter or convenient numbers like 100 (i.e. relayers who will fully * fill any relay up to 100 tokens, and partial fill with 100 tokens for larger relays). + * @dev Caller must approved this contract to transfer up to maxTokensToSend of the relayData.destinationToken. + * The amount to be sent might end up less if there is insufficient relay amount remaining to be sent. */ function _fillRelay( bytes32 relayHash, From 5a3ef77a22b81411a3616bb48acf063acabb4d2c Mon Sep 17 00:00:00 2001 From: chrismaree Date: Fri, 18 Mar 2022 08:00:33 +0200 Subject: [PATCH 6/6] nit Signed-off-by: chrismaree --- contracts/SpokePool.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/SpokePool.sol b/contracts/SpokePool.sol index 883ba6c83..04507f955 100644 --- a/contracts/SpokePool.sol +++ b/contracts/SpokePool.sol @@ -717,7 +717,7 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall * @dev relayFills keeps track of pre-fee fill amounts as a convenience to relayers who want to specify round * numbers for the maxTokensToSend parameter or convenient numbers like 100 (i.e. relayers who will fully * fill any relay up to 100 tokens, and partial fill with 100 tokens for larger relays). - * @dev Caller must approved this contract to transfer up to maxTokensToSend of the relayData.destinationToken. + * @dev Caller must approve this contract to transfer up to maxTokensToSend of the relayData.destinationToken. * The amount to be sent might end up less if there is insufficient relay amount remaining to be sent. */ function _fillRelay(