Skip to content

Commit 1f9be89

Browse files
authored
chore: sync private to v1.1055.0 (#12728)
1 parent 65b3019 commit 1f9be89

8 files changed

Lines changed: 45 additions & 25 deletions

File tree

‎packages/public-api/src/env.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const envSchema = z.object({
8484
BOB_GATEWAY_API_KEY: z.string().default(''),
8585
CHAINFLIP_API_KEY: z.string().min(1),
8686
NEAR_INTENTS_API_KEY: z.string().min(1),
87-
RELAY_API_KEY: z.string().default(''),
87+
RELAY_API_KEY: z.string().min(1),
8888
TRON_GRID_API_KEY: z.string().default(''),
8989

9090
// Feature flags

‎packages/swapper/src/swappers/BebopSwapper/utils/fetchFromBebop.ts‎

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import { chainIdToBebopChain } from '../types'
1515
import { bebopServiceFactory } from './bebopService'
1616
import { assetIdToBebopSolanaToken, assetIdToBebopToken } from './helpers'
1717

18+
// PMM charges the fee set against our api key, which nets exactly this bps
19+
const BEBOP_PMM_AFFILIATE_BPS = '60'
20+
21+
const isPmmEligible = (affiliateBps: string | undefined) =>
22+
bnOrZero(affiliateBps).eq(BEBOP_PMM_AFFILIATE_BPS)
23+
1824
export const fetchBebopQuote = async ({
1925
buyAsset,
2026
sellAsset,
@@ -53,31 +59,32 @@ export const fetchBebopQuote = async ({
5359
approval_type: 'Standard',
5460
skip_validation: 'true',
5561
gasless: 'false',
56-
// PMM fees are configured against our api key on Bebop's side, not sent per quote
5762
source: 'shapeshift',
5863
}
5964

6065
const jamParams = new URLSearchParams(baseParams)
61-
const pmmParams = new URLSearchParams(baseParams)
6266

63-
// JAM settles the fee on-chain, so it still takes our bps and a recipient per quote
64-
if (affiliateBps && affiliateBps !== '0') {
65-
jamParams.set('fee', affiliateBps)
66-
jamParams.set('fee_recipient', getAddress(getTreasuryAddressFromChainId(buyAsset.chainId)))
67-
}
67+
// Without an explicit fee JAM charges our api key's flat fee, so 1 bps is the lowest it can go
68+
jamParams.set('fee', affiliateBps && bnOrZero(affiliateBps).gt(0) ? affiliateBps : '1')
69+
jamParams.set('fee_recipient', getAddress(getTreasuryAddressFromChainId(buyAsset.chainId)))
6870

6971
const service = bebopServiceFactory({ apiKey })
7072

71-
const [maybeJam, maybePmm] = await Promise.all([
73+
const requests = [
7274
service.get<BebopQuoteResponse>(`https://api.bebop.xyz/jam/${chainName}/v2/quote`, {
7375
params: jamParams,
7476
}),
75-
service.get<BebopQuoteResponse>(`https://api.bebop.xyz/pmm/${chainName}/v3/quote`, {
76-
params: pmmParams,
77-
}),
78-
])
77+
]
7978

80-
const maybeResponses = [maybeJam, maybePmm]
79+
if (isPmmEligible(affiliateBps)) {
80+
requests.push(
81+
service.get<BebopQuoteResponse>(`https://api.bebop.xyz/pmm/${chainName}/v3/quote`, {
82+
params: new URLSearchParams(baseParams),
83+
}),
84+
)
85+
}
86+
87+
const maybeResponses = await Promise.all(requests)
8188

8289
if (maybeResponses.every(maybeResponse => maybeResponse.isErr())) {
8390
return Err(
@@ -129,6 +136,7 @@ export const fetchBebopSolanaQuote = async ({
129136
takerAddress,
130137
receiverAddress,
131138
slippageTolerancePercentageDecimal,
139+
affiliateBps,
132140
apiKey,
133141
}: {
134142
buyAsset: Asset
@@ -137,9 +145,19 @@ export const fetchBebopSolanaQuote = async ({
137145
takerAddress: string
138146
receiverAddress: string
139147
slippageTolerancePercentageDecimal: string
148+
affiliateBps?: string
140149
apiKey: string
141150
}): Promise<Result<BebopSolanaQuoteResponse, SwapErrorRight>> => {
142151
try {
152+
if (!isPmmEligible(affiliateBps)) {
153+
return Err(
154+
makeSwapErrorRight({
155+
message: 'Bebop Solana is PMM only and cannot take the requested bps',
156+
code: TradeQuoteError.NoRouteFound,
157+
}),
158+
)
159+
}
160+
143161
// Bebop's Solana routes don't wrap native SOL on the input side, so selling native SOL
144162
// always fails on-chain. Reject up front instead of returning an unexecutable quote.
145163
if (sellAsset.assetId === solAssetId) {
@@ -166,7 +184,6 @@ export const fetchBebopSolanaQuote = async ({
166184
approval_type: 'Standard',
167185
skip_validation: 'false',
168186
gasless: 'true',
169-
// Solana is PMM only, so its fees are configured against our api key on Bebop's side
170187
source: 'shapeshift',
171188
})
172189

‎packages/swapper/src/swappers/BebopSwapper/utils/getBebopSolanaTradeContext.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const getBebopSolanaTradeContext = async ({
5050
takerAddress,
5151
receiverAddress,
5252
slippageTolerancePercentageDecimal,
53+
affiliateBps,
5354
apiKey: deps.config.VITE_BEBOP_API_KEY,
5455
})
5556

‎packages/swapper/src/swappers/PortalsSwapper/endpoints.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const portalsApi: SwapperApi = {
8585

8686
return {
8787
status: txStatus,
88-
buyTxHash: relayRequest.data?.outTxs?.[0]?.hash,
88+
buyTxHash: relayRequest.data?.outTxs?.[0]?.txHash,
8989
message:
9090
txStatus === TxStatus.Failed
9191
? getRelayRequestFailureMessage(relayRequest)
@@ -94,6 +94,8 @@ export const portalsApi: SwapperApi = {
9494
: 'Bridge in progress',
9595
}
9696
}
97+
} else {
98+
console.error('Failed to fetch relay request:', relayResult.unwrapErr())
9799
}
98100

99101
const axelarscanResult = await fetchAxelarscanBridgeStatus(txHash)

‎packages/swapper/src/swappers/RelaySwapper/utils/relayStatus.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const fetchRelayRequestByTxHash = async (
3232
config: SwapperConfig,
3333
): Promise<Result<RelayRequest | undefined, SwapErrorRight>> => {
3434
const maybeResponse = await relayService.get<{ requests?: RelayRequest[] }>(
35-
`${config.VITE_RELAY_API_URL}/requests/v2?hash=${txHash}`,
35+
`${config.VITE_RELAY_API_URL}/requests/v3?depositTxHash=${txHash}`,
3636
getRelayRequestConfig(config),
3737
)
3838

@@ -41,15 +41,15 @@ export const fetchRelayRequestByTxHash = async (
4141
({ data }) =>
4242
data.requests?.find(
4343
({ data: request }) =>
44-
request?.inTxs?.some(({ hash }) => hash?.toLowerCase() === txHash.toLowerCase()),
44+
request?.inTxs?.some(({ txHash: hash }) => hash?.toLowerCase() === txHash.toLowerCase()),
4545
),
4646
)
4747
}
4848

4949
export const getRelayRequestFailureMessage = (request: RelayRequest): string => {
5050
const { failReason, refundFailReason } = request.data ?? {}
5151

52-
// Relay report 'N/A' rather than omitting the reason when there isn't one
52+
// Relay can report 'N/A' rather than null when there isn't one
5353
const reason = [failReason, refundFailReason].find(value => value && value !== 'N/A')
5454

5555
return reason ?? 'Bridge failed'

‎packages/swapper/src/swappers/RelaySwapper/utils/types.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ export type RelayMetadata = {
3333
}
3434

3535
export type RelayRequestTransaction = {
36-
hash?: string
36+
txHash?: string
3737
chainId?: number
3838
}
3939

4040
export type RelayRequestData = {
41-
failReason?: string
42-
refundFailReason?: string
41+
failReason?: string | null
42+
refundFailReason?: string | null
4343
inTxs?: RelayRequestTransaction[]
4444
outTxs?: RelayRequestTransaction[]
4545
}
4646

47-
// A single entry of the /requests/v2 listing, keyed by origin tx hash
47+
// A single entry of the /requests/v3 listing, keyed by origin tx hash
4848
export type RelayRequest = {
4949
status?: RelayStatus['status']
5050
data?: RelayRequestData

‎src/config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ const validators = {
240240
VITE_FEATURE_THORCHAIN_TCY_WIDGET: bool({ default: false }),
241241
VITE_FEATURE_THORCHAIN_TCY_ACTIVITY: bool({ default: false }),
242242
VITE_RELAY_API_URL: url(),
243-
VITE_RELAY_API_KEY: str({ default: '' }),
243+
VITE_RELAY_API_KEY: str(),
244244
VITE_COINCAP_API_KEY: str(),
245245
VITE_FEATURE_MAYA_SWAP: bool({ default: false }),
246246
VITE_FEATURE_BUTTERSWAP: bool({ default: false }),

‎src/pages/RFOX/constants.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const unstakeEvent = getAbiItem({ abi: RFOX_ABI, name: 'Unstake' })
2525

2626
export const IPFS_GATEWAY = 'https://gateway.pinata.cloud/ipfs'
2727

28-
export const CURRENT_EPOCH_IPFS_HASH = 'bafkreib3ftdt4rhq4fapplsyesyzyorayvnc3a4csdmmbzbaim6tb3gndi'
28+
export const CURRENT_EPOCH_IPFS_HASH = 'bafkreifcvn6ofyeychliwcrtvdbmxix3wcp6fgzcute4c3zkr3eiqo7gqm'
2929
export const STUB_RUNE_ADDRESS = 'thor1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqn8p0r8'
3030
export const RFOX_V3_UPGRADE_EPOCH = 18
3131

0 commit comments

Comments
 (0)