View Ship.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity 0.8.7; | |
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | |
contract Ship is Initializable { | |
string public name; | |
uint256 public fuel; | |
function initialize(string memory _name, uint256 _fuel) external initializer { | |
name = _name; |
View erc20.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IERC20 { | |
function totalSupply() external view returns (uint256); | |
function balanceOf(address who) external view returns (uint256); | |
function allowance(address owner, address spender) | |
external view returns (uint256); | |
function transfer(address to, uint256 value) external returns (bool); |
View deploy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dotenv from "dotenv"; | |
import { getDefaultProvider, Wallet } from "ethers"; | |
import { deployContract } from "ethereum-waffle"; | |
import SKETokenArtifact from "../build/SKEToken.json"; | |
import { SKEToken } from "../types/ethers-contracts/SKEToken"; | |
dotenv.config(); | |
async function deploy() { | |
const mnemonic = process.env["MNEMONIC"] || ""; |
View waffle.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { use, expect } from "chai"; | |
import { solidity, MockProvider, deployContract } from "ethereum-waffle"; | |
import SKETokenArtifact from "../build/SKEToken.json"; | |
import { SKEToken } from "../types/ethers-contracts/SKEToken"; | |
use(solidity); | |
describe("Counter smart contract", () => { | |
const provider = new MockProvider(); | |
const [wallet] = provider.getWallets(); |
View truffle.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SKEToken = artifacts.require("SKEToken"); | |
contract("2nd SKEToken test", async ([deployer, user1]) => { | |
it("should put 10000 SKEToken in the first account", async () => { | |
const token = await SKEToken.new(10000, { from: deployer }); | |
let balance = await token.balanceOf(deployer); | |
assert.equal(balance.valueOf(), 10000); | |
}); | |
}); |
View truffle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ropsten: { | |
provider: () => | |
new HDWalletProvider( | |
process.env["MNEMONIC"], | |
`https://ropsten.infura.io/v3/939fb730f6cd4449aeb9f101cca7277e` | |
), | |
network_id: 3, // Ropsten's id | |
gas: 5500000, // Ropsten has a lower block limit than mainnet | |
confirmations: 2, // # of confs to wait between deployments. (default: 0) | |
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) |
View waffle.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { use, expect } from "chai"; | |
import { solidity, createMockProvider, getWallets, deployContract } from 'ethereum-waffle' | |
import * as ERC20TokenJSON from '../build/ERC20Token.json' | |
import { ERC20Token } from '../typed-contracts/ERC20Token' | |
use(solidity); | |
describe('Counter smart contract', () => { | |
const provider = createMockProvider(); | |
const [wallet] = getWallets(provider); |
View uniswap-main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
num_traders = 100 | |
num_arbitrageurs = 10 | |
trader_dai = 10000 | |
trader_eth = 1000 | |
uniswap_dai = 1000000 | |
uniswap_eth = 10000 | |
model = UniswapModel(num_traders, num_arbitrageurs, trader_dai, trader_eth, uniswap_dai, uniswap_eth) | |
for i in range(100): |
View uniswap-model.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UniswapModel(Model): | |
def __init__(self, num_traders, num_arbitrageurs, trader_dai, trader_eth, uniswap_dai, uniswap_eth): | |
super().__init__() | |
self.num_traders = num_traders | |
self.schedule = RandomActivation(self) | |
self.uniswap = Uniswap(1, self, uniswap_dai, uniswap_eth) | |
for i in range(num_traders): | |
trader = Trader(i, self, trader_eth, trader_dai, i < num_arbitrageurs) | |
self.schedule.add(trader) |
View uniswap-agent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def transfer(from_agent, to_agent, currency, amount): | |
from_amount = getattr(from_agent, currency, 0) | |
to_amount = getattr(to_agent, currency, 0) | |
setattr(from_agent, currency, from_amount - amount) | |
setattr(to_agent, currency, to_amount + amount) | |
class Uniswap(Agent): | |
def __init__(self, unique_id, model, dai, eth): | |
super().__init__(unique_id, model) | |
self.dai = dai |
NewerOlder