Platform: Code4rena
Start Date: 05/01/2023
Pot Size: $90,500 USDC
Total HM: 55
Participants: 103
Period: 14 days
Judge: Picodes
Total Solo HM: 18
Id: 202
League: ETH
Rank: 75/103
Findings: 1
Award: $51.32
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: ladboy233
Also found by: 0x1f8b, 0xAgro, 0xSmartContract, 0xbepresent, 0xkato, Aymen0909, CodingNameKiki, Cryptor, Deekshith99, Deivitto, HE1M, IllIllI, Kaysoft, Koolex, PaludoX0, Qeew, RaymondFam, Rolezn, Sathish9098, Tointer, a12jmx, arialblack14, ast3ros, ayeslick, bin2chen, btk, caventa, ch0bu, chaduke, chrisdior4, delfin454000, descharre, evan, fatherOfBlocks, georgits, gz627, jasonxiale, joestakey, kaden, lukris02, nicobevi, nogo, oberon, oyc_109, pfapostol, rbserver, sakshamguruji, seeu, shark, simon135, slvDev, synackrst, tnevler, whilom, zaskoh
51.3151 USDC - $51.32
Context:
function setNewGuardian(address _guardian) external {
L339Recommendation:
The best practice is to use two-step procedure for critical changes to make them less error-prone.
Context:
return shares;
L140return super.withdraw(assets, receiver, owner);
L174return super.redeem(shares, receiver, owner);
L195return
L164return
L179return
L144return timeToEpochEnd() + EPOCH_LENGTH();
L719return super.mint(vault, to, shares, maxAmountIn);
L136return super.deposit(vault, to, amount, minSharesOut);
L152return super.withdraw(vault, to, amount, maxSharesOut);
L168return super.redeem(vault, to, shares, minAmountOut);
L184return vault.redeemFutureEpoch(shares, receiver, msg.sender, epoch);
L193_validateCommitment(_loadRouterSlot(), commitment, timeToSecondEpochEnd);
L431return vaultAddr;
L758return _buyoutLien(s, params);
L119return _getBuyout(_loadLienStorageSlot(), stack);
L582return _makePayment(_loadLienStorageSlot(), stack, amount);
L605return _getMaxPotentialDebtForCollateralUpToNPositions(stack, stack.length);
L712return deposit(vault, to, amount, minSharesOut);
L31return deposit(vault, to, amount, minSharesOut);
L45return redeem(vault, to, amountShares, minAmountOut);
L58Recommendation:
Choose named return variable or return statement. It is unnecessary to use both.
Context:
function balanceOf(address account, uint256 id)
L82 (account)function balanceOf(address account, uint256 id)
L82 (id)function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
L90 (ids)function isApprovedForAll(address account, address operator)
L106 (account and operator)address tokenContract, // collateral token sending the fake nft
L115address to, // buyer
L116ILienToken.AuctionStack[] storage stack = s.auctionStack.stack;
L139bytes calldata data //empty from seaport
L174address operator_,
L189address from_,
L190uint256 tokenId_,
L191bytes calldata data_
L192function deposit(uint256 assets, address receiver)
L143 (assets and receiver)address tokenContract = underlying.tokenContract;
L138uint256 tokenId = underlying.tokenId;
L139address caller,
L159address offerer,
L160address caller,
L173bytes32[] calldata priorOrderHashes,
L175CriteriaResolver[] calldata criteriaResolvers
L176address tokenContract = underlying.tokenContract;
L342uint256 assets = totalAssets();
L262function _beforeCommitToLien(IAstariaRouter.Commitment calldata params)
L413 (params)function afterDeposit(uint256 assets, uint256 shares)
L575 (shares)uint256 end = stack[position].end;
L632function _getRemainingInterest(LienStorage storage s, Stack memory stack)
L775 (s)Context:
Recommendation:
Example how to fix require(_newOwner != owner, " Same address");
Context:
function _delegate(address implementation) internal virtual {
L29 (internal function can not go after internal pure function)fallback() external payable virtual {
L69 (fallback function can not go after internal function)receive() external payable virtual {
L77 (receive function can not go after fallback function)function deposit(uint256 amount, address receiver)
L59 (public function can not go after public pure function)function setAuctionData(ILienToken.AuctionData calldata auctionData)
L66 (external function can not go after internal function)uint256(keccak256("xyz.astaria.WithdrawProxy.storage.location")) - 1;
L50 (state variable declaration can not go after event definition)function liquidatorNFTClaim(OrderParameters memory params) external {
L109 (external function can not go after public function)modifier releaseCheck(uint256 collateralId) {
L253 (modifier definition can not go after internal function)function name()
L76 (public view function can not go after public pure function)modifier validVault(address targetVault) {
L196 (modifier definition can not go after public function)function file(File calldata incoming) external requiresAuth {
L82 (external function can not go after internal function)modifier validateStack(uint256 collateralId, Stack[] memory stack) {
L265 (modifier definition can not go after internal functions)function ROUTER() external pure returns (IAstariaRouter) {
L26 (external function can not go after public function)function COLLATERAL_TOKEN() public view returns (ICollateralToken) {
L62 (public view function can not go after public pure function)function depositToVault(
L24 (external function can not go after public function)function deposit(uint256 assets, address receiver)
L19 (public function can not go after public view function)uint256(keccak256("xyz.astaria.VaultImplementation.storage.location")) - 1;
L58 (state variable declaration can not go after external function)event FileUpdated(FileType what, bytes data);
L34 (Struct definition can not go after event definition)Description:
According to official solidity documentation functions should be grouped according to their visibility and ordered:
constructor
receive function (if exists)
fallback function (if exists)
external
public
internal
private
Within a grouping, place the view and pure functions last.
Recommendation:
Put the functions in the correct order according to the documentation.
Context:
Context:
//invalid action private vautls can only be the owner or strategist
L90 (Change vautls to vaults)//revert auction params dont match
L126 (Change dont to don't)// reset liquidationWithdrawRatio to prepare for re calcualtion
L307 (Change calcualtion to calculation)* @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
L230 (Change redeemption to redemption)/// @return amount0 The amount of token0 to acheive resulting liquidity
L122 (Change acheive to achieve)/// @return amount1 The amount of token1 to acheive resulting liquidity
L123 (Change acheive to achieve)Context:
uint88 expected; // The sum of the remaining debt (amountOwed) accrued against the NFT at the timestamp when it is liquidated. yIntercept (virtual assets) of a PublicVault are not modified on liquidation, only once an auction is completed.
L54uint256 withdrawReserveReceived; // amount received from PublicVault. The WETH balance of this contract - withdrawReserveReceived = amount received from liquidations.
L56s.withdrawReserveReceived; // will never underflow because withdrawReserveReceived is always increased by the transfer amount from the PublicVault
L256* @notice This contract handles the creation, payments, buyouts, and liquidations of tokenized NFT-collateralized debt (liens). Vaults which originate loans against supported collateral are issued a LienToken representing the right to loan repayments and auctioned funds on liquidation.
L42// Blocking off payments for a lien that has exceeded the lien.end to prevent repayment unless the msg.sender() is the AuctionHouse
L804* @param params The Commitment information containing the loan parameters and the merkle proof for the strategy supporting the requested loan.
L226* Origination consists of a few phases: pre-commitment validation, lien token issuance, strategist reward, and after commitment actions
L281* Starts by depositing collateral and take optimized-out a lien against it. Next, verifies the merkle proof for a loan commitment. Vault owners are then rewarded fees for successful loan origination.
L282* @notice Retrieves the recipient of loan repayments. For PublicVaults (VAULT_TYPE 2), this is always the vault address. For PrivateVaults, retrieves the owner() of the vault.
L363* @param c The Commitment information containing the loan parameters and the merkle proof for the strategy supporting the requested loan.
L376* @notice Called at epoch boundary, computes the ratio between the funds of withdrawing liquidity providers and the balance of the underlying PublicVault so that claim() proportionally pays optimized-out to all parties.
L27* @notice Adds an auction scheduled to end in a new epoch to this WithdrawProxy, to ensure that withdrawing LPs get a proportional share of auction returns.
L33* @param finalAuctionDelta The timestamp by which the auction being added is guaranteed to end. As new auctions are added to the WithdrawProxy, this value will strictly increase as all auctions have the same maximum duration.
L35* Returns the end timestamp of the last auction tracked by this WithdrawProxy. After this timestamp has passed, claim() can be called.
L74The base router is a multicall style router inspired by Uniswap v3 with built-in features for permit, WETH9 wrap/unwrap, and ERC20 token pulling/sweeping/approving.
L10NOTE the router is capable of pulling any approved token from your wallet. This is only possible when your address is msg.sender, but regardless be careful when interacting with the router or ERC4626 Vaults.
L15/// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
L105* @return withdrawProxyIfNearBoundary The address of the WithdrawProxy to set the payee to if the liquidation is triggered near an epoch boundary.
L146* @notice Executes a FlashAction using locked collateral. A valid FlashAction performs a specified action with the collateral within a single transaction and must end with the collateral being returned to the Vault it was locked in.
L100* @param params LienActionEncumber data containing CollateralToken information and lien parameters (rate, duration, and amount, rate, and debt caps).
L181* @param params The LienActionBuyout data specifying the lien position, receiver address, and underlying CollateralToken information of the lien.
L193* Calculates the debt accrued by all liens against a CollateralToken, assuming no payments are made until the end timestamp in the stack.
L263Description:
Maximum suggested line length is 120 characters.
#0 - c4-judge
2023-01-26T14:06:31Z
Picodes marked the issue as grade-b