Skip to content

Commit d319f7a

Browse files
bug fix
1 parent 662bedf commit d319f7a

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

chat-ui-quince/src/code.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ApiClient {
3434
const errorText = await response.text();
3535
this.clearSession()
3636
throw new Error(`Verification failed: ${response.status} - ${errorText}`);
37+
refreshStatsButton.style.display = 'none';
3738
}
3839

3940
const data = await response.json();
@@ -42,6 +43,9 @@ class ApiClient {
4243
user_id: data.user_id,
4344
email: data.email
4445
};
46+
47+
refreshStatsButton.style.display = 'inline-block';
48+
4549
return data;
4650
} catch (error) {
4751
console.error('Token verification failed:', error);
@@ -74,6 +78,7 @@ class ApiClient {
7478
throw error;
7579
} finally {
7680
this.clearSession();
81+
refreshStatsButton.style.display = 'none';
7782
}
7883
}
7984
}

chat-ui-quince/src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ body {
384384
}
385385

386386
#refresh-stats-btn {
387-
background: none;
387+
background: white;
388388
border: none;
389389
cursor: pointer;
390390
padding: 5px;

src/flare_ai_defai/blockchain/sparkdex.py

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -541,34 +541,6 @@ def swap_erc20_tokens_tx(self, user: UserInfo, token_in: str, token_out: str, am
541541
deadline = self.w3.eth.get_block("latest")["timestamp"] + 300 # 5 minutes from now
542542

543543

544-
# ---- Step 0.5: calculate amount_out_min
545-
params = (
546-
token_in_address, # tokenIn
547-
token_out_address, # tokenOut
548-
fee_tier, # fee (e.g., 500 = 0.05%)
549-
self.wallet_store.get_address(user), # recipient (your address)
550-
int(self.w3.eth.get_block("latest")["timestamp"]) + 300, # deadline (5 min)
551-
amount_in_wei, # amountIn
552-
1, # amountOutMinimum (set to 0 for estimation)
553-
0 # sqrtPriceLimitX96 (no limit)
554-
)
555-
556-
amount_out_wei = 1
557-
try:
558-
amount_out_wei = universal_router.functions.exactInputSingle(params).call()
559-
except Exception as e:
560-
self.logger.error(f"Failed to estimate amount out: {str(e)}", extra={"params": params})
561-
raise
562-
563-
amount_out = amount_out_wei / (10 ** token_out_decimals)
564-
amount_out_min = int(amount_out_wei * (1 - slippage)) # Keep in wei units
565-
self.logger.debug("Estimated swap output", extra={
566-
"amount_in_wei": amount_in_wei, "token_in": token_in,
567-
"amount_out": amount_out, "token_out": token_out,
568-
"amount_out_min": amount_out_min
569-
})
570-
571-
572544

573545

574546

@@ -598,6 +570,33 @@ def swap_erc20_tokens_tx(self, user: UserInfo, token_in: str, token_out: str, am
598570

599571

600572

573+
# ---- Step 0.5: calculate amount_out_min
574+
params = (
575+
token_in_address, # tokenIn
576+
token_out_address, # tokenOut
577+
fee_tier, # fee (e.g., 500 = 0.05%)
578+
self.wallet_store.get_address(user), # recipient (your address)
579+
int(self.w3.eth.get_block("latest")["timestamp"]) + 300, # deadline (5 min)
580+
amount_in_wei, # amountIn
581+
1, # amountOutMinimum (set to 0 for estimation)
582+
0 # sqrtPriceLimitX96 (no limit)
583+
)
584+
585+
amount_out_wei = 1
586+
try:
587+
amount_out_wei = universal_router.functions.exactInputSingle(params).call()
588+
except Exception as e:
589+
self.logger.error(f"Failed to estimate amount out: {str(e)}", extra={"params": params})
590+
raise
591+
592+
amount_out = amount_out_wei / (10 ** token_out_decimals)
593+
amount_out_min = int(amount_out_wei * (1 - slippage)) # Keep in wei units
594+
self.logger.debug("Estimated swap output", extra={
595+
"amount_in_wei": amount_in_wei, "token_in": token_in,
596+
"amount_out": amount_out, "token_out": token_out,
597+
"amount_out_min": amount_out_min
598+
})
599+
601600
# --- Step 1: Approve Universal Router to Spend wFLR ---
602601
approval_tx = contract_in.functions.approve(universal_router_address, amount_in_wei).build_transaction({
603602
'from': self.wallet_store.get_address(user),

0 commit comments

Comments
 (0)