-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol): ProverPool gas optimizations (#14062)
Co-authored-by: adaki2004 <adaki2004@users.noreply.github.com> Co-authored-by: Daniel Wang <99078276+dantaik@users.noreply.github.com>
- Loading branch information
1 parent
6cac948
commit a47527d
Showing
14 changed files
with
217 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/protocol/contracts/L1/libs/LibTkoDistribution.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-License-Identifier: MIT | ||
// _____ _ _ _ _ | ||
// |_ _|_ _(_) |_____ | | __ _| |__ ___ | ||
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< | ||
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import { AddressResolver } from "../../common/AddressResolver.sol"; | ||
import { LibMath } from "../../libs/LibMath.sol"; | ||
import { SafeCastUpgradeable } from | ||
"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol"; | ||
import { TaikoData } from "../TaikoData.sol"; | ||
import { TaikoToken } from "../TaikoToken.sol"; | ||
import { LibFixedPointMath as Math } from | ||
"../../thirdparty/LibFixedPointMath.sol"; | ||
|
||
library LibTkoDistribution { | ||
error L1_INSUFFICIENT_TOKEN(); | ||
|
||
function withdrawTaikoToken( | ||
TaikoData.State storage state, | ||
AddressResolver resolver, | ||
uint256 amount | ||
) | ||
internal | ||
{ | ||
uint256 balance = state.taikoTokenBalances[msg.sender]; | ||
if (balance < amount) revert L1_INSUFFICIENT_TOKEN(); | ||
|
||
unchecked { | ||
state.taikoTokenBalances[msg.sender] -= amount; | ||
} | ||
|
||
TaikoToken(resolver.resolve("taiko_token", false)).mint( | ||
msg.sender, amount | ||
); | ||
} | ||
|
||
function depositTaikoToken( | ||
TaikoData.State storage state, | ||
AddressResolver resolver, | ||
uint256 amount | ||
) | ||
internal | ||
{ | ||
if (amount > 0) { | ||
TaikoToken(resolver.resolve("taiko_token", false)).burn( | ||
msg.sender, amount | ||
); | ||
state.taikoTokenBalances[msg.sender] += amount; | ||
} | ||
} | ||
} |
Oops, something went wrong.