2021-04-12 10:48:42 +00:00
|
|
|
pragma solidity ^0.7.0;
|
|
|
|
|
|
|
|
import { TokenInterface } from "../../common/interfaces.sol";
|
|
|
|
import { Stores } from "../../common/stores.sol";
|
|
|
|
import { Helpers } from "./helpers.sol";
|
|
|
|
import { Events } from "./events.sol";
|
|
|
|
|
|
|
|
abstract contract PolygonBridgeResolver is Events, Helpers {
|
2021-04-12 11:12:03 +00:00
|
|
|
/**
|
|
|
|
* @dev Deposit assets to the bridge.
|
|
|
|
* @notice Deposit assets to the bridge.
|
|
|
|
* @param targetDsa The address to receive the token on Polygon
|
|
|
|
* @param token The address of the token to deposit. (For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
|
|
|
* @param amt The amount of tokens to deposit. (For max: `uint256(-1)`)
|
|
|
|
* @param getId ID to retrieve amt.
|
|
|
|
* @param setId ID stores the amount of tokens deposit.
|
|
|
|
*/
|
2021-04-12 10:48:42 +00:00
|
|
|
function deposit(
|
|
|
|
address targetDsa,
|
|
|
|
address token,
|
|
|
|
uint256 amt,
|
|
|
|
uint256 getId,
|
|
|
|
uint256 setId
|
|
|
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
|
|
|
uint _amt = getUint(getId, amt);
|
|
|
|
|
|
|
|
if (token == ethAddr) {
|
|
|
|
_amt = _amt == uint(-1) ? address(this).balance : _amt;
|
|
|
|
migrator.depositEtherFor{value: _amt}(targetDsa);
|
|
|
|
} else {
|
|
|
|
TokenInterface _token = TokenInterface(token);
|
|
|
|
_amt = _amt == uint(-1) ? _token.balanceOf(address(this)) : _amt;
|
|
|
|
_token.approve(erc20Predicate, _amt);
|
|
|
|
migrator.depositFor(targetDsa, token, abi.encode(_amt));
|
|
|
|
}
|
|
|
|
|
|
|
|
setUint(setId, _amt);
|
|
|
|
|
|
|
|
_eventName = "LogDeposit(address,address,uint256,uint256,uint256)";
|
|
|
|
_eventParam = abi.encode(targetDsa, token, _amt, getId, setId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-12 21:50:10 +00:00
|
|
|
contract ConnectV2PolygonBridge is PolygonBridgeResolver {
|
|
|
|
string public constant name = "Polygon-Bridge-v1";
|
2021-04-12 10:48:42 +00:00
|
|
|
}
|