Skip to content

Instantly share code, notes, and snippets.

View JTraversa's full-sized avatar

Julian Traversa JTraversa

View GitHub Profile
/// Taker signs a previously created/validated offer, submits it to chain for signature verification.
var d = new Date();
var t = d.getTime().toString();
var currentAddress = document.getElementById("useraddress").innerHTML;
var minorSalt = currentAddress + t;
var Salt = web3.utils.keccak256(minorSalt).toString();
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
import "./safeMath.sol";
contract DefiHedge {
struct RPCSig{
uint8 v;
bytes32 r;
if (window.ethereum) {
var web3 = new Web3(window.ethereum);
window.ethereum.enable();}
const childChain = new ChildChain({ watcherUrl: "https://watcher-info.ropsten.v1.omg.network" });
account = getAccounts(function(result) {
document.getElementById("useraddress").innerHTML = result[0];
});
async function transfer () {
// We want to pay the fee in ETH, so we have to fetch the ETH fee amount from the Watcher
const allFees = await childChain.getFees()
struct RPCSig{
uint8 v;
bytes32 r;
bytes32 s;
}
struct EIP712Domain {
string name;
string version;
uint256 chainId;
function createErcOffer() {
const typedData = {
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' }
],
Offer: [
import { ethers } from "ethers";
const provider = new ethers.providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const zeroExAddress = '0x61935cbdd02287b511119ddb11aeb42f1593b7ef'
const zeroExContract = new ethers.Contract(zeroExAddress, exchangeABI, provider);
function takeOrder() {
const order = {
@JTraversa
JTraversa / gist:87f7006d6a887c3a10f130eba4322873
Last active February 18, 2021 15:25
Manual EIP 712 Hashing
function EIP712Hash(typedData) {
const types = typedData.types;
function abiEncode (types, values) {
var output = []
var data = []
var headLength = 0
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
contract Swivel {
struct RPCSig{
uint8 v;
bytes32 r;
bytes32 s;
}
@JTraversa
JTraversa / Loopring KlineChart
Created March 17, 2021 21:50
Loopring KlineChart
import { connect } from "react-redux";
import { dispose, init } from "klinecharts";
import { withUserPreferences } from "components/UserPreferenceContext";
import React, { PureComponent } from "react";
import config from "lightcone/config";
import styled, { withTheme } from "styled-components";
import "./KlineChart.less";
import { getData } from "./utils";
from time import sleep
from sys import exit
import time
import datetime
import math
import swivel-py
def truncate(number, digits) -> float:
stepper = 10.0 ** digits
return math.trunc(stepper * number) / stepper