Skip to content

Commit

Permalink
add coinmarketcap back to the list of defaults. set up auto-payments …
Browse files Browse the repository at this point in the history
…to the dev fund from the light node traders. to fund wallet development. fixed displaying slippage when swapping for inverse shares in contracts.
  • Loading branch information
zack-bitcoin committed Oct 26, 2020
1 parent 260bd78 commit 07dcb1e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/js/create_tab_builder.js
Expand Up @@ -44,14 +44,14 @@ function create_tab_builder(div, selector){
var option_qtrade = document.createElement("option");
option_qtrade.innerHTML = "qtrade.io";
option_qtrade.value = "qtrade.io";
//var option_cmc = document.createElement("option");
//option_cmc.innerHTML = "coinmarketcap.com";
//option_cmc.value = "coinmarketcap.com";
var option_cmc = document.createElement("option");
option_cmc.innerHTML = "coinmarketcap.com";
option_cmc.value = "coinmarketcap.com";
var option_cp = document.createElement("option");
option_cp.innerHTML = "coinpaprika.com";
option_cp.value = "coinpaprika.com";
website_text.appendChild(option_qtrade);
//website_text.appendChild(option_cmc);
website_text.appendChild(option_cmc);
website_text.appendChild(option_cp);
website_label = document.createElement("span");
website_label.innerHTML = "website to get the price info";
Expand Down
50 changes: 42 additions & 8 deletions src/js/multi_tx.js
Expand Up @@ -28,22 +28,56 @@ var multi_tx = (function(){
console.log(JSON.stringify(L));
return(L);
};
function vol_estimate(Txs){
var vol = 0;
for(var i = 0; i < Txs.length; i++){
var tx = Txs[i];
if(tx[0] === "spend"){
vol += tx[5];
} else if(tx[0] === "create_acc_tx"){
vol += tx[5];
//} else if(tx[0] === "oracle_new"){
} else if(tx[0] === "oracle_bet"){
vol += tx[6];
//} else if(tx[0] === "unmatched"){
//} else if(tx[0] === "oracle_winnings"){
//} else if(tx[0] === "oracle_close"){
} else if(tx[0] === "sub_spend_tx"){
vol += tx[5];
//} else if(tx[0] === "contract_timeout_tx"){
//} else if(tx[0] === "contract_simplify_tx"){
//} else if(tx[0] === "contract_winnings_tx"){
} else if(tx[0] === "contract_use_tx"){
vol += Math.abs(tx[5]);
} else if(tx[0] === "market_new_tx"){
vol += (tx[8] + tx[9]);
} else if(tx[0] === "market_liquidity_tx"){
vol += Math.abs(tx[5]);
} else if(tx[0] === "market_swap_tx"){
vol += Math.abs(tx[5]);
}
};
return(vol);
};
function pay_dev_tx(Txs, callback) {
var vol = vol_estimate(Txs);
var dev = "BL0SzhkFGFW1kTTdnO8sGnwPEzUvx2U2nyECwWmUJPRhLxbPPK+ep8eYMxlTxVO/wnQS5WmsGIKcrPP7/Fw1WVc=";
var amount = Math.floor(vol / 200);
spend_tx.make_tx(dev, keys.pub(), amount, callback);
};
function make(Txs, callback){
var fee = 152050;
//merkle.request_proof("accounts", keys.pub(), function(Acc){
rpc.post(["account", keys.pub()], function(Acc){
console.log(Acc);
var Nonce = Acc[2] + 1;
if(false){//Txs.length == 1){
var tx = Txs[0];
tx[1] = keys.pub();
tx[2] = Nonce;
tx[3] = fee;
return(callback(Txs[0]));
} else {
pay_dev_tx(Txs, function(tx){
Txs = Txs.concat([tx]);//comment out this line to not pay the dev fee.
Txs = zero_accounts_nonces(Txs);
console.log(JSON.stringify(Txs));
//return(0);
return(callback(["multi_tx", keys.pub(), Nonce, fee*(Txs.length), [-6].concat(Txs)]));
};
});
});

};
Expand Down
4 changes: 2 additions & 2 deletions src/js/spend_tab_builder.js
Expand Up @@ -77,8 +77,8 @@ function spend_tab_builder(div, selector){
Nonce,
fee, to, amount,
cid, type];
console.log(JSON.stringify(tx));
return(0);
//console.log(JSON.stringify(tx));
//return(0);
var stx = keys.sign(tx);
post_txs([stx], function(msg){
display.innerHTML = msg;
Expand Down
9 changes: 6 additions & 3 deletions src/js/swap_tab_builder.js
Expand Up @@ -1124,6 +1124,11 @@ function swap_tab_builder(swap_tab, selector, hide_non_standard){
//var price_a = Limit * loss / gain;
var price_a = Limit * gain / loss;
var price_b = Limit / P;
if(gain_currency[1] === 2){
price_a = gain/loss;
price_b = 1/P;
gain_ticker_direction = " iv";
};
//var price_b = Limit * P;
console.log(JSON.stringify([price_a, price_b, Limit, P]));
var slippage = (Math.abs(price_a - price_b))/price_b;
Expand All @@ -1142,9 +1147,6 @@ function swap_tab_builder(swap_tab, selector, hide_non_standard){
+ trading_fees;
//console.log(total_fees);
var gain_ticker_direction = " v";
if(gain_currency[1] === 2){
gain_ticker_direction = " iv";
};
//console.log(gain_currency);
var show_price =
(price_a).toFixed(8).toString()
Expand Down Expand Up @@ -1187,6 +1189,7 @@ function swap_tab_builder(swap_tab, selector, hide_non_standard){
};
display.innerHTML = to_display;
console.log(JSON.stringify(tx));
//return(0);
var stx = keys.sign(tx);
publish_tx_button.onclick = function(){
post_txs([stx], function(msg){
Expand Down

0 comments on commit 07dcb1e

Please sign in to comment.