Browse Source

Test

etomic
jl777 7 years ago
parent
commit
f7a58dde31
  1. 4
      iguana/exchanges/LP_commands.c
  2. 4
      iguana/exchanges/LP_include.h
  3. 8
      iguana/exchanges/LP_nativeDEX.c
  4. 13
      iguana/exchanges/LP_ordermatch.c

4
iguana/exchanges/LP_commands.c

@ -115,8 +115,8 @@ pricearray(base, rel, starttime=0, endtime=0, timescale=60) -> [timestamp, avebi
getrawtransaction(coin, txid)\n\
inventory(coin, reset=0, [passphrase=])\n\
lastnonce()\n\
buy(base, rel, price, relvolume, timeout=10, duration=3600, nonce, destpubkey="")\n\
sell(base, rel, price, basevolume, timeout=10, duration=3600, nonce, destpubkey="")\n\
buy(base, rel, price, relvolume, timeout=10, duration=3600, nonce)\n\
sell(base, rel, price, basevolume, timeout=10, duration=3600, nonce)\n\
withdraw(coin, outputs[])\n\
sendrawtransaction(coin, signedtx)\n\
swapstatus()\n\

4
iguana/exchanges/LP_include.h

@ -405,7 +405,7 @@ struct LP_pubkey_info
struct LP_pubkey_quote *quotes;
struct LP_pubswap *bobswaps,*aliceswaps;
uint64_t dynamictrust;
uint32_t timestamp,numerrors,lasttime;
uint32_t timestamp,numerrors,lasttime,slowresponse;
int32_t istrusted;
uint8_t rmd160[20],sig[65],pubsecp[33],siglen;
};
@ -430,7 +430,7 @@ struct LP_trade
uint64_t aliceid;
int64_t besttrust;
double bestprice;
uint32_t negotiationdone,connectsent,firsttime,lasttime,firstprocessed,lastprocessed,newtime;
uint32_t negotiationdone,bestresponse,connectsent,firsttime,lasttime,firstprocessed,lastprocessed,newtime;
char pairstr[64],funcid,iambob;
struct LP_quoteinfo Qs[4],Q;
};

8
iguana/exchanges/LP_nativeDEX.c

@ -17,19 +17,23 @@
// LP_nativeDEX.c
// marketmaker
//
// optimize electrum swap
// penalize unresponsive pubkeys more!
// big BTC swaps
// delay swap credit back until notarization
// electrum dynamic trust over 1000 tx
// https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki for signing BCH/BTG
//
// cancel bid/ask
// portfolio:
// portfolio to set prices from historical
// portfolio value based on ask?
// verify encrypted destpubkey, broadcast:0 setprice
// USD paxprice based USDvalue in portfolio
// improve critical section detection when parallel trades
// delay swap credit back until notarization
// dPoW security -> 4: KMD notarized, 5: BTC notarized, after next notary elections
// bigendian architectures need to use little endian for sighash calcs
//
// dont change error messages:
// if (enable_electrum_coin_output_data.error == 'couldnt find coin locally installed') { //{error: "couldnt find coin locally installed", coin: "BTC"}
//if (enable_native_coin_output_data.error == 'couldnt find coin locally installed') { //{error: "couldnt find coin locally installed", coin: "BTC"}

13
iguana/exchanges/LP_ordermatch.c

@ -1015,10 +1015,10 @@ struct LP_quoteinfo *LP_trades_gotconnected(void *ctx,struct LP_quoteinfo *qp,st
int32_t LP_trades_bestpricecheck(void *ctx,struct LP_trade *tp)
{
double qprice; struct LP_quoteinfo Q; int64_t dynamictrust; char *retstr;
double qprice; struct LP_quoteinfo Q; int64_t dynamictrust; char *retstr; struct LP_pubkey_info *pubp;
Q = tp->Q;
//printf("check bestprice %.8f vs new price %.8f\n",tp->bestprice,(double)Q.destsatoshis/Q.satoshis);
if ( Q.satoshis != 0 )//(qprice= LP_trades_alicevalidate(ctx,&Q)) > 0. )
if ( Q.satoshis != 0 && (pubp= LP_pubkeyfind(Q.srchash)) != 0 )//(qprice= LP_trades_alicevalidate(ctx,&Q)) > 0. )
{
qprice = (double)Q.destsatoshis / (Q.satoshis - Q.txfee);
LP_aliceid(Q.tradeid,tp->aliceid,"reserved",0,0);
@ -1026,12 +1026,13 @@ int32_t LP_trades_bestpricecheck(void *ctx,struct LP_trade *tp)
free(retstr);
//LP_trades_gotreserved(ctx,&Q,&tp->Qs[LP_RESERVED]);
dynamictrust = LP_dynamictrust(Q.srchash,LP_kmdvalue(Q.srccoin,Q.satoshis));
if ( tp->bestprice == 0. || (qprice < tp->bestprice || (qprice < tp->bestprice*1.01 && dynamictrust > tp->besttrust)) )
if ( tp->bestprice == 0. || (qprice < tp->bestprice && pubp->slowresponse <= tp->bestresponse*1.05) || (qprice < tp->bestprice*1.01 && dynamictrust > tp->besttrust && pubp->slowresponse <= tp->bestresponse*1.1) )
{
tp->Qs[LP_CONNECT] = tp->Q;
tp->bestprice = qprice;
tp->besttrust = dynamictrust;
printf("aliceid.%llu got new bestprice %.8f dynamictrust %.8f\n",(long long)tp->aliceid,tp->bestprice,dstr(dynamictrust));
tp->bestresponse = pubp->slowresponse;
printf("aliceid.%llu got new bestprice %.8f dynamictrust %.8f slowresponse.%d\n",(long long)tp->aliceid,tp->bestprice,dstr(dynamictrust),tp->bestresponse);
return(qprice);
} //else printf("qprice %.8f dynamictrust %.8f not good enough\n",qprice,dstr(dynamictrust));
} else printf("alice didnt validate\n");
@ -1040,7 +1041,7 @@ int32_t LP_trades_bestpricecheck(void *ctx,struct LP_trade *tp)
void LP_tradesloop(void *ctx)
{
struct LP_trade *qtp,*tp,*tmp; struct LP_quoteinfo *qp,Q; uint32_t now; int32_t timeout,funcid,flag,nonz; struct iguana_info *coin;
struct LP_trade *qtp,*tp,*tmp; struct LP_quoteinfo *qp,Q; uint32_t now; int32_t timeout,funcid,flag,nonz; struct iguana_info *coin; struct LP_pubkey_info *pubp;
strcpy(LP_tradesloop_stats.name,"LP_tradesloop");
LP_tradesloop_stats.threshold = 10000;
sleep(5);
@ -1145,6 +1146,8 @@ void LP_tradesloop(void *ctx)
LP_Alicemaxprice = tp->bestprice;
LP_reserved(ctx,LP_myipaddr,LP_mypubsock,&tp->Qs[LP_CONNECT]); // send LP_CONNECT
printf("repeat LP_connect aliceid.%llu %.8f\n",(long long)tp->aliceid,tp->bestprice);
if ( (pubp= LP_pubkeyfind(tp->Qs[LP_CONNECT].srchash)) != 0 )
pubp->slowresponse++;
}
}
}

Loading…
Cancel
Save