Skip to content

Commit

Permalink
Merge pull request #4 from symbioticfi/add-package-json
Browse files Browse the repository at this point in the history
Add package.json
  • Loading branch information
1kresh authored Sep 12, 2024
2 parents ab43c8d + 2e1402f commit 8190adc
Show file tree
Hide file tree
Showing 38 changed files with 346 additions and 161 deletions.
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@symbioticfi/burners",
"version": "1.0.0-devnet.1",
"description": "Symbiotic is a shared security protocol enabling decentralized networks to control and customize their own multi-asset restaking implementation.",
"homepage": "https://symbiotic.fi/",
"bugs": "https://github.com/symbioticfi/burners/issues",
"license": "MIT",
"author": "Symbiotic Team",
"files": [
"src/**/*",
"test/mocks/**/*",
"out/**/*.json"
],
"repository": {
"type": "git",
"url": "https://github.com/symbioticfi/burners.git"
},
"keywords": [
"solidity",
"ethereum",
"smart",
"contracts",
"security"
],
"dependencies": {
"@openzeppelin/contracts": "5.0.2",
"@openzeppelin/contracts-upgradeable": "5.0.2"
}
}
10 changes: 7 additions & 3 deletions src/contracts/AddressRequests.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {IAddressRequests} from "src/interfaces/IAddressRequests.sol";
import {IAddressRequests} from "../interfaces/IAddressRequests.sol";

import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
Expand Down Expand Up @@ -35,11 +35,15 @@ contract AddressRequests is IAddressRequests {
}
}

