parent
0301055abc
commit
a13839109c
@ -0,0 +1,37 @@ |
|||||||
|
// SPDX-License-Identifier: Apache-2.0 |
||||||
|
pragma solidity >=0.8.0; |
||||||
|
|
||||||
|
import {HypERC20Collateral} from "../HypERC20Collateral.sol"; |
||||||
|
|
||||||
|
/** |
||||||
|
* @title Hyperlane Rebalancing Token Collateral |
||||||
|
* @author Abacus Works |
||||||
|
*/ |
||||||
|
contract HypERC20RebalancingCollateral is HypERC20Collateral { |
||||||
|
HypERC20Collateral public immutable rebalancer; |
||||||
|
|
||||||
|
constructor( |
||||||
|
address _erc20, |
||||||
|
address _mailbox, |
||||||
|
address _rebalancer |
||||||
|
) HypERC20Collateral(_erc20, _mailbox) { |
||||||
|
rebalancer = HypERC20Collateral(_rebalancer); |
||||||
|
require( |
||||||
|
rebalancer.wrappedToken() == wrappedToken, |
||||||
|
"Rebalancer collateral must match wrapped token" |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
function transferCollateral( |
||||||
|
uint32 destination, |
||||||
|
uint256 amount |
||||||
|
) external payable onlyOwner { |
||||||
|
bytes32 router = _mustHaveRemoteRouter(destination); |
||||||
|
require(wrappedToken.approve(address(rebalancer), amount)); |
||||||
|
rebalancer.transferRemote{value: msg.value}( |
||||||
|
destination, |
||||||
|
router, |
||||||
|
amount |
||||||
|
); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
// SPDX-License-Identifier: Apache-2.0 |
||||||
|
pragma solidity >=0.8.0; |
||||||
|
|
||||||
|
import {HypNative} from "../HypNative.sol"; |
||||||
|
|
||||||
|
/** |
||||||
|
* @title Hyperlane Rebalancing Native Collateral |
||||||
|
* @author Abacus Works |
||||||
|
*/ |
||||||
|
contract HypERC20RebalancingCollateral is HypNative { |
||||||
|
HypNative public immutable rebalancer; |
||||||
|
|
||||||
|
constructor( |
||||||
|
address _mailbox, |
||||||
|
address payable _rebalancer |
||||||
|
) HypNative(_mailbox) { |
||||||
|
rebalancer = HypNative(_rebalancer); |
||||||
|
} |
||||||
|
|
||||||
|
function transferCollateral( |
||||||
|
uint32 destination, |
||||||
|
uint256 amount |
||||||
|
) external payable onlyOwner { |
||||||
|
bytes32 router = _mustHaveRemoteRouter(destination); |
||||||
|
uint256 payment = msg.value + amount; |
||||||
|
require(address(this).balance >= payment, "Insufficient balance"); |
||||||
|
rebalancer.transferRemote{value: payment}(destination, router, amount); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue