diff --git a/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/routes/launchpad/claim_fees.ts b/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/routes/launchpad/claim_fees.ts index fe9c6fdf9cb..f98f2322ff3 100644 --- a/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/routes/launchpad/claim_fees.ts +++ b/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/routes/launchpad/claim_fees.ts @@ -1,4 +1,8 @@ import { DynamicBondingCurveClient } from '@meteora-ag/dynamic-bonding-curve-sdk' +import { + createTransferInstruction, + getAssociatedTokenAddressSync +} from '@solana/spl-token' import { PublicKey } from '@solana/web3.js' import { Request, Response } from 'express' @@ -11,6 +15,8 @@ interface ClaimFeesRequestBody { receiverWalletAddress: string } +const AUDIO_MINT = '9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM' + export const claimFees = async ( req: Request, res: Response @@ -39,16 +45,31 @@ export const claimFees = async ( const poolData = tokenPool.account const ownerWallet = new PublicKey(ownerWalletAddress) const receiverWallet = new PublicKey(receiverWalletAddress) + const maxQuoteAmount = poolData.creatorQuoteFee const claimFeesTx = await dbcClient.creator.claimCreatorTradingFee({ pool: poolAddress, payer: ownerWallet, creator: ownerWallet, maxBaseAmount: poolData.creatorBaseFee, // Match max amount to the claimable amount (effectively no limit) - maxQuoteAmount: poolData.creatorQuoteFee, // Match max amount to the claimable amount (effectively no limit) - receiver: receiverWallet + maxQuoteAmount, // Match max amount to the claimable amount (effectively no limit) + receiver: ownerWallet }) + const ownerWalletATA = getAssociatedTokenAddressSync( + new PublicKey(AUDIO_MINT), + ownerWallet, + false + ) + + const sendFromOwnerWallet = createTransferInstruction( + ownerWalletATA, + receiverWallet, + ownerWallet, + BigInt(maxQuoteAmount.toString()) + ) + claimFeesTx.instructions.push(sendFromOwnerWallet) + claimFeesTx.recentBlockhash = ( await connection.getLatestBlockhash() ).blockhash @@ -58,6 +79,7 @@ export const claimFees = async ( claimFeesTx: claimFeesTx.serialize({ requireAllSignatures: false }) }) } catch (e) { + logger.error(e) logger.error( 'Error in claim_fees - unable to create creator claim fee transaction' ) diff --git a/packages/web/src/pages/artist-coins-launchpad-page/pages/BuyCoinPage.tsx b/packages/web/src/pages/artist-coins-launchpad-page/pages/BuyCoinPage.tsx index fa5eb838515..8de00d00de6 100644 --- a/packages/web/src/pages/artist-coins-launchpad-page/pages/BuyCoinPage.tsx +++ b/packages/web/src/pages/artist-coins-launchpad-page/pages/BuyCoinPage.tsx @@ -71,6 +71,8 @@ const FORM_INPUT_DECIMALS = 8 const INPUT_DEBOUNCE_TIME = 400 +const AUDIO_BALANCE_POLL_INTERVAL = 3000 + export const BuyCoinPage = ({ onContinue, onBack, @@ -114,10 +116,13 @@ export const BuyCoinPage = ({ trackBuyModalClose() setIsBuyModalOpen(false) } - const { data: audioBalance } = useWalletAudioBalance({ - address: connectedWallet?.address ?? '', - chain: connectedWallet?.chain ?? Chain.Sol - }) + const { data: audioBalance } = useWalletAudioBalance( + { + address: connectedWallet?.address ?? '', + chain: connectedWallet?.chain ?? Chain.Sol + }, + { refetchInterval: AUDIO_BALANCE_POLL_INTERVAL } + ) const { audioBalanceString } = useMemo(() => { if (!audioBalance) { return { audioBalanceString: '0.00', audioBalanceInt: 0 } diff --git a/packages/web/src/pages/asset-detail-page/components/AssetInfoSection.tsx b/packages/web/src/pages/asset-detail-page/components/AssetInfoSection.tsx index bd894647147..e3181892ecb 100644 --- a/packages/web/src/pages/asset-detail-page/components/AssetInfoSection.tsx +++ b/packages/web/src/pages/asset-detail-page/components/AssetInfoSection.tsx @@ -6,13 +6,11 @@ import { useUser, useUserCoins, useConnectedWallets, - useCurrentAccountUser, - type ConnectedWallet + useCurrentAccountUser } from '@audius/common/api' import { useDiscordOAuthLink } from '@audius/common/hooks' import { coinDetailsMessages } from '@audius/common/messages' import { Feature, WidthSizes } from '@audius/common/models' -import type { User } from '@audius/common/models' import { formatCurrencyWithSubscript, removeNullable, @@ -268,9 +266,8 @@ type AssetDetailsSectionProps = { unclaimedFees: number formattedUnclaimedFees: string isClaimFeesPending: boolean + isClaimFeesDisabled: boolean handleClaimFees: () => void - externalSolWallet: ConnectedWallet | undefined - currentUser: User | null | undefined } const AssetDetailsSection = ({ @@ -280,8 +277,7 @@ const AssetDetailsSection = ({ formattedUnclaimedFees, isClaimFeesPending, handleClaimFees, - externalSolWallet, - currentUser + isClaimFeesDisabled }: AssetDetailsSectionProps) => { return ( {overflowMessages.claim} @@ -605,6 +597,9 @@ export const AssetInfoSection = ({ mint }: AssetInfoSectionProps) => { unclaimedFees={unclaimedFees} formattedUnclaimedFees={formattedUnclaimedFees} isClaimFeesPending={isClaimFeesPending} + isClaimFeesDisabled={ + isClaimFeesPending || !externalSolWallet || !currentUser?.spl_wallet + } handleClaimFees={handleClaimFees} externalSolWallet={externalSolWallet} currentUser={currentUser}