diff --git a/.github/workflows/4bytes.yml b/.github/workflows/4bytes.yml new file mode 100644 index 0000000000..aefd37d0d9 --- /dev/null +++ b/.github/workflows/4bytes.yml @@ -0,0 +1,34 @@ +name: Tests + +on: + push: + branches: + - master + pull_request: + types: + - closed + +jobs: + deployment-scripts: + if: github.event.pull_request.merged == true + name: 'Deployment Scripts' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - uses: actions/setup-node@v3 + with: + node-version: 16.x + cache: 'yarn' + - run: yarn install --immutable + - run: yarn compile + - run: yarn run:4bytes + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 4bytes-syncced.json + commit_options: '--no-verify --signoff' + file_pattern: 'scripts/4bytes-syncced.json' + diff --git a/package.json b/package.json index de0ac36df5..ab42048a8c 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "size": "hardhat size-contracts", "slither": "python3 tools/slither.py", "prepare": "husky install", - "run:backtests": "npx hardhat run scripts/ci_backtest_plugin.ts" + "run:backtests": "npx hardhat run scripts/ci_backtest_plugin.ts", + "run:4bytes": "npx hardhat run scripts/4bytes.ts" }, "repository": { "type": "git", diff --git a/scripts/4bytes-syncced.json b/scripts/4bytes-syncced.json new file mode 100644 index 0000000000..dfcff7fe35 --- /dev/null +++ b/scripts/4bytes-syncced.json @@ -0,0 +1,1126 @@ +{ + "functions": [ + "allowance(address,address)", + "approve(address,uint256)", + "balanceOf(address)", + "totalSupply()", + "transfer(address,uint256)", + "transferFrom(address,address,uint256)", + "decimals()", + "name()", + "symbol()", + "burn(address,address,uint256,uint256)", + "getScaledUserBalanceAndSupply(address)", + "mint(address,uint256,uint256)", + "mintToTreasury(uint256,uint256)", + "scaledBalanceOf(address)", + "scaledTotalSupply()", + "transferOnLiquidation(address,address,uint256)", + "transferUnderlyingTo(address,uint256)", + "handleAction(address,uint256,uint256)", + "borrow(address,uint256,uint256,uint16,address)", + "deposit(address,uint256,address,uint16)", + "finalizeTransfer(address,address,address,uint256,uint256,uint256)", + "flashLoan(address,address[],uint256[],uint256[],address,bytes,uint16)", + "getAddressesProvider()", + "getConfiguration(address)", + "getReserveData(address)", + "getReserveNormalizedIncome(address)", + "getReserveNormalizedVariableDebt(address)", + "getReservesList()", + "getUserAccountData(address)", + "getUserConfiguration(address)", + "initReserve(address,address,address,address,address)", + "liquidationCall(address,address,address,uint256,bool)", + "paused()", + "rebalanceStableBorrowRate(address,address)", + "repay(address,uint256,uint256,address)", + "setConfiguration(address,uint256)", + "setPause(bool)", + "setReserveInterestRateStrategyAddress(address,address)", + "setUserUseReserveAsCollateral(address,bool)", + "swapBorrowRateMode(address,uint256)", + "withdraw(address,uint256,address)", + "getAddress(bytes32)", + "getEmergencyAdmin()", + "getLendingPool()", + "getLendingPoolCollateralManager()", + "getLendingPoolConfigurator()", + "getLendingRateOracle()", + "getMarketId()", + "getPoolAdmin()", + "getPriceOracle()", + "setAddress(bytes32,address)", + "setAddressAsProxy(bytes32,address)", + "setEmergencyAdmin(address)", + "setLendingPoolCollateralManager(address)", + "setLendingPoolConfiguratorImpl(address)", + "setLendingPoolImpl(address)", + "setLendingRateOracle(address)", + "setMarketId(string)", + "setPoolAdmin(address)", + "setPriceOracle(address)", + "BORROW_ALLOWANCE_NOT_ENOUGH()", + "CALLER_NOT_POOL_ADMIN()", + "CT_CALLER_MUST_BE_LENDING_POOL()", + "CT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF()", + "CT_INVALID_BURN_AMOUNT()", + "CT_INVALID_MINT_AMOUNT()", + "CT_TRANSFER_AMOUNT_NOT_GT_0()", + "LPAPR_INVALID_ADDRESSES_PROVIDER_ID()", + "LPAPR_PROVIDER_NOT_REGISTERED()", + "LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED()", + "LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD()", + "LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE()", + "LPCM_NO_ERRORS()", + "LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER()", + "LPC_CALLER_NOT_EMERGENCY_ADMIN()", + "LPC_INVALID_ADDRESSES_PROVIDER_ID()", + "LPC_INVALID_ATOKEN_POOL_ADDRESS()", + "LPC_INVALID_CONFIGURATION()", + "LPC_INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS()", + "LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS()", + "LPC_INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS()", + "LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS()", + "LPC_RESERVE_LIQUIDITY_NOT_0()", + "LP_CALLER_MUST_BE_AN_ATOKEN()", + "LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR()", + "LP_FAILED_COLLATERAL_SWAP()", + "LP_FAILED_REPAY_WITH_COLLATERAL()", + "LP_INCONSISTENT_FLASHLOAN_PARAMS()", + "LP_INCONSISTENT_PARAMS_LENGTH()", + "LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE()", + "LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET()", + "LP_INVALID_EQUAL_ASSETS_TO_SWAP()", + "LP_INVALID_FLASHLOAN_MODE()", + "LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN()", + "LP_IS_PAUSED()", + "LP_LIQUIDATION_CALL_FAILED()", + "LP_NOT_CONTRACT()", + "LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW()", + "LP_NOT_ENOUGH_STABLE_BORROW_BALANCE()", + "LP_NO_MORE_RESERVES_ALLOWED()", + "LP_REENTRANCY_NOT_ALLOWED()", + "LP_REQUESTED_AMOUNT_TOO_SMALL()", + "MATH_ADDITION_OVERFLOW()", + "MATH_DIVISION_BY_ZERO()", + "MATH_MULTIPLICATION_OVERFLOW()", + "RC_INVALID_DECIMALS()", + "RC_INVALID_LIQ_BONUS()", + "RC_INVALID_LIQ_THRESHOLD()", + "RC_INVALID_LTV()", + "RC_INVALID_RESERVE_FACTOR()", + "RL_LIQUIDITY_INDEX_OVERFLOW()", + "RL_LIQUIDITY_RATE_OVERFLOW()", + "RL_RESERVE_ALREADY_INITIALIZED()", + "RL_STABLE_BORROW_RATE_OVERFLOW()", + "RL_VARIABLE_BORROW_INDEX_OVERFLOW()", + "RL_VARIABLE_BORROW_RATE_OVERFLOW()", + "SDT_BURN_EXCEEDS_BALANCE()", + "SDT_STABLE_DEBT_OVERFLOW()", + "UL_INVALID_INDEX()", + "VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE()", + "VL_BORROWING_NOT_ENABLED()", + "VL_COLLATERAL_BALANCE_IS_0()", + "VL_COLLATERAL_CANNOT_COVER_NEW_BORROW()", + "VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY()", + "VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH()", + "VL_DEPOSIT_ALREADY_IN_USE()", + "VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD()", + "VL_INCONSISTENT_FLASHLOAN_PARAMS()", + "VL_INVALID_AMOUNT()", + "VL_INVALID_INTEREST_RATE_MODE_SELECTED()", + "VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE()", + "VL_NO_ACTIVE_RESERVE()", + "VL_NO_DEBT_OF_SELECTED_TYPE()", + "VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF()", + "VL_NO_STABLE_RATE_LOAN_IN_RESERVE()", + "VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE()", + "VL_RESERVE_FROZEN()", + "VL_STABLE_BORROWING_NOT_ENABLED()", + "VL_TRANSFER_NOT_ALLOWED()", + "VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0()", + "ATOKEN_REVISION()", + "DOMAIN_SEPARATOR()", + "EIP712_REVISION()", + "PERMIT_TYPEHASH()", + "POOL()", + "RESERVE_TREASURY_ADDRESS()", + "UINT_MAX_VALUE()", + "UNDERLYING_ASSET_ADDRESS()", + "_nonces(address)", + "decreaseAllowance(address,uint256)", + "increaseAllowance(address,uint256)", + "initialize(uint8,string,string)", + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)", + "description()", + "getRoundData(uint80)", + "latestRoundData()", + "version()", + "DEFAULT_ADMIN_ROLE()", + "getRoleAdmin(bytes32)", + "grantRole(bytes32,address)", + "hasRole(bytes32,address)", + "renounceRole(bytes32,address)", + "revokeRole(bytes32,address)", + "supportsInterface(bytes4)", + "owner()", + "renounceOwnership()", + "transferOwnership(address)", + "delegate(address)", + "delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32)", + "delegates(address)", + "getPastTotalSupply(uint256)", + "getPastVotes(address,uint256)", + "getVotes(address)", + "isValidSignature(bytes32,bytes)", + "proxiableUUID()", + "implementation()", + "upgradeTo(address)", + "upgradeToAndCall(address,bytes)", + "nonces(address)", + "BALLOT_TYPEHASH()", + "COUNTING_MODE()", + "EXTENDED_BALLOT_TYPEHASH()", + "castVote(uint256,uint8)", + "castVoteBySig(uint256,uint8,uint8,bytes32,bytes32)", + "castVoteWithReason(uint256,uint8,string)", + "castVoteWithReasonAndParams(uint256,uint8,string,bytes)", + "castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32)", + "execute(address[],uint256[],bytes[],bytes32)", + "getVotes(address,uint256)", + "getVotesWithParams(address,uint256,bytes)", + "hasVoted(uint256,address)", + "hashProposal(address[],uint256[],bytes[],bytes32)", + "onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)", + "onERC1155Received(address,address,uint256,uint256,bytes)", + "onERC721Received(address,address,uint256,bytes)", + "proposalDeadline(uint256)", + "proposalSnapshot(uint256)", + "proposalThreshold()", + "propose(address[],uint256[],bytes[],string)", + "quorum(uint256)", + "relay(address,uint256,bytes)", + "state(uint256)", + "votingDelay()", + "votingPeriod()", + "CANCELLER_ROLE()", + "EXECUTOR_ROLE()", + "PROPOSER_ROLE()", + "TIMELOCK_ADMIN_ROLE()", + "cancel(bytes32)", + "execute(address,uint256,bytes,bytes32,bytes32)", + "executeBatch(address[],uint256[],bytes[],bytes32,bytes32)", + "getMinDelay()", + "getTimestamp(bytes32)", + "hashOperation(address,uint256,bytes,bytes32,bytes32)", + "hashOperationBatch(address[],uint256[],bytes[],bytes32,bytes32)", + "isOperation(bytes32)", + "isOperationDone(bytes32)", + "isOperationPending(bytes32)", + "isOperationReady(bytes32)", + "schedule(address,uint256,bytes,bytes32,bytes32,uint256)", + "scheduleBatch(address[],uint256[],bytes[],bytes32,bytes32,uint256)", + "updateDelay(uint256)", + "proposalVotes(uint256)", + "setProposalThreshold(uint256)", + "setVotingDelay(uint256)", + "setVotingPeriod(uint256)", + "proposalEta(uint256)", + "queue(address[],uint256[],bytes[],bytes32)", + "timelock()", + "updateTimelock(address)", + "token()", + "quorumDenominator()", + "quorumNumerator(uint256)", + "quorumNumerator()", + "updateQuorumNumerator(uint256)", + "admin()", + "changeAdmin(address)", + "multicall(bytes[])", + "ENS()", + "deployments(string)", + "latestDeployment()", + "register(string,address,bool)", + "unregister(string)", + "canRunRecollateralizationAuctions(address)", + "claimRewards(address)", + "getActCalldata(address)", + "getRevenueAuctionERC20s(address)", + "runRevenueAuctions(address,address[],address[])", + "getTradesForBackingManager(address)", + "getTradesForRevenueTraders(address)", + "auctionsSettleable(address)", + "backingOverview(address)", + "backupConfig(address,bytes32)", + "basketBreakdown(address)", + "basketTokens(address)", + "issue(address,uint256)", + "maxIssuable(address,address)", + "pendingUnstakings(address,address)", + "price(address)", + "primeBasket(address)", + "redeem(address,uint256,uint48)", + "stToken(address)", + "traderBalances(address,address)", + "runAuctionsForAllTraders(address)", + "totalAssetValue(address)", + "wholeBasketsHeldBy(address,address)", + "deployRToken((string,string,string,((uint16,uint16),uint192,uint192,uint48,uint48,uint192,uint48,uint48,uint48,uint192,uint192,(uint256,uint192),(uint256,uint192))),(address[],address[],uint192[],(bytes32,uint256,address[])[],(address,(uint16,uint16))[]))", + "deployer()", + "setupGovernance(address,bool,bool,(uint256,uint256,uint256,uint256,uint256),address,address,address)", + "bal(address)", + "claimRewards()", + "erc20()", + "erc20Decimals()", + "isCollateral()", + "lotPrice()", + "maxTradeVolume()", + "price()", + "refresh()", + "refPerTok()", + "status()", + "targetName()", + "targetPerRef()", + "chainlinkFeed()", + "oracleError()", + "oracleTimeout()", + "priceTimeout()", + "delayUntilDefault()", + "whenDefault()", + "erc20s()", + "getRegistry()", + "init(address,address[])", + "isRegistered(address)", + "main()", + "register(address)", + "swapRegistered(address)", + "toAsset(address)", + "toColl(address)", + "unregister(address)", + "claimRewardsSingle(address)", + "grantRTokenAllowance(address)", + "init(address,uint48,uint192,uint192,uint192)", + "manageTokens(address[])", + "manageTokensSortedOrder(address[])", + "maxTradeSlippage()", + "minTradeVolume()", + "mulDivCeil(uint192,uint192,uint192)", + "settleTrade(address)", + "trades(address)", + "tradesOpen()", + "backingBuffer()", + "setBackingBuffer(uint192)", + "setMaxTradeSlippage(uint192)", + "setMinTradeVolume(uint192)", + "setTradingDelay(uint48)", + "tradingDelay()", + "basketsHeldBy(address)", + "disableBasket()", + "fullyCollateralized()", + "init(address)", + "nonce()", + "quantity(address)", + "quantityUnsafe(address,address)", + "quote(uint192,uint8)", + "refreshBasket()", + "setBackupConfig(bytes32,uint256,address[])", + "setPrimeBasket(address[],uint192[])", + "timestamp()", + "disabled()", + "init(address,address,address,uint48)", + "openTrade((address,address,uint256,uint256))", + "reportViolation()", + "auctionLength()", + "gnosis()", + "setAuctionLength(uint48)", + "setDisabled(bool)", + "setGnosis(address)", + "setTradeImplementation(address)", + "tradeImplementation()", + "deploy(string,string,string,address,((uint16,uint16),uint192,uint192,uint48,uint48,uint192,uint48,uint48,uint48,uint192,uint192,(uint256,uint192),(uint256,uint192)))", + "rsr()", + "rsrAsset()", + "distribute(address,uint256)", + "init(address,(uint16,uint16))", + "setDistribution(address,(uint16,uint16))", + "totals()", + "FURNACE()", + "ST_RSR()", + "distribution(address)", + "init(address,uint192)", + "melt()", + "ratio()", + "setRatio(uint192)", + "lastPayout()", + "lastPayoutBal()", + "auctionData(uint256)", + "feeNumerator()", + "initiateAuction(address,address,uint256,uint256,uint96,uint96,uint256,uint256,bool,address,bytes)", + "settleAuction(uint256)", + "freezeForever()", + "freezeLong()", + "freezeShort()", + "frozen()", + "longFreeze()", + "pause()", + "pausedOrFrozen()", + "shortFreeze()", + "unfreeze()", + "unpause()", + "assetRegistry()", + "backingManager()", + "basketHandler()", + "broker()", + "distributor()", + "furnace()", + "rToken()", + "rTokenTrader()", + "rsrTrader()", + "stRSR()", + "init((address,address,address,address,address,address,address,address,address,address),address,uint48,uint48)", + "poke()", + "longFreezes(address)", + "setLongFreeze(uint48)", + "setShortFreeze(uint48)", + "basketsNeeded()", + "init(address,string,string,string,(uint256,uint192),(uint256,uint192))", + "issuanceAvailable()", + "issue(uint256)", + "issueTo(address,uint256)", + "melt(uint256)", + "mint(address,uint256)", + "redeem(uint256,uint48)", + "redeemTo(address,uint256,uint48)", + "redemptionAvailable()", + "setBasketsNeeded(uint192)", + "issuanceThrottleParams()", + "monetizeDonations(address)", + "redemptionThrottleParams()", + "setIssuanceThrottleParams((uint256,uint192))", + "setRedemptionThrottleParams((uint256,uint192))", + "init(address,address,uint192,uint192)", + "manageToken(address)", + "tokenToBuy()", + "endIdForWithdraw(address)", + "exchangeRate()", + "init(address,string,string,uint48,uint192)", + "payoutRewards()", + "seizeRSR(uint256)", + "stake(uint256)", + "unstake(uint256)", + "withdraw(address,uint256)", + "rewardRatio()", + "setRewardRatio(uint192)", + "setUnstakingDelay(uint48)", + "unstakingDelay()", + "currentEra()", + "getPastEra(uint256)", + "buy()", + "canSettle()", + "endTime()", + "sell()", + "settle()", + "allUnique(address[])", + "sortedAndAllUnique(address[])", + "abs_(int256)", + "div(uint192,uint192)", + "divFix_(uint256,uint192)", + "divRnd(uint192,uint192,uint8)", + "divrnd_(uint256,uint256,uint8)", + "divu(uint192,uint256)", + "divuRnd(uint192,uint256,uint8)", + "divuu_(uint256,uint256)", + "eq(uint192,uint192)", + "fixMax_(uint192,uint192)", + "fixMin_(uint192,uint192)", + "fullMul_(uint256,uint256)", + "gt(uint192,uint192)", + "gte(uint192,uint192)", + "lt(uint192,uint192)", + "lte(uint192,uint192)", + "minus(uint192,uint192)", + "minusu(uint192,uint256)", + "mul(uint192,uint192)", + "mulDiv(uint192,uint192,uint192)", + "mulDiv256Rnd_(uint256,uint256,uint256,uint8)", + "mulDiv256_(uint256,uint256,uint256)", + "mulDivRnd(uint192,uint192,uint192,uint8)", + "mulRnd(uint192,uint192,uint8)", + "mul_toUint(uint192,uint192)", + "mul_toUintRnd(uint192,uint192,uint8)", + "mulu(uint192,uint256)", + "muluDivu(uint192,uint256,uint256)", + "muluDivuRnd(uint192,uint256,uint256,uint8)", + "mulu_toUint(uint192,uint256)", + "mulu_toUintRnd(uint192,uint256,uint8)", + "near(uint192,uint192,uint192)", + "neq(uint192,uint192)", + "plus(uint192,uint192)", + "plusu(uint192,uint256)", + "powu(uint192,uint48)", + "safeMul_(uint192,uint192,uint8)", + "shiftl(uint192,int8)", + "shiftlRnd(uint192,int8,uint8)", + "shiftl_toFix_(uint256,int8)", + "shiftl_toFix_Rnd(uint256,int8,uint8)", + "shiftl_toUint(uint192,int8)", + "shiftl_toUintRnd(uint192,int8,uint8)", + "toFix_(uint256)", + "toUint(uint192)", + "toUintRnd(uint192,uint8)", + "toLower(string)", + "LONG_FREEZER_ROLE()", + "OWNER_ROLE()", + "PAUSER_ROLE()", + "SHORT_FREEZER_ROLE()", + "unfreezeAt()", + "GAS_TO_RESERVE()", + "MAX_BACKING_BUFFER()", + "MAX_TRADE_SLIPPAGE()", + "MAX_TRADE_VOLUME()", + "MAX_TRADING_DELAY()", + "MAX_TARGET_AMT()", + "MAX_AUCTION_LENGTH()", + "MIN_BID_SHARE_OF_TOTAL_SUPPLY()", + "MAX_DESTINATIONS_ALLOWED()", + "MAX_RATIO()", + "PERIOD()", + "MAX_EXCHANGE_RATE()", + "MAX_THROTTLE_PCT_AMT()", + "MAX_THROTTLE_RATE_AMT()", + "MIN_EXCHANGE_RATE()", + "MIN_THROTTLE_RATE_AMT()", + "mandate()", + "MAX_REWARD_RATIO()", + "MAX_UNSTAKING_DELAY()", + "MIN_UNSTAKING_DELAY()", + "withdrawals(address,uint256)", + "prepareRecollateralizationTrade(IBackingManager,(uint192,uint192))", + "getBackupConfig(bytes32)", + "getPrimeBasket()", + "implementations()", + "delegationNonces(address)", + "draftQueueLen(uint256,address)", + "draftQueues(uint256,address,uint256)", + "draftRate()", + "firstRemainingDraft(uint256,address)", + "getDraftRSR()", + "getStakeRSR()", + "getTotalDrafts()", + "payoutLastPaid()", + "stakeRate()", + "checkpoints(address,uint48)", + "numCheckpoints(address)", + "exposedReferencePrice()", + "lastSave()", + "pegBottom()", + "pegTop()", + "revenueShowing()", + "savedHighPrice()", + "savedLowPrice()", + "tryPrice()", + "targetUnitChainlinkFeed()", + "targetUnitOracleTimeout()", + "REWARD_TOKEN()", + "claimRewardsToSelf(bool)", + "rate()", + "getIncentivesController()", + "handleRepayment(address,uint256)", + "PRECISION()", + "claimRewards(address[],uint256,address)", + "claimRewardsOnBehalf(address[],uint256,address,address)", + "configureAssets(address[],uint256[])", + "getAssetData(address)", + "getClaimer(address)", + "getRewardsBalance(address[],address)", + "getUserAssetData(address,address)", + "getUserUnclaimedRewards(address)", + "setClaimer(address,address)", + "ASSET()", + "ATOKEN()", + "INCENTIVES_CONTROLLER()", + "LENDING_POOL()", + "claimRewards(address,bool)", + "claimRewardsOnBehalf(address,address,bool)", + "collectAndUpdateRewards()", + "deposit(address,uint256,uint16,bool)", + "dynamicBalanceOf(address)", + "dynamicToStaticAmount(uint256)", + "getAccRewardsPerToken()", + "getClaimableRewards(address)", + "getDomainSeparator()", + "getLastRewardBlock()", + "getLifetimeRewards()", + "getLifetimeRewardsClaimed()", + "getTotalClaimableRewards()", + "getUnclaimedRewards(address)", + "metaDeposit(address,address,uint256,uint16,bool,uint256,(uint8,bytes32,bytes32))", + "metaWithdraw(address,address,uint256,uint256,bool,uint256,(uint8,bytes32,bytes32))", + "staticToDynamicAmount(uint256)", + "withdraw(address,uint256,bool)", + "withdrawDynamicAmount(address,uint256,bool)", + "INVALID_CLAIMER()", + "INVALID_DEPOSITOR()", + "INVALID_EXPIRATION()", + "INVALID_OWNER()", + "INVALID_RECIPIENT()", + "INVALID_SIGNATURE()", + "ONLY_ONE_AMOUNT_FORMAT_ALLOWED()", + "METADEPOSIT_TYPEHASH()", + "METAWITHDRAWAL_TYPEHASH()", + "STATIC_ATOKEN_LM_REVISION()", + "updateRatio(uint256)", + "comptroller()", + "referenceERC20Decimals()", + "exchangeRateCurrent()", + "exchangeRateStored()", + "mint(uint256)", + "redeem(uint256)", + "underlying()", + "claimComp(address)", + "getCompAddress()", + "comet()", + "reservesThresholdIffy()", + "rewardERC20()", + "BASE_SCALE()", + "EXP_SCALE()", + "RESCALE_FACTOR()", + "TRACKING_INDEX_SCALE()", + "accrue()", + "accrueAccount(address)", + "allow(address,bool)", + "baseTrackingAccrued(address)", + "baseTrackingIndex(address)", + "claimTo(address,address)", + "convertDynamicToStatic(uint256)", + "convertStaticToDynamic(uint104)", + "deposit(uint256)", + "depositFrom(address,address,uint256)", + "depositTo(address,uint256)", + "getRewardOwed(address)", + "hasPermission(address,address)", + "isAllowed(address,address)", + "rewardsAddr()", + "rewardsClaimed(address)", + "underlyingBalanceOf(address)", + "underlyingComet()", + "withdraw(uint256)", + "withdrawFrom(address,address,uint256)", + "withdrawTo(address,uint256)", + "allowBySig(address,address,bool,uint256,uint256,uint8,bytes32,bytes32)", + "baseAccrualScale()", + "baseIndexScale()", + "collateralBalanceOf(address,address)", + "factorScale()", + "maxAssets()", + "priceScale()", + "totalsBasic()", + "absorb(address,address[])", + "approveThis(address,address,uint256)", + "baseBorrowMin()", + "baseMinForRewards()", + "baseScale()", + "baseToken()", + "baseTokenPriceFeed()", + "baseTrackingBorrowSpeed()", + "baseTrackingSupplySpeed()", + "borrowBalanceOf(address)", + "borrowPerSecondInterestRateBase()", + "borrowPerSecondInterestRateSlopeHigh()", + "borrowPerSecondInterestRateSlopeLow()", + "buyCollateral(address,uint256,uint256,address)", + "extensionDelegate()", + "getAssetInfo(uint8)", + "getAssetInfoByAddress(address)", + "getBorrowRate(uint256)", + "getPrice(address)", + "getReserves()", + "getSupplyRate(uint256)", + "getUtilization()", + "governor()", + "initializeStorage()", + "isAbsorbPaused()", + "isBorrowCollateralized(address)", + "isBuyPaused()", + "isLiquidatable(address)", + "isSupplyPaused()", + "isTransferPaused()", + "isWithdrawPaused()", + "numAssets()", + "pause(bool,bool,bool,bool,bool)", + "pauseGuardian()", + "quoteCollateral(address,uint256)", + "storeFrontPriceFactor()", + "supply(address,uint256)", + "supplyFrom(address,address,address,uint256)", + "supplyKink()", + "supplyPerSecondInterestRateBase()", + "supplyPerSecondInterestRateSlopeHigh()", + "supplyPerSecondInterestRateSlopeLow()", + "supplyTo(address,address,uint256)", + "targetReserves()", + "totalBorrow()", + "trackingIndexScale()", + "transferAsset(address,address,uint256)", + "transferAssetFrom(address,address,address,uint256)", + "userBasic(address)", + "withdrawFrom(address,address,address,uint256)", + "withdrawReserves(address,uint256)", + "withdrawTo(address,address,uint256)", + "setBaseTrackingSupplySpeed(address,uint64)", + "deploy(address)", + "deployAndUpgradeTo(address,address)", + "claim(address,address,bool)", + "claimTo(address,address,address,bool)", + "getRewardOwed(address,address)", + "rewardConfig(address)", + "curvePool()", + "lpToken()", + "tokenPrice(uint8)", + "metapoolToken()", + "pairedToken()", + "pairedTokenPegBottom()", + "pairedTokenPegTop()", + "tryPairedPrice()", + "balances(uint256)", + "base_coins(uint256)", + "coins(uint256)", + "exchange(int128,int128,uint256,uint256)", + "get_virtual_price()", + "underlying_coins(uint256)", + "deposit(uint256,bool)", + "lockIncentive()", + "claim_rewards()", + "lp_token()", + "reward_tokens(uint256)", + "rewarded_token()", + "create_lock(uint256,uint256)", + "increase_amount(uint256)", + "increase_unlock_time(uint256)", + "smart_wallet_checker()", + "withdraw()", + "claimRewards(uint256,address)", + "isShutdown()", + "poolInfo(uint256)", + "rewardArbitrator()", + "rewardClaimed(uint256,address,uint256)", + "setGaugeRedirect(uint256)", + "withdrawTo(uint256,uint256,address)", + "claim()", + "mint(address)", + "addPool(address,address,uint256)", + "forceAddPool(address,address,uint256)", + "gaugeMap(address)", + "poolLength()", + "setPoolManager(address)", + "shutdownPool(uint256)", + "gauge_controller()", + "get_address(uint256)", + "get_gauges(address)", + "get_lp_token(address)", + "get_registry()", + "CreateCrvRewards(uint256,address)", + "CreateTokenRewards(address,address,address)", + "activeRewardCount(address)", + "addActiveReward(address,uint256)", + "removeActiveReward(address,uint256)", + "setAccess(address,bool)", + "addExtraReward(address)", + "earned(address)", + "exit(address)", + "getReward(address)", + "notifyRewardAmount(uint256)", + "queueNewRewards(uint256)", + "rewardToken()", + "stake(address,uint256)", + "stakeFor(address,uint256)", + "stakingToken()", + "balanceOfPool(address)", + "claimCrv(address)", + "claimFees(address,address)", + "createLock(uint256,uint256)", + "deposit(address,address)", + "execute(address,uint256,bytes)", + "increaseAmount(uint256)", + "increaseTime(uint256)", + "operator()", + "release()", + "setStashAccess(address,bool)", + "vote(uint256,address,bool)", + "voteGaugeWeight(address,uint256)", + "withdraw(address)", + "withdraw(address,address,uint256)", + "withdrawAll(address,address)", + "initialize(uint256,address,address,address,address)", + "processStash()", + "stashRewards()", + "CreateStash(uint256,address,address,uint256)", + "CreateDepositToken(address)", + "burn(address,uint256)", + "fund(address[],uint256[])", + "getVote(uint256)", + "vote(uint256,bool,bool)", + "vote_for_gauge_weights(address,uint256)", + "check(address)", + "addRewards()", + "collateralVault()", + "convexBooster()", + "convexPool()", + "convexPoolId()", + "convexToken()", + "crv()", + "curveToken()", + "cvx()", + "deposit(uint256,address)", + "earnedView(address)", + "getReward(address,address)", + "initialize(uint256)", + "isInit()", + "registeredRewards(address)", + "rewardLength()", + "rewards(uint256)", + "setApprovals()", + "shutdown()", + "stake(uint256,address)", + "totalBalanceOf(address)", + "user_checkpoint(address)", + "withdrawAndUnwrap(uint256)", + "deposit(uint256,uint256,bool)", + "deposit(uint256,bool,address)", + "ConvertCrvToCvx(uint256)", + "maxSupply()", + "reductionPerCliff()", + "totalCliffs()", + "extraRewards(uint256)", + "extraRewardsLength()", + "getReward()", + "getReward(address,bool)", + "withdrawAndUnwrap(uint256,bool)", + "submit()", + "submitAndDeposit(address)", + "convertToAssets(uint256)", + "pricePerShare()", + "rewardsCycleEnd()", + "syncRewards()", + "getBeaconStat()", + "handleOracleReport(uint256,uint256)", + "stEthPerToken()", + "targetPerRefChainlinkFeed()", + "targetPerRefChainlinkTimeout()", + "getExchangeRate()", + "getTotalETHBalance()", + "setUint(bytes32,uint256)", + "refPerTokChainlinkFeed()", + "refPerTokChainlinkTimeout()", + "ONE_HUNDRED_PERCENT()", + "cancel(address[],uint256[],bytes[],bytes32)", + "adminApprove(address,address,uint256)", + "aaveBalances(address)", + "aaveToken()", + "setAaveToken(address)", + "setExchangeRate(uint192)", + "setRewards(address,uint256)", + "setNormalizedIncome(address,uint256)", + "WETH()", + "getAssetPrice(address)", + "checkHardDefault()", + "checkSoftDefault()", + "setHardDefaultCheck(bool)", + "setSoftDefaultCheck(bool)", + "censored(address)", + "revertDecimals()", + "setCensored(address,bool)", + "borrowKink()", + "withdraw(uint256,bool)", + "setRevertDecimals(bool)", + "setTransferFee(uint192)", + "transferFee()", + "getAnswer(uint256)", + "getTimestamp(uint256)", + "latestAnswer()", + "latestAnsweredRound()", + "latestRound()", + "latestTimestamp()", + "setInvalidAnsweredRound()", + "setInvalidTimestamp()", + "updateAnswer(int256)", + "updateRoundData(uint80,int256,uint256,uint256)", + "externalDelegate()", + "setReserves(int256)", + "compBalances(address)", + "compToken()", + "setCompToken(address)", + "setBalances(uint256[])", + "setVirtualPrice(uint256)", + "setMockExchangeRate(bool,uint256)", + "hasAccess(address,bytes)", + "acceptOwnership()", + "aggregator()", + "confirmAggregator(address)", + "phaseAggregators(uint16)", + "phaseId()", + "proposeAggregator(address)", + "proposedAggregator()", + "proposedGetRoundData(uint80)", + "proposedLatestRoundData()", + "accessController()", + "setController(address)", + "__getAnswer(uint256)", + "__getTimestamp(uint256)", + "__latestAnswer()", + "__latestAnsweredRound()", + "__latestRound()", + "__latestTimestamp()", + "counter()", + "approvalsOn()", + "disableApprovals()", + "enableApprovals()", + "FEE_DENOMINATOR()", + "auctionAccessData(uint256)", + "auctionAccessManager(uint256)", + "auctionCounter()", + "cancelSellOrders(uint256,bytes32[])", + "claimFromParticipantOrder(uint256,bytes32[])", + "containsOrder(uint256,bytes32)", + "feeReceiverUserId()", + "getSecondsRemainingInBatch(uint256)", + "getUserId(address)", + "numUsers()", + "placeSellOrders(uint256,uint96[],uint96[],bytes32[],bytes)", + "placeSellOrdersOnBehalf(uint256,uint96[],uint96[],bytes32[],bytes,address)", + "precalculateSellAmountSum(uint256,uint256)", + "registerUser(address)", + "setFeeParameters(uint256,address)", + "settleAuctionAtomically(uint256,uint96[],uint96[],bytes32[],bytes)", + "infiniteLoop()", + "revertRefPerTok()", + "setRevertRefPerTok(bool)", + "auctions(uint256)", + "bids(uint256)", + "numAuctions()", + "placeBid(uint256,(address,uint256,uint256))", + "reenterOnInit()", + "reenterOnSettle()", + "setReenterOnInit(bool)", + "setReenterOnSettle(bool)", + "setSimplyRevert(bool)", + "simplyRevert()", + "rateMock()", + "refPerTokRevert()", + "setRate(uint192)", + "setRefPerTokRevert(bool)", + "setTargetPerRef(uint192)", + "priceable()", + "destroyAndTransfer(address)", + "setPricePerShare(uint256)", + "mockRefPerTok()", + "setUnpriced(bool)", + "unpriced()", + "deposit()", + "newValue()", + "setNewValue(uint256)", + "isAllowed(address,uint256,bytes)", + "contains(bytes32)", + "decodeOrder(bytes32)", + "encodeOrder(uint64,uint96,uint96)", + "first()", + "initializeEmptyList()", + "insert(bytes32)", + "insertAt(bytes32,bytes32)", + "isEmpty()", + "next(bytes32)", + "nextMap(bytes32)", + "prevMap(bytes32)", + "remove(bytes32)", + "removeKeepHistory(bytes32)", + "smallerThan(bytes32,bytes32)", + "DEFAULT_MIN_BID()", + "MAX_ORDERS()", + "auctionId()", + "init(address,address,address,uint48,(address,address,uint256,uint256))", + "initBal()", + "origin()", + "transferToOriginAfterTradeComplete(address)", + "worstCasePrice()" + ], + "events": [ + "Approval(address,address,uint256)", + "Transfer(address,address,uint256)", + "BalanceTransfer(address,address,uint256,uint256)", + "Burn(address,address,uint256,uint256)", + "Mint(address,uint256,uint256)", + "Borrow(address,address,address,uint256,uint256,uint256,uint16)", + "Deposit(address,address,address,uint256,uint16)", + "FlashLoan(address,address,address,uint256,uint256,uint16)", + "LiquidationCall(address,address,address,uint256,uint256,address,bool)", + "Paused()", + "RebalanceStableBorrowRate(address,address)", + "Repay(address,address,address,uint256)", + "ReserveDataUpdated(address,uint256,uint256,uint256,uint256,uint256)", + "ReserveUsedAsCollateralDisabled(address,address)", + "ReserveUsedAsCollateralEnabled(address,address)", + "Swap(address,address,uint256)", + "Unpaused()", + "Withdraw(address,address,address,uint256)", + "AddressSet(bytes32,address,bool)", + "ConfigurationAdminUpdated(address)", + "EmergencyAdminUpdated(address)", + "LendingPoolCollateralManagerUpdated(address)", + "LendingPoolConfiguratorUpdated(address)", + "LendingPoolUpdated(address)", + "LendingRateOracleUpdated(address)", + "MarketIdSet(string)", + "PriceOracleUpdated(address)", + "ProxyCreated(bytes32,address)", + "Initialized(uint8)", + "RoleAdminChanged(bytes32,bytes32,bytes32)", + "RoleGranted(bytes32,address,address)", + "RoleRevoked(bytes32,address,address)", + "OwnershipTransferred(address,address)", + "DelegateChanged(address,address,address)", + "DelegateVotesChanged(address,uint256,uint256)", + "AdminChanged(address,address)", + "BeaconUpgraded(address)", + "Upgraded(address)", + "ProposalCanceled(uint256)", + "ProposalCreated(uint256,address,address[],uint256[],string[],bytes[],uint256,uint256,string)", + "ProposalExecuted(uint256)", + "VoteCast(address,uint256,uint8,uint256,string)", + "VoteCastWithParams(address,uint256,uint8,uint256,string,bytes)", + "CallExecuted(bytes32,uint256,address,uint256,bytes)", + "CallScheduled(bytes32,uint256,address,uint256,bytes,bytes32,uint256)", + "Cancelled(bytes32)", + "MinDelayChange(uint256,uint256)", + "ProposalThresholdSet(uint256,uint256)", + "VotingDelaySet(uint256,uint256)", + "VotingPeriodSet(uint256,uint256)", + "ProposalQueued(uint256,uint256)", + "TimelockChange(address,address)", + "QuorumNumeratorUpdated(uint256,uint256)", + "DeploymentRegistered(string,address)", + "DeploymentUnregistered(string,address)", + "LatestChanged(string,address)", + "GovernanceCreated(address,address,address)", + "RewardsClaimed(address,uint256)", + "CollateralStatusChanged(uint8,uint8)", + "AssetRegistered(address,address)", + "AssetUnregistered(address,address)", + "BackingBufferSet(uint192,uint192)", + "MaxTradeSlippageSet(uint192,uint192)", + "MinTradeVolumeSet(uint192,uint192)", + "TradeSettled(address,address,address,uint256,uint256)", + "TradeStarted(address,address,address,uint256,uint256)", + "TradingDelaySet(uint48,uint48)", + "BackupConfigSet(bytes32,uint256,address[])", + "BasketSet(uint256,address[],uint192[],bool)", + "PrimeBasketSet(address[],uint192[],bytes32[])", + "AuctionLengthSet(uint48,uint48)", + "DisabledSet(bool,bool)", + "GnosisSet(address,address)", + "TradeImplementationSet(address,address)", + "RTokenCreated(address,address,address,address,string)", + "DistributionSet(address,uint16,uint16)", + "RevenueDistributed(address,address,uint256)", + "RatioSet(uint192,uint192)", + "LongFreezeDurationSet(uint48,uint48)", + "PausedSet(bool,bool)", + "ShortFreezeDurationSet(uint48,uint48)", + "UnfreezeAtSet(uint48,uint48)", + "AssetRegistrySet(address,address)", + "BackingManagerSet(address,address)", + "BasketHandlerSet(address,address)", + "BrokerSet(address,address)", + "DistributorSet(address,address)", + "FurnaceSet(address,address)", + "RSRTraderSet(address,address)", + "RTokenSet(address,address)", + "RTokenTraderSet(address,address)", + "StRSRSet(address,address)", + "MainInitialized()", + "BasketsNeededChanged(uint192,uint192)", + "Issuance(address,address,uint256,uint192)", + "IssuanceThrottleSet((uint256,uint192),(uint256,uint192))", + "Melted(uint256)", + "Redemption(address,address,uint256,uint192)", + "RedemptionThrottleSet((uint256,uint192),(uint256,uint192))", + "AllBalancesReset(uint256)", + "AllUnstakingReset(uint256)", + "ExchangeRateSet(uint192,uint192)", + "RewardRatioSet(uint192,uint192)", + "RewardsPaid(uint256)", + "Staked(uint256,address,uint256,uint256)", + "UnstakingCompleted(uint256,uint256,uint256,address,uint256)", + "UnstakingDelaySet(uint48,uint48)", + "UnstakingStarted(uint256,uint256,address,uint256,uint256,uint256)", + "ClaimerSet(address,address)", + "RewardsAccrued(address,uint256)", + "RewardsClaimed(address,address,uint256)", + "RewardsClaimed(address,address,address,uint256)", + "RewardClaimed(address,address,address,uint256)", + "AbsorbCollateral(address,address,address,uint256,uint256)", + "AbsorbDebt(address,address,uint256,uint256)", + "BuyCollateral(address,address,uint256,uint256)", + "PauseAction(bool,bool,bool,bool,bool)", + "Supply(address,address,uint256)", + "SupplyCollateral(address,address,address,uint256)", + "TransferCollateral(address,address,address,uint256)", + "Withdraw(address,address,uint256)", + "WithdrawCollateral(address,address,address,uint256)", + "WithdrawReserves(address,uint256)", + "Deposited(address,address,uint256,bool)", + "Withdrawn(address,uint256,bool)", + "AnswerUpdated(int256,uint256,uint256)", + "NewRound(uint256,address,uint256)", + "OwnershipTransferRequested(address,address)", + "AuctionCleared(uint256,uint96,uint96,bytes32)", + "CancellationSellOrder(uint256,uint64,uint96,uint96)", + "ClaimedFromOrder(uint256,uint64,uint96,uint96)", + "NewAuction(uint256,address,address,uint256,uint256,uint64,uint96,uint96,uint256,uint256,address,bytes)", + "NewSellOrder(uint256,uint64,uint96,uint96)", + "NewUser(uint64,address)", + "UserRegistration(address,uint64)", + "Deposit(address,uint256)", + "Withdrawal(address,uint256)", + "Empty()", + "OutOfBounds()", + "UIntOutOfBounds()", + "StalePrice()", + "InvalidInt256()", + "InvalidUInt104()", + "InvalidUInt64()", + "NegativeNumber()", + "BadAmount()", + "ExceedsBalance(uint256)", + "Unauthorized()", + "ZeroAddress()", + "BadNonce()", + "BadSignatory()", + "InvalidValueS()", + "InvalidValueV()", + "SignatureExpired()", + "Absurd()", + "AlreadyInitialized()", + "BadAsset()", + "BadDecimals()", + "BadDiscount()", + "BadMinimum()", + "BadPrice()", + "BorrowCFTooLarge()", + "BorrowTooSmall()", + "InsufficientReserves()", + "LiquidateCFTooLarge()", + "NoSelfTransfer()", + "NotCollateralized()", + "NotForSale()", + "NotLiquidatable()", + "SupplyCapExceeded()", + "TimestampTooLarge()", + "TooManyAssets()", + "TooMuchSlippage()", + "TransferInFailed()", + "TransferOutFailed()", + "NoToken(uint8)", + "WrongIndex(uint8)" + ] +} \ No newline at end of file diff --git a/scripts/4bytes.ts b/scripts/4bytes.ts new file mode 100644 index 0000000000..d8bead0fd0 --- /dev/null +++ b/scripts/4bytes.ts @@ -0,0 +1,98 @@ +import hre from 'hardhat' +import fs from 'fs' +import fetch from "isomorphic-fetch" +import previousSync from "./4bytes-syncced.json" +/** + * This script will sync any event and function we have with www.4byte.directory + * The script saves all processed signatures with 4bytes-syncced.json as it succcesses + * this way we avoid syncing the same signature twice. + * */ + +const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); + +async function main() { + const artifacts = await hre.artifacts.getAllFullyQualifiedNames(); + const artifactsWithAbi = (await Promise.all(artifacts.map(name => hre.artifacts.readArtifact(name)))).filter(artifact => artifact.abi.length !== 0); + const prevFunctions = new Set(previousSync.functions) + const prevEvents = new Set(previousSync.events) + const newErrorSignatures = new Set() + const newFunctionSignatures = new Set() + const newEventSignatures = new Set() + for (const { abi } of artifactsWithAbi) { + const abiInterface = new hre.ethers.utils.Interface(abi) + // Events and Errors seem to be the same thing for 4bytes + Object.keys(abiInterface.events).filter(e => !prevEvents.has(e)).forEach(e => newEventSignatures.add(e)) + Object.keys(abiInterface.errors).filter(e => !prevEvents.has(e)).forEach(e => newEventSignatures.add(e)) + + Object.keys(abiInterface.functions).filter(e => !prevFunctions.has(e)).forEach(e => newFunctionSignatures.add(e)) + } + const total = newErrorSignatures.size + newFunctionSignatures.size + newEventSignatures.size + if (total === 0) { + console.log("All up to date!") + return; + } + + console.log("Will sync " + total + " signatures with 4bytes...") + + const save = () => { + fs.writeFileSync("./scripts/4bytes-syncced.json", JSON.stringify(previousSync, null, 2)); + } + console.log("----- Synccing functions ----- ") + for (const sig of newFunctionSignatures) { + for (let i = 0; i < 3; i++) { + const resp = await fetch("https://www.4byte.directory/api/v1/signatures/", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + "text_signature": sig, + }) + }) + if (resp.status === 400 || resp.status === 201) { + console.log("function", sig, resp.status, await resp.text()) + previousSync.functions.push(sig); + save() + break + } + if (i === 2) { + console.log("Failed to sync function", sig, "after 3 attempts") + } else { + await sleep(1000) + } + } + + } + console.log("----- Synccing events ----- ") + for (const sig of newEventSignatures) { + for (let i = 0; i < 3; i++) { + const resp = await fetch("https://www.4byte.directory/api/v1/event-signatures/", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + "text_signature": sig, + }) + }) + if (resp.status === 400 || resp.status === 201) { + console.log("event", sig, resp.status, await resp.text()) + previousSync.events.push(sig); + save() + break + } + + if (i === 2) { + console.log("Failed to sync event", sig, "after 3 attempts") + } else { + await sleep(1000) + } + } + } + console.log("Done!") +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +})