Skip to content

Instantly share code, notes, and snippets.

@L-Kov
L-Kov / main.py
Created June 27, 2023 02:51
Web3.py transfer CTF positions
from web3 import Web3
import os
from dotenv import load_dotenv
load_dotenv()
pk = os.getenv('PRIVATE_KEY')
rpc = os.getenv('RPC_URL')
wallet_address = os.getenv('WALLET_ADDRESS')
new_wallet_address = os.getenv('NEW_WALLET_ADDRESS')
@L-Kov
L-Kov / set_allowances.py
Created January 31, 2023 06:52
CLOB Allowance Setting Python
from web3 import Web3
from web3.constants import MAX_INT
from web3.middleware import geth_poa_middleware
rpc_url = "" # Polygon rpc url
priv_key = "" # Polygon account private key (needs some MATIC)
pub_key = "" # Polygon account public key corresponding to private key
chain_id = 137
@L-Kov
L-Kov / ctf.ts
Created January 6, 2023 20:01
Conditional Tokens Framework Calculations
import { keccak256 as solidityKeccak256 } from "@ethersproject/solidity";
import BN from "bn.js";
export const getConditionId = (oracle: string, questionId: string, outcomeSlotCount: number): string =>
solidityKeccak256(["address", "bytes32", "uint256"], [oracle, questionId, outcomeSlotCount]);
const altBN128P = new BN("21888242871839275222246405745257275088696311157297823662689037894645226208583");
const altBN128PRed = BN.red(altBN128P);
const altBN128B = new BN(3).toRed(altBN128PRed);
const zeroPRed = new BN(0).toRed(altBN128PRed);
This file has been truncated, but you can view the full file.
{"time": [1545422267.6052659, 1545422269.4957619, 1545422270.469002, 1545422271.4398975, 1545422272.4109225, 1545422273.3798273, 1545422274.3479774, 1545422275.3110235, 1545422276.2727327, 1545422277.2384531, 1545422278.2009916, 1545422279.161564, 1545422280.1253865, 1545422281.1490555, 1545422282.1241975, 1545422283.0934203, 1545422284.0659976, 1545422285.0293655, 1545422286.0726593, 1545422287.134177, 1545422288.0984619, 1545422289.113013, 1545422290.1109424, 1545422291.193251, 1545422292.1596334, 1545422293.1282427, 1545422294.0896368, 1545422295.049812, 1545422296.0777402, 1545422297.0531185, 1545422298.0317602, 1545422298.9892073, 1545422299.9564652, 1545422300.9360473, 1545422301.8958302, 1545422302.8714283, 1545422303.838503, 1545422304.8033242, 1545422305.7691946, 1545422306.7333825, 1545422307.6960747, 1545422308.6804762, 1545422309.6363482, 1545422310.6080627, 1545422311.59466, 1545422312.5751548, 1545422313.5459666, 1545422314.5055177, 1545422315.4572759, 1545422316.4308088, 1545422317.3947704, 154
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import matplotlib.pyplot as plt
import numpy as np
import math
## Define functions and set domain
x = np.arange(1, 2.0, .01)
y = x**2 -1
z = np.log(x)
i = x*z
j = x -1
@L-Kov
L-Kov / radar_ddex_ZRXWETH_bidask.py
Last active August 14, 2018 18:55
Simple visualization for top bids/asks of ZRX-WETH market on Radar Relay and DDEx
import time
import requests as r
import matplotlib.pyplot as plt
# number of data points (+- 1 data point/sec)
period = 100
# marketId(s)
idex_pair, radar_pair = 'ETH_ZRX', 'ZRX-WETH'
idex_api = 'https://api.idex.market/returnTicker'