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
{ | |
"status": "success", | |
"data": [ | |
{ | |
"symbol": "ETHDGX", | |
"price": 0.07904854, | |
"time": 1524396866 | |
}, | |
{ | |
"symbol": "ETHUSD", |
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
[ | |
{ | |
"type": "enable_rebalance", | |
"timestamp": 0 | |
}, | |
{ | |
"type": "enable_setrates", | |
"timestamp": 0 | |
}, | |
{ |
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
********************************************* | |
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 | |
**** |
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 numpy as np | |
class LiquidityParams: | |
def __init__(self, | |
rate, | |
P_0_tokens_to_eth, | |
num_formula_precision_bits, | |
max_cap_buy_eth, |
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
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. |
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
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. |
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
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 |
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.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'; |
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.4.24; | |
import 'openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol'; | |
import 'openzeppelin-solidity/contracts/ownership/Ownable.sol'; | |
contract tokenWrapper is Ownable { | |
DetailedERC20 token; |
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.4.24; | |
contract Tmp1 { | |
uint f; | |
uint g; | |
constructor(uint first, uint second) public { | |
f = first; | |
g = second; |
OlderNewer