@ape.swap/bonds-sdk 6.3.0-test.69 → 7.0.0-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +223 -131
- package/dist/adapters/all/index.d.ts +13 -0
- package/dist/adapters/all/index.js +15 -0
- package/dist/adapters/all/index.js.map +1 -0
- package/dist/adapters/aptos/ActionsAptos.d.ts +5 -0
- package/dist/{views/YourBondsModal/components/Actions → adapters/aptos}/ActionsAptos.js +14 -14
- package/dist/adapters/aptos/ActionsAptos.js.map +1 -0
- package/dist/adapters/aptos/AptosAccountBridge.d.ts +3 -0
- package/dist/adapters/aptos/AptosAccountBridge.js +12 -0
- package/dist/adapters/aptos/AptosAccountBridge.js.map +1 -0
- package/dist/{views/BuyBond → adapters/aptos}/BuyComponentAptos.js +11 -17
- package/dist/adapters/aptos/BuyComponentAptos.js.map +1 -0
- package/dist/adapters/aptos/ClaimAllActionAptos.d.ts +5 -0
- package/dist/adapters/aptos/ClaimAllActionAptos.js +73 -0
- package/dist/adapters/aptos/ClaimAllActionAptos.js.map +1 -0
- package/dist/{components/ConnectAptosWalletButton → adapters/aptos}/ConnectAptosWalletButton.d.ts +1 -1
- package/dist/{components/ConnectAptosWalletButton → adapters/aptos}/ConnectAptosWalletButton.js +4 -9
- package/dist/adapters/aptos/ConnectAptosWalletButton.js.map +1 -0
- package/dist/adapters/aptos/ConnectToAptosBanner.d.ts +1 -0
- package/dist/adapters/aptos/ConnectToAptosBanner.js +21 -0
- package/dist/adapters/aptos/ConnectToAptosBanner.js.map +1 -0
- package/dist/{views/YourBondsModal/components/TransferBondModal → adapters/aptos}/TransferActionAptos.d.ts +2 -3
- package/dist/{views/YourBondsModal/components/TransferBondModal → adapters/aptos}/TransferActionAptos.js +3 -3
- package/dist/adapters/aptos/TransferActionAptos.js.map +1 -0
- package/dist/adapters/aptos/UserBondRowAptos.d.ts +5 -0
- package/dist/adapters/aptos/UserBondRowAptos.js +108 -0
- package/dist/adapters/aptos/UserBondRowAptos.js.map +1 -0
- package/dist/{utils → adapters/aptos}/aptosHelpers.d.ts +3 -2
- package/dist/{utils → adapters/aptos}/aptosHelpers.js +4 -3
- package/dist/adapters/aptos/aptosHelpers.js.map +1 -0
- package/dist/{state/bonds/fetchBondsData → adapters/aptos}/fetchBondsDataAptos.d.ts +2 -2
- package/dist/{state/bonds/fetchBondsData → adapters/aptos}/fetchBondsDataAptos.js +4 -27
- package/dist/adapters/aptos/fetchBondsDataAptos.js.map +1 -0
- package/dist/{state/bonds/fetchUsersBonds → adapters/aptos}/fetchUsersBondsAptos.d.ts +2 -2
- package/dist/{state/bonds/fetchUsersBonds → adapters/aptos}/fetchUsersBondsAptos.js +8 -8
- package/dist/adapters/aptos/fetchUsersBondsAptos.js.map +1 -0
- package/dist/adapters/aptos/index.d.ts +6 -0
- package/dist/adapters/aptos/index.js +37 -0
- package/dist/adapters/aptos/index.js.map +1 -0
- package/dist/{hooks/accounts → adapters/aptos}/useAPTAccount.js +1 -1
- package/dist/{hooks/accounts → adapters/aptos}/useAPTAccount.js.map +1 -1
- package/dist/{state/zap → adapters/aptos}/useAptosZapQuote.js +2 -3
- package/dist/adapters/aptos/useAptosZapQuote.js.map +1 -0
- package/dist/{state/balance → adapters/aptos}/useCurrencyBalanceAptos.js +1 -1
- package/dist/adapters/aptos/useCurrencyBalanceAptos.js.map +1 -0
- package/dist/adapters/evm/Actions.d.ts +5 -0
- package/dist/{views/YourBondsModal/components/Actions → adapters/evm}/Actions.js +26 -21
- package/dist/adapters/evm/Actions.js.map +1 -0
- package/dist/adapters/evm/BuyComponent.d.ts +5 -0
- package/dist/{views/BuyBond → adapters/evm}/BuyComponent.js +57 -61
- package/dist/adapters/evm/BuyComponent.js.map +1 -0
- package/dist/adapters/evm/ClaimAllActionEVM.d.ts +5 -0
- package/dist/adapters/evm/ClaimAllActionEVM.js +60 -0
- package/dist/adapters/evm/ClaimAllActionEVM.js.map +1 -0
- package/dist/adapters/evm/ConnectToEvmBanner.d.ts +1 -0
- package/dist/adapters/evm/ConnectToEvmBanner.js +12 -0
- package/dist/adapters/evm/ConnectToEvmBanner.js.map +1 -0
- package/dist/adapters/evm/EvmAccountBridge.d.ts +6 -0
- package/dist/adapters/evm/EvmAccountBridge.js +15 -0
- package/dist/adapters/evm/EvmAccountBridge.js.map +1 -0
- package/dist/{views/TransactionModal → adapters/evm}/TransactionModal.d.ts +2 -3
- package/dist/adapters/evm/TransactionModal.js +167 -0
- package/dist/adapters/evm/TransactionModal.js.map +1 -0
- package/dist/{views/YourBondsModal/components/TransferBondModal → adapters/evm}/TransferAction.d.ts +2 -3
- package/dist/{views/YourBondsModal/components/TransferBondModal → adapters/evm}/TransferAction.js +14 -12
- package/dist/adapters/evm/TransferAction.js.map +1 -0
- package/dist/adapters/evm/UserBondRow.d.ts +5 -0
- package/dist/adapters/evm/UserBondRow.js +138 -0
- package/dist/adapters/evm/UserBondRow.js.map +1 -0
- package/dist/adapters/evm/balances.d.ts +6 -0
- package/dist/adapters/evm/balances.js +61 -0
- package/dist/adapters/evm/balances.js.map +1 -0
- package/dist/{state/bonds/fetchBondsData → adapters/evm}/fetchBondsDataEVM.d.ts +3 -2
- package/dist/adapters/evm/fetchBondsDataEVM.js +156 -0
- package/dist/adapters/evm/fetchBondsDataEVM.js.map +1 -0
- package/dist/{state/bonds/fetchUsersBonds → adapters/evm}/fetchUsersBondsEVM.d.ts +2 -2
- package/dist/{state/bonds/fetchUsersBonds → adapters/evm}/fetchUsersBondsEVM.js +10 -10
- package/dist/adapters/evm/fetchUsersBondsEVM.js.map +1 -0
- package/dist/adapters/evm/getTierPoints.d.ts +3 -0
- package/dist/adapters/evm/getTierPoints.js +48 -0
- package/dist/adapters/evm/getTierPoints.js.map +1 -0
- package/dist/adapters/evm/index.d.ts +6 -0
- package/dist/adapters/evm/index.js +53 -0
- package/dist/adapters/evm/index.js.map +1 -0
- package/dist/{utils → adapters/evm}/multicall.js +3 -3
- package/dist/adapters/evm/multicall.js.map +1 -0
- package/dist/{views/BuyBond → adapters/evm/preTGE}/BuyComponentPreTGE.d.ts +1 -2
- package/dist/adapters/evm/preTGE/BuyComponentPreTGE.js +128 -0
- package/dist/adapters/evm/preTGE/BuyComponentPreTGE.js.map +1 -0
- package/dist/{views/Bonds/components/BondRows → adapters/evm/preTGE}/ModalHandlerPreTGE.d.ts +1 -2
- package/dist/{views/Bonds/components/BondRows → adapters/evm/preTGE}/ModalHandlerPreTGE.js +5 -5
- package/dist/adapters/evm/preTGE/ModalHandlerPreTGE.js.map +1 -0
- package/dist/adapters/evm/preTGE/PreTGEActions.d.ts +5 -0
- package/dist/{views/YourBonds/components/UserBondRow → adapters/evm/preTGE}/PreTGEActions.js +11 -15
- package/dist/adapters/evm/preTGE/PreTGEActions.js.map +1 -0
- package/dist/adapters/evm/preTGE/UserBondRowPreTGE.d.ts +5 -0
- package/dist/adapters/evm/preTGE/UserBondRowPreTGE.js +41 -0
- package/dist/adapters/evm/preTGE/UserBondRowPreTGE.js.map +1 -0
- package/dist/adapters/evm/preTGE/UserBondRowYield.d.ts +5 -0
- package/dist/adapters/evm/preTGE/UserBondRowYield.js +43 -0
- package/dist/adapters/evm/preTGE/UserBondRowYield.js.map +1 -0
- package/dist/{views → adapters/evm/preTGE}/YourBondsModalYield/YourBondsModalYield.d.ts +2 -3
- package/dist/adapters/evm/preTGE/YourBondsModalYield/YourBondsModalYield.js +150 -0
- package/dist/adapters/evm/preTGE/YourBondsModalYield/YourBondsModalYield.js.map +1 -0
- package/dist/{views → adapters/evm/preTGE}/YourBondsModalYield/components/UnstakeModalYield/UnstakeModalYield.d.ts +2 -3
- package/dist/adapters/evm/preTGE/YourBondsModalYield/components/UnstakeModalYield/UnstakeModalYield.js +66 -0
- package/dist/adapters/evm/preTGE/YourBondsModalYield/components/UnstakeModalYield/UnstakeModalYield.js.map +1 -0
- package/dist/{views → adapters/evm/preTGE}/YourBondsModalYield/components/YourBondModalHeader/YourBondModalHeader.d.ts +2 -3
- package/dist/adapters/evm/preTGE/YourBondsModalYield/components/YourBondModalHeader/YourBondModalHeader.js +15 -0
- package/dist/adapters/evm/preTGE/YourBondsModalYield/components/YourBondModalHeader/YourBondModalHeader.js.map +1 -0
- package/dist/{state/bonds/fetchBondsData → adapters/evm/preTGE}/fetchBondsDataPreTGE.d.ts +1 -1
- package/dist/{state/bonds/fetchBondsData → adapters/evm/preTGE}/fetchBondsDataPreTGE.js +1 -1
- package/dist/adapters/evm/preTGE/fetchBondsDataPreTGE.js.map +1 -0
- package/dist/adapters/evm/preTGE/fetchUserBondsPreTGE.d.ts +5 -0
- package/dist/adapters/evm/preTGE/fetchUserBondsPreTGE.js +204 -0
- package/dist/adapters/evm/preTGE/fetchUserBondsPreTGE.js.map +1 -0
- package/dist/{state/allowance → adapters/evm}/useAllowance.js +4 -4
- package/dist/adapters/evm/useAllowance.js.map +1 -0
- package/dist/adapters/evm/useEVMAccount.js.map +1 -0
- package/dist/{hooks → adapters/evm}/useMonitorTx.js +1 -1
- package/dist/adapters/evm/useMonitorTx.js.map +1 -0
- package/dist/{state/zap → adapters/evm}/useSoulZapBondQuote.js +12 -24
- package/dist/adapters/evm/useSoulZapBondQuote.js.map +1 -0
- package/dist/{state/bonds → adapters/evm}/useTierProofSignature.js +5 -5
- package/dist/adapters/evm/useTierProofSignature.js.map +1 -0
- package/dist/adapters/lifi/LifiModal.d.ts +4 -0
- package/dist/{views/LifiModal → adapters/lifi}/LifiModal.js +10 -7
- package/dist/adapters/lifi/LifiModal.js.map +1 -0
- package/dist/adapters/lifi/index.d.ts +6 -0
- package/dist/adapters/lifi/index.js +34 -0
- package/dist/adapters/lifi/index.js.map +1 -0
- package/dist/adapters/registry.d.ts +8 -0
- package/dist/adapters/registry.js +24 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/adapters/solana/ActionsSolana.d.ts +5 -0
- package/dist/{views/YourBondsModal/components/Actions → adapters/solana}/ActionsSolana.js +16 -16
- package/dist/adapters/solana/ActionsSolana.js.map +1 -0
- package/dist/{views/BuyBond → adapters/solana}/BuyComponentSolana.js +21 -24
- package/dist/adapters/solana/BuyComponentSolana.js.map +1 -0
- package/dist/{components/ConnectSolanaWalletButton → adapters/solana}/ConnectSolanaWalletButton.d.ts +1 -1
- package/dist/adapters/solana/ConnectSolanaWalletButton.js +14 -0
- package/dist/adapters/solana/ConnectSolanaWalletButton.js.map +1 -0
- package/dist/adapters/solana/ConnectToSolanaBanner.d.ts +1 -0
- package/dist/adapters/solana/ConnectToSolanaBanner.js +18 -0
- package/dist/adapters/solana/ConnectToSolanaBanner.js.map +1 -0
- package/dist/adapters/solana/SolanaAccountBridge.d.ts +3 -0
- package/dist/adapters/solana/SolanaAccountBridge.js +13 -0
- package/dist/adapters/solana/SolanaAccountBridge.js.map +1 -0
- package/dist/{views/YourBondsModal/components/TransferBondModal → adapters/solana}/TransferActionSolana.d.ts +2 -2
- package/dist/{views/YourBondsModal/components/TransferBondModal → adapters/solana}/TransferActionSolana.js +7 -7
- package/dist/adapters/solana/TransferActionSolana.js.map +1 -0
- package/dist/adapters/solana/UserBondRowSolana.d.ts +5 -0
- package/dist/{views/YourBonds/components/UserBondRow → adapters/solana}/UserBondRowSolana.js +27 -30
- package/dist/adapters/solana/UserBondRowSolana.js.map +1 -0
- package/dist/{utils → adapters/solana}/calculateSolanaTrueBillPrice.js +1 -1
- package/dist/adapters/solana/calculateSolanaTrueBillPrice.js.map +1 -0
- package/dist/{types → adapters/solana/codecs}/bondCodec.d.ts +2 -2
- package/dist/{types → adapters/solana/codecs}/bondCodec.js +2 -3
- package/dist/adapters/solana/codecs/bondCodec.js.map +1 -0
- package/dist/{types → adapters/solana/codecs}/bondIssuanceCodec.d.ts +2 -2
- package/dist/{types → adapters/solana/codecs}/bondIssuanceCodec.js +2 -3
- package/dist/adapters/solana/codecs/bondIssuanceCodec.js.map +1 -0
- package/dist/{types → adapters/solana/codecs}/bondPricingCodec.d.ts +1 -1
- package/dist/{types → adapters/solana/codecs}/bondPricingCodec.js +2 -2
- package/dist/adapters/solana/codecs/bondPricingCodec.js.map +1 -0
- package/dist/{types → adapters/solana/codecs}/bondTermCodec.d.ts +1 -1
- package/dist/{types → adapters/solana/codecs}/bondTermCodec.js +2 -2
- package/dist/adapters/solana/codecs/bondTermCodec.js.map +1 -0
- package/dist/adapters/solana/derivePda.js.map +1 -0
- package/dist/adapters/solana/fetchBondsDataSOL.d.ts +4 -0
- package/dist/adapters/solana/fetchBondsDataSOL.js +123 -0
- package/dist/adapters/solana/fetchBondsDataSOL.js.map +1 -0
- package/dist/{state/bonds/fetchUsersBonds → adapters/solana}/fetchUsersBondsSOL.d.ts +2 -2
- package/dist/{state/bonds/fetchUsersBonds → adapters/solana}/fetchUsersBondsSOL.js +11 -11
- package/dist/adapters/solana/fetchUsersBondsSOL.js.map +1 -0
- package/dist/{utils → adapters/solana}/getSolanaAccount.d.ts +1 -1
- package/dist/{utils → adapters/solana}/getSolanaAccount.js +4 -4
- package/dist/adapters/solana/getSolanaAccount.js.map +1 -0
- package/dist/adapters/solana/index.d.ts +8 -0
- package/dist/adapters/solana/index.js +40 -0
- package/dist/adapters/solana/index.js.map +1 -0
- package/dist/adapters/solana/polyfills.d.ts +1 -0
- package/dist/adapters/solana/polyfills.js +7 -0
- package/dist/adapters/solana/polyfills.js.map +1 -0
- package/dist/adapters/solana/solanaAtaHelper.js.map +1 -0
- package/dist/{constants → adapters/solana}/solanaConstants.js +1 -1
- package/dist/adapters/solana/solanaConstants.js.map +1 -0
- package/dist/adapters/solana/solanaMulticall.js.map +1 -0
- package/dist/adapters/solana/solanaRpc.d.ts +1 -0
- package/dist/{utils → adapters/solana}/solanaRpc.js +2 -2
- package/dist/adapters/solana/solanaRpc.js.map +1 -0
- package/dist/{state/balance → adapters/solana}/useCurrencyBalanceSolana.d.ts +4 -0
- package/dist/{state/balance → adapters/solana}/useCurrencyBalanceSolana.js +9 -2
- package/dist/adapters/solana/useCurrencyBalanceSolana.js.map +1 -0
- package/dist/adapters/solana/useJupiterSolanaQuote.js.map +1 -0
- package/dist/adapters/solana/useSOLAccount.js.map +1 -0
- package/dist/adapters/sui/ActionsSui.d.ts +5 -0
- package/dist/{views/YourBondsModal/components/Actions → adapters/sui}/ActionsSui.js +14 -14
- package/dist/adapters/sui/ActionsSui.js.map +1 -0
- package/dist/{views/BuyBond → adapters/sui}/BuyComponentSui.js +14 -21
- package/dist/adapters/sui/BuyComponentSui.js.map +1 -0
- package/dist/adapters/sui/ClaimAllActionSui.d.ts +5 -0
- package/dist/adapters/sui/ClaimAllActionSui.js +89 -0
- package/dist/adapters/sui/ClaimAllActionSui.js.map +1 -0
- package/dist/adapters/sui/ConnectToSuiBanner.d.ts +1 -0
- package/dist/adapters/sui/ConnectToSuiBanner.js +16 -0
- package/dist/adapters/sui/ConnectToSuiBanner.js.map +1 -0
- package/dist/adapters/sui/SuiAccountBridge.d.ts +3 -0
- package/dist/adapters/sui/SuiAccountBridge.js +12 -0
- package/dist/adapters/sui/SuiAccountBridge.js.map +1 -0
- package/dist/{views/YourBondsModal/components/TransferBondModal → adapters/sui}/TransferActionSui.d.ts +2 -3
- package/dist/{views/YourBondsModal/components/TransferBondModal → adapters/sui}/TransferActionSui.js +8 -8
- package/dist/adapters/sui/TransferActionSui.js.map +1 -0
- package/dist/adapters/sui/UserBondRowSui.d.ts +5 -0
- package/dist/adapters/sui/UserBondRowSui.js +125 -0
- package/dist/adapters/sui/UserBondRowSui.js.map +1 -0
- package/dist/{state/bonds/fetchBondsData → adapters/sui}/fetchBondsDataSui.d.ts +2 -2
- package/dist/{state/bonds/fetchBondsData → adapters/sui}/fetchBondsDataSui.js +4 -30
- package/dist/adapters/sui/fetchBondsDataSui.js.map +1 -0
- package/dist/{state/bonds/fetchUsersBonds → adapters/sui}/fetchUsersBondsSUI.d.ts +2 -2
- package/dist/{state/bonds/fetchUsersBonds → adapters/sui}/fetchUsersBondsSUI.js +8 -8
- package/dist/adapters/sui/fetchUsersBondsSUI.js.map +1 -0
- package/dist/adapters/sui/index.d.ts +6 -0
- package/dist/adapters/sui/index.js +37 -0
- package/dist/adapters/sui/index.js.map +1 -0
- package/dist/adapters/sui/suiConstants.js.map +1 -0
- package/dist/{utils → adapters/sui}/suiHelpers.js +1 -1
- package/dist/adapters/sui/suiHelpers.js.map +1 -0
- package/dist/adapters/sui/suiZapTokens.js.map +1 -0
- package/dist/{state/balance → adapters/sui}/useCurrencyBalanceSui.js +1 -1
- package/dist/adapters/sui/useCurrencyBalanceSui.js.map +1 -0
- package/dist/adapters/sui/useSUIAccount.d.ts +14 -0
- package/dist/{hooks/accounts → adapters/sui}/useSUIAccount.js +3 -2
- package/dist/adapters/sui/useSUIAccount.js.map +1 -0
- package/dist/{state/zap → adapters/sui}/useSuiZapQuote.js +3 -4
- package/dist/adapters/sui/useSuiZapQuote.js.map +1 -0
- package/dist/adapters/types.d.ts +110 -0
- package/dist/components/BondFilters/BondFilters.js +3 -3
- package/dist/components/BondFilters/BondFilters.js.map +1 -1
- package/dist/components/Carousel/index.d.ts +8 -0
- package/dist/components/Carousel/index.js +148 -0
- package/dist/components/Carousel/index.js.map +1 -0
- package/dist/components/ChainOptionList/ChainOptionsButtons.d.ts +1 -1
- package/dist/components/ChainOptionList/ChainOptionsButtons.js +6 -9
- package/dist/components/ChainOptionList/ChainOptionsButtons.js.map +1 -1
- package/dist/components/ChainOptionList/ChainOptionsList.d.ts +1 -1
- package/dist/components/ChainOptionList/ChainOptionsList.js +3 -4
- package/dist/components/ChainOptionList/ChainOptionsList.js.map +1 -1
- package/dist/components/CircularProgress/index.js +3 -14
- package/dist/components/CircularProgress/index.js.map +1 -1
- package/dist/components/ConnectButton/index.d.ts +1 -2
- package/dist/components/ConnectButton/index.js +2 -5
- package/dist/components/ConnectButton/index.js.map +1 -1
- package/dist/components/ConnectSuiWalletButton/ConnectSuiWalletButton.d.ts +1 -2
- package/dist/components/CustomClaimModals/AbondModal.d.ts +1 -2
- package/dist/components/CustomClaimModals/AbondModal.js +2 -3
- package/dist/components/CustomClaimModals/AbondModal.js.map +1 -1
- package/dist/components/CustomClaimModals/OabondModal.d.ts +1 -2
- package/dist/components/CustomClaimModals/OabondModal.js +2 -3
- package/dist/components/CustomClaimModals/OabondModal.js.map +1 -1
- package/dist/components/CustomClaimModals/PmusdModal.d.ts +1 -2
- package/dist/components/CustomClaimModals/PmusdModal.js +2 -9
- package/dist/components/CustomClaimModals/PmusdModal.js.map +1 -1
- package/dist/components/CustomClaimModals/PostClaimModal.d.ts +7 -0
- package/dist/components/CustomClaimModals/PostClaimModal.js +14 -0
- package/dist/components/CustomClaimModals/PostClaimModal.js.map +1 -0
- package/dist/components/FavIcons/AddFavToken.d.ts +1 -2
- package/dist/components/FavIcons/AddFavToken.js +2 -2
- package/dist/components/FavIcons/AddFavToken.js.map +1 -1
- package/dist/components/FavIcons/FavFilter.d.ts +1 -2
- package/dist/components/FavIcons/FavFilter.js +3 -3
- package/dist/components/FavIcons/FavFilter.js.map +1 -1
- package/dist/components/LoadingSpinner/index.d.ts +1 -2
- package/dist/components/LoadingSpinner/index.js +8 -30
- package/dist/components/LoadingSpinner/index.js.map +1 -1
- package/dist/components/MenuSelect/MenuSelect.d.ts +1 -2
- package/dist/components/MenuSelect/MenuSelect.js +3 -9
- package/dist/components/MenuSelect/MenuSelect.js.map +1 -1
- package/dist/components/MenuSelect/RecommendationSelector.d.ts +1 -2
- package/dist/components/MenuSelect/RecommendationSelector.js +4 -24
- package/dist/components/MenuSelect/RecommendationSelector.js.map +1 -1
- package/dist/components/NetworkFilter/index.d.ts +1 -2
- package/dist/components/NetworkFilter/index.js +14 -53
- package/dist/components/NetworkFilter/index.js.map +1 -1
- package/dist/components/PlaceholderMonkey/index.d.ts +1 -2
- package/dist/components/PlaceholderMonkey/index.js +2 -7
- package/dist/components/PlaceholderMonkey/index.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.js +3 -5
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBarWrapper.d.ts +2 -2
- package/dist/components/ProgressBar/ProgressBarWrapper.js +4 -4
- package/dist/components/ProgressBar/ProgressBarWrapper.js.map +1 -1
- package/dist/components/ProgressiveImage/index.d.ts +1 -2
- package/dist/components/ProgressiveImage/index.js +3 -21
- package/dist/components/ProgressiveImage/index.js.map +1 -1
- package/dist/components/SafeHTMLComponent/index.d.ts +1 -2
- package/dist/components/SafeHTMLComponent/index.js +1 -1
- package/dist/components/SlippageModal/index.d.ts +1 -2
- package/dist/components/SlippageModal/index.js +7 -43
- package/dist/components/SlippageModal/index.js.map +1 -1
- package/dist/components/StepBubble/index.d.ts +1 -2
- package/dist/components/StepBubble/index.js +5 -33
- package/dist/components/StepBubble/index.js.map +1 -1
- package/dist/components/Toast/index.d.ts +1 -2
- package/dist/components/Toast/index.js +4 -15
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/TokenInfoAndName/index.d.ts +3 -3
- package/dist/components/TokenInfoAndName/index.js +8 -19
- package/dist/components/TokenInfoAndName/index.js.map +1 -1
- package/dist/components/TokenSelectorModal/TokenRow.d.ts +1 -2
- package/dist/components/TokenSelectorModal/TokenRow.js +3 -3
- package/dist/components/TokenSelectorModal/TokenRow.js.map +1 -1
- package/dist/components/TokenSelectorModal/index.js +2 -14
- package/dist/components/TokenSelectorModal/index.js.map +1 -1
- package/dist/components/TokenSelectorPanel/index.d.ts +1 -1
- package/dist/components/TokenSelectorPanel/index.js +12 -25
- package/dist/components/TokenSelectorPanel/index.js.map +1 -1
- package/dist/components/Tooltip/ButtonsRow.js +3 -4
- package/dist/components/Tooltip/ButtonsRow.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +4 -4
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/YouTooltip/YouTooltip.d.ts +1 -2
- package/dist/components/YouTooltip/YouTooltip.js +2 -24
- package/dist/components/YouTooltip/YouTooltip.js.map +1 -1
- package/dist/components/uikit-sdk/Button/Button.d.ts +1 -2
- package/dist/components/uikit-sdk/Button/Button.js +34 -40
- package/dist/components/uikit-sdk/Button/Button.js.map +1 -1
- package/dist/components/uikit-sdk/Button/IconButton.js +16 -15
- package/dist/components/uikit-sdk/Button/IconButton.js.map +1 -1
- package/dist/components/uikit-sdk/Button/types.d.ts +1 -2
- package/dist/components/uikit-sdk/Button/types.js +6 -6
- package/dist/components/uikit-sdk/Button/types.js.map +1 -1
- package/dist/components/uikit-sdk/Checkbox/index.d.ts +1 -1
- package/dist/components/uikit-sdk/Checkbox/index.js +11 -8
- package/dist/components/uikit-sdk/Checkbox/index.js.map +1 -1
- package/dist/components/uikit-sdk/Checkbox/types.d.ts +2 -2
- package/dist/components/uikit-sdk/Checkbox/types.js.map +1 -1
- package/dist/components/uikit-sdk/Flex/index.d.ts +9 -3
- package/dist/components/uikit-sdk/Flex/index.js +8 -4
- package/dist/components/uikit-sdk/Flex/index.js.map +1 -1
- package/dist/components/uikit-sdk/Input/Input.d.ts +4 -7
- package/dist/components/uikit-sdk/Input/Input.js +4 -46
- package/dist/components/uikit-sdk/Input/Input.js.map +1 -1
- package/dist/components/uikit-sdk/LoadingDots/index.d.ts +1 -1
- package/dist/components/uikit-sdk/LoadingDots/index.js +2 -21
- package/dist/components/uikit-sdk/LoadingDots/index.js.map +1 -1
- package/dist/components/uikit-sdk/Modal/ModalHeader.js +5 -5
- package/dist/components/uikit-sdk/Modal/ModalHeader.js.map +1 -1
- package/dist/components/uikit-sdk/Modal/index.d.ts +1 -2
- package/dist/components/uikit-sdk/Modal/index.js +10 -14
- package/dist/components/uikit-sdk/Modal/index.js.map +1 -1
- package/dist/components/uikit-sdk/Modal/types.d.ts +3 -3
- package/dist/components/uikit-sdk/Select/Select.d.ts +1 -2
- package/dist/components/uikit-sdk/Select/Select.js +24 -17
- package/dist/components/uikit-sdk/Select/Select.js.map +1 -1
- package/dist/components/uikit-sdk/Select/SelectItem.d.ts +1 -1
- package/dist/components/uikit-sdk/Select/SelectItem.js +26 -15
- package/dist/components/uikit-sdk/Select/SelectItem.js.map +1 -1
- package/dist/components/uikit-sdk/Select/types.d.ts +1 -0
- package/dist/components/uikit-sdk/Select/types.js +9 -9
- package/dist/components/uikit-sdk/Select/types.js.map +1 -1
- package/dist/components/uikit-sdk/Skeleton/index.d.ts +1 -2
- package/dist/components/uikit-sdk/Skeleton/index.js +7 -8
- package/dist/components/uikit-sdk/Skeleton/index.js.map +1 -1
- package/dist/components/uikit-sdk/Skeleton/types.d.ts +2 -2
- package/dist/components/uikit-sdk/Skeleton/types.js.map +1 -1
- package/dist/components/uikit-sdk/Spinner/index.d.ts +11 -0
- package/dist/components/uikit-sdk/Spinner/index.js +9 -0
- package/dist/components/uikit-sdk/Spinner/index.js.map +1 -0
- package/dist/components/uikit-sdk/Svg/Icons/AllChains.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Arrow.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Arrow.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/BitTensor.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Caret.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Caret.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Close.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Close.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Cog.d.ts +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Cog.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Cog.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/CoinGecko.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/CoinGecko.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/DexScreener.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/DexScreener.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Discord.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Discord.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Discount.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Discount.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Error.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Error.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Expand.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Expand.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/External.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/External.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/FirePink.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/GiftBox.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/GiftBoxPlain.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Insight.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Insight.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/L1X.d.ts +4 -0
- package/dist/components/uikit-sdk/Svg/Icons/L1X.js +8 -0
- package/dist/components/uikit-sdk/Svg/Icons/L1X.js.map +1 -0
- package/dist/components/uikit-sdk/Svg/Icons/LineChart.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/More.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/More.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/NewOffer.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/NewOffer.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/PlaceholderMonkey.d.ts +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/PlaceholderMonkey.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/PlaceholderMonkey.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Question.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/QuestionCircle.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/QuestionCircle.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Robinhood.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Search.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Search.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/SellingFast.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/SellingFast.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/ShortSupply.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Sort.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Sort.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Star.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/StarFilled.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Success.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Success.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Tag.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Tick.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Tick.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Timer.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/TurnArrow.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/TurnArrow.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Twitter.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/Twitter.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/URL.js +2 -2
- package/dist/components/uikit-sdk/Svg/Icons/URL.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/WhaleActivity.js +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/WhaleActivity.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/styles.d.ts +5 -2
- package/dist/components/uikit-sdk/Svg/styles.js +8 -7
- package/dist/components/uikit-sdk/Svg/styles.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/APTOS.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/ARBITRUM.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/AVAX.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/BASE.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/BERA.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/BLAST.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/BNB.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/CROSSFI.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/ETH.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/GraphLinq.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/HYPEREVM.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/INEVM.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/IOTA.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/KATANA.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/LIGHTLINK.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/LINEA.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/MEGAETH.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/MONAD.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/POLYGON.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/SOL.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/SONIC.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/SUI.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/TLOS.js +1 -1
- package/dist/components/uikit-sdk/Svg/tokens/UNICHAIN.js +1 -1
- package/dist/components/uikit-sdk/SwiperDots/index.d.ts +1 -2
- package/dist/components/uikit-sdk/SwiperDots/index.js +3 -9
- package/dist/components/uikit-sdk/SwiperDots/index.js.map +1 -1
- package/dist/components/uikit-sdk/TabNav/index.js +3 -34
- package/dist/components/uikit-sdk/TabNav/index.js.map +1 -1
- package/dist/components/uikit-sdk/Tag/ListTag.d.ts +1 -2
- package/dist/components/uikit-sdk/Tag/ListTag.js +13 -16
- package/dist/components/uikit-sdk/Tag/ListTag.js.map +1 -1
- package/dist/components/uikit-sdk/Text/index.d.ts +1 -2
- package/dist/components/uikit-sdk/Text/index.js +21 -8
- package/dist/components/uikit-sdk/Text/index.js.map +1 -1
- package/dist/components/uikit-sdk/Text/types.d.ts +3 -2
- package/dist/components/uikit-sdk/Text/types.js.map +1 -1
- package/dist/components/uikit-sdk/Toggle/index.d.ts +1 -2
- package/dist/components/uikit-sdk/Toggle/index.js +7 -8
- package/dist/components/uikit-sdk/Toggle/index.js.map +1 -1
- package/dist/components/uikit-sdk/TokenImage/index.d.ts +1 -2
- package/dist/components/uikit-sdk/TokenImage/index.js +3 -45
- package/dist/components/uikit-sdk/TokenImage/index.js.map +1 -1
- package/dist/components/uikit-sdk/TooltipBubble/index.js +29 -53
- package/dist/components/uikit-sdk/TooltipBubble/index.js.map +1 -1
- package/dist/components/uikit-sdk/TooltipBubble/types.d.ts +5 -4
- package/dist/components/uikit-sdk/TooltipBubble/types.js.map +1 -1
- package/dist/config/constants/addresses.d.ts +1 -1
- package/dist/config/constants/addresses.js +22 -17
- package/dist/config/constants/addresses.js.map +1 -1
- package/dist/config/constants/chains.d.ts +0 -2
- package/dist/config/constants/chains.js +6 -2
- package/dist/config/constants/chains.js.map +1 -1
- package/dist/config/constants/networks.js +1 -0
- package/dist/config/constants/networks.js.map +1 -1
- package/dist/config/constants/queryKeys.d.ts +1 -0
- package/dist/config/constants/queryKeys.js +1 -0
- package/dist/config/constants/queryKeys.js.map +1 -1
- package/dist/config/constants/variables.d.ts +2 -4
- package/dist/config/constants/variables.js +15 -30
- package/dist/config/constants/variables.js.map +1 -1
- package/dist/constants/aptosConstants.d.ts +0 -2
- package/dist/constants/aptosConstants.js +1 -4
- package/dist/constants/aptosConstants.js.map +1 -1
- package/dist/contexts/ModalContext.d.ts +1 -1
- package/dist/contexts/ModalContext.js +1 -1
- package/dist/contexts/Popups.d.ts +1 -1
- package/dist/contexts/Popups.js +2 -2
- package/dist/contexts/Popups.js.map +1 -1
- package/dist/hooks/useSendReferenceId.js +2 -2
- package/dist/hooks/useSendReferenceId.js.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/providers/index.d.ts +3 -4
- package/dist/providers/index.js +5 -39
- package/dist/providers/index.js.map +1 -1
- package/dist/state/balance/useCurrencyBalance.js +3 -23
- package/dist/state/balance/useCurrencyBalance.js.map +1 -1
- package/dist/state/balance/useUserTokensBalance.js +8 -78
- package/dist/state/balance/useUserTokensBalance.js.map +1 -1
- package/dist/state/bondApiStats/useGetBondApiStats.js +2 -3
- package/dist/state/bondApiStats/useGetBondApiStats.js.map +1 -1
- package/dist/state/bonds/fetchBondsData/bondPricing.d.ts +4 -0
- package/dist/state/bonds/fetchBondsData/bondPricing.js +39 -0
- package/dist/state/bonds/fetchBondsData/bondPricing.js.map +1 -0
- package/dist/state/bonds/useBondsData.js +25 -37
- package/dist/state/bonds/useBondsData.js.map +1 -1
- package/dist/state/bonds/useBondsList.js +2 -3
- package/dist/state/bonds/useBondsList.js.map +1 -1
- package/dist/state/bonds/useBondsListPreTGE.js +2 -3
- package/dist/state/bonds/useBondsListPreTGE.js.map +1 -1
- package/dist/state/bonds/useUserBonds.d.ts +3 -1
- package/dist/state/bonds/useUserBonds.js +25 -37
- package/dist/state/bonds/useUserBonds.js.map +1 -1
- package/dist/state/bonds/useUserBondsPreTGE.d.ts +1 -2
- package/dist/state/bonds/useUserBondsPreTGE.js +7 -203
- package/dist/state/bonds/useUserBondsPreTGE.js.map +1 -1
- package/dist/state/chainAccount/useChainAccount.d.ts +13 -0
- package/dist/state/chainAccount/useChainAccount.js +30 -0
- package/dist/state/chainAccount/useChainAccount.js.map +1 -0
- package/dist/state/hotBonds/useHotBonds.js +4 -4
- package/dist/state/hotBonds/useHotBonds.js.map +1 -1
- package/dist/state/recommendations/useGetBondRecommendations.js +2 -2
- package/dist/state/recommendations/useGetBondRecommendations.js.map +1 -1
- package/dist/state/tiers/tiers.d.ts +66 -0
- package/dist/state/tiers/tiers.js +97 -0
- package/dist/state/tiers/tiers.js.map +1 -0
- package/dist/state/tiers/useTierPoints.d.ts +2 -66
- package/dist/state/tiers/useTierPoints.js +13 -148
- package/dist/state/tiers/useTierPoints.js.map +1 -1
- package/dist/state/tokenPrices/resolveTokenPrice.d.ts +13 -0
- package/dist/state/tokenPrices/resolveTokenPrice.js +37 -0
- package/dist/state/tokenPrices/resolveTokenPrice.js.map +1 -0
- package/dist/state/tokenPrices/useTokenPrices.js +2 -3
- package/dist/state/tokenPrices/useTokenPrices.js.map +1 -1
- package/dist/state/useSDKConfig.d.ts +3 -2
- package/dist/state/useSDKConfig.js +53 -6
- package/dist/state/useSDKConfig.js.map +1 -1
- package/dist/styles.css +2 -1588
- package/dist/utils/bondPriceHelpers.js +1 -11
- package/dist/utils/bondPriceHelpers.js.map +1 -1
- package/dist/utils/campaignStyles.d.ts +5 -5
- package/dist/utils/campaignStyles.js.map +1 -1
- package/dist/utils/displayHelpers.js +1 -1
- package/dist/utils/displayHelpers.js.map +1 -1
- package/dist/utils/httpClient.d.ts +11 -0
- package/dist/utils/httpClient.js +48 -0
- package/dist/utils/httpClient.js.map +1 -0
- package/dist/utils/resolveColor.d.ts +1 -0
- package/dist/utils/resolveColor.js +9 -0
- package/dist/utils/resolveColor.js.map +1 -0
- package/dist/views/Bonds/Bonds.d.ts +1 -2
- package/dist/views/Bonds/Bonds.js +2 -11
- package/dist/views/Bonds/Bonds.js.map +1 -1
- package/dist/views/Bonds/components/BondRows/ActiveBondRows.js +6 -11
- package/dist/views/Bonds/components/BondRows/ActiveBondRows.js.map +1 -1
- package/dist/views/Bonds/components/BondRows/BondRow.js +23 -14
- package/dist/views/Bonds/components/BondRows/BondRow.js.map +1 -1
- package/dist/views/Bonds/components/BondRows/ChainTitle.d.ts +1 -2
- package/dist/views/Bonds/components/BondRows/ChainTitle.js +5 -13
- package/dist/views/Bonds/components/BondRows/ChainTitle.js.map +1 -1
- package/dist/views/Bonds/components/BondRows/ModalHandler.d.ts +1 -2
- package/dist/views/Bonds/components/BondRows/ModalHandler.js +9 -36
- package/dist/views/Bonds/components/BondRows/ModalHandler.js.map +1 -1
- package/dist/views/Bonds/components/BondRows/SoldOutRows.d.ts +1 -2
- package/dist/views/Bonds/components/BondRows/SoldOutRows.js +6 -8
- package/dist/views/Bonds/components/BondRows/SoldOutRows.js.map +1 -1
- package/dist/views/Bonds/components/BondsMenu/BondsMenu.js +4 -10
- package/dist/views/Bonds/components/BondsMenu/BondsMenu.js.map +1 -1
- package/dist/views/Bonds/components/BonusComponents/BonusComponent.d.ts +1 -2
- package/dist/views/Bonds/components/BonusComponents/BonusComponent.js +5 -25
- package/dist/views/Bonds/components/BonusComponents/BonusComponent.js.map +1 -1
- package/dist/views/Bonds/components/BonusComponents/BonusContainer.d.ts +3 -3
- package/dist/views/Bonds/components/BonusComponents/BonusContainer.js +6 -3
- package/dist/views/Bonds/components/BonusComponents/BonusContainer.js.map +1 -1
- package/dist/views/Bonds/components/BonusComponents/BonusTable.d.ts +1 -2
- package/dist/views/Bonds/components/BonusComponents/BonusTable.js +10 -22
- package/dist/views/Bonds/components/BonusComponents/BonusTable.js.map +1 -1
- package/dist/views/Bonds/components/BuyAgainRow/index.d.ts +1 -2
- package/dist/views/Bonds/components/BuyAgainRow/index.js +3 -22
- package/dist/views/Bonds/components/BuyAgainRow/index.js.map +1 -1
- package/dist/views/Bonds/components/ChainBanner/ChainBanner.d.ts +1 -2
- package/dist/views/Bonds/components/ChainBanner/ChainBanner.js +5 -11
- package/dist/views/Bonds/components/ChainBanner/ChainBanner.js.map +1 -1
- package/dist/views/Bonds/components/CheckURL/index.d.ts +1 -2
- package/dist/views/Bonds/components/CheckURL/index.js +9 -5
- package/dist/views/Bonds/components/CheckURL/index.js.map +1 -1
- package/dist/views/Bonds/components/HotBondCards/HotBondCard.d.ts +1 -2
- package/dist/views/Bonds/components/HotBondCards/HotBondCard.js +2 -19
- package/dist/views/Bonds/components/HotBondCards/HotBondCard.js.map +1 -1
- package/dist/views/Bonds/components/HotBondCards/index.d.ts +1 -2
- package/dist/views/Bonds/components/HotBondCards/index.js +4 -38
- package/dist/views/Bonds/components/HotBondCards/index.js.map +1 -1
- package/dist/views/Bonds/components/LoadingSkeleton/LoadingSkeleton.d.ts +1 -2
- package/dist/views/Bonds/components/LoadingSkeleton/LoadingSkeleton.js +2 -17
- package/dist/views/Bonds/components/LoadingSkeleton/LoadingSkeleton.js.map +1 -1
- package/dist/views/Bonds/components/RecommendationCards/SmallRecommendationCard.d.ts +1 -2
- package/dist/views/Bonds/components/RecommendationCards/SmallRecommendationCard.js +3 -3
- package/dist/views/Bonds/components/RecommendationCards/SmallRecommendationCard.js.map +1 -1
- package/dist/views/Bonds/components/RecommendationCards/index.d.ts +1 -2
- package/dist/views/Bonds/components/RecommendationCards/index.js +5 -15
- package/dist/views/Bonds/components/RecommendationCards/index.js.map +1 -1
- package/dist/views/Bonds/index.js +2 -2
- package/dist/views/Bonds/index.js.map +1 -1
- package/dist/views/Bonds/utils.js +2 -2
- package/dist/views/Bonds/utils.js.map +1 -1
- package/dist/views/BuyBond/BuyBondModal.js +3 -8
- package/dist/views/BuyBond/BuyBondModal.js.map +1 -1
- package/dist/views/BuyBond/ChainBuyComponent.d.ts +5 -0
- package/dist/views/BuyBond/ChainBuyComponent.js +11 -0
- package/dist/views/BuyBond/ChainBuyComponent.js.map +1 -0
- package/dist/views/BuyBond/ParticipationSuccessful.d.ts +1 -2
- package/dist/views/BuyBond/ParticipationSuccessful.js +8 -26
- package/dist/views/BuyBond/ParticipationSuccessful.js.map +1 -1
- package/dist/views/BuyBond/components/BondCards/BondCards.d.ts +1 -2
- package/dist/views/BuyBond/components/BondCards/BondCards.js +27 -54
- package/dist/views/BuyBond/components/BondCards/BondCards.js.map +1 -1
- package/dist/views/BuyBond/components/BondCards/BondCardsPreTGE.d.ts +1 -2
- package/dist/views/BuyBond/components/BondCards/BondCardsPreTGE.js +3 -56
- package/dist/views/BuyBond/components/BondCards/BondCardsPreTGE.js.map +1 -1
- package/dist/views/BuyBond/components/BondModalHeader.d.ts +1 -2
- package/dist/views/BuyBond/components/BondModalHeader.js +6 -49
- package/dist/views/BuyBond/components/BondModalHeader.js.map +1 -1
- package/dist/views/BuyBond/components/BondModalMinTierHeader.d.ts +1 -1
- package/dist/views/BuyBond/components/BondModalMinTierHeader.js +4 -9
- package/dist/views/BuyBond/components/BondModalMinTierHeader.js.map +1 -1
- package/dist/views/BuyBond/components/Estimations.d.ts +1 -2
- package/dist/views/BuyBond/components/Estimations.js +10 -39
- package/dist/views/BuyBond/components/Estimations.js.map +1 -1
- package/dist/views/BuyBond/components/ExpandedViewButton.d.ts +1 -2
- package/dist/views/BuyBond/components/ExpandedViewButton.js +2 -15
- package/dist/views/BuyBond/components/ExpandedViewButton.js.map +1 -1
- package/dist/views/BuyBond/components/L1xIframe/L1xIframe.d.ts +4 -0
- package/dist/views/BuyBond/components/L1xIframe/L1xIframe.js +12 -0
- package/dist/views/BuyBond/components/L1xIframe/L1xIframe.js.map +1 -0
- package/dist/views/BuyBond/components/NewRateModal/NewRateModal.d.ts +1 -2
- package/dist/views/BuyBond/components/NewRateModal/NewRateModal.js +2 -14
- package/dist/views/BuyBond/components/NewRateModal/NewRateModal.js.map +1 -1
- package/dist/views/BuyBond/components/NoBonusModal/NoBonusModal.js +2 -2
- package/dist/views/BuyBond/components/NoBonusModal/NoBonusModal.js.map +1 -1
- package/dist/views/BuyBond/components/PointsLeftForNextTier/PointsLeftForNextTier.js +14 -94
- package/dist/views/BuyBond/components/PointsLeftForNextTier/PointsLeftForNextTier.js.map +1 -1
- package/dist/views/BuyBond/components/ProjectDescription.d.ts +1 -2
- package/dist/views/BuyBond/components/ProjectDescription.js +2 -15
- package/dist/views/BuyBond/components/ProjectDescription.js.map +1 -1
- package/dist/views/BuyBond/index.d.ts +2 -2
- package/dist/views/BuyBond/index.js +2 -2
- package/dist/views/BuyBond/index.js.map +1 -1
- package/dist/views/BuyBond/utils.js +1 -1
- package/dist/views/BuyBond/utils.js.map +1 -1
- package/dist/views/FullBondsView/FullBondsView.d.ts +1 -2
- package/dist/views/FullBondsView/FullBondsView.js +2 -2
- package/dist/views/FullBondsView/FullBondsView.js.map +1 -1
- package/dist/views/FullBondsView/index.js +2 -2
- package/dist/views/FullBondsView/index.js.map +1 -1
- package/dist/views/ProjectView/ProjectView.js +3 -16
- package/dist/views/ProjectView/ProjectView.js.map +1 -1
- package/dist/views/ProjectView/components/BondLeaderboard/components/SalesTable.d.ts +1 -2
- package/dist/views/ProjectView/components/BondLeaderboard/components/SalesTable.js +5 -24
- package/dist/views/ProjectView/components/BondLeaderboard/components/SalesTable.js.map +1 -1
- package/dist/views/ProjectView/components/BondLeaderboard/components/TopSaleCard.d.ts +1 -2
- package/dist/views/ProjectView/components/BondLeaderboard/components/TopSaleCard.js +9 -21
- package/dist/views/ProjectView/components/BondLeaderboard/components/TopSaleCard.js.map +1 -1
- package/dist/views/ProjectView/components/BondLeaderboard/components/TopThreeSalesCards.d.ts +1 -2
- package/dist/views/ProjectView/components/BondLeaderboard/components/TopThreeSalesCards.js +2 -2
- package/dist/views/ProjectView/components/BondLeaderboard/components/TopThreeSalesCards.js.map +1 -1
- package/dist/views/ProjectView/components/BondLeaderboard/index.d.ts +1 -2
- package/dist/views/ProjectView/components/BondLeaderboard/index.js +2 -14
- package/dist/views/ProjectView/components/BondLeaderboard/index.js.map +1 -1
- package/dist/views/ProjectView/components/BondStats/LineChart.d.ts +10 -0
- package/dist/views/ProjectView/components/BondStats/LineChart.js +144 -0
- package/dist/views/ProjectView/components/BondStats/LineChart.js.map +1 -0
- package/dist/views/ProjectView/components/BondStats/index.d.ts +1 -2
- package/dist/views/ProjectView/components/BondStats/index.js +18 -47
- package/dist/views/ProjectView/components/BondStats/index.js.map +1 -1
- package/dist/views/ProjectView/components/BondStats/types.d.ts +2 -37
- package/dist/views/ProjectView/components/BondStats/types.js +1 -28
- package/dist/views/ProjectView/components/BondStats/types.js.map +1 -1
- package/dist/views/ProjectView/components/NavPanel/index.d.ts +1 -2
- package/dist/views/ProjectView/components/NavPanel/index.js +2 -10
- package/dist/views/ProjectView/components/NavPanel/index.js.map +1 -1
- package/dist/views/ProjectView/components/PriceChart/components/CandleStickChart.d.ts +1 -2
- package/dist/views/ProjectView/components/PriceChart/components/CandleStickChart.js +1 -1
- package/dist/views/ProjectView/components/PriceChart/components/LineChart.d.ts +1 -2
- package/dist/views/ProjectView/components/PriceChart/components/LineChart.js +1 -1
- package/dist/views/ProjectView/components/PriceChart/index.d.ts +1 -2
- package/dist/views/ProjectView/components/PriceChart/index.js +5 -4
- package/dist/views/ProjectView/components/PriceChart/index.js.map +1 -1
- package/dist/views/ProjectView/components/ProjectInfo/index.d.ts +1 -2
- package/dist/views/ProjectView/components/ProjectInfo/index.js +2 -3
- package/dist/views/ProjectView/components/ProjectInfo/index.js.map +1 -1
- package/dist/views/ProjectView/components/RecommendationCards/index.d.ts +1 -2
- package/dist/views/ProjectView/components/RecommendationCards/index.js +6 -20
- package/dist/views/ProjectView/components/RecommendationCards/index.js.map +1 -1
- package/dist/views/ProjectView/index.js +2 -2
- package/dist/views/ProjectView/index.js.map +1 -1
- package/dist/views/SingleBond/SingleBond.js +5 -11
- package/dist/views/SingleBond/SingleBond.js.map +1 -1
- package/dist/views/SingleBond/SoldOutBuyBondPlaceholder.js +9 -31
- package/dist/views/SingleBond/SoldOutBuyBondPlaceholder.js.map +1 -1
- package/dist/views/SingleBond/index.js +2 -2
- package/dist/views/SingleBond/index.js.map +1 -1
- package/dist/views/YourBonds/YourBonds.d.ts +1 -2
- package/dist/views/YourBonds/YourBonds.js +29 -36
- package/dist/views/YourBonds/YourBonds.js.map +1 -1
- package/dist/views/YourBonds/components/ClaimAll/ClaimAllModal.d.ts +1 -2
- package/dist/views/YourBonds/components/ClaimAll/ClaimAllModal.js +11 -197
- package/dist/views/YourBonds/components/ClaimAll/ClaimAllModal.js.map +1 -1
- package/dist/views/YourBonds/components/ClaimAll/index.d.ts +1 -2
- package/dist/views/YourBonds/components/ClaimAll/index.js +6 -16
- package/dist/views/YourBonds/components/ClaimAll/index.js.map +1 -1
- package/dist/views/YourBonds/components/ProfitCard/ProfitCard.d.ts +1 -2
- package/dist/views/YourBonds/components/ProfitCard/ProfitCard.js +3 -15
- package/dist/views/YourBonds/components/ProfitCard/ProfitCard.js.map +1 -1
- package/dist/views/YourBonds/components/YourBondsMenu/YourBondsMenu.d.ts +1 -2
- package/dist/views/YourBonds/components/YourBondsMenu/YourBondsMenu.js +3 -3
- package/dist/views/YourBonds/components/YourBondsMenu/YourBondsMenu.js.map +1 -1
- package/dist/views/YourBonds/index.js +2 -2
- package/dist/views/YourBonds/index.js.map +1 -1
- package/dist/views/YourBondsModal/YourBondsModal.d.ts +1 -2
- package/dist/views/YourBondsModal/YourBondsModal.js +9 -101
- package/dist/views/YourBondsModal/YourBondsModal.js.map +1 -1
- package/dist/views/YourBondsModal/components/LinkShare/LinkShare.d.ts +1 -1
- package/dist/views/YourBondsModal/components/LinkShare/LinkShare.js +3 -16
- package/dist/views/YourBondsModal/components/LinkShare/LinkShare.js.map +1 -1
- package/dist/views/YourBondsModal/components/LinkShare/templateImageShare.js +1 -2
- package/dist/views/YourBondsModal/components/LinkShare/templateImageShare.js.map +1 -1
- package/dist/views/YourBondsModal/components/LinkShare/utils.js +8 -7
- package/dist/views/YourBondsModal/components/LinkShare/utils.js.map +1 -1
- package/dist/views/YourBondsModal/components/NFTImage/NFTImage.d.ts +1 -2
- package/dist/views/YourBondsModal/components/NFTImage/NFTImage.js +8 -86
- package/dist/views/YourBondsModal/components/NFTImage/NFTImage.js.map +1 -1
- package/dist/views/YourBondsModal/components/Recommendations/CardRecommendation.d.ts +1 -1
- package/dist/views/YourBondsModal/components/Recommendations/CardRecommendation.js +2 -15
- package/dist/views/YourBondsModal/components/Recommendations/CardRecommendation.js.map +1 -1
- package/dist/views/YourBondsModal/components/Recommendations/RecSkeleton.d.ts +1 -2
- package/dist/views/YourBondsModal/components/Recommendations/RecSkeleton.js +2 -12
- package/dist/views/YourBondsModal/components/Recommendations/RecSkeleton.js.map +1 -1
- package/dist/views/YourBondsModal/components/Recommendations/Recommendations.d.ts +1 -2
- package/dist/views/YourBondsModal/components/Recommendations/Recommendations.js +5 -9
- package/dist/views/YourBondsModal/components/Recommendations/Recommendations.js.map +1 -1
- package/dist/views/YourBondsModal/components/TransferBondModal/index.js +5 -9
- package/dist/views/YourBondsModal/components/TransferBondModal/index.js.map +1 -1
- package/dist/views/YourBondsModal/components/YourBondModalHeader/YourBondModalHeader.d.ts +1 -2
- package/dist/views/YourBondsModal/components/YourBondModalHeader/YourBondModalHeader.js +2 -24
- package/dist/views/YourBondsModal/components/YourBondModalHeader/YourBondModalHeader.js.map +1 -1
- package/package.json +100 -21
- package/dist/components/ChainOptionList/styles.d.ts +0 -2
- package/dist/components/ChainOptionList/styles.js +0 -54
- package/dist/components/ChainOptionList/styles.js.map +0 -1
- package/dist/components/ConnectAptosWalletButton/ConnectAptosWalletButton.js.map +0 -1
- package/dist/components/ConnectSolanaWalletButton/ConnectSolanaWalletButton.js +0 -19
- package/dist/components/ConnectSolanaWalletButton/ConnectSolanaWalletButton.js.map +0 -1
- package/dist/components/ConnectoToVmBanners/ConnectToAptosBanner.d.ts +0 -1
- package/dist/components/ConnectoToVmBanners/ConnectToAptosBanner.js +0 -50
- package/dist/components/ConnectoToVmBanners/ConnectToAptosBanner.js.map +0 -1
- package/dist/components/ConnectoToVmBanners/ConnectToEvmBanner.d.ts +0 -1
- package/dist/components/ConnectoToVmBanners/ConnectToEvmBanner.js +0 -50
- package/dist/components/ConnectoToVmBanners/ConnectToEvmBanner.js.map +0 -1
- package/dist/components/ConnectoToVmBanners/ConnectToSolanaBanner.d.ts +0 -1
- package/dist/components/ConnectoToVmBanners/ConnectToSolanaBanner.js +0 -49
- package/dist/components/ConnectoToVmBanners/ConnectToSolanaBanner.js.map +0 -1
- package/dist/components/ConnectoToVmBanners/ConnectToSuiBanner.d.ts +0 -1
- package/dist/components/ConnectoToVmBanners/ConnectToSuiBanner.js +0 -45
- package/dist/components/ConnectoToVmBanners/ConnectToSuiBanner.js.map +0 -1
- package/dist/components/ProgressBar/styles.d.ts +0 -2
- package/dist/components/ProgressBar/styles.js +0 -15
- package/dist/components/ProgressBar/styles.js.map +0 -1
- package/dist/components/Toast/styles.d.ts +0 -3
- package/dist/components/Toast/styles.js +0 -30
- package/dist/components/Toast/styles.js.map +0 -1
- package/dist/components/Tooltip/styles.d.ts +0 -2
- package/dist/components/Tooltip/styles.js +0 -32
- package/dist/components/Tooltip/styles.js.map +0 -1
- package/dist/components/uikit-sdk/Button/styles.d.ts +0 -3
- package/dist/components/uikit-sdk/Button/styles.js +0 -31
- package/dist/components/uikit-sdk/Button/styles.js.map +0 -1
- package/dist/components/uikit-sdk/Modal/styles.d.ts +0 -3
- package/dist/components/uikit-sdk/Modal/styles.js +0 -47
- package/dist/components/uikit-sdk/Modal/styles.js.map +0 -1
- package/dist/components/uikit-sdk/Select/styles.d.ts +0 -4
- package/dist/components/uikit-sdk/Select/styles.js +0 -50
- package/dist/components/uikit-sdk/Select/styles.js.map +0 -1
- package/dist/components/uikit-sdk/Skeleton/styles.d.ts +0 -3
- package/dist/components/uikit-sdk/Skeleton/styles.js +0 -43
- package/dist/components/uikit-sdk/Skeleton/styles.js.map +0 -1
- package/dist/components/uikit-sdk/Toggle/styles.d.ts +0 -3
- package/dist/components/uikit-sdk/Toggle/styles.js +0 -22
- package/dist/components/uikit-sdk/Toggle/styles.js.map +0 -1
- package/dist/components/uikit-sdk/TooltipBubble/styles.d.ts +0 -4
- package/dist/components/uikit-sdk/TooltipBubble/styles.js +0 -108
- package/dist/components/uikit-sdk/TooltipBubble/styles.js.map +0 -1
- package/dist/config/constants/suiZapTokens.js.map +0 -1
- package/dist/constants/solanaConstants.js.map +0 -1
- package/dist/constants/suiConstants.js.map +0 -1
- package/dist/contexts/SwiperProvider.d.ts +0 -12
- package/dist/contexts/SwiperProvider.js +0 -21
- package/dist/contexts/SwiperProvider.js.map +0 -1
- package/dist/hooks/accounts/useEVMAccount.js.map +0 -1
- package/dist/hooks/accounts/useSOLAccount.js.map +0 -1
- package/dist/hooks/accounts/useSUIAccount.d.ts +0 -7
- package/dist/hooks/accounts/useSUIAccount.js.map +0 -1
- package/dist/hooks/useMonitorTx.js.map +0 -1
- package/dist/hooks/useSwiper.d.ts +0 -2
- package/dist/hooks/useSwiper.js +0 -13
- package/dist/hooks/useSwiper.js.map +0 -1
- package/dist/providers/AptosWalletProvider.d.ts +0 -5
- package/dist/providers/SolanaWalletProvider.d.ts +0 -5
- package/dist/providers/SuiWalletProvider.d.ts +0 -5
- package/dist/state/allowance/useAllowance.js.map +0 -1
- package/dist/state/balance/useCurrencyBalanceAptos.js.map +0 -1
- package/dist/state/balance/useCurrencyBalanceSolana.js.map +0 -1
- package/dist/state/balance/useCurrencyBalanceSui.js.map +0 -1
- package/dist/state/bonds/fetchBondsData/cleanBillsData.d.ts +0 -4
- package/dist/state/bonds/fetchBondsData/cleanBillsData.js +0 -142
- package/dist/state/bonds/fetchBondsData/cleanBillsData.js.map +0 -1
- package/dist/state/bonds/fetchBondsData/fetchBondsDataAptos.js.map +0 -1
- package/dist/state/bonds/fetchBondsData/fetchBondsDataEVM.js +0 -89
- package/dist/state/bonds/fetchBondsData/fetchBondsDataEVM.js.map +0 -1
- package/dist/state/bonds/fetchBondsData/fetchBondsDataPreTGE.js.map +0 -1
- package/dist/state/bonds/fetchBondsData/fetchBondsDataSOL.d.ts +0 -3
- package/dist/state/bonds/fetchBondsData/fetchBondsDataSOL.js +0 -68
- package/dist/state/bonds/fetchBondsData/fetchBondsDataSOL.js.map +0 -1
- package/dist/state/bonds/fetchBondsData/fetchBondsDataSui.js.map +0 -1
- package/dist/state/bonds/fetchUsersBonds/fetchUsersBondsAptos.js.map +0 -1
- package/dist/state/bonds/fetchUsersBonds/fetchUsersBondsEVM.js.map +0 -1
- package/dist/state/bonds/fetchUsersBonds/fetchUsersBondsSOL.js.map +0 -1
- package/dist/state/bonds/fetchUsersBonds/fetchUsersBondsSUI.js.map +0 -1
- package/dist/state/bonds/useTierProofSignature.js.map +0 -1
- package/dist/state/zap/useAptosZapQuote.js.map +0 -1
- package/dist/state/zap/useJupiterSolanaQuote.js.map +0 -1
- package/dist/state/zap/useSoulZapBondQuote.js.map +0 -1
- package/dist/state/zap/useSuiZapQuote.js.map +0 -1
- package/dist/theme/base.d.ts +0 -109
- package/dist/theme/base.js +0 -125
- package/dist/theme/base.js.map +0 -1
- package/dist/theme/colors.d.ts +0 -20
- package/dist/theme/colors.js +0 -25
- package/dist/theme/colors.js.map +0 -1
- package/dist/theme/components.d.ts +0 -411
- package/dist/theme/components.js +0 -365
- package/dist/theme/components.js.map +0 -1
- package/dist/theme/index.d.ts +0 -2
- package/dist/theme/index.js +0 -12
- package/dist/theme/index.js.map +0 -1
- package/dist/types/bondCodec.js.map +0 -1
- package/dist/types/bondIssuanceCodec.js.map +0 -1
- package/dist/types/bondPricingCodec.js.map +0 -1
- package/dist/types/bondTermCodec.js.map +0 -1
- package/dist/utils/aptosHelpers.js.map +0 -1
- package/dist/utils/calculateSolanaTrueBillPrice.js.map +0 -1
- package/dist/utils/derivePda.js.map +0 -1
- package/dist/utils/getDotPos.d.ts +0 -1
- package/dist/utils/getDotPos.js +0 -12
- package/dist/utils/getDotPos.js.map +0 -1
- package/dist/utils/getSolanaAccount.js.map +0 -1
- package/dist/utils/multicall.js.map +0 -1
- package/dist/utils/solanaAtaHelper.js.map +0 -1
- package/dist/utils/solanaMulticall.js.map +0 -1
- package/dist/utils/solanaRpc.d.ts +0 -1
- package/dist/utils/solanaRpc.js.map +0 -1
- package/dist/utils/suiHelpers.js.map +0 -1
- package/dist/views/Bonds/components/BondRows/ModalHandlerPreTGE.js.map +0 -1
- package/dist/views/Bonds/components/HotBondCards/styles.d.ts +0 -35
- package/dist/views/Bonds/components/HotBondCards/styles.js +0 -38
- package/dist/views/Bonds/components/HotBondCards/styles.js.map +0 -1
- package/dist/views/Bonds/components/RecommendationCards/styles.d.ts +0 -2
- package/dist/views/Bonds/components/RecommendationCards/styles.js +0 -24
- package/dist/views/Bonds/components/RecommendationCards/styles.js.map +0 -1
- package/dist/views/BuyBond/BuyComponent.d.ts +0 -11
- package/dist/views/BuyBond/BuyComponent.js.map +0 -1
- package/dist/views/BuyBond/BuyComponentAptos.js.map +0 -1
- package/dist/views/BuyBond/BuyComponentPreTGE.js +0 -147
- package/dist/views/BuyBond/BuyComponentPreTGE.js.map +0 -1
- package/dist/views/BuyBond/BuyComponentSolana.js.map +0 -1
- package/dist/views/BuyBond/BuyComponentSui.js.map +0 -1
- package/dist/views/BuyBond/components/GetUpToComponent/GetUpToComponent.js +0 -61
- package/dist/views/BuyBond/components/GetUpToComponent/GetUpToComponent.js.map +0 -1
- package/dist/views/BuyBond/styles.d.ts +0 -2
- package/dist/views/BuyBond/styles.js +0 -33
- package/dist/views/BuyBond/styles.js.map +0 -1
- package/dist/views/LifiModal/LifiModal.d.ts +0 -7
- package/dist/views/LifiModal/LifiModal.js.map +0 -1
- package/dist/views/ProjectView/components/BondLeaderboard/components/styles.d.ts +0 -2
- package/dist/views/ProjectView/components/BondLeaderboard/components/styles.js +0 -51
- package/dist/views/ProjectView/components/BondLeaderboard/components/styles.js.map +0 -1
- package/dist/views/ProjectView/components/BondStats/styles.d.ts +0 -2
- package/dist/views/ProjectView/components/BondStats/styles.js +0 -49
- package/dist/views/ProjectView/components/BondStats/styles.js.map +0 -1
- package/dist/views/ProjectView/components/PriceChart/styles.d.ts +0 -2
- package/dist/views/ProjectView/components/PriceChart/styles.js +0 -44
- package/dist/views/ProjectView/components/PriceChart/styles.js.map +0 -1
- package/dist/views/ProjectView/components/ProjectInfo/styles.d.ts +0 -2
- package/dist/views/ProjectView/components/ProjectInfo/styles.js +0 -21
- package/dist/views/ProjectView/components/ProjectInfo/styles.js.map +0 -1
- package/dist/views/ProjectView/styles.d.ts +0 -2
- package/dist/views/ProjectView/styles.js +0 -10
- package/dist/views/ProjectView/styles.js.map +0 -1
- package/dist/views/TransactionModal/TransactionModal.js +0 -195
- package/dist/views/TransactionModal/TransactionModal.js.map +0 -1
- package/dist/views/YourBonds/components/UserBondRow/PreTGEActions.d.ts +0 -6
- package/dist/views/YourBonds/components/UserBondRow/PreTGEActions.js.map +0 -1
- package/dist/views/YourBonds/components/UserBondRow/UserBondRow.d.ts +0 -6
- package/dist/views/YourBonds/components/UserBondRow/UserBondRow.js +0 -136
- package/dist/views/YourBonds/components/UserBondRow/UserBondRow.js.map +0 -1
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowAptos.d.ts +0 -6
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowAptos.js +0 -109
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowAptos.js.map +0 -1
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowPreTGE.d.ts +0 -6
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowPreTGE.js +0 -43
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowPreTGE.js.map +0 -1
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowSolana.d.ts +0 -6
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowSolana.js.map +0 -1
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowSui.d.ts +0 -6
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowSui.js +0 -126
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowSui.js.map +0 -1
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowYield.d.ts +0 -6
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowYield.js +0 -50
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowYield.js.map +0 -1
- package/dist/views/YourBonds/components/UserBondRow/index.d.ts +0 -5
- package/dist/views/YourBondsModal/components/Actions/Actions.d.ts +0 -6
- package/dist/views/YourBondsModal/components/Actions/Actions.js.map +0 -1
- package/dist/views/YourBondsModal/components/Actions/ActionsAptos.d.ts +0 -6
- package/dist/views/YourBondsModal/components/Actions/ActionsAptos.js.map +0 -1
- package/dist/views/YourBondsModal/components/Actions/ActionsSolana.d.ts +0 -6
- package/dist/views/YourBondsModal/components/Actions/ActionsSolana.js.map +0 -1
- package/dist/views/YourBondsModal/components/Actions/ActionsSui.d.ts +0 -6
- package/dist/views/YourBondsModal/components/Actions/ActionsSui.js.map +0 -1
- package/dist/views/YourBondsModal/components/TransferBondModal/TransferAction.js.map +0 -1
- package/dist/views/YourBondsModal/components/TransferBondModal/TransferActionAptos.js.map +0 -1
- package/dist/views/YourBondsModal/components/TransferBondModal/TransferActionSolana.js.map +0 -1
- package/dist/views/YourBondsModal/components/TransferBondModal/TransferActionSui.js.map +0 -1
- package/dist/views/YourBondsModalYield/YourBondsModalYield.js +0 -220
- package/dist/views/YourBondsModalYield/YourBondsModalYield.js.map +0 -1
- package/dist/views/YourBondsModalYield/components/UnstakeModalYield/UnstakeModalYield.js +0 -71
- package/dist/views/YourBondsModalYield/components/UnstakeModalYield/UnstakeModalYield.js.map +0 -1
- package/dist/views/YourBondsModalYield/components/YourBondModalHeader/YourBondModalHeader.js +0 -32
- package/dist/views/YourBondsModalYield/components/YourBondModalHeader/YourBondModalHeader.js.map +0 -1
- /package/dist/{views/BuyBond → adapters/aptos}/BuyComponentAptos.d.ts +0 -0
- /package/dist/{types → adapters/aptos}/aptosBonds.d.ts +0 -0
- /package/dist/{hooks/accounts → adapters/aptos}/useAPTAccount.d.ts +0 -0
- /package/dist/{state/zap → adapters/aptos}/useAptosZapQuote.d.ts +0 -0
- /package/dist/{state/balance → adapters/aptos}/useCurrencyBalanceAptos.d.ts +0 -0
- /package/dist/{utils → adapters/evm}/multicall.d.ts +0 -0
- /package/dist/{state/allowance → adapters/evm}/useAllowance.d.ts +0 -0
- /package/dist/{hooks/accounts → adapters/evm}/useEVMAccount.d.ts +0 -0
- /package/dist/{hooks/accounts → adapters/evm}/useEVMAccount.js +0 -0
- /package/dist/{hooks → adapters/evm}/useMonitorTx.d.ts +0 -0
- /package/dist/{state/zap → adapters/evm}/useSoulZapBondQuote.d.ts +0 -0
- /package/dist/{state/bonds → adapters/evm}/useTierProofSignature.d.ts +0 -0
- /package/dist/{views/BuyBond → adapters/solana}/BuyComponentSolana.d.ts +0 -0
- /package/dist/{utils → adapters/solana}/calculateSolanaTrueBillPrice.d.ts +0 -0
- /package/dist/{types → adapters/solana/codecs}/index.d.ts +0 -0
- /package/dist/{utils → adapters/solana}/derivePda.d.ts +0 -0
- /package/dist/{utils → adapters/solana}/derivePda.js +0 -0
- /package/dist/{types → adapters/solana}/helius.d.ts +0 -0
- /package/dist/{utils → adapters/solana}/solanaAtaHelper.d.ts +0 -0
- /package/dist/{utils → adapters/solana}/solanaAtaHelper.js +0 -0
- /package/dist/{types → adapters/solana}/solanaBonds.d.ts +0 -0
- /package/dist/{constants → adapters/solana}/solanaConstants.d.ts +0 -0
- /package/dist/{utils → adapters/solana}/solanaMulticall.d.ts +0 -0
- /package/dist/{utils → adapters/solana}/solanaMulticall.js +0 -0
- /package/dist/{state/zap → adapters/solana}/useJupiterSolanaQuote.d.ts +0 -0
- /package/dist/{state/zap → adapters/solana}/useJupiterSolanaQuote.js +0 -0
- /package/dist/{hooks/accounts → adapters/solana}/useSOLAccount.d.ts +0 -0
- /package/dist/{hooks/accounts → adapters/solana}/useSOLAccount.js +0 -0
- /package/dist/{views/BuyBond → adapters/sui}/BuyComponentSui.d.ts +0 -0
- /package/dist/{constants → adapters/sui}/suiConstants.d.ts +0 -0
- /package/dist/{constants → adapters/sui}/suiConstants.js +0 -0
- /package/dist/{utils → adapters/sui}/suiHelpers.d.ts +0 -0
- /package/dist/{config/constants → adapters/sui}/suiZapTokens.d.ts +0 -0
- /package/dist/{config/constants → adapters/sui}/suiZapTokens.js +0 -0
- /package/dist/{state/balance → adapters/sui}/useCurrencyBalanceSui.d.ts +0 -0
- /package/dist/{state/zap → adapters/sui}/useSuiZapQuote.d.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAllowance.js","sources":["../../../src/state/allowance/useAllowance.ts"],"sourcesContent":["import { useQuery, UseQueryResult } from '@tanstack/react-query'\nimport { ChainId, Token } from '@ape.swap/apeswap-lists'\nimport erc20ABI from '../../config/abi/erc20.json'\nimport { QUERY_KEYS } from '../../config/constants/queryKeys'\nimport multicall, { Call } from '../../utils/multicall'\nimport { convertToBigish } from '../../utils/convertToBigish'\nimport { getBalanceNumber } from '../../utils/getBalanceNumber'\nimport ERC_20_ABI from '../../config/abi/erc20.json'\nimport USDT_ETH_ABI from '../../config/abi/usdtETH.json'\nimport { useCallback, useEffect, useState } from 'react'\nimport { useWriteContract } from 'wagmi'\nimport { useMonitorTx } from '../../hooks/useMonitorTx'\nimport { usePopups } from '../popups/usePopups'\nimport { reportError } from '../../utils/reportError'\nimport { useURLByEnvironment } from '../useSDKConfig'\n\n/**\n * useAllowance hook: fetches the amount approved by the user for a given token\n * useApproval hook: returns the approval state (not approved, pending or approved) and a function to approve on chain\n * getTokenAllowance function fetches the allowance on chain\n */\n\nexport enum ApprovalState {\n NOT_APPROVED = 'NOT_APPROVED',\n PENDING = 'PENDING',\n APPROVED = 'APPROVED',\n}\n\nexport default function useAllowance(\n currency: 'NATIVE' | Token | null,\n spender: string | null,\n account: string | null,\n chainId: ChainId | null,\n): UseQueryResult<number | null> {\n return useQuery({\n queryKey: [\n QUERY_KEYS.ALLOWANCE,\n account ?? '',\n chainId,\n currency === 'NATIVE' ? currency : currency?.symbol,\n spender,\n ],\n queryFn: () => getTokenAllowance(currency, spender, account, chainId),\n refetchInterval: 10000, // i.e. 10 sec\n refetchOnWindowFocus: false,\n retry: 1,\n })\n}\n\nexport const getTokenAllowance = async (\n currency: 'NATIVE' | Token | null,\n spender: string | null,\n account: string | null,\n chainId: ChainId | null,\n): Promise<number | null> => {\n if (currency === 'NATIVE') return null\n // if (!account) {\n // console.log('Account disconnected')\n // } else if (!currency) {\n // console.log('No currency selected')\n // } else if (!chainId) {\n // console.log('No chainId selected')\n // } else if (!spender) {\n // console.log('No spender selected')\n // }\n if (!account || !currency || !chainId || !spender) return null\n const calls: Call[] = [\n {\n address: currency.address[chainId]!,\n name: 'allowance',\n params: [account, spender],\n },\n ]\n const data = await multicall(chainId, erc20ABI, calls)\n return getBalanceNumber(data[0][0] ?? 0, currency.decimals![chainId]!)\n}\n\nexport const useApproval = (\n amount: string,\n currency: 'NATIVE' | Token | null,\n spender: string | null,\n account: string | null,\n chainId: ChainId | null,\n): [ApprovalState, () => Promise<string | null | undefined>] => {\n const apiUrl = useURLByEnvironment('apiV2')\n const [confirmingTxOnWallet, setConfirmingTxOnWallet] = useState(false)\n const { data: allowance, refetch } = useAllowance(currency, spender, account, chainId)\n\n const { writeContractAsync, data: txHash, reset } = useWriteContract()\n const { isLoading: isConfirming, isSuccess: isConfirmed } = useMonitorTx(txHash, chainId as ChainId)\n const { addToastError } = usePopups()\n const confirmingTxOnChain = isConfirming && !isConfirmed\n\n useEffect(() => {\n if (txHash && isConfirmed) {\n setTimeout(() => {\n refetch()\n console.log('refetch allowance')\n reset()\n }, 1500)\n }\n /* eslint-disable react-hooks/exhaustive-deps */\n }, [txHash, confirmingTxOnChain, isConfirmed])\n\n const handleApprove = useCallback(async () => {\n if (!chainId || !amount || currency === 'NATIVE' || !currency) return null\n const decimals = currency.decimals![chainId]\n const tokenAddress = currency.address[chainId] as `0x${string}`\n if (!decimals || !tokenAddress) return null\n try {\n const bigishAmount = convertToBigish(amount, decimals)\n setConfirmingTxOnWallet(true)\n const hash = await writeContractAsync({\n address: tokenAddress,\n abi:\n tokenAddress?.toLowerCase() === '0xdAC17F958D2ee523a2206206994597C13D831ec7'.toLowerCase()\n ? USDT_ETH_ABI\n : ERC_20_ABI,\n functionName: 'approve',\n args: [spender, bigishAmount],\n account: account as `0x${string}`,\n chain: chainId as any,\n })\n setConfirmingTxOnWallet(false)\n // Adding a delay as I suspect RPCs need to catch up as the txs are indexed onchain too fast\n await new Promise((resolve) => setTimeout(resolve, 1500))\n return hash\n } catch (error: any) {\n setConfirmingTxOnWallet(false)\n console.error('Approval failed:', error)\n addToastError(error?.shortMessage || error?.details || error?.message)\n reportError({\n apiUrl,\n error,\n extraInfo: { type: 'approval', tokenAddress: tokenAddress, spenderAddress: spender, error },\n chainId,\n account: account!,\n })\n throw error\n }\n /* eslint-disable react-hooks/exhaustive-deps */\n }, [amount, currency, chainId])\n\n let approvalState: ApprovalState = ApprovalState.NOT_APPROVED\n\n if (allowance && amount) {\n approvalState = allowance >= parseFloat(amount) ? ApprovalState.APPROVED : ApprovalState.NOT_APPROVED\n }\n if (currency === 'NATIVE') {\n approvalState = ApprovalState.APPROVED\n }\n if (confirmingTxOnChain || confirmingTxOnWallet) {\n approvalState = ApprovalState.PENDING\n }\n\n return [approvalState ?? ApprovalState.NOT_APPROVED, handleApprove]\n}\n"],"names":["ERC_20_ABI"],"mappings":";;;;;;;;;;;;;;AAgBA;;;;AAIG;IAES;AAAZ,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,cAAA,CAAA,GAAA,cAA6B;AAC7B,IAAA,aAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,aAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACvB,CAAC,EAJW,aAAa,KAAb,aAAa,GAAA,EAAA,CAAA,CAAA;AAMX,SAAU,YAAY,CAClC,QAAiC,EACjC,OAAsB,EACtB,OAAsB,EACtB,OAAuB,EAAA;AAEvB,IAAA,OAAO,QAAQ,CAAC;AACd,QAAA,QAAQ,EAAE;AACR,YAAA,UAAU,CAAC,SAAS;AACpB,YAAA,OAAO,IAAI,EAAE;YACb,OAAO;YACP,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAG,QAAQ,EAAE,MAAM;YACnD,OAAO;AACR,SAAA;AACD,QAAA,OAAO,EAAE,MAAM,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;QACrE,eAAe,EAAE,KAAK;AACtB,QAAA,oBAAoB,E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EAAE,aAAa,CAAC;AACrE;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrencyBalanceAptos.js","sources":["../../../src/state/balance/useCurrencyBalanceAptos.ts"],"sourcesContent":["// Aptos balance reads — mirrors useCurrencyBalanceSolana.ts\n\nimport { ChainId, Token } from '@ape.swap/apeswap-lists'\nimport { getAptosClient } from '../../utils/aptosHelpers'\nimport { formatUnits } from '../../utils/fixedPoint'\n\nconst APTOS_KEY = ChainId.APTOS\n\n/**\n * Single-token balance read for Aptos.\n * Used by `useCurrencyBalance` when `chainId === ChainId.APTOS`.\n */\nexport const getTokenBalanceAptos = async (\n currency: 'NATIVE' | Token | null,\n account: string | null,\n): Promise<string | null> => {\n if (!account || !currency) return null\n\n try {\n const aptos = getAptosClient()\n if (currency === 'NATIVE') {\n const amount = await aptos.getAccountAPTAmount({ accountAddress: account })\n return formatUnits(String(amount), 8)\n }\n const tokenAddress = currency.address[APTOS_KEY]\n if (!tokenAddress) return '0'\n const isCoinType = tokenAddress.includes('::')\n const amount = await aptos.getAccountCoinAmount({\n accountAddress: account,\n ...(isCoinType\n ? { coinType: tokenAddress as `${string}::${string}::${string}` }\n : { faMetadataAddress: tokenAddress }),\n })\n const decimals = currency.decimals?.[APTOS_KEY] ?? 8\n return formatUnits(String(amount), decimals)\n } catch {\n return '0'\n }\n}\n\n/**\n * Multi-token balance read for Aptos.\n * Used by `useUserTokensBalance` when `chainId === ChainId.APTOS`.\n */\nexport const getTokensBalanceAptos = async (\n account: string,\n tokens: ('NATIVE' | Token)[],\n): Promise<{ address: string; balance: string }[]> => {\n const aptos = getAptosClient()\n return await Promise.all(\n tokens.map(async (token) => {\n const address = token === 'NATIVE' ? 'NATIVE' : ((token as Token).address[APTOS_KEY] as string)\n if (token === 'NATIVE') {\n try {\n const amount = await aptos.getAccountAPTAmount({ accountAddress: account })\n return { address, balance: formatUnits(String(amount), 8) }\n } catch {\n return { address, balance: '0' }\n }\n }\n try {\n // FA tokens use faMetadataAddress; legacy coins use coinType.\n // Detect by checking if address looks like a coin type (contains ::).\n const isCoinType = address.includes('::')\n const amount = await aptos.getAccountCoinAmount({\n accountAddress: account,\n ...(isCoinType ? { coinType: address as `${string}::${string}::${string}` } : { faMetadataAddress: address }),\n })\n const decimals = (token as Token).decimals?.[APTOS_KEY] ?? 8\n return {\n address,\n balance: formatUnits(String(amount), decimals),\n }\n } catch {\n return { address, balance: '0' }\n }\n }),\n )\n}\n"],"names":[],"mappings":";;;;AAAA;AAMA,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK;AAE/B;;;AAGG;AACI,MAAM,oBAAoB,GAAG,OAClC,QAAiC,EACjC,OAAsB,KACI;AAC1B,IAAA,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,IAAI;AAEtC,IAAA,IAAI;AACF,QAAA,MAAM,KAAK,GAAG,cAAc,EAAE;AAC9B,QAAA,IAAI,QAAQ,KAAK,QAAQ,EAAE;AACzB,YAAA,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,mBAAmB,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;YAC3E,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACvC;QACA,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;AAChD,QAAA,IAAI,CAAC,YAAY;AAAE,YAAA,OAAO,GAAG;QAC7B,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC9C,QAAA,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,oBAAoB,CAAC;AAC9C,YAAA,cAAc,EAAE,OAAO;AACvB,YAAA,IAAI;AACF,kBAAE,EAAE,QAAQ,EAAE,YAAiD;AAC/D,kBAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAC;AACzC,SAAA,CAAC;QACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,GAAG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ACP,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;aAC/C;QACH;AAAE,QAAA,MAAM;AACN,YAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE;QAClC;IACF,CAAC,CAAC,CACH;AACH;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrencyBalanceSolana.js","sources":["../../../src/state/balance/useCurrencyBalanceSolana.ts"],"sourcesContent":["import { Connection, PublicKey } from '@solana/web3.js'\nimport { getAccount } from '@solana/spl-token'\nimport { ChainId, Token } from '@ape.swap/apeswap-lists'\nimport { formatUnits } from '../../utils/fixedPoint'\nimport { getRPC } from '../../config/constants/networks'\nimport { getTokenProgramForMint } from '../../utils/solanaAtaHelper'\nimport { getAssociatedTokenAddress } from '@solana/spl-token'\n\n// Use devnet or your custom cluster URL\nexport const getTokenBalanceSolana = async (\n currency: 'NATIVE' | Token | null,\n account: string | null,\n): Promise<string | null> => {\n if (!account || !currency) return null\n\n const connection = new Connection(getRPC(ChainId.SOL), 'confirmed')\n const userPubkey = new PublicKey(account)\n\n try {\n if (currency === 'NATIVE') {\n const lamports = await connection.getBalance(userPubkey)\n return formatUnits(lamports, 9)\n } else {\n const mint = new PublicKey(currency?.address?.[ChainId.SOL] as string)\n // Detect token program to get correct ATA (supports Token-2022)\n const tokenProgram = await getTokenProgramForMint(connection, mint)\n const ata = await getAssociatedTokenAddress(mint, userPubkey, true, tokenProgram)\n if (!ata) return '0'\n const tokenAccount = await getAccount(connection, ata, undefined, tokenProgram)\n return formatUnits(tokenAccount.amount.toString(), currency?.decimals?.[ChainId.SOL] as number)\n }\n } catch {\n // If account doesn't exist (e.g. never received that token)\n return '0'\n }\n}\n"],"names":[],"mappings":";;;;;;;AAQA;AACO,MAAM,qBAAqB,GAAG,OACnC,QAAiC,EACjC,OAAsB,KACI;AAC1B,IAAA,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,IAAI;AAEtC,IAAA,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;AACnE,IAAA,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC;AAEzC,IAAA,IAAI;AACF,QAAA,IAAI,QAAQ,KAAK,QAAQ,EAAE;YACzB,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC;AACxD,YAAA,OAAO,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjC;aAAO;AACL,YAAA,MAAM,IAAI,GAAG,IAAI,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAW,CAAC;;YAEtE,MAAM,YAAY,GAAG,MAAM,sBAAsB,CAAC,UAAU,EAAE,IAAI,CAAC;AACnE,YAAA,MAAM,GAAG,GAAG,MAAM,yBAAyB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,CAAC;AACjF,YAAA,IAAI,CAAC,GAAG;AAAE,gBAAA,OAAO,GAAG;AACpB,YAAA,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC;AAC/E,YAAA,OAAO,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAW,CAAC;QACjG;IACF;AAAE,IAAA,MAAM;;AAEN,QAAA,OAAO,GAAG;IACZ;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrencyBalanceSui.js","sources":["../../../src/state/balance/useCurrencyBalanceSui.ts"],"sourcesContent":["// Sui balance reads — mirrors useCurrencyBalanceAptos.ts\n\nimport { ChainId, Token } from '@ape.swap/apeswap-lists'\nimport { getSuiClient } from '../../utils/suiHelpers'\nimport { formatUnits } from '../../utils/fixedPoint'\n\nconst SUI_KEY = ChainId.SUI\nconst SUI_NATIVE_COIN_TYPE = '0x2::sui::SUI'\nconst SUI_NATIVE_DECIMALS = 9\n\n/**\n * Single-token balance read for Sui.\n * Used by `useCurrencyBalance` when `chainId === ChainId.SUI`.\n */\nexport const getTokenBalanceSui = async (\n currency: 'NATIVE' | Token | null,\n account: string | null,\n): Promise<string | null> => {\n if (!account || !currency) return null\n\n const coinType = currency === 'NATIVE' ? SUI_NATIVE_COIN_TYPE : currency.address[SUI_KEY]\n if (!coinType) return '0'\n\n const decimals = currency === 'NATIVE' ? SUI_NATIVE_DECIMALS : (currency.decimals?.[SUI_KEY] ?? 9)\n\n try {\n const client = getSuiClient()\n const result = await client.getBalance({ owner: account, coinType })\n return formatUnits(result.totalBalance, decimals)\n } catch {\n return '0'\n }\n}\n\n/**\n * Multi-token balance read for Sui.\n * Used by `useUserTokensBalance` when `chainId === ChainId.SUI`.\n */\nexport const getTokensBalanceSui = async (\n account: string,\n tokens: ('NATIVE' | Token)[],\n): Promise<{ address: string; balance: string }[]> => {\n return Promise.all(\n tokens.map(async (token) => {\n const address = token === 'NATIVE' ? 'NATIVE' : ((token as Token).address[SUI_KEY] as string)\n const balance = await getTokenBalanceSui(token, account)\n return { address, balance: balance ?? '0' }\n }),\n )\n}\n"],"names":[],"mappings":";;;;AAAA;AAMA,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG;AAC3B,MAAM,oBAAoB,GAAG,eAAe;AAC5C,MAAM,mBAAmB,GAAG,CAAC;AAE7B;;;AAGG;AACI,MAAM,kBAAkB,GAAG,OAChC,QAAiC,EACjC,OAAsB,KACI;AAC1B,IAAA,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,IAAI;AAEtC,IAAA,MAAM,QAAQ,GAAG,QAAQ,KAAK,QAAQ,GAAG,oBAAoB,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;AACzF,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,GAAG;IAEzB,MAAM,QAAQ,GAAG,QAAQ,KAAK,QAAQ,GAAG,mBAAmB,IAAI,QAAQ,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAElG,IAAA,IAAI;AACF,QAAA,MAAM,MAAM,GAAG,YAAY,EAAE;AAC7B,QAAA,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;QACpE,OAAO,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC;IACnD;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,GAAG;IACZ;AACF;AAEA;;;AAGG;AACI,MAAM,mBAAmB,GAAG,OACjC,OAAe,EACf,MAA4B,KACuB;AACnD,IAAA,OAAO,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,GAAG,CAAC,OAAO,KAAK,KAAI;AACzB,QAAA,MAAM,OAAO,GAAG,KAAK,KAAK,QAAQ,GAAG,QAAQ,GAAK,KAAe,CAAC,OAAO,CAAC,OAAO,CAAY;QAC7F,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC;QACxD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE;IAC7C,CAAC,CAAC,CACH;AACH;;;;"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BillsConfig, ChainId } from '@ape.swap/apeswap-lists';
|
|
2
|
-
import { TokenPrices } from '../../tokenPrices/useTokenPrices';
|
|
3
|
-
import { BondsData } from '../../../types/bonds';
|
|
4
|
-
export declare const cleanBillsData: (billIds: number[], chunkedBills: any[], chainId: ChainId, bills: BillsConfig[], tokenPrices?: TokenPrices[]) => Promise<BondsData[]>;
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { ChainId, BillVersion } from '@ape.swap/apeswap-lists';
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import { getBalanceNumber } from '../../../utils/getBalanceNumber.js';
|
|
4
|
-
import { calculateTrueBondPrice } from '../../../utils/calculateSolanaTrueBillPrice.js';
|
|
5
|
-
import { TIER_MAPPING } from '../../tiers/useTierPoints.js';
|
|
6
|
-
import { formatUnits, mulDivRound, parseUnits } from '../../../utils/fixedPoint.js';
|
|
7
|
-
import { PRICE_API_URL } from '../../../config/constants/variables.js';
|
|
8
|
-
|
|
9
|
-
const cleanBillsData = async (billIds, chunkedBills, chainId, bills, tokenPrices) => {
|
|
10
|
-
const data = await Promise.all(chunkedBills?.map(async (chunk, index) => {
|
|
11
|
-
const bill = bills?.find((bill) => bill?.index === billIds[index]);
|
|
12
|
-
let principalTokenPrice = tokenPrices?.find((tokenPrice) => tokenPrice?.tokenAddress?.toLowerCase() === bill?.lpToken?.address?.[bill?.chainId]?.toLowerCase() &&
|
|
13
|
-
tokenPrice?.chainId === chainId);
|
|
14
|
-
if (principalTokenPrice === undefined || !!principalTokenPrice.error) {
|
|
15
|
-
try {
|
|
16
|
-
// Missing token price, therefor make a single call to api to fetch it
|
|
17
|
-
const res = await axios.get(`${PRICE_API_URL}/realtime/price?token=${bill?.lpToken?.address?.[bill?.chainId]}&chain=${bill?.chainId}`);
|
|
18
|
-
console.log('Individual call for: ', bill.lpToken.symbol, '. Price: ', res.data.price);
|
|
19
|
-
principalTokenPrice = res.data;
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
console.error('Failed to fetch price for: ', bill.lpToken.symbol);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
let payoutTokenPrice = tokenPrices?.find((tokenPrice) => tokenPrice?.tokenAddress?.toLowerCase() === bill?.earnToken?.address?.[bill?.chainId]?.toLowerCase() &&
|
|
26
|
-
tokenPrice?.chainId === chainId);
|
|
27
|
-
if (payoutTokenPrice === undefined || !!payoutTokenPrice.error) {
|
|
28
|
-
try {
|
|
29
|
-
// Missing token price, therefor make a single call to api to fetch it
|
|
30
|
-
const res = await axios.get(`${PRICE_API_URL}/realtime/price?token=${bill?.earnToken?.address?.[bill?.chainId]}&chain=${bill?.chainId}`);
|
|
31
|
-
console.log('Individual call for: ', bill.earnToken.symbol, '. Price: ', res.data.price);
|
|
32
|
-
payoutTokenPrice = res.data;
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
console.error('Failed to fetch price for: ', bill.earnToken.symbol);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const lpPrice = principalTokenPrice?.price ?? 0;
|
|
39
|
-
const earnTokenPrice = payoutTokenPrice?.price ?? 0;
|
|
40
|
-
const [trueBillPriceFromChunk, totalPayoutGiven, terms, maxTotalPayout, feeInPayoutRaw, feeInPrincipalRaw, paused, , customTreasuryBalance, bondPricing, bondTerms,] = chunk;
|
|
41
|
-
let trueBillPrice = trueBillPriceFromChunk;
|
|
42
|
-
const feeInPayout = Number(feeInPayoutRaw / 10000);
|
|
43
|
-
const feeInPrincipal = Number(feeInPrincipalRaw / 10000);
|
|
44
|
-
const tierBoostRate = bill.tierBoostRate === undefined ? 1 : bill.tierBoostRate;
|
|
45
|
-
const [, vestingTerm, , maxPayout] = terms;
|
|
46
|
-
const tokensRemaining = Number(formatUnits(BigInt(maxTotalPayout ?? '0') - BigInt(totalPayoutGiven), bill?.earnToken.decimals[bill?.chainId] ?? 18));
|
|
47
|
-
const treasuryBalance = customTreasuryBalance
|
|
48
|
-
? getBalanceNumber(customTreasuryBalance, bill?.earnToken?.decimals?.[bill?.chainId] ?? 18)
|
|
49
|
-
: null;
|
|
50
|
-
if (chainId === ChainId.SOL) {
|
|
51
|
-
const principalDecimals = bill?.lpToken.decimals[ChainId.SOL];
|
|
52
|
-
const payoutDecimals = bill?.earnToken.decimals[ChainId.SOL];
|
|
53
|
-
const timeStamp = Math.floor(Date.now() / 1000);
|
|
54
|
-
trueBillPrice = calculateTrueBondPrice(bondPricing, bondTerms, timeStamp, principalDecimals, payoutDecimals, feeInPrincipal);
|
|
55
|
-
}
|
|
56
|
-
let trueBondPrices = [];
|
|
57
|
-
if (bill?.billVersion === BillVersion.V4) {
|
|
58
|
-
trueBondPrices = trueBillPrice[0].map((data) => {
|
|
59
|
-
return {
|
|
60
|
-
points: data?.points?.toString(),
|
|
61
|
-
trueBondPrice: data?.trueBondPrice.toString(),
|
|
62
|
-
discount: getRawDiscount(data?.trueBondPrice.toString(), lpPrice, earnTokenPrice),
|
|
63
|
-
bonus: getRawBonus(data?.trueBondPrice.toString(), lpPrice, earnTokenPrice),
|
|
64
|
-
discountWithFee: getDiscountWithFee(feeInPayout, tierBoostRate, data?.trueBondPrice.toString(), lpPrice, earnTokenPrice),
|
|
65
|
-
bonusWithFee: getBonusWithFee(feeInPayout, tierBoostRate, data?.trueBondPrice.toString(), lpPrice, earnTokenPrice),
|
|
66
|
-
boost: TIER_MAPPING[data?.points?.toString()],
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
const bonus = getRawBonus(trueBillPrice, lpPrice, earnTokenPrice);
|
|
72
|
-
const bonusWithFee = getBonusWithFee(feeInPayout, tierBoostRate, trueBillPrice, lpPrice, earnTokenPrice);
|
|
73
|
-
const discount = getRawDiscount(trueBillPrice, lpPrice, earnTokenPrice);
|
|
74
|
-
const discountWithFee = getDiscountWithFee(feeInPayout, tierBoostRate, trueBillPrice, lpPrice, earnTokenPrice);
|
|
75
|
-
trueBondPrices = [
|
|
76
|
-
{
|
|
77
|
-
points: '0',
|
|
78
|
-
boost: 0,
|
|
79
|
-
trueBondPrice: trueBillPrice.toString(),
|
|
80
|
-
bonus,
|
|
81
|
-
bonusWithFee,
|
|
82
|
-
discount,
|
|
83
|
-
discountWithFee,
|
|
84
|
-
},
|
|
85
|
-
];
|
|
86
|
-
}
|
|
87
|
-
const cleanedData = {
|
|
88
|
-
...bill,
|
|
89
|
-
soldOut: paused[0] ? true : bill.soldOut,
|
|
90
|
-
feeInPayout,
|
|
91
|
-
feeInPrincipal,
|
|
92
|
-
showcaseTokenName: bill?.showcaseToken?.symbol ?? bill?.earnToken.symbol ?? '',
|
|
93
|
-
trueBondPrices,
|
|
94
|
-
principalTokenPrice: lpPrice?.toString(),
|
|
95
|
-
payoutTokenPrice: earnTokenPrice?.toString(),
|
|
96
|
-
tokensRemaining: treasuryBalance !== null ? Math.min(treasuryBalance, tokensRemaining).toString() : tokensRemaining.toString(),
|
|
97
|
-
maxTotalPayout: maxTotalPayout?.toString(),
|
|
98
|
-
maxPayout: maxPayout?.toString(),
|
|
99
|
-
totalPayoutGiven: totalPayoutGiven?.toString(),
|
|
100
|
-
vestingTerm: typeof vestingTerm === 'number' ? vestingTerm : parseInt(vestingTerm),
|
|
101
|
-
tierBoostRate: bill.tierBoostRate === undefined ? 1 : bill.tierBoostRate,
|
|
102
|
-
};
|
|
103
|
-
return cleanedData;
|
|
104
|
-
}));
|
|
105
|
-
return data;
|
|
106
|
-
};
|
|
107
|
-
// Scale used to carry percentage ratios (tier boost, reverse fee) into integer math
|
|
108
|
-
// alongside the wei-scale `trueBillPrice`, so the huge integer never round-trips through
|
|
109
|
-
// a JS float before the final getBalanceNumber() conversion.
|
|
110
|
-
const RATIO_SCALE = 1000000000000n; // 1e12
|
|
111
|
-
const scaleRatio = (ratio) => parseUnits(ratio.toString(), 12);
|
|
112
|
-
const getBonusWithFee = (feeInPayout, tierBoostRate, trueBillPrice, lpPrice, earnTokenPrice) => {
|
|
113
|
-
const fee = feeInPayout ?? 0;
|
|
114
|
-
const reverseFee = fee / 100 / (1 - fee / 100);
|
|
115
|
-
const trueBillPriceBig = BigInt(trueBillPrice);
|
|
116
|
-
const tierAdjusted = mulDivRound(trueBillPriceBig, scaleRatio((100 + tierBoostRate) / 100), RATIO_SCALE);
|
|
117
|
-
const feeAdjusted = mulDivRound(trueBillPriceBig, scaleRatio(reverseFee), RATIO_SCALE);
|
|
118
|
-
const trueBondPrice = tierAdjusted + feeAdjusted;
|
|
119
|
-
const priceUSDMinusFee = getBalanceNumber(trueBondPrice) * lpPrice;
|
|
120
|
-
const bonusWithoutFee = ((earnTokenPrice - priceUSDMinusFee) / earnTokenPrice) * 100;
|
|
121
|
-
const validatedBonus = bonusWithoutFee > 0 ? (bonusWithoutFee / (100 - bonusWithoutFee)) * 100 : 0;
|
|
122
|
-
return validatedBonus;
|
|
123
|
-
};
|
|
124
|
-
const getRawBonus = (trueBillPrice, lpPrice, earnTokenPrice) => {
|
|
125
|
-
const priceUsd = getBalanceNumber(trueBillPrice.toString()) * lpPrice;
|
|
126
|
-
const discount = ((earnTokenPrice - priceUsd) / earnTokenPrice) * 100;
|
|
127
|
-
return discount > 0 ? (discount / (100 - discount)) * 100 : 0;
|
|
128
|
-
};
|
|
129
|
-
const getRawDiscount = (trueBillPrice, lpPrice, earnTokenPrice) => {
|
|
130
|
-
const trueBondPrice = getBalanceNumber(trueBillPrice.toString());
|
|
131
|
-
return ((earnTokenPrice - lpPrice * trueBondPrice) / earnTokenPrice) * 100;
|
|
132
|
-
};
|
|
133
|
-
const getDiscountWithFee = (feeInPayout, tierBoostRate, trueBillPrice, lpPrice, earnTokenPrice) => {
|
|
134
|
-
const trueBondPrice = getBalanceNumber(trueBillPrice.toString());
|
|
135
|
-
const trueBondPriceWithFee = trueBondPrice * (1 / ((100 - (feeInPayout ?? 0)) / 100));
|
|
136
|
-
const discount = ((earnTokenPrice - lpPrice * trueBondPriceWithFee) / earnTokenPrice) * 100;
|
|
137
|
-
const discountToReturn = 100 - ((100 - discount) / (100 - tierBoostRate)) * 100;
|
|
138
|
-
return discountToReturn;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export { cleanBillsData };
|
|
142
|
-
//# sourceMappingURL=cleanBillsData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cleanBillsData.js","sources":["../../../../src/state/bonds/fetchBondsData/cleanBillsData.ts"],"sourcesContent":["import { BillsConfig, BillVersion, ChainId } from '@ape.swap/apeswap-lists'\nimport { TokenPrices } from '../../tokenPrices/useTokenPrices'\nimport { BondsData, TrueBondPrices } from '../../../types/bonds'\nimport axios from 'axios'\nimport { getBalanceNumber } from '../../../utils/getBalanceNumber'\nimport { calculateTrueBondPrice } from '../../../utils/calculateSolanaTrueBillPrice'\nimport { TIER_MAPPING } from '../../tiers/useTierPoints'\nimport { formatUnits, mulDivRound, parseUnits } from '../../../utils/fixedPoint'\nimport { PRICE_API_URL } from '../../../config/constants/variables'\n\nexport const cleanBillsData = async (\n billIds: number[],\n chunkedBills: any[],\n chainId: ChainId,\n bills: BillsConfig[],\n tokenPrices?: TokenPrices[],\n): Promise<BondsData[]> => {\n const data: BondsData[] = await Promise.all(\n chunkedBills?.map(async (chunk, index) => {\n const bill = bills?.find((bill) => bill?.index === billIds[index]) as BillsConfig\n\n let principalTokenPrice = tokenPrices?.find(\n (tokenPrice) =>\n tokenPrice?.tokenAddress?.toLowerCase() === bill?.lpToken?.address?.[bill?.chainId]?.toLowerCase() &&\n tokenPrice?.chainId === chainId,\n )\n\n if (principalTokenPrice === undefined || !!principalTokenPrice.error) {\n try {\n // Missing token price, therefor make a single call to api to fetch it\n const res = await axios.get(\n `${PRICE_API_URL}/realtime/price?token=${bill?.lpToken?.address?.[bill?.chainId]}&chain=${bill?.chainId}`,\n )\n console.log('Individual call for: ', bill.lpToken.symbol, '. Price: ', res.data.price)\n principalTokenPrice = res.data\n } catch {\n console.error('Failed to fetch price for: ', bill.lpToken.symbol)\n }\n }\n\n let payoutTokenPrice = tokenPrices?.find(\n (tokenPrice) =>\n tokenPrice?.tokenAddress?.toLowerCase() === bill?.earnToken?.address?.[bill?.chainId]?.toLowerCase() &&\n tokenPrice?.chainId === chainId,\n )\n\n if (payoutTokenPrice === undefined || !!payoutTokenPrice.error) {\n try {\n // Missing token price, therefor make a single call to api to fetch it\n const res = await axios.get(\n `${PRICE_API_URL}/realtime/price?token=${bill?.earnToken?.address?.[bill?.chainId]}&chain=${bill?.chainId}`,\n )\n console.log('Individual call for: ', bill.earnToken.symbol, '. Price: ', res.data.price)\n payoutTokenPrice = res.data\n } catch {\n console.error('Failed to fetch price for: ', bill.earnToken.symbol)\n }\n }\n const lpPrice = principalTokenPrice?.price ?? 0\n const earnTokenPrice = payoutTokenPrice?.price ?? 0\n\n const [\n trueBillPriceFromChunk,\n totalPayoutGiven,\n terms,\n maxTotalPayout,\n feeInPayoutRaw,\n feeInPrincipalRaw,\n paused,\n ,\n customTreasuryBalance,\n bondPricing,\n bondTerms,\n ] = chunk\n let trueBillPrice = trueBillPriceFromChunk\n\n const feeInPayout = Number(feeInPayoutRaw / 10000)\n const feeInPrincipal = Number(feeInPrincipalRaw / 10000)\n const tierBoostRate = bill.tierBoostRate === undefined ? 1 : bill.tierBoostRate\n const [, vestingTerm, , maxPayout] = terms\n const tokensRemaining = Number(\n formatUnits(\n BigInt(maxTotalPayout ?? '0') - BigInt(totalPayoutGiven),\n bill?.earnToken.decimals[bill?.chainId] ?? 18,\n ),\n )\n const treasuryBalance = customTreasuryBalance\n ? getBalanceNumber(customTreasuryBalance, bill?.earnToken?.decimals?.[bill?.chainId] ?? 18)\n : null\n\n if (chainId === ChainId.SOL) {\n const principalDecimals = bill?.lpToken.decimals[ChainId.SOL] as number\n const payoutDecimals = bill?.earnToken.decimals[ChainId.SOL] as number\n const timeStamp = Math.floor(Date.now() / 1000)\n trueBillPrice = calculateTrueBondPrice(\n bondPricing,\n bondTerms,\n timeStamp,\n principalDecimals,\n payoutDecimals,\n feeInPrincipal,\n )\n }\n\n let trueBondPrices: TrueBondPrices[] = []\n if (bill?.billVersion === BillVersion.V4) {\n trueBondPrices = trueBillPrice[0].map((data: any) => {\n return {\n points: data?.points?.toString(),\n trueBondPrice: data?.trueBondPrice.toString(),\n discount: getRawDiscount(data?.trueBondPrice.toString(), lpPrice, earnTokenPrice),\n bonus: getRawBonus(data?.trueBondPrice.toString(), lpPrice, earnTokenPrice),\n discountWithFee: getDiscountWithFee(\n feeInPayout,\n tierBoostRate,\n data?.trueBondPrice.toString(),\n lpPrice,\n earnTokenPrice,\n ),\n bonusWithFee: getBonusWithFee(\n feeInPayout,\n tierBoostRate,\n data?.trueBondPrice.toString(),\n lpPrice,\n earnTokenPrice,\n ),\n boost: TIER_MAPPING[data?.points?.toString() as keyof typeof TIER_MAPPING],\n }\n })\n } else {\n const bonus = getRawBonus(trueBillPrice, lpPrice, earnTokenPrice)\n const bonusWithFee = getBonusWithFee(feeInPayout, tierBoostRate, trueBillPrice, lpPrice, earnTokenPrice)\n const discount = getRawDiscount(trueBillPrice, lpPrice, earnTokenPrice)\n const discountWithFee = getDiscountWithFee(feeInPayout, tierBoostRate, trueBillPrice, lpPrice, earnTokenPrice)\n trueBondPrices = [\n {\n points: '0',\n boost: 0,\n trueBondPrice: trueBillPrice.toString(),\n bonus,\n bonusWithFee,\n discount,\n discountWithFee,\n },\n ]\n }\n const cleanedData: BondsData = {\n ...bill,\n soldOut: paused[0] ? true : bill.soldOut,\n feeInPayout,\n feeInPrincipal,\n showcaseTokenName: bill?.showcaseToken?.symbol ?? bill?.earnToken.symbol ?? '',\n trueBondPrices,\n principalTokenPrice: lpPrice?.toString(),\n payoutTokenPrice: earnTokenPrice?.toString(),\n tokensRemaining:\n treasuryBalance !== null ? Math.min(treasuryBalance, tokensRemaining).toString() : tokensRemaining.toString(),\n maxTotalPayout: maxTotalPayout?.toString(),\n maxPayout: maxPayout?.toString(),\n totalPayoutGiven: totalPayoutGiven?.toString(),\n vestingTerm: typeof vestingTerm === 'number' ? vestingTerm : parseInt(vestingTerm),\n tierBoostRate: bill.tierBoostRate === undefined ? 1 : bill.tierBoostRate,\n }\n return cleanedData\n }),\n )\n return data\n}\n\n// Scale used to carry percentage ratios (tier boost, reverse fee) into integer math\n// alongside the wei-scale `trueBillPrice`, so the huge integer never round-trips through\n// a JS float before the final getBalanceNumber() conversion.\nconst RATIO_SCALE = 1_000_000_000_000n // 1e12\nconst scaleRatio = (ratio: number): bigint => parseUnits(ratio.toString(), 12)\n\nconst getBonusWithFee = (\n feeInPayout: number,\n tierBoostRate: number,\n trueBillPrice: string,\n lpPrice: number,\n earnTokenPrice: number,\n) => {\n const fee = feeInPayout ?? 0\n const reverseFee = fee / 100 / (1 - fee / 100)\n const trueBillPriceBig = BigInt(trueBillPrice)\n const tierAdjusted = mulDivRound(trueBillPriceBig, scaleRatio((100 + tierBoostRate) / 100), RATIO_SCALE)\n const feeAdjusted = mulDivRound(trueBillPriceBig, scaleRatio(reverseFee), RATIO_SCALE)\n const trueBondPrice = tierAdjusted + feeAdjusted\n const priceUSDMinusFee = getBalanceNumber(trueBondPrice) * lpPrice\n const bonusWithoutFee = ((earnTokenPrice - priceUSDMinusFee) / earnTokenPrice) * 100\n const validatedBonus = bonusWithoutFee > 0 ? (bonusWithoutFee / (100 - bonusWithoutFee)) * 100 : 0\n return validatedBonus\n}\n\nconst getRawBonus = (trueBillPrice: any, lpPrice: number, earnTokenPrice: number) => {\n const priceUsd = getBalanceNumber(trueBillPrice.toString()) * lpPrice\n const discount: number = ((earnTokenPrice - priceUsd) / earnTokenPrice) * 100\n return discount > 0 ? (discount / (100 - discount)) * 100 : 0\n}\n\nconst getRawDiscount = (trueBillPrice: any, lpPrice: number, earnTokenPrice: number) => {\n const trueBondPrice = getBalanceNumber(trueBillPrice.toString())\n\n return ((earnTokenPrice - lpPrice * trueBondPrice) / earnTokenPrice) * 100\n}\n\nconst getDiscountWithFee = (\n feeInPayout: number,\n tierBoostRate: number,\n trueBillPrice: any,\n lpPrice: number,\n earnTokenPrice: number,\n) => {\n const trueBondPrice = getBalanceNumber(trueBillPrice.toString())\n const trueBondPriceWithFee = trueBondPrice * (1 / ((100 - (feeInPayout ?? 0)) / 100))\n const discount = ((earnTokenPrice - lpPrice * trueBondPriceWithFee) / earnTokenPrice) * 100\n const discountToReturn = 100 - ((100 - discount) / (100 - tierBoostRate)) * 100\n return discountToReturn\n}\n"],"names":[],"mappings":";;;;;;;;AAUO,MAAM,cAAc,GAAG,OAC5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;AAC5E,CAAC;AAED,MAAM,kBAAkB,GAAG,CACzB,WAAmB,EACnB,aAAqB,EACrB,aAAkB,EAClB,OAAe,EACf,cAAsB,KACpB;IACF,MAAM,aAAa,GAAG,gBAAgB,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IAChE,MAAM,oBAAoB,GAAG,aAAa,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,WAAW,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;AACrF,IAAA,MAAM,QAAQ,GAAG,CAAC,CAAC,cAAc,GAAG,OAAO,GAAG,oBAAoB,IAAI,cAAc,IAAI,GAAG;AAC3F,IAAA,MAAM,gBAAgB,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,QAAQ,KAAK,GAAG,GAAG,aAAa,CAAC,IAAI,GAAG;AAC/E,IAAA,OAAO,gBAAgB;AACzB,CAAC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchBondsDataAptos.js","sources":["../../../../src/state/bonds/fetchBondsData/fetchBondsDataAptos.ts"],"sourcesContent":["// =============================================================================\n// Aptos bond enrichment — builds BondsData[] from BillsConfig[] + prices\n// =============================================================================\n//\n// On-chain first: reads bond::market_info via view function for each config\n// and projects the tuple onto BondsData. No backend dependency (realtime-api\n// does not support Aptos).\n\nimport { BillsConfig, ChainId } from '@ape.swap/apeswap-lists'\nimport { BondsData } from '../../../types/bonds'\nimport { TokenPrices } from '../../tokenPrices/useTokenPrices'\nimport { readAptosMarketInfo } from '../../../utils/aptosHelpers'\nimport { formatUnits } from '../../../utils/fixedPoint'\nimport axios from 'axios'\nimport { PRICE_API_URL } from '../../../config/constants/variables'\n\nconst APTOS_KEY = ChainId.APTOS\n\n/**\n * Enrich Aptos bond configs into full BondsData objects.\n *\n * Calls `bond::market_info(market)` for each config and projects the tuple\n * onto BondsData. Scale conversion: contract returns `true_bill_price` as u64\n * scaled by PRICE_DECIMALS = 1e8; the SDK stores `trueBondPrice` scaled by\n * 1e18 (legacy EVM format) → multiply by 1e10.\n */\nexport const fetchBondsDataAptos = async (bonds?: BillsConfig[], aptosPrices?: TokenPrices[]): Promise<BondsData[]> => {\n const aptosConfigs = bonds?.filter((b) => !b.soldOut)\n if (!aptosConfigs || aptosConfigs?.length === 0) return []\n\n const enriched = await Promise.all(\n aptosConfigs.map(async (bond): Promise<BondsData | null> => {\n const marketAddr = bond.contractAddress[APTOS_KEY]\n if (!marketAddr) return null\n try {\n // Firstly we fetch prices\n let principalPrice = aptosPrices?.find((t) => t.tokenAddress.toLowerCase() === principalAddr)?.price!\n if (principalPrice === undefined) {\n try {\n const res = await axios.get(\n `${PRICE_API_URL}/realtime/price?token=${bond?.lpToken?.address?.[bond?.chainId]}&chain=${bond?.chainId}`,\n )\n principalPrice = res.data.price ?? 0\n } catch {\n principalPrice = 0\n }\n }\n\n let payoutPrice = aptosPrices?.find((t) => t.tokenAddress.toLowerCase() === payoutAddr)?.price!\n if (payoutPrice === undefined) {\n try {\n // Missing token price, therefor make a single call to api to fetch it\n const res = await axios.get(\n `${PRICE_API_URL}/realtime/price?token=${bond?.earnToken?.address?.[bond?.chainId]}&chain=${bond?.chainId}`,\n )\n payoutPrice = res.data.price ?? 0\n } catch {\n payoutPrice = 0\n }\n }\n\n const info = await readAptosMarketInfo(marketAddr)\n const principalAddr = bond.lpToken.address[APTOS_KEY]?.toLowerCase()\n const payoutAddr = bond.earnToken.address[APTOS_KEY]?.toLowerCase()\n\n // Convert on-chain u64 (scaled 1e8) to the SDK's legacy 1e18 scale\n const trueBillPriceU64 = info[17]\n const trueBondPriceScaled = (BigInt(trueBillPriceU64) * 10n ** 10n).toString()\n const trueBondPriceHuman = Number(trueBillPriceU64) / 1e8\n\n // Same formula as getRawDiscount / getRawBonus in state/bonds/utils.ts\n const discount = payoutPrice > 0 ? ((payoutPrice - principalPrice * trueBondPriceHuman) / payoutPrice) * 100 : 0\n const bonus = discount > 0 && discount < 100 ? (discount / (100 - discount)) * 100 : 0\n\n // Fees: u64 in PERCENTAGE_BASE (1e6) → divide by 10_000 for human %\n const feeInPayout = Number(info[14]) / 10_000\n const feeInPrincipal = Number(info[13]) / 10_000\n const trueBondPriceWithFee =\n feeInPayout < 100 ? trueBondPriceHuman * (1 / ((100 - feeInPayout) / 100)) : trueBondPriceHuman\n const discountWithFee =\n payoutPrice > 0 ? ((payoutPrice - principalPrice * trueBondPriceWithFee) / payoutPrice) * 100 : 0\n const bonusWithFee =\n discountWithFee > 0 && discountWithFee < 100 ? (discountWithFee / (100 - discountWithFee)) * 100 : 0\n\n const payoutDecimals = bond.earnToken.decimals[APTOS_KEY] ?? 8\n const tokensRemaining = formatUnits(BigInt(info[23]) - BigInt(info[5]), payoutDecimals)\n\n return {\n ...bond,\n soldOut: info[2] || info[3] ? true : bond.soldOut,\n maxTotalPayout: String(info[23]),\n totalPayoutGiven: String(info[5]),\n maxPayout: String(info[21]),\n tokensRemaining,\n showcaseTokenName: bond.earnToken.symbol,\n vestingTerm: Number(info[19]),\n feeInPayout,\n feeInPrincipal,\n trueBondPrices: [\n {\n trueBondPrice: trueBondPriceScaled,\n points: '0',\n discount,\n discountWithFee,\n bonus,\n bonusWithFee,\n boost: 0,\n },\n ],\n principalTokenPrice: principalPrice.toString(),\n payoutTokenPrice: payoutPrice.toString(),\n }\n } catch (e) {\n console.warn(`[Aptos] Failed to read market_info for ${marketAddr}`, e)\n // Hide the bond from the list when on-chain data is unavailable —\n // showing a card with all zeros is confusing for users.\n return null\n }\n }),\n )\n return enriched.filter((b): b is BondsData => b !== null)\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK;AAE/B;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAAG,OAAO,KAAqB,EAAE,WAA2B,KAA0B;AACpH,IAAA,MAAM,YAAY,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,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;AACD,gBAAA,mBAAmB,EAAE,cAAc,CAAC,QAAQ,EAAE;AAC9C,gBAAA,gBAAgB,EAAE,WAAW,CAAC,QAAQ,EAAE;aACzC;QACH;QAAE,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,CAAA,uCAAA,EAA0C,UAAU,CAAA,CAAE,EAAE,CAAC,CAAC;;;AAGvE,YAAA,OAAO,IAAI;QACb;IACF,CAAC,CAAC,CACH;AACD,IAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAqB,CAAC,KAAK,IAAI,CAAC;AAC3D;;;;"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { BillVersion } from '@ape.swap/apeswap-lists';
|
|
2
|
-
import multicall from '../../../utils/multicall.js';
|
|
3
|
-
import BOND_ABI from '../../../config/abi/BOND_2_4_0.json.js';
|
|
4
|
-
import erc20ABI from '../../../config/abi/erc20.json.js';
|
|
5
|
-
import chunk from 'lodash-es/chunk.js';
|
|
6
|
-
import { cleanBillsData } from './cleanBillsData.js';
|
|
7
|
-
|
|
8
|
-
const fetchBondsDataEVM = async (chainId, bonds, apiUrl, tokenPrices) => {
|
|
9
|
-
try {
|
|
10
|
-
const bills = bonds.filter((b) => !b.soldOut);
|
|
11
|
-
const billIds = [];
|
|
12
|
-
const billCalls = bills.flatMap((bill) => {
|
|
13
|
-
billIds.push(bill.index);
|
|
14
|
-
return [
|
|
15
|
-
{
|
|
16
|
-
address: bill.contractAddress[bill.chainId] ?? '',
|
|
17
|
-
name: bill.billVersion === BillVersion.V4 ? 'trueBondPrices' : 'trueBillPrice()',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
address: bill.contractAddress[bill.chainId] ?? '',
|
|
21
|
-
name: 'totalPayoutGiven',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
address: bill.contractAddress[bill.chainId] ?? '',
|
|
25
|
-
name: 'terms',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
address: bill.contractAddress[bill.chainId] ?? '',
|
|
29
|
-
name: bill.billVersion !== BillVersion.V1 ? 'getMaxTotalPayout' : 'maxTotalPayout',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
address: bill.contractAddress[bill.chainId] ?? '',
|
|
33
|
-
name: 'feeInPayout',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
address: bill.contractAddress[bill.chainId] ?? '',
|
|
37
|
-
name: 'feeInPrincipal',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
address: bill.contractAddress[bill.chainId] ?? '',
|
|
41
|
-
name: 'paused',
|
|
42
|
-
},
|
|
43
|
-
// keep custom treasury at the very last position
|
|
44
|
-
{
|
|
45
|
-
address: bill.contractAddress[bill.chainId] ?? '',
|
|
46
|
-
name: 'customTreasury',
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
});
|
|
50
|
-
const vals = await multicall(chainId, BOND_ABI, billCalls);
|
|
51
|
-
// The following lines basically grab the values from customTreasury returned from bills contract and then,
|
|
52
|
-
// appends the treasury contract's balance to the chunk that will be passed to cleanBillsData
|
|
53
|
-
// appendIndex value assumes customTreasury will be at the end of the billCalls array
|
|
54
|
-
const appendIndex = billCalls.length / bills.length;
|
|
55
|
-
const treasuryAddresses = vals
|
|
56
|
-
.filter((_, i) => (i % appendIndex) + 1 === appendIndex)
|
|
57
|
-
.map((customTreasury) => customTreasury[0]);
|
|
58
|
-
const treasuryBalanceCalls = treasuryAddresses.map((treasuryAddress, i) => ({
|
|
59
|
-
address: bills?.[i]?.earnToken?.address?.[chainId] ?? '',
|
|
60
|
-
name: 'balanceOf',
|
|
61
|
-
params: [treasuryAddress],
|
|
62
|
-
}));
|
|
63
|
-
const treasuryBalances = await multicall(chainId, erc20ABI, treasuryBalanceCalls);
|
|
64
|
-
const updatedVals = vals.reduce((acc, val, index) => {
|
|
65
|
-
acc.push(val);
|
|
66
|
-
if ((index + 1) % appendIndex === 0) {
|
|
67
|
-
const pos = (index + 1) / appendIndex;
|
|
68
|
-
// balanceOf has a single output, so multicall wraps it as [balance] — unwrap it
|
|
69
|
-
acc.push(treasuryBalances[pos - 1][0]);
|
|
70
|
-
}
|
|
71
|
-
return acc;
|
|
72
|
-
}, []);
|
|
73
|
-
const chunkSize = updatedVals?.length / bills?.length;
|
|
74
|
-
const chunkedBills = chunk(updatedVals, chunkSize);
|
|
75
|
-
return await cleanBillsData(billIds, chunkedBills, chainId, bills, tokenPrices);
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
console.error(e);
|
|
79
|
-
reportError({
|
|
80
|
-
apiUrl,
|
|
81
|
-
error: e,
|
|
82
|
-
extraInfo: { type: 'getBondsData', e },
|
|
83
|
-
});
|
|
84
|
-
return [];
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export { fetchBondsDataEVM };
|
|
89
|
-
//# sourceMappingURL=fetchBondsDataEVM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchBondsDataEVM.js","sources":["../../../../src/state/bonds/fetchBondsData/fetchBondsDataEVM.ts"],"sourcesContent":["import { BillsConfig, BillVersion, ChainId } from '@ape.swap/apeswap-lists'\nimport { TokenPrices } from '../../tokenPrices/useTokenPrices'\nimport multicall from '../../../utils/multicall'\nimport BOND_2_4_0 from '../../../config/abi/BOND_2_4_0.json'\nimport ERC20ABI from '../../../config/abi/erc20.json'\nimport chunk from 'lodash-es/chunk.js'\nimport { cleanBillsData } from './cleanBillsData'\n\nexport const fetchBondsDataEVM = async (\n chainId: number,\n bonds: BillsConfig[],\n apiUrl: string,\n tokenPrices?: TokenPrices[],\n) => {\n try {\n const bills = bonds.filter((b) => !b.soldOut)\n const billIds: number[] = []\n const billCalls = bills.flatMap((bill) => {\n billIds.push(bill.index)\n return [\n {\n address: bill.contractAddress[bill.chainId] ?? '',\n name: bill.billVersion === BillVersion.V4 ? 'trueBondPrices' : 'trueBillPrice()',\n },\n {\n address: bill.contractAddress[bill.chainId] ?? '',\n name: 'totalPayoutGiven',\n },\n {\n address: bill.contractAddress[bill.chainId] ?? '',\n name: 'terms',\n },\n {\n address: bill.contractAddress[bill.chainId] ?? '',\n name: bill.billVersion !== BillVersion.V1 ? 'getMaxTotalPayout' : 'maxTotalPayout',\n },\n {\n address: bill.contractAddress[bill.chainId] ?? '',\n name: 'feeInPayout',\n },\n {\n address: bill.contractAddress[bill.chainId] ?? '',\n name: 'feeInPrincipal',\n },\n {\n address: bill.contractAddress[bill.chainId] ?? '',\n name: 'paused',\n },\n // keep custom treasury at the very last position\n {\n address: bill.contractAddress[bill.chainId] ?? '',\n name: 'customTreasury',\n },\n ]\n })\n const vals = await multicall(chainId, BOND_2_4_0, billCalls)\n\n // The following lines basically grab the values from customTreasury returned from bills contract and then,\n // appends the treasury contract's balance to the chunk that will be passed to cleanBillsData\n\n // appendIndex value assumes customTreasury will be at the end of the billCalls array\n const appendIndex = billCalls.length / bills.length\n const treasuryAddresses = vals\n .filter((_: any, i: number) => (i % appendIndex) + 1 === appendIndex)\n .map((customTreasury: string[]) => customTreasury[0])\n const treasuryBalanceCalls = treasuryAddresses.map((treasuryAddress: string, i: number) => ({\n address: bills?.[i]?.earnToken?.address?.[chainId as ChainId] ?? '',\n name: 'balanceOf',\n params: [treasuryAddress],\n }))\n const treasuryBalances = await multicall(chainId, ERC20ABI, treasuryBalanceCalls)\n const updatedVals = vals.reduce((acc: any, val: any, index: number) => {\n acc.push(val)\n if ((index + 1) % appendIndex === 0) {\n const pos = (index + 1) / appendIndex\n // balanceOf has a single output, so multicall wraps it as [balance] — unwrap it\n acc.push(treasuryBalances[pos - 1][0])\n }\n return acc\n }, [])\n\n const chunkSize = updatedVals?.length / bills?.length\n const chunkedBills = chunk(updatedVals, chunkSize)\n\n return await cleanBillsData(billIds, chunkedBills, chainId, bills, tokenPrices)\n } catch (e) {\n console.error(e)\n reportError({\n apiUrl,\n error: e,\n extraInfo: { type: 'getBondsData', e },\n })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AQ,EAAE,KAAa,KAAI;AACpE,YAAA,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;YACb,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,WAAW,KAAK,CAAC,EAAE;gBACnC,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,WAAW;;AAErC,gBAAA,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC;AACA,YAAA,OAAO,GAAG;QACZ,CAAC,EAAE,EAAE,CAAC;QAEN,MAAM,SAAS,GAAG,WAAW,EAAE,MAAM,GAAG,KAAK,EAAE,MAAM;QACrD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC;AAElD,QAAA,OAAO,MAAM,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC;IACjF;IAAE,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,QAAA,WAAW,CAAC;YACV,MAAM;AACN,YAAA,KAAK,EAAE,CAAC;AACR,YAAA,SAAS,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,EAAE;AACvC,SAAA,CAAC;AACF,QAAA,OAAO,EAAE;IACX;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchBondsDataPreTGE.js","sources":["../../../../src/state/bonds/fetchBondsData/fetchBondsDataPreTGE.ts"],"sourcesContent":["import { BondsData } from '../../../types/bonds'\nimport { getBalanceNumber } from '../../../utils/getBalanceNumber'\nimport { ChainId, PreTGEConfig } from '@ape.swap/apeswap-lists'\nimport { TokenPrices } from '../../tokenPrices/useTokenPrices'\nimport multicall from '../../../utils/multicall'\nimport chunk from 'lodash-es/chunk.js'\nimport launchBondsABI_V2_4_1 from '../../../config/abi/launchBond_v2_4_1.json'\nimport Vault_Shares_ABI from '../../../config/abi/Vault_Shares.json'\nimport { reportError } from '../../../utils/reportError'\n\nexport const fetchBondsDataPreTGE = async (\n chain: number,\n tokenPrices: Partial<Record<ChainId, TokenPrices[]>>,\n preTGEBonds: PreTGEConfig[],\n apiUrl?: string,\n): Promise<BondsData[]> => {\n try {\n if (!preTGEBonds?.length) return []\n const data = []\n const chainId = chain as ChainId\n\n const preTGEBondsIds: number[] = []\n const launchBondsCalls = preTGEBonds.flatMap((bond) => {\n preTGEBondsIds.push(bond.index)\n const bill = bond\n return [\n {\n address: bill.contractAddress[bill.chainId] as string,\n name: 'trueBillPrice',\n },\n {\n address: bill.contractAddress[bill.chainId] as string,\n name: 'terms',\n },\n {\n address: bill.contractAddress[bill.chainId] as string,\n name: 'totalPrincipalBilled',\n },\n {\n address: bill.contractAddress[bill.chainId] as string,\n name: 'finalized',\n },\n {\n address: bill.contractAddress[bill.chainId] as string,\n name: 'minPoints',\n },\n {\n address: bill.contractAddress[bill.chainId] as string,\n name: 'maxPoints',\n },\n {\n address: bill.contractAddress[bill.chainId] as string,\n name: 'startVestingTimestamp',\n },\n ]\n })\n const vals = await multicall(chainId, launchBondsABI_V2_4_1, launchBondsCalls)\n const chunkSize = vals.length / preTGEBonds.length\n const chunkedBills = chunk(vals, chunkSize)\n const returnedBills = await Promise.all(\n chunkedBills?.map(async (chunk: any, index) => {\n const bondConfig = preTGEBonds?.find((bill) => bill?.index === preTGEBondsIds[index])!\n\n const [trueBillPrice, terms, totalPrincipalBilled, finalized, minPoints, maxPoints, startVestingTimestamp] =\n chunk\n const [, , vestingTerm, , , initialRelease, totalRaise, maxTotalPayout] = terms\n\n const initPrice = getBalanceNumber(\n trueBillPrice,\n bondConfig?.lpToken?.decimals?.[bondConfig?.chainId as ChainId] ?? 18,\n )\n\n const lpPrice =\n tokenPrices?.[bondConfig?.chainId]?.find(\n (tokenPrice) =>\n tokenPrice?.tokenAddress?.toLowerCase() ===\n bondConfig?.lpToken?.address?.[bondConfig?.chainId]?.toLowerCase(),\n )?.price ?? 0\n const earnTokenPrice =\n tokenPrices?.[bondConfig?.chainId]?.find(\n (tokenPrice) =>\n tokenPrice?.tokenAddress?.toLowerCase() ===\n bondConfig?.earnToken?.address?.[bondConfig?.chainId]?.toLowerCase(),\n )?.price ?? 0\n\n const principalTokenPrice = lpPrice?.toString() ?? '0'\n const payoutTokenPrice = earnTokenPrice ? earnTokenPrice?.toString() : initPrice?.toString()\n\n const bonus = Math.round((bondConfig.tgePrice! / initPrice) * 100 - 100)\n\n const endTime = parseInt(terms[0])\n const startTime = parseInt(terms[1])\n const now = Math.floor(Date.now() / 1000)\n const progress = Math.min(1, Math.max(0, (now - startTime) / (endTime - startTime)))\n const currentAPR =\n bondConfig.startAPR != null && bondConfig.endAPR != null && endTime > startTime\n ? bondConfig.startAPR + (bondConfig.endAPR - bondConfig.startAPR) * progress\n : 0\n let rewardDistributionEnd = 0\n if (bondConfig.yieldBond) {\n const calls = [\n {\n address: bondConfig.earnToken.address[bondConfig.chainId] ?? '',\n name: 'vestingEnd',\n },\n ]\n const res = await multicall(bondConfig.chainId, Vault_Shares_ABI, calls)\n rewardDistributionEnd = parseInt(res[0][0])\n }\n const data: BondsData = {\n ...bondConfig,\n initialRelease: initialRelease / 10000,\n vestingTerm: parseInt(vestingTerm),\n trueBondPrices: [\n {\n points: '0',\n boost: 0,\n trueBondPrice: trueBillPrice?.toString(),\n bonus,\n bonusWithFee: bonus, // placeholder, wont be used\n discount: bonus, // placeholder, wont be used\n discountWithFee: bonus, // placeholder, wont be used\n },\n ],\n maxTotalPayout: maxTotalPayout?.toString(),\n totalPrincipalBilled: totalPrincipalBilled?.toString(),\n payoutTokenPrice,\n principalTokenPrice,\n totalRaise: totalRaise?.toString(),\n finalized: finalized[0],\n minPoints: minPoints.toString(),\n maxPoints: maxPoints.toString(),\n startVestingTimestamp: startVestingTimestamp?.toString(),\n initTime: { [bondConfig.chainId]: parseInt(terms[1]) },\n finishTime: parseInt(terms[0]),\n initPrice,\n soldOut: finalized[0] || (parseInt(terms[0]) ?? 0) < Date.now() / 1000 || bondConfig.soldOut,\n yieldData: {\n apr: bondConfig.finalAPR || currentAPR,\n rewardDistributionEnd,\n },\n }\n return data\n }),\n )\n data.push(returnedBills)\n return data.flat()\n } catch (e) {\n console.error(e)\n reportError({\n apiUrl,\n error: e,\n extraInfo: { type: 'getLaunchBondsPublicData', preTGEBonds, chain, e },\n })\n return []\n }\n}\n"],"names":["launchBondsABI_V2_4_1"],"mappings":";;;;;;;AAUO,MAAM,oBAAoB,GAAG,OAClC,KAAa,EACb,WAAoD,EACpD,WAA2B,EAC3B,MAAe,KACS;AACxB,IAAA,IAAI;QACF,IAAI,CAAC,WAAW,EAAE,MAAM;AAAE,YAAA,OAAO,EAAE;QACnC,MAAM,IAAI,GAAG,EAAE;QACf,MAAM,OAAO,GAAG,KAAgB;QAEhC,MAAM,cAAc,GAAa,EAAE;QACnC,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AACpD,YAAA,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;YAC/B,MAAM,IAAI,GAAG,IAAI;YACjB,OAAO;AACL,gBAAA;oBACE,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAW;AACrD,oBAAA,IAAI,EAAE,eAAe;AACtB,iBAAA;AACD,gBAAA;oBACE,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAW;AACrD,oBAAA,IAAI,EAAE,OAAO;AACd,iBAAA;AACD,gBAAA;oBACE,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAW;AACrD,oBAAA,IAAI,EAAE,sBAAsB;AAC7B,iBAAA;AACD,gBAAA;oBACE,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAW;AACrD,oBAAA,IAAI,EAAE,WAAW;AAClB,iBAAA;AACD,gBAAA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AE,SAAS,CAAC,QAAQ,EAAE;AAC/B,gBAAA,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE;AAC/B,gBAAA,qBAAqB,EAAE,qBAAqB,EAAE,QAAQ,EAAE;AACxD,gBAAA,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;AACtD,gBAAA,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC9B,SAAS;gBACT,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,UAAU,CAAC,OAAO;AAC5F,gBAAA,SAAS,EAAE;AACT,oBAAA,GAAG,EAAE,UAAU,CAAC,QAAQ,IAAI,UAAU;oBACtC,qBAAqB;AACtB,iBAAA;aACF;AACD,YAAA,OAAO,IAAI;QACb,CAAC,CAAC,CACH;AACD,QAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;AACxB,QAAA,OAAO,IAAI,CAAC,IAAI,EAAE;IACpB;IAAE,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,QAAA,WAAW,CAAC;YACV,MAAM;AACN,YAAA,KAAK,EAAE,CAAC;YACR,SAAS,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE;AACvE,SAAA,CAAC;AACF,QAAA,OAAO,EAAE;IACX;AACF;;;;"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { BillsConfig } from '@ape.swap/apeswap-lists';
|
|
2
|
-
import { TokenPrices } from '../../tokenPrices/useTokenPrices';
|
|
3
|
-
export declare const fetchBondsDataSOL: (bonds: BillsConfig[], apiUrl: string, tokenPrices?: TokenPrices[]) => Promise<import("../../../types/bonds").BondsData[]>;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
2
|
-
import { solanaMulticall } from '../../../utils/solanaMulticall.js';
|
|
3
|
-
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { derivePda } from '../../../utils/derivePda.js';
|
|
5
|
-
import { PROGRAM_ID } from '../../../constants/solanaConstants.js';
|
|
6
|
-
import { cleanBillsData } from './cleanBillsData.js';
|
|
7
|
-
|
|
8
|
-
const fetchBondsDataSOL = async (bonds, apiUrl, tokenPrices) => {
|
|
9
|
-
const bills = bonds.filter((b) => !b.soldOut);
|
|
10
|
-
try {
|
|
11
|
-
const solanaCalls = [];
|
|
12
|
-
const solanaBillIds = [];
|
|
13
|
-
for (const bill of bills) {
|
|
14
|
-
const bondIssuanceAddress = bill.contractAddress[ChainId.SOL];
|
|
15
|
-
if (!bondIssuanceAddress)
|
|
16
|
-
continue;
|
|
17
|
-
solanaBillIds.push(bill.index);
|
|
18
|
-
const bondIssuancePubkey = new PublicKey(bondIssuanceAddress);
|
|
19
|
-
const bondTermPda = derivePda('bond_term', bondIssuancePubkey, PROGRAM_ID);
|
|
20
|
-
const bondPricingPda = derivePda('bond_pricing', bondIssuancePubkey, PROGRAM_ID);
|
|
21
|
-
solanaCalls.push({ accountAddress: bondIssuanceAddress, accountType: 'bondIssuance' }, { accountAddress: bondTermPda.toBase58(), accountType: 'bondTerm' }, { accountAddress: bondPricingPda.toBase58(), accountType: 'bondPricing' });
|
|
22
|
-
}
|
|
23
|
-
// Fetch Solana bills
|
|
24
|
-
const solanaResults = (await solanaMulticall(solanaCalls));
|
|
25
|
-
const solanaBills = solanaResults?.bondIssuance
|
|
26
|
-
?.map((bondIssuance, index) => {
|
|
27
|
-
const vestingTermDuration = Number(solanaResults.bondTerm[index]?.vestingEnd.toString());
|
|
28
|
-
const bill = {
|
|
29
|
-
...bondIssuance,
|
|
30
|
-
...solanaResults.bondPricing[index],
|
|
31
|
-
terms: solanaResults.bondTerm[index],
|
|
32
|
-
};
|
|
33
|
-
return [
|
|
34
|
-
bill.trueBillPrice,
|
|
35
|
-
bill.totalPayoutGiven,
|
|
36
|
-
[bill.terms.controlVariable, vestingTermDuration, bill.terms.minimumDebt, bill.terms.maxPayout],
|
|
37
|
-
bill.terms.maxTotalPayout,
|
|
38
|
-
bill.feeInPayout.toString(),
|
|
39
|
-
bill.feeInPrincipal.toString(),
|
|
40
|
-
false,
|
|
41
|
-
undefined,
|
|
42
|
-
undefined,
|
|
43
|
-
solanaResults.bondPricing[index],
|
|
44
|
-
solanaResults.bondTerm[index],
|
|
45
|
-
]; // Map to reflect evm structure
|
|
46
|
-
})
|
|
47
|
-
.filter((bill) => typeof bill !== 'undefined') ?? [];
|
|
48
|
-
const allBillsIds = [];
|
|
49
|
-
const allBillsData = [];
|
|
50
|
-
if (solanaBills.length > 0) {
|
|
51
|
-
allBillsIds.push(...solanaBillIds);
|
|
52
|
-
allBillsData.push(...solanaBills);
|
|
53
|
-
}
|
|
54
|
-
return await cleanBillsData(allBillsIds, allBillsData, ChainId.SOL, bills, tokenPrices);
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
console.error(e);
|
|
58
|
-
reportError({
|
|
59
|
-
apiUrl,
|
|
60
|
-
error: e,
|
|
61
|
-
extraInfo: { type: 'getBondsDataSOL', e },
|
|
62
|
-
});
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export { fetchBondsDataSOL };
|
|
68
|
-
//# sourceMappingURL=fetchBondsDataSOL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchBondsDataSOL.js","sources":["../../../../src/state/bonds/fetchBondsData/fetchBondsDataSOL.ts"],"sourcesContent":["import { BillsConfig, ChainId } from '@ape.swap/apeswap-lists'\nimport { TokenPrices } from '../../tokenPrices/useTokenPrices'\nimport { SolanaCall, solanaMulticall } from '../../../utils/solanaMulticall'\nimport { PublicKey } from '@solana/web3.js'\nimport { derivePda } from '../../../utils/derivePda'\nimport { PROGRAM_ID } from '../../../constants/solanaConstants'\nimport { BondIssuance, SolanaBondData, SolanaBondsResult } from '../../../types/solanaBonds'\nimport { cleanBillsData } from './cleanBillsData'\n\nexport const fetchBondsDataSOL = async (bonds: BillsConfig[], apiUrl: string, tokenPrices?: TokenPrices[]) => {\n const bills = bonds.filter((b) => !b.soldOut)\n try {\n const solanaCalls: SolanaCall[] = []\n const solanaBillIds: number[] = []\n for (const bill of bills) {\n const bondIssuanceAddress = bill.contractAddress[ChainId.SOL]\n if (!bondIssuanceAddress) continue\n\n solanaBillIds.push(bill.index)\n const bondIssuancePubkey = new PublicKey(bondIssuanceAddress)\n const bondTermPda = derivePda('bond_term', bondIssuancePubkey, PROGRAM_ID)\n const bondPricingPda = derivePda('bond_pricing', bondIssuancePubkey, PROGRAM_ID)\n solanaCalls.push(\n { accountAddress: bondIssuanceAddress, accountType: 'bondIssuance' },\n { accountAddress: bondTermPda.toBase58(), accountType: 'bondTerm' },\n { accountAddress: bondPricingPda.toBase58(), accountType: 'bondPricing' },\n )\n }\n // Fetch Solana bills\n const solanaResults = (await solanaMulticall(solanaCalls)) as SolanaBondsResult\n\n const solanaBills =\n solanaResults?.bondIssuance\n ?.map((bondIssuance: BondIssuance, index: number) => {\n const vestingTermDuration = Number(solanaResults.bondTerm[index]?.vestingEnd.toString())\n const bill = {\n ...bondIssuance,\n ...solanaResults.bondPricing[index],\n terms: solanaResults.bondTerm[index],\n } as SolanaBondData\n\n return [\n bill.trueBillPrice,\n bill.totalPayoutGiven,\n [bill.terms.controlVariable, vestingTermDuration, bill.terms.minimumDebt, bill.terms.maxPayout],\n bill.terms.maxTotalPayout,\n bill.feeInPayout.toString(),\n bill.feeInPrincipal.toString(),\n false,\n undefined,\n undefined,\n solanaResults.bondPricing[index],\n solanaResults.bondTerm[index],\n ] // Map to reflect evm structure\n })\n .filter((bill: any) => typeof bill !== 'undefined') ?? []\n const allBillsIds = []\n const allBillsData = []\n if (solanaBills.length > 0) {\n allBillsIds.push(...solanaBillIds)\n allBillsData.push(...solanaBills)\n }\n return await cleanBillsData(allBillsIds, allBillsData, ChainId.SOL, bills, tokenPrices)\n } catch (e) {\n console.error(e)\n reportError({\n apiUrl,\n error: e,\n extraInfo: { type: 'getBondsDataSOL', e },\n })\n return []\n }\n}\n"],"names":[],"mappings":";;;;;;;AASO,MAAM,iBAAiB,GAAG,OAAO,KAAoB,EAAE,MAAc,EAAE,WAA2B,KAAI;AAC3G,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AAC7C,IAAA,IAAI;QACF,MAAM,WAAW,GAAiB,EAAE;QACpC,MAAM,aAAa,GAAa,EAAE;AAClC,QAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,mBAAmB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC;AAC7D,YAAA,IAAI,CAAC,mBAAmB;gBAAE;AAE1B,YAAA,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;AAC9B,YAAA,MAAM,kBAAkB,GAAG,IAAI,SAAS,CAAC,mBAAmB,CAAC;YAC7D,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,EAAE,kBAAkB,EAAE,UAAU,CAAC;YAC1E,MAAM,cAAc,GAAG,SAAS,CAAC,cAAc,EAAE,kBAAkB,EAAE,UAAU,CAAC;AAChF,YAAA,WAAW,CAAC,IAAI,CACd,EAAE,cAAc,EAAE,mBAAmB,EAAE,WAAW,EAAE,cAAc,EAAE,EACpE,EAAE,cAAc,EAAE,WAAW,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,EACnE,EAAE,cAAc,EAAE,cAAc,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,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AC,GAAG,aAAa,CAAC;AAClC,YAAA,YAAY,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;QACnC;AACA,QAAA,OAAO,MAAM,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC;IACzF;IAAE,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,QAAA,WAAW,CAAC;YACV,MAAM;AACN,YAAA,KAAK,EAAE,CAAC;AACR,YAAA,SAAS,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,EAAE;AAC1C,SAAA,CAAC;AACF,QAAA,OAAO,EAAE;IACX;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchBondsDataSui.js","sources":["../../../../src/state/bonds/fetchBondsData/fetchBondsDataSui.ts"],"sourcesContent":["// =============================================================================\n// Sui bond enrichment — builds BondsData[] from BillsConfig[] + prices\n// =============================================================================\n//\n// On-chain first: reads BondMarket objects directly via getObject for each\n// config and projects the fields onto BondsData. No backend dependency\n// (realtime-api does not support Sui).\n\nimport { BillsConfig, ChainId } from '@ape.swap/apeswap-lists'\nimport { BondsData } from '../../../types/bonds'\nimport { TokenPrices } from '../../tokenPrices/useTokenPrices'\nimport { getSuiClient } from '../../../utils/suiHelpers'\nimport { formatUnits } from '../../../utils/fixedPoint'\nimport axios from 'axios'\nimport { PRICE_API_URL } from '../../../config/constants/variables'\n\nconst SUI_KEY = ChainId.SUI\n\n// Contract constants — must match the Move source\nconst PRICE_DECIMALS = 100_000_000n // 1e8\nconst PERCENTAGE_BASE = 1_000_000n // 1e6\n\n// ---------------------------------------------------------------------------\n// Helpers — replicate bond_math on the client so we can compute true_price\n// from the raw object fields without needing a view function call.\n// ---------------------------------------------------------------------------\n\nconst pow10 = (n: number): bigint => 10n ** BigInt(n)\n\n/** debt_ratio = (current_debt * payout_scale) / payout_initial_supply */\nconst calculateDebtRatio = (currentDebt: bigint, payoutInitialSupply: bigint, payoutScale: bigint): bigint => {\n if (payoutInitialSupply === 0n) return 0n\n return (currentDebt * payoutScale) / payoutInitialSupply\n}\n\n/** value_of_token — convert amount from one decimal basis to another */\nconst valueOfToken = (fromDecimals: number, toDecimals: number, amount: bigint): bigint => {\n if (toDecimals >= fromDecimals) {\n return amount * pow10(toDecimals - fromDecimals)\n }\n return amount / pow10(fromDecimals - toDecimals)\n}\n\n/** bond_price = (control_variable * debt_ratio * token_scale) / PRICE_DECIMALS */\nconst calculateBondPrice = (controlVariable: bigint, debtRatio: bigint, tokenScale: bigint): bigint => {\n const temp = controlVariable * debtRatio\n return (temp * tokenScale) / PRICE_DECIMALS\n}\n\n/** true_price = (base_price * PERCENTAGE_BASE) / (PERCENTAGE_BASE - fee_in_principal) */\nconst calculateTruePrice = (basePrice: bigint, feeInPrincipal: bigint, minimumPrice: bigint): bigint => {\n const denominator = PERCENTAGE_BASE - feeInPrincipal\n if (denominator === 0n) return basePrice\n const truePrice = (basePrice * PERCENTAGE_BASE) / denominator\n return truePrice < minimumPrice ? minimumPrice : truePrice\n}\n\n// ---------------------------------------------------------------------------\n// Object field extraction — Sui getObject returns nested content.fields\n// ---------------------------------------------------------------------------\n\ninterface SuiMarketFields {\n paused: boolean\n emergency_paused: boolean\n treasury_id: string\n total_principal_billed: string\n total_payout_given: string\n total_debt: string\n last_decay: number\n payout_token_initial_supply: string\n payout_decimals: number\n principal_decimals: number\n fee_in_principal: string\n fee_in_payout: string\n cliff_period: number\n terms: {\n fields: {\n control_variable: string\n vesting_term: string\n minimum_price: string\n max_payout: string\n max_debt: string\n max_total_payout: string\n }\n }\n}\n\nconst extractMarketFields = (content: any): SuiMarketFields | null => {\n if (!content?.fields) return null\n const f = content.fields\n const terms = f.terms?.fields ?? f.terms\n if (!terms) return null\n return {\n paused: Boolean(f.paused),\n emergency_paused: Boolean(f.emergency_paused),\n treasury_id: String(f.treasury_id ?? ''),\n total_principal_billed: String(f.total_principal_billed ?? '0'),\n total_payout_given: String(f.total_payout_given ?? '0'),\n total_debt: String(f.total_debt ?? '0'),\n last_decay: Number(f.last_decay ?? 0),\n payout_token_initial_supply: String(f.payout_token_initial_supply ?? '0'),\n payout_decimals: Number(f.payout_decimals ?? 9),\n principal_decimals: Number(f.principal_decimals ?? 9),\n fee_in_principal: String(f.fee_in_principal ?? '0'),\n fee_in_payout: String(f.fee_in_payout ?? '0'),\n cliff_period: f.vesting_config?.variant === 'CliffLinear' ? Number(f.vesting_config?.fields?.cliff_period ?? 0) : 0,\n terms: {\n fields: {\n control_variable: String(terms.control_variable ?? '0'),\n vesting_term: String(terms.vesting_term ?? '0'),\n minimum_price: String(terms.minimum_price ?? '0'),\n max_payout: String(terms.max_payout ?? '0'),\n max_debt: String(terms.max_debt ?? '0'),\n max_total_payout: String(terms.max_total_payout ?? '0'),\n },\n },\n }\n}\n\n// ---------------------------------------------------------------------------\n// Main enrichment function\n// ---------------------------------------------------------------------------\n\n/**\n * Enrich Sui bond configs into full BondsData objects.\n *\n * Reads each BondMarket object directly via `getObject` and computes\n * true_bill_price client-side using the same bond_math formulas as the\n * Move contract. Scale conversion: computed `true_bill_price` is u64\n * scaled by PRICE_DECIMALS = 1e8; the SDK stores `trueBondPrice` scaled\n * by 1e18 (legacy EVM format) → multiply by 1e10.\n */\nexport const fetchBondsDataSUI = async (bondsParam?: BillsConfig[], prices?: TokenPrices[]): Promise<BondsData[]> => {\n const bonds = bondsParam?.filter((b) => !b.soldOut)\n if (!bonds || bonds?.length === 0) return []\n\n const client = getSuiClient()\n\n const enriched = await Promise.all(\n bonds.map(async (bond): Promise<BondsData | null> => {\n const marketAddr = bond.contractAddress[SUI_KEY]\n if (!marketAddr) return null\n try {\n const obj = await client.getObject({\n id: marketAddr,\n options: { showContent: true },\n })\n\n const fields = extractMarketFields(obj.data?.content)\n if (!fields) {\n console.warn(`[Sui] No content fields for market ${marketAddr}`)\n return null\n }\n\n const principalAddr = bond.lpToken.address[SUI_KEY]?.toLowerCase()\n const payoutAddr = bond.earnToken.address[SUI_KEY]?.toLowerCase()\n\n let principalPrice = prices?.find((t) => t.tokenAddress.toLowerCase() === principalAddr)?.price!\n if (principalPrice === undefined) {\n // principalPrice = 1\n try {\n const res = await axios.get(\n `${PRICE_API_URL}/realtime/price?token=${bond?.lpToken?.address?.[bond?.chainId]}&chain=${bond?.chainId}`,\n )\n principalPrice = res.data.price ?? 0\n } catch {\n console.error('Failed to fetch price for: ', bond.lpToken.symbol)\n principalPrice = 0\n }\n }\n\n let payoutPrice = prices?.find((t) => t.tokenAddress.toLowerCase() === payoutAddr)?.price!\n if (payoutPrice === undefined) {\n try {\n // Missing token price, therefor make a single call to api to fetch it\n const res = await axios.get(\n `${PRICE_API_URL}/realtime/price?token=${bond?.earnToken?.address?.[bond?.chainId]}&chain=${bond?.chainId}`,\n )\n payoutPrice = res.data.price ?? 0\n } catch {\n console.error('Failed to fetch price for: ', bond.earnToken.symbol)\n payoutPrice = 0\n }\n }\n\n // ---------- Compute true_bill_price client-side ----------\n const payoutDecimals = bond.earnToken.decimals[SUI_KEY] ?? fields.payout_decimals\n const principalDecimals = bond.lpToken.decimals?.[SUI_KEY] ?? fields.principal_decimals\n\n // Apply debt decay to match on-chain behavior (bond_math::calculate_decay).\n // The contract decays debt inside deposit(), but getObject returns the stale\n // total_debt from the last interaction. Without this, the SDK shows a worse\n // discount than the user actually gets.\n const rawTotalDebt = BigInt(fields.total_debt)\n const vestingTermSec = Number(fields.terms.fields.vesting_term)\n const nowSec = Math.floor(Date.now() / 1000)\n const elapsed = Math.max(0, nowSec - fields.last_decay)\n let totalDebt = rawTotalDebt\n if (vestingTermSec > 0 && elapsed > 0 && rawTotalDebt > 0n) {\n if (elapsed >= vestingTermSec) {\n totalDebt = 0n\n } else {\n // decay = total_debt * elapsed / vesting_term, capped at 90%\n const decay = (rawTotalDebt * BigInt(elapsed)) / BigInt(vestingTermSec)\n const maxDecay = (rawTotalDebt * 90n) / 100n\n totalDebt = rawTotalDebt - (decay > maxDecay ? maxDecay : decay)\n }\n }\n\n const payoutInitialSupply = BigInt(fields.payout_token_initial_supply)\n const controlVariable = BigInt(fields.terms.fields.control_variable)\n const minimumPrice = BigInt(fields.terms.fields.minimum_price)\n const feeInPrincipalRaw = BigInt(fields.fee_in_principal)\n\n // Replicate calculate_current_debt → calculate_price → calculate_true_price\n const currentDebtPayout = valueOfToken(principalDecimals, payoutDecimals, totalDebt)\n const payoutScale = pow10(payoutDecimals)\n const principalScale = pow10(principalDecimals)\n\n const debtRatio = calculateDebtRatio(currentDebtPayout, payoutInitialSupply, payoutScale)\n const basePrice = calculateBondPrice(controlVariable, debtRatio, principalScale)\n const trueBillPriceU64 = calculateTruePrice(basePrice, feeInPrincipalRaw, minimumPrice)\n\n // Convert on-chain u64 to SDK formats.\n // The on-chain price is used as: payout = value * 10^payoutDec / price\n // So \"principal per payout\" in human terms = price / 10^payoutDec.\n // The SDK's legacy format scales to 1e18: trueBondPriceScaled = price * 10^(18-payoutDec).\n const trueBondPriceScaled = (trueBillPriceU64 * pow10(18 - payoutDecimals)).toString()\n const trueBondPriceHuman = Number(trueBillPriceU64) / Math.pow(10, payoutDecimals)\n\n // Same formula as getRawDiscount / getRawBonus in state/bonds/utils.ts\n const discount = payoutPrice > 0 ? ((payoutPrice - principalPrice * trueBondPriceHuman) / payoutPrice) * 100 : 0\n const bonus = discount > 0 && discount < 100 ? (discount / (100 - discount)) * 100 : 0\n\n // Fees: u64 in PERCENTAGE_BASE (1e6) → divide by 10_000 for human %\n const feeInPayout = Number(fields.fee_in_payout) / 10_000\n const feeInPrincipal = Number(fields.fee_in_principal) / 10_000\n const trueBondPriceWithFee =\n feeInPayout < 100 ? trueBondPriceHuman * (1 / ((100 - feeInPayout) / 100)) : trueBondPriceHuman\n const discountWithFee =\n payoutPrice > 0 ? ((payoutPrice - principalPrice * trueBondPriceWithFee) / payoutPrice) * 100 : 0\n const bonusWithFee =\n discountWithFee > 0 && discountWithFee < 100 ? (discountWithFee / (100 - discountWithFee)) * 100 : 0\n\n const tokensRemaining = formatUnits(\n BigInt(fields.terms.fields.max_total_payout) - BigInt(fields.total_payout_given),\n payoutDecimals,\n )\n\n return {\n ...bond,\n suiTreasuryId: fields.treasury_id || undefined,\n soldOut:\n fields.paused ||\n fields.emergency_paused ||\n BigInt(fields.total_payout_given) >= BigInt(fields.terms.fields.max_total_payout)\n ? true\n : bond.soldOut,\n maxTotalPayout: fields.terms.fields.max_total_payout,\n totalPayoutGiven: fields.total_payout_given,\n maxPayout: fields.terms.fields.max_payout,\n tokensRemaining,\n showcaseTokenName: bond.earnToken.symbol,\n vestingTerm: Number(fields.terms.fields.vesting_term),\n vestingCliff: fields.cliff_period || undefined,\n feeInPayout,\n feeInPrincipal,\n trueBondPrices: [\n {\n trueBondPrice: trueBondPriceScaled,\n points: '0',\n discount,\n discountWithFee,\n bonus,\n bonusWithFee,\n boost: 0,\n },\n ],\n principalTokenPrice: principalPrice.toString(),\n payoutTokenPrice: payoutPrice.toString(),\n }\n } catch (e) {\n console.warn(`[Sui] Failed to read BondMarket for ${marketAddr}`, e)\n // Hide the bond from the list when on-chain data is unavailable —\n // showing a card with all zeros is confusing for users.\n return null\n }\n }),\n )\n return enriched.filter((b): b is BondsData => b !== null)\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG;AAE3B;AACA,MAAM,cAAc,GAAG,UAAY,CAAA;AACnC,MAAM,eAAe,GAAG,QAAU,CAAA;AAElC;AACA;AACA;AACA;AAEA,MAAM,KAAK,GAAG,CAAC,CAAS,KAAa,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC;AAErD;AACA,MAAM,kBAAkB,GAAG,CAAC,WAAmB,EAAE,mBAA2B,EAAE,WAAmB,KAAY;IAC3G,IAAI,mBAAmB,KAAK,EAAE;AAAE,QAAA,OAAO,EAAE;AACzC,IAAA,OAAO,CAAC,W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WAAW;gBACX,cAAc;AACd,gBAAA,cAAc,EAAE;AACd,oBAAA;AACE,wBAAA,aAAa,EAAE,mBAAmB;AAClC,wBAAA,MAAM,EAAE,GAAG;wBACX,QAAQ;wBACR,eAAe;wBACf,KAAK;wBACL,YAAY;AACZ,wBAAA,KAAK,EAAE,CAAC;AACT,qBAAA;AACF,iBAAA;AACD,gBAAA,mBAAmB,EAAE,cAAc,CAAC,QAAQ,EAAE;AAC9C,gBAAA,gBAAgB,EAAE,WAAW,CAAC,QAAQ,EAAE;aACzC;QACH;QAAE,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,CAAA,oCAAA,EAAuC,UAAU,CAAA,CAAE,EAAE,CAAC,CAAC;;;AAGpE,YAAA,OAAO,IAAI;QACb;IACF,CAAC,CAAC,CACH;AACD,IAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAqB,CAAC,KAAK,IAAI,CAAC;AAC3D;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchUsersBondsAptos.js","sources":["../../../../src/state/bonds/fetchUsersBonds/fetchUsersBondsAptos.ts"],"sourcesContent":["// =============================================================================\n// fetchUserOwnedAptosBonds — user bills fetcher for the Aptos chain\n// =============================================================================\n//\n// On-chain first: reads user bills directly via Move view functions (no\n// api-v2 dependency). Uses:\n//\n// bond_nft::user_bills(user) → [bill_id, ...]\n// bond_nft::bond_market_by_id(bill_id) → market_addr\n// bond_nft::nft_address(bill_id) → bill_addr\n// bond::bill_info(market, bill_addr) → Bill struct\n// bond_nft::vesting_progress(bill_id) → [total_vested, claimable]\n\nimport { BillsConfig, ChainId } from '@ape.swap/apeswap-lists'\nimport type { UserOwnedBillsData, UserBill } from '../../../types/yourbonds'\nimport type { BondsData } from '../../../types/bonds'\nimport type { TokenPrices } from '../../tokenPrices/useTokenPrices'\nimport { APTOS_PLACEHOLDER_BILL_IMAGE } from '../../../constants/aptosConstants'\nimport axios from 'axios'\nimport {\n readAptosBillInfo,\n readBondMarketByBillId,\n readNftAddressByBillId,\n readUserBillIds,\n readVestingProgress,\n} from '../../../utils/aptosHelpers'\nimport { PRICE_API_URL } from '../../../config/constants/variables'\n\nexport async function fetchUsersBondsAptos(\n user: string | undefined,\n bondData: BillsConfig[],\n tokenPrices: Partial<Record<ChainId, TokenPrices[]>>,\n): Promise<UserOwnedBillsData[]> {\n if (!user) return []\n\n // Build one `UserOwnedBillsData` per known bond config. We always return\n // the outer shell so downstream code (`getUserBonds` in useUserBonds.ts)\n // can match bills back to their bond config.\n const aptosKey = ChainId.APTOS\n const aptosPrices = tokenPrices?.[aptosKey] ?? []\n\n // Index bonds by lowercased market address for O(1) lookup when matching\n // bill_ids back to their market.\n const bondsByMarket = new Map<string, BillsConfig>()\n for (const bond of bondData) {\n const marketAddr = bond.contractAddress[aptosKey]\n if (marketAddr) bondsByMarket.set(marketAddr.toLowerCase(), bond)\n }\n\n // Seed the result with empty shells so every bond is represented.\n const result: UserOwnedBillsData[] = bondData.map((bond) => ({\n index: bond.index,\n userOwnedBills: [] as UserBill[],\n }))\n const indexByBondIndex = new Map<number, UserOwnedBillsData>()\n for (const entry of result) indexByBondIndex.set(entry.index, entry)\n\n try {\n const billIds = await readUserBillIds(user)\n if (billIds.length === 0) return result\n\n // For each bill the user owns, resolve its market, object address, state\n // and vesting progress in parallel. Bills whose market is not in our\n // bondData are silently skipped (they belong to a market the SDK isn't\n // configured to display).\n await Promise.all(\n billIds.map(async (billId) => {\n try {\n const [marketAddr, billAddr] = await Promise.all([\n readBondMarketByBillId(billId),\n readNftAddressByBillId(billId),\n ])\n const bond = bondsByMarket.get(marketAddr.toLowerCase())\n if (!bond) return\n\n const [billInfo, vesting] = await Promise.all([\n readAptosBillInfo(marketAddr, billId),\n readVestingProgress(marketAddr, billId),\n ])\n\n const principalAddr = bond.lpToken.address[aptosKey]?.toLowerCase()\n const payoutAddr = bond.earnToken.address[aptosKey]?.toLowerCase()\n let principalPrice = aptosPrices.find((t) => t.tokenAddress.toLowerCase() === principalAddr)?.price\n let payoutPrice = aptosPrices.find((t) => t.tokenAddress.toLowerCase() === payoutAddr)?.price\n\n // Fallback: individual price-api call (same pattern as fetchBillsUserSolana.ts).\n // TODO(aptos): price-api pending Aptos support. Fallback to hardcoded prices.\n if (principalPrice === undefined) {\n try {\n const res = await axios.get(\n `${PRICE_API_URL}/realtime/price?token=${bond.lpToken.address[aptosKey]}&chain=${aptosKey}`,\n )\n principalPrice = parseFloat(res.data.price ?? '0')\n } catch {\n principalPrice = 0\n }\n }\n if (payoutPrice === undefined) {\n try {\n const res = await axios.get(\n `${PRICE_API_URL}/realtime/price?token=${bond.earnToken.address[aptosKey]}&chain=${aptosKey}`,\n )\n payoutPrice = parseFloat(res.data.price ?? '0')\n } catch {\n payoutPrice = 0\n }\n }\n\n const payoutTotal = String(billInfo.payout ?? '0')\n const payoutClaimed = String(billInfo.payout_claimed ?? '0')\n const payoutRemaining = (BigInt(payoutTotal) - BigInt(payoutClaimed)).toString()\n const vestingStart = billInfo.vesting_start_timestamp ?? billInfo.last_timestamp ?? '0'\n const lastClaim = billInfo.last_claim_timestamp ?? billInfo.last_timestamp ?? vestingStart\n\n // Compute human-readable amounts for the modal display.\n const payoutDecimals = bond.earnToken.decimals[aptosKey] ?? 8\n const principalDecimals = bond.lpToken.decimals[aptosKey] ?? 8\n const payoutHuman = parseFloat(payoutTotal) / 10 ** payoutDecimals\n // Reconstruct deposit from payout and true_price_paid:\n // price = principal_amount * 1e8 / payout_amount → principal = payout * price / 1e8\n const truePricePaid = parseFloat(String(billInfo.true_price_paid ?? '0'))\n const depositAtomic = (parseFloat(payoutTotal) * truePricePaid) / 1e8\n const depositHuman = depositAtomic / 10 ** principalDecimals\n const depositUSD = depositHuman * (principalPrice ?? 0)\n\n const userBill: UserBill = {\n // `UserBill.address` is used by the SDK's claim flow as the\n // second argument to `bond::claim(market, bill_addr)`. Must be\n // the object address, NOT the scalar bill_id.\n address: billAddr,\n id: billId,\n vestingTerm: String(billInfo.vesting_term ?? '0'),\n payout: payoutRemaining,\n totalPayout: payoutTotal,\n truePricePaid: String(billInfo.true_price_paid ?? '0'),\n lastBlockTimestamp: String(lastClaim),\n vestingStartTimestamp: String(vestingStart),\n pendingRewards: vesting[1], // claimable from vesting_progress tuple\n billNftAddress: bond.billNnftAddress[aptosKey] ?? '',\n payoutClaimed,\n nftData: {\n tokenId: 0,\n billNftId: parseInt(billId),\n processing: false,\n image: APTOS_PLACEHOLDER_BILL_IMAGE,\n // Populate `data` so YourBondsModal can display Deposit/Bond Value.\n // api-v2 won't enrich Aptos bills, so we compute from on-chain data.\n data: {\n dollarValue: depositUSD,\n payout: payoutHuman,\n billContract: marketAddr,\n billNftAddress: bond.billNnftAddress[aptosKey] ?? '',\n billNftId: parseInt(billId),\n blockNumber: 0,\n bondArtCollection: '',\n bondPartner: '',\n bondVersion: bond.version ?? '',\n chainId: aptosKey,\n createTransactionHash: '',\n createdAddressOwner: user,\n createdAt: parseInt(String(vestingStart)),\n deposit: depositHuman,\n expires: parseInt(String(vestingStart)) + parseInt(String(billInfo.vesting_term ?? '0')),\n pairName: `${bond.lpToken.symbol}-${bond.earnToken.symbol}`,\n payoutToken: bond.earnToken.address[aptosKey] ?? '',\n payoutTokenData: {\n address: bond.earnToken.address[aptosKey] ?? '',\n name: bond.earnToken.symbol,\n symbol: bond.earnToken.symbol,\n decimals: bond.earnToken.decimals,\n },\n payoutTokenPrice: (payoutPrice ?? 0).toString(),\n principalToken: bond.lpToken.address[aptosKey] ?? '',\n token0: {\n address: bond.lpToken.address[aptosKey] ?? '',\n symbol: bond.lpToken.symbol,\n name: bond.lpToken.symbol,\n decimals: bond.lpToken.decimals,\n },\n token1: {\n address: bond.earnToken.address[aptosKey] ?? '',\n symbol: bond.earnToken.symbol,\n name: bond.earnToken.symbol,\n decimals: bond.earnToken.decimals,\n },\n type: bond.billType ?? 'reserve',\n vestingPeriodSeconds: parseInt(String(billInfo.vesting_term ?? '0')),\n },\n },\n bond: {\n ...bond,\n payoutTokenPrice: payoutPrice?.toString(),\n principalTokenPrice: principalPrice?.toString(),\n } as BondsData,\n }\n\n const entry = indexByBondIndex.get(bond.index)\n entry?.userOwnedBills.push(userBill)\n } catch (billErr) {\n console.warn(`[Aptos] Failed to read bill ${billId}`, billErr)\n }\n }),\n )\n } catch (e) {\n console.warn(`[Aptos] Failed to list user bills for ${user}`, e)\n }\n\n return result\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiBO,eAAe,oBAAoB,CACxC,IAAwB,EACxB,QAAuB,EACvB,WAAoD,EAAA;AAEpD,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,OAAO,EAAE;;;;AAKpB,IAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK;IAC9B,MAAM,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC,IAAI,EAAE;;;AAIjD,IAAA,MAAM,aAAa,GAAG,IAAI,GAAG,EAAuB;AACpD,IAAA,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE;QAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;AACjD,QAAA,IAAI,UAAU;YAAE,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC;IACnE;;IAGA,MAAM,MAAM,GAAyB,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,MAAM;QAC3D,KAAK,EAAE,IAAI,CAAC,KAAK;AACjB,QAAA,cAAc,EAAE,EAAgB;AACjC,KAAA,CAAC,CAAC;AACH,IAAA,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA8B;IAC9D,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC;AAEpE,IAAA,IAAI;AACF,QAAA,MAAM,OAAO,GAAG,MAAM,eAA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