Skip to content

s_currentBridged accounting is performed on non-normalized releaseOrMintIn.amount #33

@cyberthirst

Description

@cyberthirst

given

function releaseOrMint(
Pool.ReleaseOrMintInV1 calldata releaseOrMintIn
) external virtual override returns (Pool.ReleaseOrMintOutV1 memory) {
// This should never occur. Amount should never exceed the current bridged amount
if (releaseOrMintIn.amount > s_currentBridged) revert NotEnoughBridgedAmount();
// Reduce bridged amount because tokens are back to source chain
s_currentBridged -= releaseOrMintIn.amount;
_validateReleaseOrMint(releaseOrMintIn);
// Calculate the local amount
uint256 localAmount = _calculateLocalAmount(
releaseOrMintIn.amount,
_parseRemoteDecimals(releaseOrMintIn.sourcePoolData)
);
// Release to the recipient
getToken().safeTransfer(releaseOrMintIn.receiver, localAmount);
emit Released(msg.sender, releaseOrMintIn.receiver, localAmount);
return Pool.ReleaseOrMintOutV1({destinationAmount: localAmount});
}

i think the s_currentBridged should be decremented by localAmount

given that all GHO deployments use 18 decimals it functionally doesn't matter wrt current deployments:

  function _calculateLocalAmount(uint256 remoteAmount, uint8 remoteDecimals) internal view virtual returns (uint256) {
    if (remoteDecimals == i_tokenDecimals) {
      return remoteAmount;
    }

but might screw up the accounting in case of a future deployment/adaptation for a different token

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions