Skip to content

Instantly share code, notes, and snippets.

@cag
cag / ERC1155ToERC20Adapter.sol
Last active August 14, 2020 17:20
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.6+commit.6c089d02.js&optimize=false&gist=
pragma solidity ^0.6.0;
import { Address } from "github.com/OpenZeppelin/openzeppelin-contracts/contracts/utils/Address.sol";
import { ERC20 } from "github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import { IERC1155 } from "github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol";
import { ERC1155Receiver } from "github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC1155/ERC1155Receiver.sol";
contract Wrapped1155Metadata {
// workaround which also arranges first storage slots of Wrapped1155
Wrapped1155Factory public factory;
@cag
cag / CTHelpers.sol
Created July 14, 2020 19:33
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.6+commit.6c089d02.js&optimize=false&gist=
pragma solidity ^0.6.0;
import { IERC20 } from "github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
library CTHelpers {
/// @dev Constructs a condition ID from an oracle, a question ID, and the outcome slot count for the question.
/// @param oracle The account assigned to report the result for the prepared condition.
/// @param questionId An identifier for the question to be answered by the oracle.
/// @param outcomeSlotCount The number of outcome slots which should be used for this condition. Must not exceed 256.
function getConditionId(address oracle, bytes32 questionId, uint outcomeSlotCount) internal pure returns (bytes32) {

Keybase proof

I hereby claim:

  • I am cag on github.
  • I am alanlu (https://keybase.io/alanlu) on keybase.
  • I have a public key ASBX3-uF-zUydOwAOV8ZBKdcWEIbKrA-KUXqinngWs-ZjQo

To claim this, I am signing this object:

@cag
cag / lmsr-bid-ask-chart.html
Created December 13, 2019 21:53
LMSR Bid/Ask Chart
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>LMSR Bid/Ask Chart</title>
<main style="max-width: 960px; margin: auto;">
<h1>LMSR Bid/Ask Chart</h1>
<form>
<ul>
@cag
cag / OracleMetadataTests.sol
Last active December 13, 2020 09:35
Gas tests for oracle metadata
pragma solidity ^0.4.24;
contract SingleWordConsumer {
event LogWord(bytes32 w);
function receiveResult(bytes) external {
bytes32 w;
assembly {
w := calldataload(0x44) // 4 byte func selector +
// word of 1st arg offset +
pragma solidity ^0.4.21;
import "./ProxyPostByzantium.sol";
import "./Ownable.sol";
contract UpdateableProxyData is ProxyData, OwnableData {}
contract UpdateableProxy is Proxy, Ownable {
function UpdateableProxy(address proxied, address owner)
public
pragma solidity ^0.4.21;
contract OwnableData {
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
address internal owner;
pragma solidity ^0.4.21;
import "./ProxyPostByzantium.sol";
import "./KombuchaMINoAcc.sol";
contract KombuchaFactory {
Kombucha private masterCopy;
function KombuchaFactory() public {
masterCopy = new Kombucha();
pragma solidity ^0.4.21;
import "./KombuchaWithInit.sol";
import "./ProxyPostByzantium.sol";
contract KombuchaFactory {
Kombucha private masterCopy;
function KombuchaFactory(Kombucha _masterCopy) public {
masterCopy = _masterCopy;