Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: crosschain lp #1584

Open
wants to merge 248 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
248 commits
Select commit Hold shift + click to select a range
8e1615a
refactor icon balances
swiftcc624 Dec 22, 2024
e6bbcfa
WIP: crosschain lp - LP Panel
swiftcc624 Dec 24, 2024
55d788d
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Jan 3, 2025
833f39c
crosschain lp - send/remove token, add liquidity
swiftcc624 Jan 3, 2025
4afaafe
update balanced sdk
swiftcc624 Jan 8, 2025
20438ff
crosschain lp - remove liquidity
swiftcc624 Jan 8, 2025
be32b51
update url search params when pair is changed in supply page
swiftcc624 Jan 8, 2025
89d6749
crosschain lp - stake, unstake
swiftcc624 Jan 8, 2025
5a8e5fa
useXTokenDepositAmount refactor
swiftcc624 Jan 8, 2025
bbecdf0
select the correct xchain id in LP Panel when click a pool record
swiftcc624 Jan 8, 2025
2cabfb2
lp panel description - supply amount
swiftcc624 Jan 9, 2025
c91ea3e
rewrite XWalletClient classes to support crosschain lp
swiftcc624 Jan 9, 2025
17b6f80
implement lp functions in IconXWalletClient
swiftcc624 Jan 10, 2025
f6727b2
fix useHasLiquidity
swiftcc624 Jan 10, 2025
d725c38
fix liquidity pool list
swiftcc624 Jan 10, 2025
5bd625d
supply modal ui
swiftcc624 Jan 10, 2025
cd32349
use all signed accounts to get pools
swiftcc624 Jan 10, 2025
9c6b25f
orverride lessThan, equalTo, greaterThan in CurrencyAmount class for …
swiftcc624 Jan 10, 2025
ad69868
fix LPPanel
swiftcc624 Jan 10, 2025
4b2ace5
crosschain lp - SuiXWalletClient
swiftcc624 Jan 10, 2025
529068c
rewrite EvmXWalletClient
swiftcc624 Jan 10, 2025
88dc639
rewrite SuiXWalletClient
swiftcc624 Jan 10, 2025
cf0f769
refactor SolanaXWalletClient
swiftcc624 Jan 10, 2025
4a60018
refactor EvmXWalletClient
swiftcc624 Jan 10, 2025
3d9e8b1
refactor HavahXWalletClient
swiftcc624 Jan 10, 2025
d8dd141
refactor ArchwyXWalletClient
swiftcc624 Jan 10, 2025
d0010a0
refactor InjectiveXWalletClient
swiftcc624 Jan 10, 2025
c7e2d00
refactor SuiXWalletClient
swiftcc624 Jan 10, 2025
4a39e53
refactor StellarXWalletClient
swiftcc624 Jan 11, 2025
1f7e3f7
refactor XWalletClient classes
swiftcc624 Jan 11, 2025
3315ef2
refactor XWalletClient
swiftcc624 Jan 11, 2025
fac6b1c
refactor XWalletClient
swiftcc624 Jan 11, 2025
d6a7752
refactor XWalletClient
swiftcc624 Jan 11, 2025
25c9ab9
fix circular imports in xwagmi
swiftcc624 Jan 11, 2025
7df8564
refactor XWalletClient - make consistent data format
swiftcc624 Jan 12, 2025
4b5a3d1
refactor XWalletClient - make consistent data format
swiftcc624 Jan 12, 2025
0902f96
make PoolLogoWithNetwork component
swiftcc624 Jan 13, 2025
65c2544
implement _sendCall in ArchwayXWalletClient
swiftcc624 Jan 13, 2025
bdf3997
calculate correct xcall fee in crosschain lp hooks
swiftcc624 Jan 13, 2025
50dea00
implement _sendCall in HavahXWalletClient
swiftcc624 Jan 13, 2025
260dfb7
show xcall fee in supply modal
swiftcc624 Jan 13, 2025
2421c91
approve logic in supply modal
swiftcc624 Jan 13, 2025
72703fe
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Jan 14, 2025
7f9a281
refactor code
0xmilktea Jan 14, 2025
6ca7a13
don't persist useXChainHeightStore
swiftcc624 Jan 14, 2025
30cdfba
crosschain lp - implement wICX
swiftcc624 Jan 14, 2025
f143553
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Jan 15, 2025
1e5b8cb
Merge remote-tracking branch 'origin/feat/add-sICX-bnUSD-on-SUI-Injec…
0xmilktea Jan 15, 2025
b92eb69
refactor code
0xmilktea Jan 15, 2025
3b445f1
update locales
0xmilktea Jan 15, 2025
7e32ba5
rewards panel chain selector, claim rewards
swiftcc624 Jan 16, 2025
ce0832d
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 16, 2025
ebf419a
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Jan 16, 2025
4f9dc8c
update locales
0xmilktea Jan 16, 2025
306f926
refactor code
0xmilktea Jan 16, 2025
5739784
improve ui
0xmilktea Jan 20, 2025
2fe3b86
remove stable coins in the supply input
0xmilktea Jan 20, 2025
8505cfb
crosschain rewards on homepage
swiftcc624 Jan 20, 2025
eb02dd1
Use rgb(15, 57, 90) for the chain background colour
swiftcc624 Jan 20, 2025
009ee99
Let's add a vertical divider to the modal, reduce the margin around t…
swiftcc624 Jan 21, 2025
e49b13b
If you click Cancel after supplying one/both assets, you'll see a me…
swiftcc624 Jan 21, 2025
5464936
supply modal - switch network for the wrong chain
swiftcc624 Jan 21, 2025
75c1ae9
add ICX in the default token list
0xmilktea Jan 21, 2025
aa6de97
refactor the code
0xmilktea Jan 21, 2025
0432c71
fix supply quote currency input
0xmilktea Jan 21, 2025
7a57c0d
The Your pools section should include the asset tickers
swiftcc624 Jan 21, 2025
de0330d
fix icx currency in the currency input panel
0xmilktea Jan 21, 2025
b02d5ad
fix a bug
0xmilktea Jan 21, 2025
1bfdc9f
update getTransactionText for crosschain lp transactions
swiftcc624 Jan 21, 2025
3e42514
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 21, 2025
b82fc89
fix ui
0xmilktea Jan 21, 2025
167cdbb
This pool should be ICX / sICX (remove the w)
swiftcc624 Jan 21, 2025
1c75819
improve code
0xmilktea Jan 21, 2025
07653b0
improve ui
0xmilktea Jan 21, 2025
186f125
fix currency input panel for crosschain lp
swiftcc624 Jan 21, 2025
2e3f9b3
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 21, 2025
71eec8e
fix liquidity pools
swiftcc624 Jan 22, 2025
214ef5e
fix liquidity pools
swiftcc624 Jan 22, 2025
70227a2
stake modal - gas checker and switch network for wrong chain
swiftcc624 Jan 22, 2025
7fc7b06
gas checker in supply modal
swiftcc624 Jan 22, 2025
c820e12
gas checker and switch network in withdraw modal
swiftcc624 Jan 22, 2025
8d67a78
gas checker and switch network in claim modal
swiftcc624 Jan 22, 2025
6ecd657
The Send button changes to Sending as soon as you click it. If possi…
swiftcc624 Jan 22, 2025
efb385b
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Jan 22, 2025
6674aa8
remove debug code in PoolRecord
swiftcc624 Jan 23, 2025
e9f162d
chore: remove prettier-vscode from recommended extensions
hetfly Jan 23, 2025
009a092
fix: fix lp description component after merge
hetfly Jan 23, 2025
70608fd
fix: fix pool record component after merge
hetfly Jan 23, 2025
6756a4a
fix: fix respo rewards info apr
hetfly Jan 23, 2025
d9c5f4d
fix: There's too much space between the Rewards header and the chain …
swiftcc624 Jan 27, 2025
e8341a3
fix: The chain list keeps jumping around
swiftcc624 Jan 27, 2025
0e10a2b
fix: In case it's not related to the above issue, remove the prompt …
swiftcc624 Jan 27, 2025
c4face7
fix: I can still get it into a state where the assets are set to dif…
swiftcc624 Jan 28, 2025
e36c847
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Jan 28, 2025
396f621
fix: Update the APR tooltip:
swiftcc624 Jan 28, 2025
dcf9142
fix wallet section
0xmilktea Jan 28, 2025
c6583d1
refactor the code
0xmilktea Jan 28, 2025
565b493
fix: The slider should be maxed out by the time the first asset reac…
swiftcc624 Jan 28, 2025
05d163a
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 28, 2025
aa36d6b
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Jan 28, 2025
c4a41fa
display address in the quote currency panel
0xmilktea Jan 28, 2025
dd4c1f7
fix: Let's add the button animation to Supplying, so it shows someth…
swiftcc624 Jan 28, 2025
0e5189b
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 28, 2025
fda15ce
fix: show baln apr range for icon pools only
hetfly Jan 28, 2025
555a09f
fix: I can't complete the Send transaction for the bnUSD on Sui, and…
swiftcc624 Jan 28, 2025
ced53dc
Merge branch 'feat/crosschain-lp' of https://github.com/balancednetwo…
hetfly Jan 28, 2025
6a4daa7
fix: fix external rewards info display
hetfly Jan 28, 2025
ad1975c
update locales
0xmilktea Jan 28, 2025
3d7ef94
fix jsonStorageOption bug
0xmilktea Jan 28, 2025
5c2d82d
fix: I removed the SUI to cancel this transaction, and when the amou…
swiftcc624 Jan 28, 2025
49078f8
refactor code
0xmilktea Jan 28, 2025
fb0115e
fix wICX symbol
swiftcc624 Jan 31, 2025
7a80b9d
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 31, 2025
045903d
fix exporting type in xwagmi
swiftcc624 Jan 31, 2025
f8c3c14
fix jsonStorage reviver for zustand in xwagmi
swiftcc624 Jan 31, 2025
5d1eccf
fix: When the final supply transaction is finished, the modal should …
swiftcc624 Jan 31, 2025
7bbd14a
extract WithdrawLiquidityModal from WithdrawPanel
swiftcc624 Jan 31, 2025
8c5274e
fix: show transfer fee, modal status in withdraw modal
swiftcc624 Jan 31, 2025
0fe52f9
fix: decimal issue when withdraw
0xmilktea Jan 31, 2025
cb8d834
refactor StakeLPPanel
0xmilktea Jan 31, 2025
a5ab14c
refactor RespoRewardInfo component
0xmilktea Jan 31, 2025
84ac9ff
ClaimLPRewardsModal
swiftcc624 Jan 31, 2025
eaa25af
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 31, 2025
7783ea2
StakeLPModal
swiftcc624 Jan 31, 2025
930551f
refactor mint hook
0xmilktea Jan 31, 2025
c747ae5
fix: 3x gas fee issue
0xmilktea Jan 31, 2025
e32abaa
fix: the slider doesn't work correctly when the token input amount is…
swiftcc624 Jan 31, 2025
6ce0dbf
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Jan 31, 2025
7ff8c94
update locales
0xmilktea Feb 3, 2025
4340faa
update wallet modal
swiftcc624 Feb 3, 2025
a445dfd
update BALN text to rewards
0xmilktea Feb 3, 2025
90d5581
fix: This tooltip should have a , after the sICX amount (sICX (5.94%)…
swiftcc624 Feb 3, 2025
97388ed
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Feb 3, 2025
2c443b6
fix: Use a – for rewards on any chain that are less than $0.01
swiftcc624 Feb 3, 2025
c9f48ae
fix: Once a cross-chain transaction is in progress, we should change …
swiftcc624 Feb 3, 2025
77bf0b0
fix: I'm finding the transfer fee confusing, as I don't know at a gl…
swiftcc624 Feb 3, 2025
f9eafa4
fix: If you click on one of the liquidity pools to make it active in…
swiftcc624 Feb 3, 2025
78f3a38
fix: Update the transaction messages in the Bridge tab:
swiftcc624 Feb 3, 2025
b4943d9
fix: If the pool offers rewards, we should prompt people to stake th…
swiftcc624 Feb 3, 2025
1c11ceb
fix: disable sICX in archway & havah
0xmilktea Feb 3, 2025
8f8fc51
refactor: remove dead code
0xmilktea Feb 3, 2025
6bd9d2c
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 4, 2025
3f6968b
fix: If no chain is specified, tokens should default to their native…
swiftcc624 Feb 4, 2025
c0fa358
fix: I haven't been able to reproduce the issue with the AVAX pool y…
swiftcc624 Feb 4, 2025
a2b34ea
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Feb 5, 2025
af2be76
fix: There seems to be a gradient style applied to the Havah logo. I…
swiftcc624 Feb 6, 2025
ae7673b
fix: The Liquidity Pools section looks broken on mobile:
swiftcc624 Feb 6, 2025
5c562ff
fix: On mobile, the reward chain dropdown takes up more than the ava…
swiftcc624 Feb 6, 2025
f47397d
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 6, 2025
f1841e6
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 6, 2025
c5fdbd5
fix: Changed my mind regarding the 'switch network' handling, as the…
swiftcc624 Feb 6, 2025
009f7f9
fix: You can use the 25/50/75/100 buttons to exceed the amount avail…
swiftcc624 Feb 6, 2025
e1cf537
fix: Show the onboarding text for the Savings Rate section instead of…
swiftcc624 Feb 10, 2025
c8ef1bf
fix: What order is being used when every chain has zero rewards? Mig…
swiftcc624 Feb 10, 2025
ffea194
fix: The Rewards dropdown is hard to use & see which chains you're e…
swiftcc624 Feb 10, 2025
abd825e
fix: After I removed the second asset from the contract, it went into…
swiftcc624 Feb 10, 2025
6ba9915
fix SavingsChainSelector
swiftcc624 Feb 11, 2025
94af2a4
fix: When I choose Base, I dont see any rewards:
swiftcc624 Feb 11, 2025
fe6c270
fix: The stake/unstake LP token modal handling is a bit off. 0:28 in…
swiftcc624 Feb 11, 2025
bf3c268
fix: After I withdrew my liquidity from the same pool, it says my su…
swiftcc624 Feb 11, 2025
147a01b
fix gas fee checker in supply liquidity modal
swiftcc624 Feb 11, 2025
1a32017
fix PoolRecord
swiftcc624 Feb 11, 2025
0f31b9c
fix: useXTokenDepositAmount
swiftcc624 Feb 11, 2025
bfc4404
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Feb 12, 2025
fafbe67
update locales
0xmilktea Feb 12, 2025
72b4233
fix liquidity rewards question mark
swiftcc624 Feb 12, 2025
e6e5d84
fix pool record daily reward for crosschain
swiftcc624 Feb 12, 2025
79d6dcf
fix pool record daily reward for crosschain
swiftcc624 Feb 12, 2025
10514b7
fix: fix reward estimate
hetfly Feb 12, 2025
718da86
fix PoolRecord daily rewards
swiftcc624 Feb 13, 2025
060a978
fix: I can still get it into states where the assets are on differen…
swiftcc624 Feb 13, 2025
45ed660
set AssetsTab.YOUR by default for CurrencySelectionType.TRADE_MINT_BASE
swiftcc624 Feb 13, 2025
2bdcb3a
Merge remote-tracking branch 'origin/master' into feat/crosschain-lp
0xmilktea Feb 13, 2025
18df304
update locales
0xmilktea Feb 13, 2025
c277b0b
fix icx balance
0xmilktea Feb 13, 2025
23f794c
fix: maxAmountSpend function
0xmilktea Feb 14, 2025
34bdef7
fix: fix: I supplied INJ/bnUSD, but was then prompted to stake LP to…
swiftcc624 Feb 14, 2025
5b8274c
fix: If I use the % buttons, it always sets the amount based on the …
swiftcc624 Feb 14, 2025
9ce048f
fix 100% issue in slider
0xmilktea Feb 14, 2025
92b68f4
fix: If you've staked your LP tokens and then try to adjust them, th…
swiftcc624 Feb 14, 2025
9f5bba6
fix: Adjust the modals so the transfer fee comes before any message:
swiftcc624 Feb 14, 2025
723e7c2
fix: Network fees should use the onboarding text for non-ICON chains
swiftcc624 Feb 14, 2025
4bb983e
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Feb 14, 2025
73687da
fix: The Your supply section still shows a negative amount after I w…
swiftcc624 Feb 14, 2025
91ab07c
show base token balances
0xmilktea Feb 14, 2025
6f4fc4c
fix: Let's make the Sign in on ICON text a link that connects your w…
swiftcc624 Feb 14, 2025
56a26e4
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Feb 14, 2025
6bb9061
use xcallscan.xyz for all chains
swiftcc624 Feb 14, 2025
80d52ac
update locales
0xmilktea Feb 14, 2025
8696619
Revert "show base token balances"
swiftcc624 Feb 14, 2025
01b16f9
fix wallet balances in currency dropdown
swiftcc624 Feb 14, 2025
250defd
fix supply decimal issue
0xmilktea Feb 14, 2025
d544e90
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 17, 2025
33426cc
Merge branch 'master' into feat/crosschain-lp
hetfly Feb 17, 2025
45dc481
fix: If you click Cancel when you get the Stake LP tokens prompt, it…
swiftcc624 Feb 17, 2025
5fd42a3
fix: If you're earning rewards but don't have anything significant t…
swiftcc624 Feb 17, 2025
cb07079
chore: update locales
hetfly Feb 17, 2025
edba552
fix: fix bugs after merge
hetfly Feb 17, 2025
b5ea513
fix: fix bugs after merge
hetfly Feb 17, 2025
e8bb814
fix SupplyLiquidityModal
swiftcc624 Feb 17, 2025
75decdf
fix: After successfully staking/unstaking LP tokens, the slider rese…
swiftcc624 Feb 17, 2025
fdb947a
Merge branch 'feat/crosschain-lp' of github.com:balancednetwork/balan…
swiftcc624 Feb 17, 2025
5ace95f
fix: show reward range for icon LP only
hetfly Feb 17, 2025
7cc53e9
Merge branch 'feat/crosschain-lp' of https://github.com/balancednetwo…
hetfly Feb 17, 2025
5c83bf2
fix: For 5-10 seconds after you open it, the second dropdown will le…
swiftcc624 Feb 18, 2025
602db17
refactor CurrencyXChainItem component
0xmilktea Feb 18, 2025
b9ae456
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 18, 2025
87f9c2e
refactor CurrencyRow
swiftcc624 Feb 18, 2025
22ebbbd
refactor CurrencyRow
0xmilktea Feb 18, 2025
8420098
refactor code
0xmilktea Feb 18, 2025
4f54fae
refactor code
0xmilktea Feb 18, 2025
abb83ea
remove warning
0xmilktea Feb 18, 2025
65819e4
fetch oracle price per 10 secs
0xmilktea Feb 18, 2025
ed6a965
optimize speed
0xmilktea Feb 18, 2025
d71df1d
fix: All pairs now include a chain selector for the second asset for…
swiftcc624 Feb 19, 2025
0c55a1a
fix: Assets I don't hold don't appear in the asset dropdown at all n…
swiftcc624 Feb 19, 2025
091f52e
feat: If I choose to deposit HVH on Havah instead of ICON, it defaul…
swiftcc624 Feb 19, 2025
7a89b65
fix: I'm prompted to stake LP tokens for BALN/bnUSD after supplying …
swiftcc624 Feb 19, 2025
c86a00e
fix: After I withdrew liquidity from the ICX/sICX pool, the top sect…
swiftcc624 Feb 19, 2025
2df7790
update stellar gasThreshold
swiftcc624 Feb 19, 2025
69a5d2d
fix: This modal remained pending in the UI for a number of minutes a…
swiftcc624 Feb 19, 2025
43925b7
fix: A couple of LP token stake transactions failed the first time:
swiftcc624 Feb 19, 2025
f48c768
fix: However, I was able to close out of the modal without any warnin…
swiftcc624 Feb 20, 2025
a1414aa
try/catch useLPRewards
swiftcc624 Feb 20, 2025
19a5b3a
don't useXCallScanner for Arbitrum
swiftcc624 Feb 20, 2025
8bd0600
fix: Rewards on ICON should include savings rewards, liquidity rewar…
swiftcc624 Feb 20, 2025
94c01c1
useLPRewards with test code
swiftcc624 Feb 20, 2025
e3bd6fa
fix: I'm unable to supply liquidity for sARCH/bnUSD. Clicking the Sup…
swiftcc624 Feb 21, 2025
f1f2b8c
fix: should not be able to stake LP on archway and havah
swiftcc624 Feb 21, 2025
fa75607
fix: You can't earn rewards on Archway and Havah, so let's update the…
swiftcc624 Feb 21, 2025
cdecc76
increase stellar gasThreshold to 1 XLM
swiftcc624 Feb 21, 2025
0e57fa4
fix SupplyLiquidityModal
swiftcc624 Feb 21, 2025
ede2972
revert to use our own xcallscan engine
swiftcc624 Feb 21, 2025
96978ac
fix SupplyLiquidityModal
swiftcc624 Feb 21, 2025
54209c0
fix XTransactionHistoryItem description
swiftcc624 Feb 21, 2025
b3bac2a
fix XTransactionHistoryItem description
swiftcc624 Feb 21, 2025
29d8305
disable other buttons while sending/removing for stella in supply liq…
swiftcc624 Feb 22, 2025
844a9de
fix: There’s a formatting issue on mobile:
swiftcc624 Feb 24, 2025
c111837
fix: This message came up after signing the withdraw transaction. Can…
swiftcc624 Feb 24, 2025
1a42653
fix: There’s an issue with cross-chain loans that doesn’t exist in th…
swiftcc624 Feb 24, 2025
2db1308
fix: If you close out of the Claim modal while the transaction is sti…
swiftcc624 Feb 24, 2025
8000d01
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 24, 2025
34fb8fa
Merge branch 'master' into feat/crosschain-lp
swiftcc624 Feb 25, 2025
f17500c
fix withdraw liquidity on archway
swiftcc624 Feb 25, 2025
426aa7b
fix: Remove Stellar-specific liquidity supply conditions
swiftcc624 Feb 25, 2025
b6688c3
fix: Reduce XMessage stale timeout from 2 to 1 minute
swiftcc624 Feb 25, 2025
70c574c
fix: Safely handle undefined pool balance in LP staking suggestion modal
swiftcc624 Feb 25, 2025
268f41b
fix: Handle potential errors when fetching LP rewards across chains
swiftcc624 Feb 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: 3x gas fee issue
  • Loading branch information
0xmilktea committed Jan 31, 2025
commit c747ae52bfc2d3ef17a4ae14ca447cbaa858952f
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, { useCallback, useEffect } from 'react';
import React, { useCallback, useEffect, useMemo } from 'react';

import { Currency, CurrencyAmount } from '@balancednetwork/sdk-core';
import { Trans, t } from '@lingui/macro';
import { Box, Flex } from 'rebass/styled-components';
import styled from 'styled-components';
import { formatUnits } from 'viem';

import { TextButton } from '@/app/components/Button';
import { StyledButton } from '@/app/components/Button/StyledButton';
@@ -21,11 +22,13 @@ import {
ICON_XCALL_NETWORK_ID,
XToken,
XTransactionStatus,
convertCurrencyAmount,
getNetworkDisplayName,
useXAddLiquidity,
useXCallFee,
useXTokenDepositAmount,
useXTransactionStore,
xChainMap,
} from '@balancednetwork/xwagmi';
import { useQueryClient } from '@tanstack/react-query';
import { AnimatePresence, motion } from 'framer-motion';
@@ -111,9 +114,22 @@ export default function SupplyLiquidityModal({ isOpen, onClose, parsedAmounts, c
}
};

const { formattedXCallFee } = useXCallFee(lpXChainId, ICON_XCALL_NETWORK_ID);
const { xCallFee } = useXCallFee(lpXChainId, ICON_XCALL_NETWORK_ID);
const formattedXCallFee: string = useMemo(() => {
return xCallFee
? formatUnits(xCallFee.rollback * 3n, xChainMap[lpXChainId].nativeCurrency.decimals) +
' ' +
xChainMap[lpXChainId].nativeCurrency.symbol
: '';
}, [xCallFee, lpXChainId]);

const { isWrongChain, handleSwitchChain } = useEvmSwitchChain(lpXChainId);
const gasChecker = useXCallGasChecker(lpXChainId, undefined);
const gasChecker = useXCallGasChecker(
lpXChainId,
parsedAmounts[Field.CURRENCY_A] ? convertCurrencyAmount(lpXChainId, parsedAmounts[Field.CURRENCY_A]) : undefined,
3,
);

return (
<>
<Modal isOpen={isOpen} onDismiss={() => undefined}>
9 changes: 5 additions & 4 deletions apps/web/src/hooks/useXCallGasChecker.tsx
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import { useMemo } from 'react';
function useXCallGasChecker(
xChainId: XChainId,
inputAmount: CurrencyAmount<XToken> | CurrencyAmount<Currency> | undefined,
multiplier: number | undefined = 1,
): { hasEnoughGas: boolean; errorMessage: string } {
const balances = useCrossChainWalletBalances();

@@ -28,8 +29,8 @@ function useXCallGasChecker(
const nativeCurrency: XToken = xTokenMap[xChainId].find(x => x.isNativeToken)!;

const gasThreshold = inputAmount?.currency.isNativeToken
? xChain.gasThreshold + Number(inputAmount.toFixed())
: xChain.gasThreshold;
? xChain.gasThreshold * multiplier + Number(inputAmount.toFixed())
: xChain.gasThreshold * multiplier;

const hasEnoughGas =
balances[xChainId] &&
@@ -38,7 +39,7 @@ function useXCallGasChecker(
);

const errorMessage = !hasEnoughGas
? `You need at least ${formatBigNumber(new BigNumber(xChain.gasThreshold), 'currency')} ${
? `You need at least ${formatBigNumber(new BigNumber(xChain.gasThreshold * multiplier), 'currency')} ${
nativeCurrency.symbol
} in your wallet to pay for transaction fees on ${getNetworkDisplayName(xChainId)}.`
: '';
@@ -49,7 +50,7 @@ function useXCallGasChecker(
}

return { hasEnoughGas: false, errorMessage: 'Unknown' };
}, [balances, xChainId, inputAmount]);
}, [balances, xChainId, inputAmount, multiplier]);
}

export default useXCallGasChecker;