Jupiter referral accounting in UI with a minor fee (#298)
* use platform fee bps Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * Fixes from review Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> --------- Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
66fb89f1f8
commit
fb3a9239ec
|
@ -137,6 +137,21 @@ export const fetchJupiterTransaction = async (
|
|||
outputMint: PublicKey,
|
||||
isDirectWalletSwap = false,
|
||||
): Promise<[TransactionInstruction[], AddressLookupTableAccount[]]> => {
|
||||
// TODO: replace by something that belongs to the DAO
|
||||
// https://referral.jup.ag/
|
||||
// EV4qhLE2yPKdUPdQ74EWJUn21xT3eGQxG3DRR1g9NNFc belongs to 8SSLjXBEVk9nesbhi9UMCA32uijbVBUqWoKPPQPTekzt
|
||||
// for now
|
||||
const feeAccountPdas = await PublicKey.findProgramAddressSync(
|
||||
[
|
||||
Buffer.from('referral_ata'),
|
||||
new PublicKey('EV4qhLE2yPKdUPdQ74EWJUn21xT3eGQxG3DRR1g9NNFc').toBuffer(),
|
||||
outputMint.toBuffer(),
|
||||
],
|
||||
new PublicKey('REFER4ZgmyYx9c6He5XfaTMiGfdLwRnkV4RPp9t9iF3'),
|
||||
)
|
||||
const feeAccount = feeAccountPdas[0]
|
||||
|
||||
// docs https://station.jup.ag/api-v6/post-swap
|
||||
const transactions = await (
|
||||
await fetch(`${JUPITER_V6_QUOTE_API_MAINNET}/swap`, {
|
||||
method: 'POST',
|
||||
|
@ -148,10 +163,13 @@ export const fetchJupiterTransaction = async (
|
|||
quoteResponse: selectedRoute,
|
||||
// user public key to be used for the swap
|
||||
userPublicKey,
|
||||
// feeAccount is optional. Use if you want to charge a fee. feeBps must have been passed in /quote API.
|
||||
// This is the ATA account for the output token where the fee will be sent to. If you are swapping from SOL->USDC then this would be the USDC ATA you want to collect the fee.
|
||||
// feeAccount: 'fee_account_public_key',
|
||||
slippageBps: Math.ceil(slippage * 100),
|
||||
// docs
|
||||
// https://station.jup.ag/docs/additional-topics/referral-program
|
||||
// https://github.com/TeamRaccoons/referral
|
||||
// https://github.com/TeamRaccoons/referral/blob/main/packages/sdk/src/referral.ts
|
||||
platformFeeBps: 1,
|
||||
feeAccount,
|
||||
}),
|
||||
})
|
||||
).json()
|
||||
|
|
|
@ -30,7 +30,7 @@ const fetchJupiterRoute = async (
|
|||
amount = 0,
|
||||
slippage = 50,
|
||||
swapMode = 'ExactIn',
|
||||
feeBps = 0,
|
||||
feeBps = 1,
|
||||
onlyDirectRoutes = true,
|
||||
maxAccounts = 64,
|
||||
) => {
|
||||
|
@ -40,7 +40,7 @@ const fetchJupiterRoute = async (
|
|||
outputMint: outputMint.toString(),
|
||||
amount: amount.toString(),
|
||||
slippageBps: Math.ceil(slippage * 100).toString(),
|
||||
pfeeBps: feeBps.toString(),
|
||||
platformFeeBps: feeBps.toString(),
|
||||
maxAccounts: maxAccounts.toString(),
|
||||
swapMode,
|
||||
onlyDirectRoutes: `${onlyDirectRoutes}`,
|
||||
|
@ -119,7 +119,7 @@ export const handleGetRoutes = async (
|
|||
amount = 0,
|
||||
slippage = 50,
|
||||
swapMode = 'ExactIn',
|
||||
feeBps = 0,
|
||||
feeBps = 1,
|
||||
wallet: string | undefined,
|
||||
mangoAccount: MangoAccount | undefined,
|
||||
mode: SwapModes = 'ALL',
|
||||
|
@ -239,7 +239,7 @@ const useQuoteRoutes = ({
|
|||
nativeAmount.toNumber(),
|
||||
slippage,
|
||||
swapMode,
|
||||
0,
|
||||
1,
|
||||
wallet,
|
||||
mangoAccount,
|
||||
mode,
|
||||
|
|
Loading…
Reference in New Issue