Skip to content

Instantly share code, notes, and snippets.

View riordant's full-sized avatar
💯

tadhg riordant

💯
View GitHub Profile
#!/usr/bin/env bash
# takes in a deployment file and verifies on etherscan/arbitrum/etc.
# useful if you deploy without verification, or verification fails
# needs to have ETHERSCAN_API_KEY set in the environment
# execute like so: sh ./verify_after_deploy_foundry.sh ./broadcast/<SCRIPT_NAME>.sol/<CHAIN_ID>/run-latest.json
set -e
set -o xtrace
INPUT_FILE=$1
ARG_FILE="$(dirname $INPUT_FILE)/arguments.json"
CHAIN_ID=$(jq -r '.chain' < $INPUT_FILE)
@riordant
riordant / hola-ipsec.conf
Created March 6, 2024 11:59
Hola Premium - VPN Client - Linux (ipsec)
# prerequisites:
# - log in with premium account
# - go to https://hola.org/plus_setup?platform=router
# - grab: USERNAME, PASSWORD and LOCATION_ID (eg. "us", "uk" etc.)
# in /etc/ipsec.secrets:
$USERNAME : EAP "$PASSWORD"
# in ipsec.conf:
conn Hola
@riordant
riordant / hexens_gearbox_followup.md
Created February 26, 2024 15:34
Hexens Audit: GearboxV3Strategy: Follow Up

SPOOL3-4 - IMPLEMENT BEFOREDEPOSITCHECK

SPOOL3-2 - REDUNDANT SAFEAPPROVE USAGE

  • Commit: N/A
  • Description:
    • This optimization is acknowledged; However, on review of this issue, we have decided to not implement a change. The optimization is a non-security related change to code implemented by all strategies, including ones already deployed (the change is for Strategy.sol). As a result, we would have to maintain two versions of Strategy.sol in the codebase (existing one for already deployed strategies, and a newer one with these changes). We would rather not maintain two versions of Strategy.sol in the codebase at this point, unless there is a security related concern.
@riordant
riordant / hexens_convexstfrxeth_followup.md
Created February 2, 2024 09:57
Hexens Audit: ConvexStFrxEthStrategy: Follow Up

SPOOL2-2 - DISCREPANCIES IN _REDEEMFROMPROTOCOL FUNCTION IMPLEMENTATION

  • Commit: https://github.com/SpoolFi/spool-v2-core/commit/86065428a4d5e6de3c7b10909db532033c578c80

  • Description:

    • Acknowledged, implemented in the commit hash above.

    • the _redeemFromProtocol() function now uses just one slippage value, for the output WETH amount. We pass an empty array to redeem inner for the slippages, as we assume that we will catch any issues on the output WETH amount. We must allow passing slippages to _redeemInner, as in the emergencyWithdraw function, we will just get back stETH and frxETH and send to the emergency recipient, and so we still want to use slippages for stETH and frxETH in this case. I've updated the redeemFast/emergencyWithdraw description, to better relate this.

    • In this commit, I have also included some event emissions that we missed:

  • in assetGroupWrap, we return a ratio array, which represents the amounts of stETH/frxETH that's used as input t

@riordant
riordant / get-addresses-ledger.ts
Created February 24, 2023 15:33
Get the PATH master viewing key from a USB-connected Ledger device opened in the Ethereum app, use this to acquire all the child addresses in this path within the defined RANGE.
import TransportNodeHid from "@ledgerhq/hw-transport-node-hid";
import Eth from "@ledgerhq/hw-app-eth";
import BIP32Factory from 'bip32';
import * as ecc from 'tiny-secp256k1';
import publicKeyToAddress from 'ethereum-public-key-to-address';
const bip32 = BIP32Factory(ecc);
const PATH = "44'/60'/0'";
const RANGE = 10;
@riordant
riordant / set_balance_arbitrum.sh
Created February 22, 2023 17:18
Set Balance of the 3 major stables (DAI, USDT, USDC) on Arbitrum forked node, via Anvil/HH setStorageAt.
import { ethers } from "ethers";
async function setBalance(account: string, token: string, slot: number){
const paddedSlot = ethers.utils.hexZeroPad(ethers.utils.hexlify(slot), 32);
const paddedKey = ethers.utils.hexZeroPad(account, 32);
const itemSlot = ethers.utils.keccak256(paddedKey + paddedSlot.slice(2));
const storageSlot = ethers.utils.hexStripZeros(itemSlot);
await ethers.provider.send("anvil_setStorageAt", [
token,
storageSlot,
@riordant
riordant / get_solc_versions.sh
Created October 3, 2022 09:03
Download all Solidity Linux versions, make executable, and organize into folders based on version name.
#!/bin/bash
# will skip already created folders, just need to prepend new version names.
versions=(0.8.17 0.8.16 0.8.15 0.8.14 0.8.13 0.8.12 0.8.11 0.8.10 0.8.9 0.8.8 0.8.7 0.8.6 0.8.5 0.8.4 0.8.3 0.8.2 0.8.1 0.8.0 0.7.6 0.7.5 0.7.4 0.7.3 0.7.2 0.7.1 0.7.0 0.6.12 0.6.11 0.6.10 0.6.9 0.6.8 0.6.7 0.6.6 0.6.5 0.6.4 0.6.3 0.6.2 0.6.1 0.6.0 0.5.17 0.5.16 0.5.15 0.5.14 0.5.13 0.5.12 0.5.11 0.5.10 0.5.9 0.5.8 0.5.7 0.5.6 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 0.4.26 0.4.25 0.4.24 0.4.23 0.4.22 0.4.21 0.4.20 0.4.19 0.4.18 0.4.17 0.4.16 0.4.15 0.4.14 0.4.13 0.4.12 0.4.11 0.4.10)
for i in "${versions[@]}"
do
mkdir $i && cd $i && wget https://github.com/ethereum/solidity/releases/download/v$i/solc-static-linux && mv solc-static-linux solc && chmod +x solc && cd ..
done
@riordant
riordant / hardhat-artifact-to-inteface.sh
Created March 28, 2022 09:45
Converts a hardhat artifact JSON file to an interface from CLI. Useful for compiled contracts that you don't have an interface file for.
# requirements:
# jq
# abi2solidity
cat Contract.json | jq '.abi' > Contract.abi.json
abi2solidity -i Contract.abi.json -o IContract.sol
@riordant
riordant / get_inner_struct_mapping.ts
Last active March 22, 2022 07:03
Retrieve the storage slot value of a (mapping => Struct) -> (mapping => uint) in Solidity.
/*
architecture is like so:
Struct struct {
...
mapping(address => uint) map;
...
}
contract X {
@riordant
riordant / test-fork.ts
Created December 22, 2021 09:02
Separate Hardhat task to run tests on mainnet fork
import {task, types} from "hardhat/config";
task("test-fork", "Runs mocha tests on a fork of mainnet").addOptionalParam(
"url",
"The URL of the Mainnet archive node",
"",
types.string
).setAction(async (taskArgs, hre) => {
hre.config.networks.hardhat.forking = {
url: taskArgs.url,