Verified contractPartialLGPL-3.0-only
BondingOwnershipLib
Address0x17536f96a9d755ed7224cbdf201c2799d5e6d001
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.28
- Same code
Only this contract
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- Yes, 1 runs
- EVM version
- paris
- License
- LGPL-3.0-only
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,529,399
- Creation transaction
- 0xa8d089fabd…167b827c4a
78 files
The source code is large: one file is shown at a time. Choose a file in the list.
- project/contracts/lib/BondingOwnershipLib.solmain8.2 KB
- npm/@openzeppelin/[email protected]/access/Ownable2StepUpgradeable.sol3.01 KB
- npm/@openzeppelin/[email protected]/access/OwnableUpgradeable.sol4.03 KB
- npm/@openzeppelin/[email protected]/proxy/utils/Initializable.sol8.91 KB
- npm/@openzeppelin/[email protected]/utils/ContextUpgradeable.sol1.19 KB
- npm/@openzeppelin/[email protected]/utils/ReentrancyGuardUpgradeable.sol4.36 KB
- npm/@openzeppelin/[email protected]/access/Ownable.sol3.1 KB
- npm/@openzeppelin/[email protected]/access/Ownable2Step.sol2.48 KB
- npm/@openzeppelin/[email protected]/governance/utils/IVotes.sol2.32 KB
- npm/@openzeppelin/[email protected]/governance/utils/Votes.sol9.71 KB
- npm/@openzeppelin/[email protected]/interfaces/IERC1363.sol4.45 KB
- npm/@openzeppelin/[email protected]/interfaces/IERC165.sol192 B
- npm/@openzeppelin/[email protected]/interfaces/IERC20.sol181 B
- npm/@openzeppelin/[email protected]/interfaces/IERC5267.sol739 B
- npm/@openzeppelin/[email protected]/interfaces/IERC5805.sol272 B
- npm/@openzeppelin/[email protected]/interfaces/IERC6372.sol519 B
- npm/@openzeppelin/[email protected]/interfaces/draft-IERC6093.sol6.54 KB
- npm/@openzeppelin/[email protected]/token/ERC20/ERC20.sol10.88 KB
- npm/@openzeppelin/[email protected]/token/ERC20/IERC20.sol2.78 KB
- npm/@openzeppelin/[email protected]/token/ERC20/extensions/ERC20Votes.sol3.61 KB
- npm/@openzeppelin/[email protected]/token/ERC20/extensions/ERC20Wrapper.sol3.46 KB
- npm/@openzeppelin/[email protected]/token/ERC20/extensions/IERC20Metadata.sol684 B
- npm/@openzeppelin/[email protected]/token/ERC20/utils/SafeERC20.sol10.08 KB
- npm/@openzeppelin/[email protected]/utils/Arrays.sol18.34 KB
- npm/@openzeppelin/[email protected]/utils/Comparators.sol443 B
- npm/@openzeppelin/[email protected]/utils/Context.sol963 B
- npm/@openzeppelin/[email protected]/utils/Nonces.sol1.49 KB
- npm/@openzeppelin/[email protected]/utils/Panic.sol1.97 KB
- npm/@openzeppelin/[email protected]/utils/ReentrancyGuard.sol3.38 KB
- npm/@openzeppelin/[email protected]/utils/ShortStrings.sol4.3 KB
- npm/@openzeppelin/[email protected]/utils/SlotDerivation.sol5.32 KB
- npm/@openzeppelin/[email protected]/utils/StorageSlot.sol4.18 KB
- npm/@openzeppelin/[email protected]/utils/Strings.sol19.28 KB
- npm/@openzeppelin/[email protected]/utils/cryptography/ECDSA.sol7.82 KB
- npm/@openzeppelin/[email protected]/utils/cryptography/EIP712.sol6.71 KB
- npm/@openzeppelin/[email protected]/utils/cryptography/MessageHashUtils.sol4.25 KB
- npm/@openzeppelin/[email protected]/utils/introspection/IERC165.sol870 B
- npm/@openzeppelin/[email protected]/utils/math/Math.sol32.15 KB
- npm/@openzeppelin/[email protected]/utils/math/SafeCast.sol34.94 KB
- npm/@openzeppelin/[email protected]/utils/math/SignedMath.sol2.61 KB
- npm/@openzeppelin/[email protected]/utils/structs/Checkpoints.sol21.43 KB
- npm/@openzeppelin/[email protected]/utils/structs/EnumerableSet.sol14.72 KB
- npm/@openzeppelin/[email protected]/utils/types/Time.sol5.16 KB
- project/contracts/interfaces/IBondOwnerHistory.sol759 B
- project/contracts/interfaces/IBondedCheckpoints.sol2.99 KB
- project/contracts/interfaces/IBondingAdmission.sol1.13 KB
- project/contracts/interfaces/IBondingIdentity.sol901 B
- project/contracts/interfaces/IBondingRegistry.sol36.62 KB
- project/contracts/interfaces/ICiphernodeRegistry.sol37.46 KB
- project/contracts/interfaces/ICiphertextVerifier.sol1.21 KB
- project/contracts/interfaces/IDecryptionVerifier.sol3.77 KB
- project/contracts/interfaces/IDkgFoldAttestationVerifier.sol1.58 KB
- project/contracts/interfaces/IE3.sol2.43 KB
- project/contracts/interfaces/IE3Program.sol2.43 KB
- project/contracts/interfaces/IE3RefundManager.sol19 KB
- project/contracts/interfaces/IInterfold.sol43.1 KB
- project/contracts/interfaces/ILockAwareCiphernodeBondToken.sol729 B
- project/contracts/interfaces/INodeReleaseManager.sol940 B
- project/contracts/interfaces/INodeReleaseRegistry.sol2.55 KB
- project/contracts/interfaces/IOwnerIdentityRegistry.sol3.11 KB
- project/contracts/interfaces/IPkVerifier.sol3.07 KB
- project/contracts/interfaces/IRandomnessProvider.sol1.82 KB
- project/contracts/interfaces/ISlashingManager.sol33.77 KB
- project/contracts/lib/BondOwnerCapacityLib.sol6.93 KB
- project/contracts/lib/BondingAdmissionLib.sol5.18 KB
- project/contracts/lib/BondingAssetLib.sol17 KB
- project/contracts/lib/BondingEligibilityLib.sol10.93 KB
- project/contracts/lib/BondingIdentityLib.sol3.66 KB
- project/contracts/lib/BondingRegistrationLib.sol6.85 KB
- project/contracts/lib/BondingSlashingLib.sol14.52 KB
- project/contracts/lib/ExitQueueLib.sol25.9 KB
- project/contracts/registry/BondingRegistry.sol53.42 KB
- project/contracts/storage/BondOwnerHistoryStorage.sol931 B
- project/contracts/storage/BondingAdmissionStorage.sol746 B
- project/contracts/storage/BondingEligibilityStorage.sol914 B
- project/contracts/storage/BondingIdentityStorage.sol658 B
- project/contracts/storage/BondingSlashingStorage.sol2.26 KB
- project/contracts/token/InterfoldTicketToken.sol21.27 KB
project/contracts/lib/BondingOwnershipLib.sol
// SPDX-License-Identifier: LGPL-3.0-only
//
// This file is provided WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.
pragma solidity 0.8.28;
import { InterfoldTicketToken } from "../token/InterfoldTicketToken.sol";
import { IBondingRegistry } from "../interfaces/IBondingRegistry.sol";
import { BondingRegistry } from "../registry/BondingRegistry.sol";
import { ExitQueueLib } from "./ExitQueueLib.sol";
import {
BondOwnerHistoryStorage
} from "../storage/BondOwnerHistoryStorage.sol";
import {
Checkpoints
} from "@openzeppelin/contracts/utils/structs/Checkpoints.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import { BondOwnerCapacityLib } from "./BondOwnerCapacityLib.sol";
import { BondingAdmissionLib } from "./BondingAdmissionLib.sol";
import { BondingIdentityLib } from "./BondingIdentityLib.sol";
import { BondingAssetLib } from "./BondingAssetLib.sol";
import { IBondedCheckpoints } from "../interfaces/IBondedCheckpoints.sol";
/**
* @title BondingOwnershipLib
* @notice Bond-owner assignment for `BondingRegistry`.
*
* @dev External, so this code is delegatecalled and does not count against the registry's
* EIP-170 limit.
*
* This library checks transfer authorization and locked balances before changing ownership.
* It then checkpoints both owners' bonded balances in the same transaction.
*/
library BondingOwnershipLib {
using ExitQueueLib for ExitQueueLib.ExitQueueState;
using Checkpoints for Checkpoints.Trace208;
// keccak256(abi.encode(uint256(keccak256(namespace)) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OWNER_HISTORY_SLOT =
0xfe211ffeb4589816a55506d3b74a3970b9121045b3d5fc44a9615b3f32a58e00;
/// @notice Records ownership before either assignment path changes the current mapping.
function _recordOwner(
address operator,
address previousOwner,
address newOwner
) private {
if (previousOwner == newOwner) return;
Checkpoints.Trace208 storage history = _ownerHistory().history[
operator
];
// Seed an existing operator lazily. No owner change after the upgrade can erase
// the owner that a new request saw before that change.
if (history.length() == 0)
history.push(0, uint208(uint160(previousOwner)));
history.push(
SafeCast.toUint48(block.timestamp),
uint208(uint160(newOwner))
);
BondingAdmissionLib.start(operator);
bool allowed = BondingAdmissionLib.allows(
operator,
block.timestamp,
BondingAdmissionLib.policyAt(block.timestamp)
) && BondingIdentityLib.allows(operator, block.timestamp);
BondOwnerCapacityLib.transfer(
operator,
allowed ? newOwner : address(0)
);
}
/// @notice Checks and commits a transfer, including admission and bonded checkpoints.
function completeTransfer(
mapping(address => address) storage bondOwners,
mapping(address => address) storage pendingBondOwners,
mapping(address => uint256) storage bondedByOwner,
mapping(address => BondingRegistry.Operator) storage operators,
ExitQueueLib.ExitQueueState storage exits,
address token,
IBondedCheckpoints checkpoints,
address operator
) external {
require(
msg.sender == pendingBondOwners[operator],
IBondingRegistry.Unauthorized()
);
address previousOwner = bondOwners[operator];
(, uint256 pendingBond) = exits.getPendingAmounts(operator);
uint256 delegatedBond = operators[operator].ciphernodeBond +
pendingBond;
BondingAssetLib.validateBondOwnerTransfer(
token,
previousOwner,
bondedByOwner[previousOwner],
delegatedBond
);
delete pendingBondOwners[operator];
_recordOwner(operator, previousOwner, msg.sender);
bondOwners[operator] = msg.sender;
bondedByOwner[previousOwner] -= delegatedBond;
bondedByOwner[msg.sender] += delegatedBond;
if (address(checkpoints) != address(0)) {
checkpoints.sync(previousOwner, bondedByOwner[previousOwner]);
checkpoints.sync(msg.sender, bondedByOwner[msg.sender]);
}
emit IBondingRegistry.BondOwnerSet(operator, msg.sender);
}
/// @notice Proposes a replacement owner without changing snapshot ownership.
function proposeTransfer(
mapping(address => address) storage bondOwners,
mapping(address => address) storage pendingBondOwners,
address operator,
address newOwner
) external {
if (msg.sender != bondOwners[operator]) {
revert IBondingRegistry.NotBondOwner(msg.sender, operator);
}
require(newOwner != address(0), IBondingRegistry.ZeroAddress());
pendingBondOwners[operator] = newOwner;
emit IBondingRegistry.BondOwnerTransferProposed(
operator,
msg.sender,
newOwner
);
}
/// @notice Reads timestamp-based ownership, including unchanged pre-upgrade operators.
function bondOwnerAt(
mapping(address => address) storage bondOwners,
address operator,
uint256 timepoint
) external view returns (address) {
Checkpoints.Trace208 storage history = _ownerHistory().history[
operator
];
if (history.length() == 0) return bondOwners[operator];
return
address(
uint160(history.upperLookupRecent(SafeCast.toUint48(timepoint)))
);
}
function _ownerHistory()
private
pure
returns (BondOwnerHistoryStorage.OwnerHistoryLayout storage state)
{
bytes32 slot = OWNER_HISTORY_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
state.slot := slot
}
}
/**
* @notice Assign the caller's bond owner.
* @dev Reassignment is refused once the operator holds anything, because the bond owner is
* who collateral returns to. The check covers active bond, tickets, and amounts still queued
* for exit — an operator mid-exit still has assets to return.
* @param bondOwners Operator to bond-owner mapping.
* @param pendingBondOwners Proposed owners in the two-step transfer flow.
* @param operators The registry's operator records.
* @param exits The registry's exit queue.
* @param ticketToken The ticket token to read balances from.
* @param bondOwner The owner being assigned.
*/
function setBondOwner(
mapping(address operator => address bondOwner) storage bondOwners,
mapping(address operator => address pendingOwner)
storage pendingBondOwners,
mapping(address operator => BondingRegistry.Operator data)
storage operators,
ExitQueueLib.ExitQueueState storage exits,
InterfoldTicketToken ticketToken,
address bondOwner
) external {
require(bondOwner != address(0), IBondingRegistry.ZeroAddress());
address currentOwner = bondOwners[msg.sender];
if (currentOwner != address(0)) {
(uint256 pendingTicket, uint256 pendingCiphernodeBond) = exits
.getPendingAmounts(msg.sender);
BondingRegistry.Operator storage op = operators[msg.sender];
if (
op.registered ||
op.ciphernodeBond != 0 ||
pendingCiphernodeBond != 0 ||
ticketToken.balanceOf(msg.sender) != 0 ||
pendingTicket != 0
) {
revert IBondingRegistry.BondOwnerAlreadySet(
msg.sender,
currentOwner
);
}
}
delete pendingBondOwners[msg.sender];
_recordOwner(msg.sender, currentOwner, bondOwner);
bondOwners[msg.sender] = bondOwner;
emit IBondingRegistry.BondOwnerSet(msg.sender, bondOwner);
}
}
Compiler settingsShow
{
"debug": {
"revertStrings": "strip"
},
"metadata": {
"bytecodeHash": "none"
},
"libraries": {},
"optimizer": {
"runs": 1,
"enabled": true
},
"evmVersion": "paris",
"remappings": [
"project/:@openzeppelin/contracts-upgradeable/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts-upgradeable/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.