Verified contractExactUNLICENSED
CTokenRewardsLib
Address0xcda63d7eccf838f2732bff676706bde5aba4dcf7
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.35
- Same code
Only this contract
Details
- Compiler
- solc 0.8.35+commit.47b9dedd
- Language
- solidity
- Optimization
- Yes, 100 runs
- EVM version
- cancun
- Via IR
- yes
- License
- UNLICENSED
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,396,569
- Creation transaction
- 0x6ac9485cea…c55b04bbf7
- Libraries
- src/core/mm/MMRouterLib.sol:MMRouterLib0xa474…d2b4e5src/core/flamm/FLAMMLane.sol:FLAMMLane0x0988…d22e98src/core/flamm/FLAMMRoute.sol:FLAMMRoute0x312e…0fdaa9src/periphery/FLAMMMaxima.sol:FLAMMMaxima0x4a99…d6259csrc/core/flamm/FLAMMLawLib.sol:FLAMMLawLib0x5d47…27cc62src/core/flamm/FLAMMOpsLib.sol:FLAMMOpsLib0x0bfe…043753src/core/mm/AaveV3ReadsLib.sol:AaveV3ReadsLib0xd53f…ed5983src/core/flamm/FLAMMFlowLib.sol:FLAMMFlowLib0x2577…4e3473src/core/flamm/FLAMMGateLib.sol:FLAMMGateLib0xf0be…2b9555src/core/flamm/FLAMMKeptLib.sol:FLAMMKeptLib0x7a11…58517bsrc/core/mm/CTokenMarketLib.sol:CTokenMarketLib0x18c5…b2071csrc/core/flamm/FLAMMAdmitLib.sol:FLAMMAdmitLib0xa6db…bdcbcbsrc/core/flamm/FLAMMBlindLib.sol:FLAMMBlindLib0x0b8d…2e7e5csrc/core/flamm/FLAMMClaimLib.sol:FLAMMClaimLib0x02b4…731ccesrc/core/flamm/FLAMMFenceLib.sol:FLAMMFenceLib0xa16d…a201e8src/core/flamm/FLAMMFloatLib.sol:FLAMMFloatLib0x539e…a79737src/core/flamm/FLAMMQuoteLib.sol:FLAMMQuoteLib0xa4d3…d5ce2esrc/core/flamm/FLAMMTopUpLib.sol:FLAMMTopUpLib0x7c55…d233dfsrc/core/mm/CTokenRewardsLib.sol:CTokenRewardsLib0xcda6…a4dcf7src/core/mm/MMRouterAdminLib.sol:MMRouterAdminLib0x8423…7adc96src/core/flamm/FLAMMPolicyLib.sol:FLAMMPolicyLib0xa6b4…0c67f9src/core/flamm/FLAMMSettleLib.sol:FLAMMSettleLib0xb489…d3c7cbsrc/core/flamm/FLAMMSharedLib.sol:FLAMMSharedLib0xfaae…2511basrc/periphery/FLAMMExitMaxima.sol:FLAMMExitMaxima0x480f…4e0a81src/hooks/everlong/LeverageLib.sol:LeverageLib0x1b1d…40ad11src/core/flamm/FLAMMMaintainLib.sol:FLAMMMaintainLib0x9499…409cc2src/core/flamm/FLAMMPairQuoteLib.sol:FLAMMPairQuoteLib0x0775…d94cbesrc/hooks/everlong/EverlongOpsLib.sol:EverlongOpsLib0xabe4…7426f7
src/core/mm/CTokenRewardsLib.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025-2026 Everlong Labs Limited
pragma solidity ^0.8.26;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IVenusComptroller} from "src/interfaces/utils/integrations/IVenus.sol";
/// @notice The Venus kind's (`CTokenAccount`) reward legs, linked to it rather than inlined, so the account keeps its
/// EIP-170 margin: each runs in the account's context and moves a venue's sub-accounts through their one entry,
/// a call from the account (`CTokenSubAccount`), as the account's own legs do.
library CTokenRewardsLib {
/// @notice `CTokenAccount.claimRewards`: claims the XVS the comptroller pays the debt sub-account `d` and the
/// credit sub-account `cs` in markets `cv` and `lv`, and sends each one's whole XVS balance to `safe`.
function claim(address comptroller, address safe, address cv, address lv, address d, address cs) public {
address xvs = IVenusComptroller(comptroller).getXVSAddress();
address[] memory markets = new address[](2);
(markets[0], markets[1]) = (cv, lv);
for (uint256 k; k < 2; ++k) {
address sub = k == 0 ? d : cs;
IVenusComptroller(comptroller).claimVenus(sub, markets);
uint256 got = IERC20(xvs).balanceOf(sub);
if (got != 0) _exec(sub, xvs, IERC20.transfer.selector, uint256(uint160(safe)), got);
}
}
/// @notice `CTokenAccount.steerRewardsToTheSafe`: each of the two sub-accounts names `safe` its recipient at the
/// Merkl distributor for every token and lets anyone claim for it, set once.
function steer(address distributor, address safe, address d, address cs) public {
for (uint256 k; k < 2; ++k) {
address sub = k == 0 ? d : cs;
_exec(sub, distributor, 0x68508c98, uint256(uint160(safe)), 0); // setClaimRecipient(address,address)
// operators(address,address), then toggleOperator(address,address)
(bool ok, bytes memory r) = distributor.staticcall(abi.encodeWithSelector(0x2637588e, sub, address(0)));
if (!ok) {
assembly ("memory-safe") {
revert(add(r, 0x20), mload(r))
}
}
if (r.length < 32) revert();
if (abi.decode(r, (uint256)) == 0) _exec(sub, distributor, 0xbdac7ca3, uint256(uint160(sub)), 0);
}
}
}
/// @dev Calls `target`'s `selector(a, b)` as sub-account `holder` (a function of one argument ignores `b`), its one
/// entry (`CTokenSubAccount`); returns the answer's first word, zero for none. A revert passes through. The
/// account's legs and these alike.
function _exec(address holder, address target, bytes4 selector, uint256 a, uint256 b) returns (uint256 first) {
assembly ("memory-safe") {
let p := mload(0x40)
mstore(p, target)
mstore(add(p, 0x20), selector)
mstore(add(p, 0x24), a)
mstore(add(p, 0x44), b)
if iszero(call(gas(), holder, 0, p, 0x64, 0, 0)) {
returndatacopy(p, 0, returndatasize())
revert(p, returndatasize())
}
if gt(returndatasize(), 0x1f) {
returndatacopy(0, 0, 0x20)
first := mload(0)
}
}
}
lib/openzeppelin-contracts-compat/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
src/interfaces/utils/integrations/IVenus.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025-2026 Everlong Labs Limited
pragma solidity ^0.8.26;
/// @notice A Compound-style market token as `CTokenAccount` uses it: Venus's VBep20 on BNB Chain. Its mutators return
/// an error code (0: done) where a failure does not revert. `getCash` is the market's tracked cash, which a
/// transfer to it does not move.
interface IVToken {
function underlying() external view returns (address);
function comptroller() external view returns (address);
function interestRateModel() external view returns (address);
function accrualBlockNumber() external view returns (uint256);
function borrowIndex() external view returns (uint256);
function getCash() external view returns (uint256);
function totalBorrows() external view returns (uint256);
function totalReserves() external view returns (uint256);
function totalSupply() external view returns (uint256);
function reserveFactorMantissa() external view returns (uint256);
function exchangeRateStored() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function borrowBalanceStored(address account) external view returns (uint256);
/// @notice (error, vToken balance, stored borrow balance, stored exchange rate); a nonzero error zeroes the rest.
function getAccountSnapshot(address account) external view returns (uint256, uint256, uint256, uint256);
function accrueInterest() external returns (uint256);
function exchangeRateCurrent() external returns (uint256);
function borrowBalanceCurrent(address account) external returns (uint256);
function mintBehalf(address receiver, uint256 mintAmount) external returns (uint256);
function redeem(uint256 redeemTokens) external returns (uint256);
function redeemUnderlying(uint256 redeemAmount) external returns (uint256);
function borrow(uint256 borrowAmount) external returns (uint256);
function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);
}
/// @notice The Venus Core Pool comptroller (a diamond) as `CTokenAccount` reads and drives it. `action` is Venus's
/// `Action` (0 mint, 1 redeem, 2 borrow, 3 repay, 7 enter market, 8 exit market); `weighting` 0 reads the
/// collateral factor, 1 the liquidation threshold. `markets` and `poolMarkets` answer (listed, collateral
/// factor, isVenus, liquidation threshold, liquidation incentive, pool id, borrow allowed).
interface IVenusComptroller {
/// @notice Enters `vToken` for `onBehalf`, the caller itself or one it approved as a delegate.
function enterMarketBehalf(address onBehalf, address vToken) external returns (uint256);
function exitMarket(address vToken) external returns (uint256);
/// @notice Pays `holder` the XVS it accrued in `vTokens`, as supplier and borrower.
function claimVenus(address holder, address[] calldata vTokens) external;
function getXVSAddress() external view returns (address);
function enterPool(uint96 poolId) external;
function protocolPaused() external view returns (bool);
function actionPaused(address market, uint8 action) external view returns (bool);
function supplyCaps(address vToken) external view returns (uint256);
function borrowCaps(address vToken) external view returns (uint256);
function treasuryPercent() external view returns (uint256);
function checkMembership(address account, address vToken) external view returns (bool);
/// @notice The markets `account` has entered, each of which a liquidity check Venus makes for it prices.
function getAssetsIn(address account) external view returns (address[] memory);
function pools(uint96 poolId) external view returns (string memory label, bool isActive, bool allowCorePoolFallback);
function markets(address vToken) external view returns (bool, uint256, bool, uint256, uint256, uint96, bool);
function poolMarkets(uint96 poolId, address vToken)
external
view
returns (bool, uint256, bool, uint256, uint256, uint96, bool);
function getEffectiveLtvFactor(address account, address vToken, uint8 weighting) external view returns (uint256);
function isForcedLiquidationEnabled(address vToken) external view returns (bool);
function isForcedLiquidationEnabledForUser(address account, address vToken) external view returns (bool);
function deviationBoundedOracle() external view returns (address);
/// @notice (error, liquidity, shortfall) at the collateral factor and the bounded prices, `redeemTokens` of
/// `vTokenModify` redeemed and `borrowAmount` of it borrowed.
function getHypotheticalAccountLiquidity(
address account,
address vTokenModify,
uint256 redeemTokens,
uint256 borrowAmount
) external view returns (uint256, uint256, uint256);
}
/// @notice Venus's deviation-bounded oracle: per market, the price its collateral-factor checks value collateral at
/// and the price they value debt at, each in USD per base unit scaled by 1e36 (a whole token's USD price
/// times 10^(36 - decimals)). Reverts while the resilient oracle behind it cannot price.
interface IVenusBoundedOracle {
function getBoundedPricesView(address vToken) external view returns (uint256 collateralPrice, uint256 debtPrice);
}
/// @notice A Venus rate model: the borrow rate per block, and its blocks per year under one of two names.
interface IVenusRateModel {
function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) external view returns (uint256);
function blocksPerYear() external view returns (uint256);
function BLOCKS_PER_YEAR() external view returns (int256);
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {
"src/core/mm/MMRouterLib.sol": {
"MMRouterLib": "0xA4749766934833DfBeaF4Fc0d79c150A1Dd2B4E5"
},
"src/core/flamm/FLAMMLane.sol": {
"FLAMMLane": "0x0988077AB06F1efd8cFa3f08FC60CAf3e6d22e98"
},
"src/core/flamm/FLAMMRoute.sol": {
"FLAMMRoute": "0x312ee92ecd113F925dD513d450b062C8740fDaA9"
},
"src/periphery/FLAMMMaxima.sol": {
"FLAMMMaxima": "0x4A997343D91c981BF63274fc222AA96D32d6259c"
},
"src/core/flamm/FLAMMLawLib.sol": {
"FLAMMLawLib": "0x5D473B15E032756Cd81fc66B8F1e9BE2f427cc62"
},
"src/core/flamm/FLAMMOpsLib.sol": {
"FLAMMOpsLib": "0x0BFe60fB1f5223F1A2b7B02Ef18f5C33fb043753"
},
"src/core/mm/AaveV3ReadsLib.sol": {
"AaveV3ReadsLib": "0xD53F6170226A74D453e84414Ffc2FFcE5ded5983"
},
"src/core/flamm/FLAMMFlowLib.sol": {
"FLAMMFlowLib": "0x2577D707D41209489b2EF53101a4f6baDd4E3473"
},
"src/core/flamm/FLAMMGateLib.sol": {
"FLAMMGateLib": "0xF0BE115A2D6F27274F2e9EE50B89Ed42db2B9555"
},
"src/core/flamm/FLAMMKeptLib.sol": {
"FLAMMKeptLib": "0x7a11899232dd9F17c28bF062Ec2ee2267158517b"
},
"src/core/mm/CTokenMarketLib.sol": {
"CTokenMarketLib": "0x18c53F2aCAbcDEEdb575A136f49fa4C43EB2071c"
},
"src/core/flamm/FLAMMAdmitLib.sol": {
"FLAMMAdmitLib": "0xA6dBD8cD5Cd10F8a5857cbeD54a28405ffbDcBCb"
},
"src/core/flamm/FLAMMBlindLib.sol": {
"FLAMMBlindLib": "0x0b8d436F1a7AE25C5d16955ed4CDa781E42e7E5C"
},
"src/core/flamm/FLAMMClaimLib.sol": {
"FLAMMClaimLib": "0x02b4354a56630ab165A880B1198a603E62731cCE"
},
"src/core/flamm/FLAMMFenceLib.sol": {
"FLAMMFenceLib": "0xA16ddA83f47a42F875f141b6954595D584a201e8"
},
"src/core/flamm/FLAMMFloatLib.sol": {
"FLAMMFloatLib": "0x539EfC2b17cF0fdF254AAaB925b3A7c360A79737"
},
"src/core/flamm/FLAMMQuoteLib.sol": {
"FLAMMQuoteLib": "0xa4D34f4882a529574840881e755BCFae2bd5ce2e"
},
"src/core/flamm/FLAMMTopUpLib.sol": {
"FLAMMTopUpLib": "0x7C55a535Ce298b1e5e6d00F645088F777ad233DF"
},
"src/core/mm/CTokenRewardsLib.sol": {
"CTokenRewardsLib": "0xcda63d7eCCF838F2732Bff676706BDE5abA4DcF7"
},
"src/core/mm/MMRouterAdminLib.sol": {
"MMRouterAdminLib": "0x8423744b3F304ED0B43043d7ad4E7d8A247aDc96"
},
"src/core/flamm/FLAMMPolicyLib.sol": {
"FLAMMPolicyLib": "0xa6B495B2BdcDcf4F327844d9aaA0eD4C550c67F9"
},
"src/core/flamm/FLAMMSettleLib.sol": {
"FLAMMSettleLib": "0xB4890a27205505BDAA05717B6c3aB38b2dd3C7Cb"
},
"src/core/flamm/FLAMMSharedLib.sol": {
"FLAMMSharedLib": "0xFaAEd38962aEb6c282Ac36E0cdE9313AbA2511ba"
},
"src/periphery/FLAMMExitMaxima.sol": {
"FLAMMExitMaxima": "0x480f51866554e92649c9d3502bA31AA4234e0a81"
},
"src/hooks/everlong/LeverageLib.sol": {
"LeverageLib": "0x1B1D1C42d26c169dB59D8681d0FD4C9a2840Ad11"
},
"src/core/flamm/FLAMMMaintainLib.sol": {
"FLAMMMaintainLib": "0x94998f13fc5d5D2271c90b835c6a805dad409cC2"
},
"src/core/flamm/FLAMMPairQuoteLib.sol": {
"FLAMMPairQuoteLib": "0x077523D1427aE408105fe8592F907ECDa0D94cbE"
},
"src/hooks/everlong/EverlongOpsLib.sol": {
"EverlongOpsLib": "0xAbe4447C954E3C7a405f8E75116BF9f5787426F7"
}
},
"optimizer": {
"runs": 100,
"enabled": true
},
"viaSSACFG": false,
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts-compat/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable-compat/contracts/",
"solady/=lib/solady/src/",
"forge-std/=lib/forge-std/src/"
],
"experimental": false
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.