Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/bridge/BridgeController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ pragma solidity 0.8.18;
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol";
import {BaseBridgeController} from "./BaseBridgeController.sol";

import "../interfaces/ILGORedemption.sol";
import "../interfaces/IERC20Burnable.sol";
/// @notice BridgeController on the original chain. Bridged token will be locked in this contract
/// and release once token is send back to original chain.
contract BridgeController is BaseBridgeController {
using SafeERC20 for IERC20;

mapping(uint256 batchId => bool burned) public batchLGOBurned;
ILGORedemption public lgoRedemption = ILGORedemption(0x6A5607CeAeE3F947fb5736753F7722D7Fb69eE4F);

constructor() {
_disableInitializers();
}
Expand All @@ -26,4 +30,19 @@ contract BridgeController is BaseBridgeController {
function _releaseTokens(address _to, uint256 _amount) internal override {
IERC20(token).safeTransfer(_to, _amount);
}

function burnLGO(uint256 _batchId) external onlyOwner {
require(!batchLGOBurned[_batchId], "Burned");
(,,,bool _isFinalized) = lgoRedemption.snapshots(_batchId);
require(_isFinalized, "!Finalized");
uint256 _amountLGO = lgoRedemption.totalRedemptionAllChain(_batchId) - lgoRedemption.totalRedemptionByChain(_batchId, 56);
if(_amountLGO > 0) {
batchLGOBurned[_batchId] = true;
IERC20Burnable(address(token)).burn(_amountLGO);
emit LGOBurned(_batchId, _amountLGO);
}
}

/*============ EVENTS ===============*/
event LGOBurned(uint256 _batchId, uint256 _amount);
}
13 changes: 13 additions & 0 deletions src/interfaces/ILGORedemption.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.18;

interface ILGORedemption {
function totalRedemptionAllChain(uint256 _batchId) external returns (uint256);

function totalRedemptionByChain(uint256 _batchId, uint256 _chainId) external returns (uint256);

function snapshots(uint256 _batchId)
external
returns (uint256 _startTimestamp, uint256 _endTimestamp, uint256 _lgoSupply, bool _isFinalized);
// batchId => snapshot info
}