diff --git a/site/swap.html b/site/swap.html index 196dc10fb..c6775f3d8 100644 --- a/site/swap.html +++ b/site/swap.html @@ -430,6 +430,7 @@ dt{color:var(--ash)}dd{margin:0;font-family:var(--f-mono);font-size:13px;overflo lastQuote=null;$('amount-out').value=''; if(!tin||!tout||tin.key===tout.key){say($('quote-line'),'Pick two different tokens.','');return;} if(amt===null||amt===0n){say($('quote-line'),'Enter an amount for a quote. Slippage limit 1 percent, deadline 10 minutes.','');return;} + if(rpcBehind){say($('quote-line'),'The public RPC is still syncing; quotes come when it reaches the pools.','bad');return;} call(A.router,enc(S.getAmountsOut,['uint256','address[]'],[amt,path(tin,tout)])).then(function(r){ var w=words(r);var out=w[w.length-1];lastQuote={tin:tin,tout:tout,amt:amt,out:out,min:out*99n/100n}; $('amount-out').value=fmt(out,6); @@ -479,7 +480,15 @@ dt{color:var(--ash)}dd{margin:0;font-family:var(--f-mono);font-size:13px;overflo setInterval(refreshProofs,10000); // ---- pools and the faucets ---- + var DEPLOY_BLOCK=26972, rpcBehind=false; function refreshPools(){ + rpc('eth_blockNumber',[]).then(function(n){ + var h=parseInt(n,16);rpcBehind=h';return;} + return readPools(); + }).catch(function(){$('pools-body').innerHTML='The public RPC did not answer. Try again in a minute.';}); + } + function readPools(){ Promise.all(POOLS.map(function(p){return call(A.router,enc(S.getReserves,['address','address'],[p.a,p.b])).then(function(r){var w=words(r);return fmt(w[0],2)+' '+p.sa+' / '+fmt(w[1],2)+' '+p.sb;}).catch(function(){return 'unreadable';});})).then(function(rows){ $('pools-body').innerHTML=POOLS.map(function(p,i){return ''+p.name+''+rows[i]+'';}).join(''); });