Skip to content

Commit

Permalink
fix: changes to magpie
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsambugs committed Jan 20, 2025
1 parent fbf623b commit 74ddb7b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/services/quotes/quote-sources/magpie-quote-source.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import qs from 'qs';
import { parseUnits } from 'viem';
import { Chains } from '@chains';
import { Address, ChainId, TokenAddress } from '@types';
import { ChainId, TokenAddress } from '@types';
import { AlwaysValidConfigAndContextSource } from './base/always-valid-source';
import { BuildTxParams, QuoteParams, QuoteSourceMetadata, SourceQuoteResponse, SourceQuoteTransaction } from './types';
import { addQuoteSlippage, calculateAllowanceTarget, failed } from './utils';
Expand Down Expand Up @@ -35,7 +35,7 @@ const MAGPIE_METADATA: QuoteSourceMetadata<MagpieSupport> = {
};
type MagpieSupport = { buyOrders: false; swapAndTransfer: true };
type MagpieConfig = { sourceAllowlist?: string[] };
type MagpieData = { quoteId: string; takeFrom: Address; recipient: Address | undefined };
type MagpieData = { quoteId: string };
export class MagpieQuoteSource extends AlwaysValidConfigAndContextSource<MagpieSupport, MagpieConfig, MagpieData> {
getMetadata() {
return MAGPIE_METADATA;
Expand All @@ -60,6 +60,9 @@ export class MagpieQuoteSource extends AlwaysValidConfigAndContextSource<MagpieS
sellAmount: order.sellAmount.toString(),
slippage: slippagePercentage / 100,
liquiditySources: config.sourceAllowlist,
fromAddress: takeFrom,
toAddress: recipient ?? takeFrom,
gasless: false,
};

const quoteQueryString = qs.stringify(quoteQueryParams, { skipNulls: true, arrayFormat: 'comma' });
Expand Down Expand Up @@ -90,13 +93,11 @@ export class MagpieQuoteSource extends AlwaysValidConfigAndContextSource<MagpieS
sellToken,
buyToken,
config: { timeout },
customData: { quoteId, takeFrom, recipient },
customData: { quoteId },
},
}: BuildTxParams<MagpieConfig, MagpieData>): Promise<SourceQuoteTransaction> {
const transactionQueryParams = {
quoteId,
toAddress: recipient ?? takeFrom,
fromAddress: takeFrom,
estimateGas: false,
};
const transactionQueryString = qs.stringify(transactionQueryParams, { skipNulls: true, arrayFormat: 'comma' });
Expand Down

0 comments on commit 74ddb7b

Please sign in to comment.