function _addRequestId(address requestId) internal {
function _addRequestId(
address requestId
) internal {
_requestIds.add(requestId);
}

function _removeRequestId(address requestId) internal {
function _removeRequestId(
address requestId
) internal {
if (!_requestIds.remove(requestId)) {
revert InvalidRequestId();
}
Expand Down
10 changes: 7 additions & 3 deletions src/contracts/UintRequests.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {IUintRequests} from "src/interfaces/IUintRequests.sol";
import {IUintRequests} from "../interfaces/IUintRequests.sol";

import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
Expand Down Expand Up @@ -35,11 +35,15 @@ contract UintRequests is IUintRequests {
}
}

function _addRequestId(uint256 requestId) internal {
function _addRequestId(
uint256 requestId
) internal {
_requestIds.add(requestId);
}

function _removeRequestId(uint256 requestId) internal {
function _removeRequestId(
uint256 requestId
) internal {
if (!_requestIds.remove(requestId)) {
revert InvalidRequestId();
}
Expand Down
20 changes: 12 additions & 8 deletions src/contracts/burners/ETHx_Burner.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {SelfDestruct} from "src/contracts/SelfDestruct.sol";
import {UintRequests} from "src/contracts/UintRequests.sol";
import {SelfDestruct} from "../SelfDestruct.sol";
import {UintRequests} from "../UintRequests.sol";

import {IETHx_Burner} from "src/interfaces/burners/ETHx/IETHx_Burner.sol";
import {IStaderConfig} from "src/interfaces/burners/ETHx/IStaderConfig.sol";
import {IStaderStakePoolsManager} from "src/interfaces/burners/ETHx/IStaderStakePoolsManager.sol";
import {IUserWithdrawalManager} from "src/interfaces/burners/ETHx/IUserWithdrawalManager.sol";
import {IETHx_Burner} from "../../interfaces/burners/ETHx/IETHx_Burner.sol";
import {IStaderConfig} from "../../interfaces/burners/ETHx/IStaderConfig.sol";
import {IStaderStakePoolsManager} from "../../interfaces/burners/ETHx/IStaderStakePoolsManager.sol";
import {IUserWithdrawalManager} from "../../interfaces/burners/ETHx/IUserWithdrawalManager.sol";

import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
Expand Down Expand Up @@ -51,7 +51,9 @@ contract ETHx_Burner is UintRequests, Multicall, IETHx_Burner {
/**
* @inheritdoc IETHx_Burner
*/
function triggerWithdrawal(uint256 maxWithdrawalAmount) external returns (uint256 requestId) {
function triggerWithdrawal(
uint256 maxWithdrawalAmount
) external returns (uint256 requestId) {
uint256 maxETHWithdrawAmount = IStaderConfig(STADER_CONFIG).getMaxWithdrawAmount();
if (
IStaderStakePoolsManager(STAKE_POOLS_MANAGER).previewWithdraw(maxWithdrawalAmount) > maxETHWithdrawAmount
Expand All @@ -73,7 +75,9 @@ contract ETHx_Burner is UintRequests, Multicall, IETHx_Burner {
/**
* @inheritdoc IETHx_Burner
*/
function triggerBurn(uint256 requestId) external {
function triggerBurn(
uint256 requestId
) external {
_requestIds.remove(requestId);

IUserWithdrawalManager(USER_WITHDRAW_MANAGER).claim(requestId);
Expand Down
18 changes: 11 additions & 7 deletions src/contracts/burners/mETH_Burner.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {SelfDestruct} from "src/contracts/SelfDestruct.sol";
import {UintRequests} from "src/contracts/UintRequests.sol";
import {SelfDestruct} from "../SelfDestruct.sol";
import {UintRequests} from "../UintRequests.sol";

import {IMETH} from "src/interfaces/burners/mETH/IMETH.sol";
import {IStaking} from "src/interfaces/burners/mETH/IStaking.sol";
import {ImETH_Burner} from "src/interfaces/burners/mETH/ImETH_Burner.sol";
import {IMETH} from "../../interfaces/burners/mETH/IMETH.sol";
import {IStaking} from "../../interfaces/burners/mETH/IStaking.sol";
import {ImETH_Burner} from "../../interfaces/burners/mETH/ImETH_Burner.sol";

import {IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

Expand All @@ -21,7 +21,9 @@ contract mETH_Burner is UintRequests, ImETH_Burner {
*/
address public immutable STAKING;

constructor(address collateral) {
constructor(
address collateral
) {
COLLATERAL = collateral;

STAKING = IMETH(COLLATERAL).stakingContract();
Expand All @@ -45,7 +47,9 @@ contract mETH_Burner is UintRequests, ImETH_Burner {
/**
* @inheritdoc ImETH_Burner
*/
function triggerBurn(uint256 requestId) external {
function triggerBurn(
uint256 requestId
) external {
_removeRequestId(requestId);

IStaking(STAKING).claimUnstakeRequest(requestId);
Expand Down
14 changes: 9 additions & 5 deletions src/contracts/burners/rETH_Burner.sol
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {SelfDestruct} from "src/contracts/SelfDestruct.sol";
import {SelfDestruct} from "../SelfDestruct.sol";

import {IRocketTokenRETH} from "src/interfaces/burners/rETH/IRocketTokenRETH.sol";
import {IrETH_Burner} from "src/interfaces/burners/rETH/IrETH_Burner.sol";
import {IRocketTokenRETH} from "../../interfaces/burners/rETH/IRocketTokenRETH.sol";
import {IrETH_Burner} from "../../interfaces/burners/rETH/IrETH_Burner.sol";

contract rETH_Burner is IrETH_Burner {
/**
* @inheritdoc IrETH_Burner
*/
address public immutable COLLATERAL;

constructor(address collateral) {
constructor(
address collateral
) {
COLLATERAL = collateral;
}

/**
* @inheritdoc IrETH_Burner
*/
function triggerBurn(uint256 amount) external {
function triggerBurn(
uint256 amount
) external {
IRocketTokenRETH(COLLATERAL).burn(amount);

uint256 ethToBurn = address(this).balance;
Expand Down
20 changes: 12 additions & 8 deletions src/contracts/burners/sUSDe/sUSDe_Burner.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {AddressRequests} from "src/contracts/AddressRequests.sol";
import {SelfDestruct} from "src/contracts/SelfDestruct.sol";
import {AddressRequests} from "../../AddressRequests.sol";
import {SelfDestruct} from "../../SelfDestruct.sol";
import {sUSDe_Miniburner} from "./sUSDe_Miniburner.sol";

import {IEthenaMinting} from "src/interfaces/burners/sUSDe/IEthenaMinting.sol";
import {ISUSDe} from "src/interfaces/burners/sUSDe/ISUSDe.sol";
import {IUSDe} from "src/interfaces/burners/sUSDe/IUSDe.sol";
import {IsUSDe_Burner} from "src/interfaces/burners/sUSDe/IsUSDe_Burner.sol";
import {IEthenaMinting} from "../../../interfaces/burners/sUSDe/IEthenaMinting.sol";
import {ISUSDe} from "../../../interfaces/burners/sUSDe/ISUSDe.sol";
import {IUSDe} from "../../../interfaces/burners/sUSDe/IUSDe.sol";
import {IsUSDe_Burner} from "../../../interfaces/burners/sUSDe/IsUSDe_Burner.sol";

import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
Expand Down Expand Up @@ -78,7 +78,9 @@ contract sUSDe_Burner is AddressRequests, IERC1271, IsUSDe_Burner {
/**
* @inheritdoc IsUSDe_Burner
*/
function triggerClaim(address requestId) external {
function triggerClaim(
address requestId
) external {
_removeRequestId(requestId);

sUSDe_Miniburner(requestId).triggerClaim();
Expand All @@ -104,7 +106,9 @@ contract sUSDe_Burner is AddressRequests, IERC1271, IsUSDe_Burner {
/**
* @inheritdoc IsUSDe_Burner
*/
function triggerBurn(address asset) external {
function triggerBurn(
address asset
) external {
if (asset == COLLATERAL || asset == USDE) {
revert InvalidAsset();
}
Expand Down
10 changes: 7 additions & 3 deletions src/contracts/burners/sUSDe/sUSDe_Miniburner.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {ISUSDe} from "src/interfaces/burners/sUSDe/ISUSDe.sol";
import {ISUSDe} from "../../../interfaces/burners/sUSDe/ISUSDe.sol";

import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

Expand All @@ -10,14 +10,18 @@ contract sUSDe_Miniburner is OwnableUpgradeable {

address private immutable _USDE;

constructor(address collateral) {
constructor(
address collateral
) {
_disableInitializers();

_COLLATERAL = collateral;
_USDE = ISUSDe(collateral).asset();
}

function initialize(uint256 amount) external initializer {
function initialize(
uint256 amount
) external initializer {
__Ownable_init(msg.sender);

ISUSDe(_COLLATERAL).cooldownShares(amount);
Expand Down
12 changes: 7 additions & 5 deletions src/contracts/burners/sfrxETH_Burner.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {SelfDestruct} from "src/contracts/SelfDestruct.sol";
import {UintRequests} from "src/contracts/UintRequests.sol";
import {SelfDestruct} from "../SelfDestruct.sol";
import {UintRequests} from "../UintRequests.sol";

import {IFraxEtherRedemptionQueue} from "src/interfaces/burners/sfrxETH/IFraxEtherRedemptionQueue.sol";
import {IsfrxETH_Burner} from "src/interfaces/burners/sfrxETH/IsfrxETH_Burner.sol";
import {IFraxEtherRedemptionQueue} from "../../interfaces/burners/sfrxETH/IFraxEtherRedemptionQueue.sol";
import {IsfrxETH_Burner} from "../../interfaces/burners/sfrxETH/IsfrxETH_Burner.sol";

import {IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
Expand Down Expand Up @@ -47,7 +47,9 @@ contract sfrxETH_Burner is UintRequests, IsfrxETH_Burner, IERC721Receiver {
/**
* @inheritdoc IsfrxETH_Burner
*/
function triggerBurn(uint256 requestId) external {
function triggerBurn(
uint256 requestId
) external {
_removeRequestId(requestId);

IFraxEtherRedemptionQueue(FRAX_ETHER_REDEMPTION_QUEUE).burnRedemptionTicketNft(
Expand Down
16 changes: 10 additions & 6 deletions src/contracts/burners/swETH_Burner.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {SelfDestruct} from "src/contracts/SelfDestruct.sol";
import {UintRequests} from "src/contracts/UintRequests.sol";
import {SelfDestruct} from "../SelfDestruct.sol";
import {UintRequests} from "../UintRequests.sol";

import {ISwEXIT} from "src/interfaces/burners/swETH/ISwEXIT.sol";
import {IswETH_Burner} from "src/interfaces/burners/swETH/IswETH_Burner.sol";
import {ISwEXIT} from "../../interfaces/burners/swETH/ISwEXIT.sol";
import {IswETH_Burner} from "../../interfaces/burners/swETH/IswETH_Burner.sol";

import {IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
Expand Down Expand Up @@ -35,7 +35,9 @@ contract swETH_Burner is UintRequests, IswETH_Burner, IERC721Receiver {
/**
* @inheritdoc IswETH_Burner
*/
function triggerWithdrawal(uint256 maxRequests) external returns (uint256 firstRequestId, uint256 lastRequestId) {
function triggerWithdrawal(
uint256 maxRequests
) external returns (uint256 firstRequestId, uint256 lastRequestId) {
uint256 amount = IERC20(COLLATERAL).balanceOf(address(this));

uint256 maxWithdrawalAmount = ISwEXIT(SWEXIT).withdrawRequestMaximum();
Expand Down Expand Up @@ -72,7 +74,9 @@ contract swETH_Burner is UintRequests, IswETH_Burner, IERC721Receiver {
/**
* @inheritdoc IswETH_Burner
*/
function triggerBurn(uint256 requestId) external {
function triggerBurn(
uint256 requestId
) external {
_removeRequestId(requestId);

ISwEXIT(SWEXIT).finalizeWithdrawal(requestId);
Expand Down
18 changes: 11 additions & 7 deletions src/contracts/burners/wstETH_Burner.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {SelfDestruct} from "src/contracts/SelfDestruct.sol";
import {UintRequests} from "src/contracts/UintRequests.sol";
import {SelfDestruct} from "../SelfDestruct.sol";
import {UintRequests} from "../UintRequests.sol";

import {IWithdrawalQueue} from "src/interfaces/burners/wstETH/IWithdrawalQueue.sol";
import {IWstETH} from "src/interfaces/burners/wstETH/IWstETH.sol";
import {IwstETH_Burner} from "src/interfaces/burners/wstETH/IwstETH_Burner.sol";
import {IWithdrawalQueue} from "../../interfaces/burners/wstETH/IWithdrawalQueue.sol";
import {IWstETH} from "../../interfaces/burners/wstETH/IWstETH.sol";
import {IwstETH_Burner} from "../../interfaces/burners/wstETH/IwstETH_Burner.sol";

import {IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
Expand Down Expand Up @@ -54,7 +54,9 @@ contract wstETH_Burner is UintRequests, IwstETH_Burner {
/**
* @inheritdoc IwstETH_Burner
*/
function triggerWithdrawal(uint256 maxRequests) external returns (uint256[] memory requestIds_) {
function triggerWithdrawal(
uint256 maxRequests
) external returns (uint256[] memory requestIds_) {
IWstETH(COLLATERAL).unwrap(IERC20(COLLATERAL).balanceOf(address(this)));
uint256 stETHAmount = IERC20(STETH).balanceOf(address(this));

Expand Down Expand Up @@ -88,7 +90,9 @@ contract wstETH_Burner is UintRequests, IwstETH_Burner {
/**
* @inheritdoc IwstETH_Burner
*/
function triggerBurn(uint256 requestId) external {
function triggerBurn(
uint256 requestId
) external {
_removeRequestId(requestId);

IWithdrawalQueue(LIDO_WITHDRAWAL_QUEUE).claimWithdrawal(requestId);
Expand Down
Loading

0 comments on commit 8190adc

Please sign in to comment.