Skip to content

Instantly share code, notes, and snippets.

{
"status": "success",
"data": [
{
"symbol": "ETHDGX",
"price": 0.07904854,
"time": 1524396866
},
{
"symbol": "ETHUSD",
@talbaneth
talbaneth / gist:a678b9220524fa4343475e8085ffb94a
Created April 28, 2018 07:08
rm simulation json including dgx stable token params.
[
{
"type": "enable_rebalance",
"timestamp": 0
},
{
"type": "enable_setrates",
"timestamp": 0
},
{
*********************************************
token: knc
current price: 0.00229499
****
{'rate': 0.01, 'min_token_to_eth_ratio': 0.7, 'max_token_to_eth_ratio': 1.3}
calc_E_T_based_on_pmin_pmax:
E_0_ether: 35.66749439387324
T_0_tokens: 10055.347987103682
T_0_tokens_in_eth: 23.076923076923077
****
import numpy as np
class LiquidityParams:
def __init__(self,
rate,
P_0_tokens_to_eth,
num_formula_precision_bits,
max_cap_buy_eth,
MIN_Q_FOR_RANDOMNESS = 0.3 # in eth
MIN_Q_RANDOMNESS_FACTOR = 0.7 # should be close to 1, otherwise qudratic looses it's edge.
SLOW_MODE_AVG_TRADE_TIME_IN_10S_RES = 6
FAST_MODE_AVG_TRADE_TIME_IN_10S_RES = 1
SANITY_FACTOR = 0.2
for each token:
# randomness in time with a specific average:
avg_trade_time_in_10s_res = is_fast_mode(token) ? FAST_MODE_AVG_TRADE_TIME_IN_10S_RES : SLOW_MODE_AVG_TRADE_TIME_IN_10S_RES
if rand_int(0,avg_trade_time_in_10s_res) skip trade.
@talbaneth
talbaneth / gist:f8164c6a8fe6914c00ae8ca3802be290
Created July 16, 2018 09:26
Running the Deployment Script on Testrpc
The deployment script can be ran also on testrpc/ganache:
-clone smart-contracts repository.
-run "npm install"
-run "testrpc" in another terminal/tab.
-run he deployment script: "./node_modules/.bin/truffle test scripts/deployment.js"
notes:
-The script uses test tokens, which it generates according to the json file at smart-contracts/deployment_input.json.
-At the test part under "set eth to dgd rate" we init rates for 1 token. In order to change/add tokens this part should be modified.
function sellAllAmount(ERC20 pay_gem, uint pay_amt, ERC20 buy_gem, uint min_fill_amount)
public
returns (uint fill_amt)
{
uint offerId;
while (pay_amt > 0) { //while there is amount to sell
offerId = getBestOffer(buy_gem, pay_gem); //Get the best offer for the token pair
require(offerId != 0); //Fails if there are not more offers
// There is a chance that pay_amt is smaller than 1 wei of the other token
pragma solidity ^0.4.24;
import 'openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol';
import 'openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol';
import 'openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol';
import 'openzeppelin-solidity/contracts/token/ERC20/BurnableToken.sol';
import 'openzeppelin-solidity/contracts/ownership/Claimable.sol';
import 'openzeppelin-solidity/contracts/ownership/CanReclaimToken.sol';
import 'openzeppelin-solidity/contracts/ownership/HasNoEther.sol';
pragma solidity ^0.4.24;
import 'openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol';
import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';
contract tokenWrapper is Ownable {
DetailedERC20 token;
pragma solidity 0.4.24;
contract Tmp1 {
uint f;
uint g;
constructor(uint first, uint second) public {
f = first;
g = second;