Skip to content

Instantly share code, notes, and snippets.

View alexroan's full-sized avatar

Alex Roan alexroan

View GitHub Profile
[
{
"inputs": [
{
"internalType": "contract DataStore",
"name": "dataStore",
"type": "address"
},
{
"internalType": "contract Reader",
@alexroan
alexroan / gist:af5e7612eecde8e70c6b950b35d79ed6
Created September 1, 2023 15:19
GMX executeOrder revert
[FAIL. Reason: EvmError: Revert] test_perform_upkeep_real_performData() (gas: 8660281895700906882)
Traces:
[6936613] MarketAutomationTest_End2End::setUp()
├─ [0] VM::envString(ARBITRUM_GOERLI_URL) [staticcall]
│ └─ ← <env var value>
├─ [0] VM::createSelectFork(https://arb-goerli.g.alchemy.com/v2/-WCwmeQ9qLa5T5Lrm8KlXtaiQdWAsfX_)
│ └─ ← 0
├─ [0] VM::envAddress(DATA_STORE) [staticcall]
│ └─ ← <env var value>
├─ [0] VM::envAddress(READER) [staticcall]
@alexroan
alexroan / UniswapOC.md
Last active August 9, 2022 13:51
Uniswap V3 Oracle Gas Tests - Observation Cardinality

Uniswap V3 Oracle Gas Tests - Observation Cardinality

Results

┌─────────┬──────────┬─────────────────────────────────┬────────────┬────────────┬────────────────────────┬─────────┐
│ (index) │   kind   │              name               │ minGasUsed │ maxGasUsed │ observationCardinality │ avgGas  │
├─────────┼──────────┼─────────────────────────────────┼────────────┼────────────┼────────────────────────┼─────────┤
│    0    │ 'uni-v3' │     'AAVE/ETH (Uniswap V3)'     │   65550    │   65550    │           50           │  65550  │
│    1    │ 'uni-v3' │     'APE/ETH (Uniswap V3)'      │   65142    │   65158    │           50           │ 65148.4 │
@alexroan
alexroan / MultiwordResponseExamples.sol
Last active June 23, 2021 10:38
Example implementations of Multi-word response
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@chainlink/contracts/src/v0.8/dev/ChainlinkClient.sol";
/**
* @notice DO NOT USE THIS CODE IN PRODUCTION. This is an example contract.
*/
contract Consumer is ChainlinkClient {
using Chainlink for Chainlink.Request;
@alexroan
alexroan / Example.sol
Last active June 17, 2021 14:45
Contract Structure Example
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; // solidity version
// imports
import "./AnInterface.sol";
import "./ALibrary.sol";
contract Example is AnInterface {
// library using statements
using ALibrary for uint256;
from web3 import Web3
import requests, datetime
# Replace INFURA_URL with mainnet url
# Run this file with:
# `python3 compare_oracles.py`
w3 = Web3(Web3.HTTPProvider('INFURA_URL'))
prod_oracle='0x4007B71e01424b2314c020fB0344b03A7C499E1A'
proposed_oracle='0x841616a5CBA946CF415Efe8a326A621A794D0f97'
@alexroan
alexroan / UniswapAnchoredView.sol
Last active May 24, 2021 10:33
UniswapAnchoredView 2021-05-24
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;
// Based on code from https://github.com/Uniswap/uniswap-v2-periphery
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
library FixedPoint {
// range: [0, 2**112 - 1]
@alexroan
alexroan / BadStalenessChecker.sol
Last active May 13, 2021 15:47
Solidity Tech Talk - Bad Code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
import "https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract BadStalenessChecker is Ownable {
// Details about a price feed.
@alexroan
alexroan / KeeperCompatibleStaleness.sol
Created May 12, 2021 12:35
Keeper Compatible Staleness Flagger
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
interface KeeperCompatibleInterface {
function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData);
function performUpkeep(bytes calldata performData) external;
}
@alexroan
alexroan / Staleness.sol
Created May 12, 2021 12:12
Simple Staleness Flagger
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract Staleness {
uint public immutable interval;
mapping(AggregatorV3Interface => bool) public staleFlag;