Skip to content

Instantly share code, notes, and snippets.

View alexroan's full-sized avatar

Alex Roan alexroan

View GitHub Profile
@alexroan
alexroan / bytesSwap.sol
Created October 23, 2020 15:23
bytesSwap.sol
pragma solidity ^0.7.0;
library bytesSwap {
function bytes32ToString(bytes32 _bytes32) public pure returns (string memory) {
uint8 i = 0;
while(i < 32 && _bytes32[i] != 0) {
i++;
}
bytes memory bytesArray = new bytes(i);
[
{
"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 │
/*
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
*/
'use strict';
const shim = require('fabric-shim');
const util = require('util');
@alexroan
alexroan / Chainlink-PriceConsumer.sol
Last active March 23, 2022 22:18
Chainlink-PriceConsumer.sol
@alexroan
alexroan / PriceConsumerV3.sol
Last active March 11, 2022 13:39
PriceConsumerV3
// This example code is designed to quickly deploy an example contract using Remix.
pragma solidity ^0.6.7;
import "https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
contract PriceConsumerV3 {
AggregatorV3Interface internal priceFeed;
@alexroan
alexroan / APIConsumer.sol
Last active March 11, 2022 03:38
APIConsumer.sol
// This example code is designed to quickly deploy an example contract using Remix.
pragma solidity ^0.6.0;
import "https://raw.githubusercontent.com/smartcontractkit/chainlink/master/evm-contracts/src/v0.6/ChainlinkClient.sol";
contract APIConsumer is ChainlinkClient {
uint256 public volume;
@alexroan
alexroan / BasicERC721Full.sol
Created April 22, 2020 09:33
BasicERC721Full.sol
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/token/ERC721/ERC721Full.sol";
import "@openzeppelin/contracts/drafts/Counters.sol";
contract GameItem is ERC721Full {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() ERC721Full("GameItem", "ITM") public {
@alexroan
alexroan / RandomNumberGenerator.sol
Created May 27, 2020 11:29
lottery/RandomNumberGenerator.sol
pragma solidity ^0.6.2;
import "./VRFConsumerBase.sol";
import "./Lottery.sol";
contract RandomNumberGenerator is VRFConsumerBase {
address requester;
bytes32 keyHash;
uint256 fee;