Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.
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
Expand Up @@ -27,21 +27,21 @@ const SUPPORTED_CHAINS: Record<ChainId, string> = {
[Chains.LINEA.chainId]: 'linea',
};

const MAGPIE_METADATA: QuoteSourceMetadata<MagpieSupport> = {
name: 'Magpie',
const FLY_METADATA: QuoteSourceMetadata<FlySupport> = {
name: 'Fly',
supports: {
chains: Object.keys(SUPPORTED_CHAINS).map(Number),
swapAndTransfer: true,
buyOrders: false,
},
logoURI: 'ipfs://QmfR2ybY1gvctAxU5KArQ1UDXFixBY8ehgTBUBvUqY4Q4b',
logoURI: 'ipfs://bafkreidiz34vnfrvsakwfzibepsbni5pnvdrjo4vjssteyspeaxwydubmq',
};
type MagpieSupport = { buyOrders: false; swapAndTransfer: true };
type MagpieConfig = { sourceAllowlist?: string[]; apiKey?: string; enableRFQ?: boolean };
type MagpieData = { quoteId: string };
export class MagpieQuoteSource extends AlwaysValidConfigAndContextSource<MagpieSupport, MagpieConfig, MagpieData> {
type FlySupport = { buyOrders: false; swapAndTransfer: true };
type FlyConfig = { sourceAllowlist?: string[]; apiKey?: string; enableRFQ?: boolean };
type FlyData = { quoteId: string };
export class FlyQuoteSource extends AlwaysValidConfigAndContextSource<FlySupport, FlyConfig, FlyData> {
getMetadata() {
return MAGPIE_METADATA;
return FLY_METADATA;
}

async quote({
Expand All @@ -55,7 +55,7 @@ export class MagpieQuoteSource extends AlwaysValidConfigAndContextSource<MagpieS
config: { slippagePercentage, timeout },
},
config,
}: QuoteParams<MagpieSupport, MagpieConfig>): Promise<SourceQuoteResponse<MagpieData>> {
}: QuoteParams<FlySupport, FlyConfig>): Promise<SourceQuoteResponse<FlyData>> {
const quoteQueryParams = {
network: SUPPORTED_CHAINS[chainId],
fromTokenAddress: mapToken(sellToken),
Expand All @@ -77,7 +77,7 @@ export class MagpieQuoteSource extends AlwaysValidConfigAndContextSource<MagpieS
const quoteUrl = `https://api.magpiefi.xyz/aggregator/quote?${quoteQueryString}`;
const quoteResponse = await fetchService.fetch(quoteUrl, { timeout, headers });
if (!quoteResponse.ok) {
failed(MAGPIE_METADATA, chainId, sellToken, buyToken, await quoteResponse.text());
failed(FLY_METADATA, chainId, sellToken, buyToken, await quoteResponse.text());
}
const { id: quoteId, amountOut, targetAddress, fees } = await quoteResponse.json();
const estimatedGasNum: `${number}` | undefined = fees.find((fee: { type: string; value: `${number}` }) => fee.type === 'gas')?.value;
Expand All @@ -103,7 +103,7 @@ export class MagpieQuoteSource extends AlwaysValidConfigAndContextSource<MagpieS
config: { timeout },
customData: { quoteId },
},
}: BuildTxParams<MagpieConfig, MagpieData>): Promise<SourceQuoteTransaction> {
}: BuildTxParams<FlyConfig, FlyData>): Promise<SourceQuoteTransaction> {
const transactionQueryParams = {
quoteId,
estimateGas: false,
Expand All @@ -112,7 +112,7 @@ export class MagpieQuoteSource extends AlwaysValidConfigAndContextSource<MagpieS
const transactionUrl = `https://api.magpiefi.xyz/aggregator/transaction?${transactionQueryString}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

same url?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's the same. At least for now

const transactionResponse = await fetchService.fetch(transactionUrl, { timeout });
if (!transactionResponse.ok) {
failed(MAGPIE_METADATA, chainId, sellToken, buyToken, await transactionResponse.text());
failed(FLY_METADATA, chainId, sellToken, buyToken, await transactionResponse.text());
}
const { to, value, data } = await transactionResponse.json();
return { to, calldata: data, value: BigInt(value) };
Expand Down
4 changes: 2 additions & 2 deletions src/services/quotes/source-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { PortalsFiQuoteSource } from './quote-sources/portals-fi-quote-source';
import { OKXDexQuoteSource } from './quote-sources/okx-dex-quote-source';
import { BebopQuoteSource } from './quote-sources/bebop-quote-source';
import { XYFinanceQuoteSource } from './quote-sources/xy-finance-quote-source';
import { MagpieQuoteSource } from './quote-sources/magpie-quote-source';
import { FlyQuoteSource } from './quote-sources/fly-quote-source';
import { SquidQuoteSource } from './quote-sources/squid-quote-source';
import { ConveyorQuoteSource } from './quote-sources/conveyor-quote-source';
import { OkuQuoteSource } from './quote-sources/oku-quote-source';
Expand Down Expand Up @@ -47,7 +47,7 @@ export const QUOTE_SOURCES = {
changelly: new ChangellyQuoteSource(),
balmy: new BalmyQuoteSource(),
oku: new OkuQuoteSource(),
magpie: new MagpieQuoteSource(),
fly: new FlyQuoteSource(),
squid: new SquidQuoteSource(),
'portals-fi': new PortalsFiQuoteSource(),
enso: new EnsoQuoteSource(),
Expand Down
4 changes: 2 additions & 2 deletions test/integration/services/quotes/quote-tests-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ if (process.env.OKX_DEX_API_KEY && process.env.OKX_DEX_SECRET_KEY && process.env
passphrase: process.env.OKX_DEX_PASSPHRASE,
};
}
if (process.env.MAGPIE_API_KEY) {
CONFIG.custom!.magpie = { apiKey: process.env.MAGPIE_API_KEY };
if (process.env.FLY_API_KEY) {
CONFIG.custom!.fly = { apiKey: process.env.FLY_API_KEY };
}

export enum Test {
Expand Down