Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -11,6 +15,8 @@ interface ClaimFeesRequestBody {
receiverWalletAddress: string
}

const AUDIO_MINT = '9LzCMqDgTKYz9Drzqnpgee3SGa89up3a247ypMj2xrqM'

export const claimFees = async (
req: Request<unknown, unknown, ClaimFeesRequestBody>,
res: Response
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be missing context, this intentional?

})

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
Expand All @@ -58,6 +79,7 @@ export const claimFees = async (
claimFeesTx: claimFeesTx.serialize({ requireAllSignatures: false })
})
} catch (e) {
logger.error(e)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra logger?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intentional?

logger.error(
'Error in claim_fees - unable to create creator claim fee transaction'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = ({
Expand All @@ -280,8 +277,7 @@ const AssetDetailsSection = ({
formattedUnclaimedFees,
isClaimFeesPending,
handleClaimFees,
externalSolWallet,
currentUser
isClaimFeesDisabled
}: AssetDetailsSectionProps) => {
return (
<Flex
Expand Down Expand Up @@ -347,11 +343,7 @@ const AssetDetailsSection = ({
<TextLink
onClick={handleClaimFees}
variant={isClaimFeesPending ? 'subdued' : 'visible'}
disabled={
isClaimFeesPending ||
!externalSolWallet ||
!currentUser?.spl_wallet
}
disabled={isClaimFeesDisabled}
>
{overflowMessages.claim}
</TextLink>
Expand Down Expand Up @@ -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}
Expand Down