Skip to content

Instantly share code, notes, and snippets.

@DicksonWu654
DicksonWu654 / F013_PartialInsolventBidStaleMM.t.sol
Last active May 21, 2026 04:35
Derive F-013 fork PoC — DutchAuction partial-insolvent-bid leaves stale totalInsolventMM, causing false-positive withdrawal block (function DoS) across all cash holders
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.27;
import {Test, console2} from "forge-std/Test.sol";
import {
IAsset,
ICashAsset,
IDutchAuction,
IERC20,
IERC20Metadata,
@DicksonWu654
DicksonWu654 / F017_AssetDeltaCacheOverflow.t.sol
Created May 21, 2026 04:30
Derive F-017 fork PoC — SubAccounts AssetDeltaArrayCache fixed-100 capacity vs BaseManager maxAccountSize=128 mismatch breaks LiquidateModule/LyraAuctionUtils merge-back paths for 101+ asset accounts
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.27;
import {Test, console2} from "forge-std/Test.sol";
import {
IAllowances,
IAsset,
IManager,
ISubAccounts,
AssetDeltaLib,
@DicksonWu654
DicksonWu654 / F004_ReservedCashReset.t.sol
Last active May 21, 2026 04:31
Derive F-004 fork PoC — DutchAuction reservedCash reset on solvent-to-insolvent conversion enables theft of prior bidder's deposit
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import {Test, console2} from "forge-std/Test.sol";
import {
IERC20Metadata,
IAsset,
IManager,
ISubAccounts,
ICashAsset,
@DicksonWu654
DicksonWu654 / F008_StaleScenarioInsolventMM.t.sol
Last active May 21, 2026 04:31
Derive F-008 fork PoC — DutchAuction updateScenarioId leaves stale totalInsolventMM during insolvent auction, breaking bank-run protection and letting cash holders escape socialized loss
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.27;
import {Test, console2} from "forge-std/Test.sol";
import {
IAsset,
ICashAssetFull,
IDutchAuctionFull,
IERC20Like,
IManager,
@DicksonWu654
DicksonWu654 / Fv4029_CashAssetDivByZero.t.sol
Last active May 21, 2026 04:27
Derive F-v4-029 fork PoC — CashAsset._accrueInterest div-by-zero when totalSupply reaches 0 while totalBorrow > 0 permanently bricks all cash operations
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
import {stdError} from "forge-std/StdError.sol";
import {console2} from "forge-std/console2.sol";
import {IntegrationTestBase} from "v2-core/test/integration-tests/shared/IntegrationTestBase.t.sol";
import {IAsset} from "v2-core/src/interfaces/IAsset.sol";
import {IManager} from "v2-core/src/interfaces/IManager.sol";
import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol";
@DicksonWu654
DicksonWu654 / F001_StaleBridgeApproval.t.sol
Last active May 21, 2026 02:56
Derive F-001 fork PoC — TSAShareHandler stale bridge approval enables direct theft of in-motion user funds
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
import {Test, console2} from "forge-std/Test.sol";
import {IBridge, ITSAShareHandler, IDeriveTSA} from "./IDerive.sol";
import {MaliciousBridge} from "./MaliciousBridge.sol";
import {MaliciousConnector} from "./MaliciousConnector.sol";
interface IERC20 {
function balanceOf(address) external view returns (uint256);
query MyQuery {
users(where: {borrowedReservesCount_gte: 5}, first: 1000) {
borrowHistory {
borrowRate
borrowRateMode
amount
id
timestamp
}
liquidationCallHistory(where: {}) {
def train(model, iterator, optimizer, loss_func):
#Initializing them
epoch_loss = 0
epoch_accuracy = 0
#Gets the model in training mode
model.train()
for batch in iterator:
#Set the gradietns to 0
TEXT = Field(tokenize=tok,batch_first=True,include_lengths=True)
LABEL = Field(sequential=False, use_vocab=True)
train_iter = BucketIterator(train_thing, batch_size=bs, sort_key=lambda x: len(x.sequence),
device=device, sort=True, sort_within_batch=True)
valid_iter = BucketIterator(valid_thing, batch_size=bs, sort_key=lambda x: len(x.sequence),
device=device, sort=True, sort_within_batch=True)