Verified contractExactMIT
CawProfileQuoter
Address0x01fdbc549caaa9585c931f114a6cc323944f0be4
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.30
- Same code
1 more contract
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- Yes, 1 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,389,008
- Creation transaction
- 0x29c160ddf9…918b6221dd
127 files
The source code is large: one file is shown at a time. Choose a file in the list.
- contracts/CawProfileQuoter.solmain18.65 KB
- @layerzerolabs/lz-evm-messagelib-v2/contracts/MessageLibBase.sol528 B
- @layerzerolabs/lz-evm-messagelib-v2/contracts/SendLibBase.sol10.51 KB
- @layerzerolabs/lz-evm-messagelib-v2/contracts/interfaces/IExecutor.sol1.4 KB
- @layerzerolabs/lz-evm-messagelib-v2/contracts/interfaces/IExecutorFeeLib.sol1.66 KB
- @layerzerolabs/lz-evm-messagelib-v2/contracts/interfaces/ILayerZeroExecutor.sol1.35 KB
- @layerzerolabs/lz-evm-messagelib-v2/contracts/interfaces/ILayerZeroReadExecutor.sol878 B
- @layerzerolabs/lz-evm-messagelib-v2/contracts/interfaces/ILayerZeroTreasury.sol442 B
- @layerzerolabs/lz-evm-messagelib-v2/contracts/interfaces/IWorker.sol985 B
- @layerzerolabs/lz-evm-messagelib-v2/contracts/libs/ExecutorOptions.sol4.33 KB
- @layerzerolabs/lz-evm-messagelib-v2/contracts/libs/SafeCall.sol4.64 KB
- @layerzerolabs/lz-evm-messagelib-v2/contracts/uln/libs/DVNOptions.sol7.32 KB
- @layerzerolabs/lz-evm-messagelib-v2/contracts/uln/libs/UlnOptions.sol8.48 KB
- @layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OApp.sol1.53 KB
- @layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OAppCore.sol3.36 KB
- @layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OAppReceiver.sol5.41 KB
- @layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OAppSender.sol5.63 KB
- @layerzerolabs/lz-evm-oapp-v2/contracts/oapp/interfaces/IOAppCore.sol1.86 KB
- @layerzerolabs/lz-evm-oapp-v2/contracts/oapp/interfaces/IOAppReceiver.sol1.08 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/EndpointV2ViewUpgradeable.sol3.44 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/MessagingContext.sol1.48 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol2.59 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroReceiver.sol519 B
- @layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLib.sol805 B
- @layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol2.76 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingChannel.sol1.54 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingComposer.sol1.03 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingContext.sol239 B
- @layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ISendLib.sol923 B
- @layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol1.47 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/libs/CalldataBytesLib.sol1.78 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/libs/Errors.sol1.26 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/libs/GUID.sol460 B
- @layerzerolabs/lz-evm-protocol-v2/contracts/libs/Transfer.sol1.12 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/BitMaps.sol751 B
- @layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/ExecutorOptions.sol3.56 KB
- @layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol3.67 KB
- @layerzerolabs/oapp-evm/contracts/oapp/OAppCore.sol3.36 KB
- @layerzerolabs/oapp-evm/contracts/oapp/OAppReceiver.sol5.41 KB
- @layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppCore.sol1.86 KB
- @layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppReceiver.sol1.08 KB
- @layerzerolabs/oapp-evm/contracts/oapp/libs/OptionsBuilder.sol9.28 KB
- @layerzerolabs/oft-evm/contracts/libs/OFTMsgCodec.sol2.91 KB
- @layerzerolabs/test-devtools-evm-hardhat/contracts/mocks/EndpointV2Mock.sol27.37 KB
- @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol6.64 KB
- @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol9.38 KB
- @openzeppelin/contracts/access/Ownable.sol2.62 KB
- @openzeppelin/contracts/interfaces/IERC1271.sol666 B
- @openzeppelin/contracts/interfaces/IERC5267.sol738 B
- @openzeppelin/contracts/security/ReentrancyGuard.sol3.13 KB
- @openzeppelin/contracts/token/ERC20/ERC20.sol12.85 KB
- @openzeppelin/contracts/token/ERC20/IERC20.sol2.74 KB
- @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol683 B
- @openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol3.8 KB
- @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol6.94 KB
- @openzeppelin/contracts/token/ERC721/ERC721.sol17.01 KB
- @openzeppelin/contracts/token/ERC721/IERC721.sol4.88 KB
- @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol987 B
- @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol6.81 KB
- @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol1.02 KB
- @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol761 B
- @openzeppelin/contracts/utils/Address.sol9.36 KB
- @openzeppelin/contracts/utils/Base64.sol3.89 KB
- @openzeppelin/contracts/utils/Context.sol962 B
- @openzeppelin/contracts/utils/ShortStrings.sol4.29 KB
- @openzeppelin/contracts/utils/StorageSlot.sol4.11 KB
- @openzeppelin/contracts/utils/Strings.sol2.78 KB
- @openzeppelin/contracts/utils/cryptography/ECDSA.sol9.13 KB
- @openzeppelin/contracts/utils/cryptography/EIP712.sol5.66 KB
- @openzeppelin/contracts/utils/cryptography/MerkleProof.sol9.62 KB
- @openzeppelin/contracts/utils/cryptography/draft-EIP712.sol231 B
- @openzeppelin/contracts/utils/introspection/ERC165.sol987 B
- @openzeppelin/contracts/utils/introspection/IERC165.sol853 B
- @openzeppelin/contracts/utils/math/Math.sol12.79 KB
- @openzeppelin/contracts/utils/math/SafeCast.sol35.08 KB
- @openzeppelin/contracts/utils/math/SignedMath.sol1.26 KB
- @openzeppelin/contracts/utils/structs/EnumerableSet.sol12.96 KB
- contracts/CawActions.sol93.41 KB
- contracts/CawActionsArchive.sol39.68 KB
- contracts/CawActionsERC1271.sol13.13 KB
- contracts/CawBuyAndBurn.sol4.09 KB
- contracts/CawCapOracle.sol23.55 KB
- contracts/CawChallengeRelay.sol11.05 KB
- contracts/CawFontDataA.sol35.4 KB
- contracts/CawFontDataB.sol23.93 KB
- contracts/CawL1PriceReader.sol5.52 KB
- contracts/CawNetworkManager.sol36.56 KB
- contracts/CawProfile.sol59.58 KB
- contracts/CawProfileLedger.sol61.35 KB
- contracts/CawProfileLens.sol5.15 KB
- contracts/CawProfileMarketplace.sol36.94 KB
- contracts/CawProfileMinter.sol46.75 KB
- contracts/CawProfileURI.sol23.24 KB
- contracts/CivicKycVerifier.sol1.01 KB
- contracts/ISwapRouter.sol5.12 KB
- contracts/IZKActionsVerifier.sol565 B
- contracts/MintableCaw.sol951 B
- contracts/MockLayerZeroEndpoint.sol398 B
- contracts/OnlyOnce.sol474 B
- contracts/PathwayExpander.sol16.37 KB
- contracts/SessionMessageParser.sol10.99 KB
- contracts/SigVerification.sol4.18 KB
- contracts/SmartEOA.sol54.16 KB
- contracts/examples/CawActionVerifier.sol5.98 KB
- contracts/examples/CawMultisigProfile.sol6.22 KB
- contracts/examples/CawTipResponder.sol6.45 KB
- contracts/interfaces/ICawActions.sol2.08 KB
- contracts/interfaces/ICawCapOracle.sol1.06 KB
- contracts/interfaces/IMint.sol2.31 KB
- contracts/interfaces/ISmartEOA.sol1.78 KB
- contracts/interfaces/ISpend.sol578 B
- contracts/interfaces/IUniswapV2Pair.sol599 B
- contracts/mocks/FeeRecipientMock.sol497 B
- contracts/mocks/LzReceiveHelper.sol1.16 KB
- contracts/mocks/MockContractOwner.sol1.87 KB
- contracts/mocks/MockLzEndpointSimple.sol881 B
- contracts/mocks/MockOAppOwnable.sol576 B
- contracts/mocks/MockSwapRouter.sol1.32 KB
- contracts/sp1-vendor/Groth16Verifier.sol26.77 KB
- contracts/sp1-vendor/ISP1Verifier.sol955 B
- contracts/sp1-vendor/SP1VerifierGroth16.sol3.24 KB
- contracts/test-helpers/CawActionsDigestExposer.sol3.04 KB
- contracts/test-helpers/MockCawActionsCapTarget.sol941 B
- contracts/test-helpers/MockSP1Verifier.sol1.5 KB
- contracts/test/GasMeter.sol1.49 KB
- contracts/test/RevertingBidder.sol728 B
- solidity-bytes-utils/contracts/BytesLib.sol19.44 KB
contracts/CawProfileQuoter.sol
// contracts/CawProfileQuoter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@layerzerolabs/oapp-evm/contracts/oapp/libs/OptionsBuilder.sol";
import { MessagingFee } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OApp.sol";
import { CawNetworkManager } from "./CawNetworkManager.sol";
struct CawProfileSelectors {
bytes4 updateOwners;
}
interface ICawProfileForQuoter {
function networkManager() external view returns (CawNetworkManager);
function authenticated(uint32 networkId, uint32 tokenId) external view returns (bool);
function withdrawFeeLocked(uint32 networkId, uint32 tokenId) external view returns (bool);
function lockedWithdrawFee(uint32 networkId, uint32 tokenId) external view returns (uint256);
function pendingTransferUpdates(uint32 lzDestId, address newOwner, uint32 tokenId) external view returns (uint32[] memory, address[] memory, uint64[] memory);
function mainnetLzId() external view returns (uint32);
function lzQuote(uint32 cawNetworkId, bytes4 selector, uint256 n, bytes memory payload, uint32 lzDestId, bool _payInLzToken) external view returns (MessagingFee memory quote);
}
/**
* @title CawProfileQuoter
* @notice Separate contract for CawProfile quote functions to reduce main contract size
* @dev All functions are view-only and read from the main CawProfile contract
*/
contract CawProfileQuoter {
using OptionsBuilder for bytes;
ICawProfileForQuoter public immutable cawProfile;
// Unified L2 dispatcher selector — matches CawProfileLedger.lzDepositMintSession exactly.
bytes4 private constant _lzBundleSelector = bytes4(keccak256(
"lzDepositMintSession(uint32,uint32,uint256,string,address,uint64,uint256,uint64,uint32[],address[],uint64[])"
));
// Remaining single-purpose selectors still present on CawProfileLedger.
bytes4 private constant _updateOwnersSel = bytes4(keccak256("updateOwners(uint32[],address[],uint64[])"));
// ACC-1: selector must match the real 3-arg CawProfileLedger.setAllowFreeAuth(uint32,bool,uint64)
// signature; an incorrect signature has no CawProfile.gasBaseFor entry, so gasLimitFor returns 0
// and the quote would underfund the destination gas for broadcastAllowFreeAuth.
bytes4 private constant _allowFreeAuthSel = bytes4(keccak256("setAllowFreeAuth(uint32,bool,uint64)"));
constructor(address _cawProfile) {
cawProfile = ICawProfileForQuoter(_cawProfile);
}
/// @dev Returns the updateOwners selector struct (kept for syncTransfer / updateOwner quote paths).
function _s() private pure returns (CawProfileSelectors memory s) {
s.updateOwners = _updateOwnersSel;
}
function authenticateQuote(uint32 networkId, uint32 tokenId, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
uint32[] memory tokenIds; address[] memory owners; uint64[] memory stamps;
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, msg.sender, tokenId);
bytes memory payload = abi.encodeWithSelector(
_lzBundleSelector, networkId, tokenId, uint256(0), "", address(0), uint64(0), uint256(0), uint64(0), tokenIds, owners, stamps
);
quote = cawProfile.lzQuote(networkId, _lzBundleSelector, tokenIds.length, payload, lzDestId, payInLzToken);
quote.nativeFee += cawProfile.networkManager().getAuthFee(networkId) * 2;
return quote;
}
function depositQuote(uint32 networkId, uint32 tokenId, uint256 amount, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
uint32[] memory tokenIds; address[] memory owners; uint64[] memory stamps;
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, msg.sender, tokenId);
bytes memory payload = abi.encodeWithSelector(
_lzBundleSelector, networkId, tokenId, amount, "", address(0), uint64(0), uint256(0), uint64(0), tokenIds, owners, stamps
);
quote = cawProfile.lzQuote(networkId, _lzBundleSelector, tokenIds.length, payload, lzDestId, payInLzToken);
quote.nativeFee += cawProfile.networkManager().getDepositFee(networkId) * 2;
if (!cawProfile.authenticated(networkId, tokenId))
quote.nativeFee += cawProfile.networkManager().getAuthFee(networkId) * 2;
return quote;
}
/// @notice Quote for the plain `CawProfile.mint` entry point (no LZ message
/// fires from this path — the L2 mirror picks up the new token on
/// its next auth or deposit). Returns Network mint fee × 2 only.
function mintQuote(uint32 networkId, bool /*payInLzToken*/) public view returns (MessagingFee memory quote) {
quote.nativeFee = cawProfile.networkManager().getMintFee(networkId) * 2;
return quote;
}
function mintAndDepositQuote(uint32 networkId, uint256 depositAmount, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
// Storage-fee leg: mint + deposit + auth (new user always needs auth).
quote.nativeFee = cawProfile.networkManager().getMintFee(networkId) * 2
+ cawProfile.networkManager().getDepositFee(networkId) * 2
+ cawProfile.networkManager().getAuthFee(networkId) * 2;
// LZ leg: only needed for true L2-storage networks. In bypassLZ
// (lzDestId == mainnetLzId) the L2 mirror is updated via a direct call.
if (lzDestId == cawProfile.mainnetLzId()) return quote;
uint32[] memory tokenIds; address[] memory owners; uint64[] memory stamps;
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, msg.sender, 0);
bytes memory payload = abi.encodeWithSelector(
_lzBundleSelector, networkId, uint32(0), depositAmount, "", address(0), uint64(0), uint256(0), uint64(0), tokenIds, owners, stamps
);
MessagingFee memory lz = cawProfile.lzQuote(networkId, _lzBundleSelector, tokenIds.length, payload, lzDestId, payInLzToken);
quote.nativeFee += lz.nativeFee;
quote.lzTokenFee += lz.lzTokenFee;
return quote;
}
function mintAndAuthQuote(uint32 networkId, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
// Storage-fee leg: mint + auth (the deposit fee is intentionally skipped).
quote.nativeFee = cawProfile.networkManager().getMintFee(networkId) * 2
+ cawProfile.networkManager().getAuthFee(networkId) * 2;
// LZ leg: only needed when the storage chain is a true L2 peer. In bypassLZ
// (lzDestId == mainnetLzId) the L2 mirror is updated via a direct call, so
// there's no LayerZero send and no LZ fee. (mintAndDepositQuote has the
// same gap today; this version short-circuits explicitly so the L1-storage
// path doesn't revert with NoPeer.)
if (lzDestId == cawProfile.mainnetLzId()) return quote;
uint32[] memory tokenIds; address[] memory owners; uint64[] memory stamps;
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, msg.sender, 0);
bytes memory payload = abi.encodeWithSelector(
_lzBundleSelector,
networkId,
uint32(0),
uint256(0),
"placeholdr", // ~10-char placeholder username for sizing
address(0),
uint64(0),
uint256(0),
uint64(0),
tokenIds,
owners,
stamps
);
MessagingFee memory lz = cawProfile.lzQuote(networkId, _lzBundleSelector, tokenIds.length, payload, lzDestId, payInLzToken);
quote.nativeFee += lz.nativeFee;
quote.lzTokenFee += lz.lzTokenFee;
return quote;
}
/// @notice Quote the bundled mint+deposit+auth+quicksign flow.
/// @dev When `sessionKey == address(0)`, falls through to mintAndDepositQuote (no session leg).
/// When `lzDestId == mainnetLzId` (bypassLZ), there's no LZ fee — just storage fees.
function mintAndDepositAndQuickSignQuote(
uint32 networkId, uint256 depositAmount, uint32 lzDestId, bool payInLzToken,
address sessionKey
) public view returns (MessagingFee memory quote) {
// Storage fees (mint + deposit + auth) — same as mintAndDepositQuote.
quote.nativeFee = cawProfile.networkManager().getMintFee(networkId) * 2
+ cawProfile.networkManager().getDepositFee(networkId) * 2
+ cawProfile.networkManager().getAuthFee(networkId) * 2;
if (lzDestId == cawProfile.mainnetLzId()) return quote;
uint32[] memory tokenIds; address[] memory owners; uint64[] memory stamps;
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, msg.sender, 0);
bytes memory payload;
if (sessionKey == address(0)) {
payload = abi.encodeWithSelector(
_lzBundleSelector, networkId, uint32(0), depositAmount, "", address(0), uint64(0), uint256(0), uint64(0), tokenIds, owners, stamps
);
} else {
payload = abi.encodeWithSelector(
_lzBundleSelector, networkId, uint32(0), depositAmount, "",
sessionKey, uint64(0), uint256(0), uint64(0), tokenIds, owners, stamps
);
}
MessagingFee memory lz = cawProfile.lzQuote(networkId, _lzBundleSelector, tokenIds.length, payload, lzDestId, payInLzToken);
quote.nativeFee += lz.nativeFee;
quote.lzTokenFee += lz.lzTokenFee;
return quote;
}
/// @notice Quote the bundled mint+auth+quicksign flow (no deposit).
/// @dev When `sessionKey == address(0)`, falls through to mintAndAuthQuote (no session leg).
/// When `lzDestId == mainnetLzId` (bypassLZ), there's no LZ fee — just storage fees.
function mintAndAuthAndQuickSignQuote(
uint32 networkId, uint32 lzDestId, bool payInLzToken,
address sessionKey
) public view returns (MessagingFee memory quote) {
quote.nativeFee = cawProfile.networkManager().getMintFee(networkId) * 2
+ cawProfile.networkManager().getAuthFee(networkId) * 2;
if (lzDestId == cawProfile.mainnetLzId()) return quote;
uint32[] memory tokenIds; address[] memory owners; uint64[] memory stamps;
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, msg.sender, 0);
bytes memory payload;
if (sessionKey == address(0)) {
payload = abi.encodeWithSelector(
_lzBundleSelector, networkId, uint32(0), uint256(0), "placeholdr", address(0), uint64(0), uint256(0), uint64(0), tokenIds, owners, stamps
);
} else {
payload = abi.encodeWithSelector(
_lzBundleSelector, networkId, uint32(0), uint256(0), "placeholdr",
sessionKey, uint64(0), uint256(0), uint64(0), tokenIds, owners, stamps
);
}
MessagingFee memory lz = cawProfile.lzQuote(networkId, _lzBundleSelector, tokenIds.length, payload, lzDestId, payInLzToken);
quote.nativeFee += lz.nativeFee;
quote.lzTokenFee += lz.lzTokenFee;
return quote;
}
// ============================================
// ZAP QUOTES — pay-with-ETH variants of deposit / mintAndDeposit /
// mintAndDepositAndQuickSign
// ============================================
// The on-chain LZ + storage fees for a ZAP are identical to its CAW-paid
// sibling — the swap leg is a frontend concern (read pool reserves,
// compute minCawOut). The `*ZapQuote` wrappers provide a single quoter
// entry point so callers need not select the selector/payload directly.
// The mint zap quotes drop the `depositAmount` argument because the swap
// output (and therefore the deposit) is unknown until the tx settles; a
// placeholder value is used for LZ payload sizing only.
function depositZapQuote(uint32 cawNetworkId, uint32 tokenId, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
// Storage fees: deposit + auth (auth only if not yet authenticated).
quote.nativeFee = cawProfile.networkManager().getDepositFee(cawNetworkId) * 2;
if (!cawProfile.authenticated(cawNetworkId, tokenId))
quote.nativeFee += cawProfile.networkManager().getAuthFee(cawNetworkId) * 2;
// bypassLZ: no LZ leg, just storage fees. Mirrors the mintAndDeposit short-circuit.
if (lzDestId == cawProfile.mainnetLzId()) return quote;
// Cross-chain (true L2 storage): include the LZ messaging cost.
uint32[] memory tokenIds; address[] memory owners; uint64[] memory stamps;
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, msg.sender, tokenId);
// Use 0 as placeholder for `amount` — it doesn't affect LZ payload size.
bytes memory payload = abi.encodeWithSelector(
_lzBundleSelector, cawNetworkId, tokenId, uint256(0), "", address(0), uint64(0), uint256(0), uint64(0), tokenIds, owners, stamps
);
MessagingFee memory lz = cawProfile.lzQuote(cawNetworkId, _lzBundleSelector, tokenIds.length, payload, lzDestId, payInLzToken);
quote.nativeFee += lz.nativeFee;
quote.lzTokenFee += lz.lzTokenFee;
return quote;
}
function mintAndDepositZapQuote(uint32 networkId, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
return mintAndDepositQuote(networkId, 0, lzDestId, payInLzToken);
}
function mintAndDepositAndQuickSignZapQuote(uint32 networkId, address sessionKey, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
return mintAndDepositAndQuickSignQuote(networkId, 0, lzDestId, payInLzToken, sessionKey);
}
/// @notice Quote for `CawProfile.withdrawTo`. Caller passes the destination
/// L2 they want to opportunistically flush pending owner-updates to —
/// typically the active token's storage chain. lzDestId == 0 skips
/// the flush entirely (callers who don't want one).
function withdrawQuote(uint32 networkId, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
quote = updateOwnerQuote(lzDestId, payInLzToken);
quote.nativeFee += cawProfile.networkManager().getWithdrawFee(networkId) * 2;
return quote;
}
/// @notice Returns the effective withdraw fee for a specific token, accounting for the locked-in
/// rate if one exists. Use this for accurate quotes — `withdrawQuote(networkId)` returns
/// the current network fee without considering the lock.
/// @return The lower of (current network fee, locked-in fee for this token), in wei
function effectiveWithdrawFee(uint32 networkId, uint32 tokenId) public view returns (uint256) {
uint256 current = cawProfile.networkManager().getWithdrawFee(networkId);
if (cawProfile.withdrawFeeLocked(networkId, tokenId)) {
uint256 locked = cawProfile.lockedWithdrawFee(networkId, tokenId);
if (locked < current) return locked;
}
return current;
}
/// @notice Quote the LZ fee for a standalone updateOwners flush to `lzDestId`.
/// @dev Callers (withdrawQuote, transferAndSync wrappers) pick the destination
/// themselves — usually the storage chain associated with the tokenId of
/// interest. lzDestId == 0 (sentinel) returns zero — no peer chosen.
/// lzDestId == mainnetLzId is the bypassLZ co-deployment case (L2 mirror
/// is updated synchronously, no LZ message fires) and likewise returns
/// zero. If the queue for `lzDestId` is empty, also returns zero.
function updateOwnerQuote(uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
if (lzDestId == 0 || lzDestId == cawProfile.mainnetLzId()) return MessagingFee(0, 0);
CawProfileSelectors memory s = _s();
uint32[] memory tokenIds; address[] memory owners; uint64[] memory stamps;
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, address(0), 0);
if (tokenIds.length == 0) return MessagingFee(0, 0);
bytes memory payload = abi.encodeWithSelector(
s.updateOwners, tokenIds, owners, stamps
);
// updateOwners isn't bound to a single networkId — use 0 (no override).
return cawProfile.lzQuote(0, s.updateOwners, tokenIds.length, payload, lzDestId, payInLzToken);
}
/// @notice Quote the LZ fee for `CawProfile.broadcastAllowFreeAuth`.
/// @dev In bypassLZ mode (lzDestId == mainnetLzId) the L2 mirror is updated via a direct call
/// (no LZ message), so the quote is zero. On cross-chain deployments the fee covers one
/// LZ message to the storage chain with a single SSTORE handler. No ownership-update
/// tail is carried by this message, so n=0 is used for gas sizing.
/// @param networkId The network whose free-auth flag is being propagated.
/// @param lzDestId The L2 storage chain endpoint ID.
/// @param payInLzToken True to quote in ZRO token, false for native gas.
function broadcastAllowFreeAuthQuote(uint32 networkId, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
if (lzDestId == cawProfile.mainnetLzId()) return MessagingFee(0, 0);
// Payload: selector(4) + networkId(32) + allow(32) + seq(32) = 100 bytes.
// Matches what broadcastAllowFreeAuth sends (3-arg, includes the seq). The seq
// value doesn't affect the quote size, so a placeholder uint64(0) is fine here.
bytes memory payload = abi.encodeWithSelector(_allowFreeAuthSel, networkId, false, uint64(0));
return cawProfile.lzQuote(networkId, _allowFreeAuthSel, 0, payload, lzDestId, payInLzToken);
}
/**
* @notice Quote the LZ fee for transferAndSync or syncTransfer to a specific destination.
* @dev Includes the given tokenId + new owner in the payload alongside any other pending
* transfers for that destination. Call with tokenId=0 and newOwner=address(0) to
* quote just flushing existing pending transfers. Returns (0,0) if the destination
* is mainnet (synchronous bypassLZ path — no LZ message fires) or has no pending updates.
*/
function syncTransferQuote(uint32 tokenId, address newOwner, uint32 lzDestId, bool payInLzToken) public view returns (MessagingFee memory quote) {
if (lzDestId == cawProfile.mainnetLzId()) return MessagingFee(0, 0);
CawProfileSelectors memory s = _s();
uint32[] memory tokenIds; address[] memory owners; uint64[] memory stamps;
if (tokenId > 0 && newOwner != address(0)) {
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, newOwner, tokenId);
} else {
(tokenIds, owners, stamps) = cawProfile.pendingTransferUpdates(lzDestId, address(0), 0);
}
if (tokenIds.length == 0) return MessagingFee(0, 0);
bytes memory payload = abi.encodeWithSelector(
s.updateOwners, tokenIds, owners, stamps
);
// updateOwners isn't bound to a single networkId — use 0 (no override).
return cawProfile.lzQuote(0, s.updateOwners, tokenIds.length, payload, lzDestId, payInLzToken);
}
}
Compiler settingsShow
{
"viaIR": true,
"optimizer": {
"runs": 1,
"enabled": true
},
"evmVersion": "cancun"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.