Skip to content

Instantly share code, notes, and snippets.

@nginnever
Last active November 10, 2020 23:26
Show Gist options
  • Save nginnever/38bcb22bd17dee9f23208478a698a9d4 to your computer and use it in GitHub Desktop.
Save nginnever/38bcb22bd17dee9f23208478a698a9d4 to your computer and use it in GitHub Desktop.
address constant public amb_mediator = 0x5275e7264AB0Bb75D970E7442De0Aadd0C0b85ae;
function depositAndBridge() external override payable returns (bool success) {
require(address(this).balance + flashSupply <= type(uint112).max, "WETH::deposit: supply limit exceeded");
// Create token balance for deposit
balanceOf[msg.sender] += msg.value;
// Approve the new tokens to the mediator contract
allowance[msg.sender][amb_mediator] = msg.value;
emit Approval(msg.sender, amb_mediator, msg.value);
// Transfer new tokens to mediator contract here to lock newly printed balance on the mediator
emit TransferAndBridge(address(0), msg.sender, msg.value);
(bool _success, bytes memory data) = amb_mediator.call(abi.encodeWithSignature("relayTokens(ERC677 token, address _receiver, uint256 _value)", address(this), msg.sender, msg.value));
return true;
}
function respondToMediatorApproval(address _token, address _sender, uint256 _val) external override returns (bool success) {
(bool _success, bytes memory data) = amb_mediator.call(abi.encodeWithSignature("relayTokens(ERC677 token, address _receiver, uint256 _value)", _token, _sender, _val));
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment