Skip to content

Commit

Permalink
fix: add fee option to top level config
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Nov 17, 2022
1 parent 370b38e commit 4ce4d7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/widget-embedded/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export const widgetBaseConfig: WidgetConfig = {
buildSwapUrl: true,
// disabledUI: ['toAddress', 'fromAmount', 'toToken', 'fromToken'],
sdkConfig: {
apiUrl: 'https://staging.li.quest/v1/',
// apiUrl: 'https://staging.li.quest/v1/',
defaultRouteOptions: {
// slippage: 0.02,
// slippage: 0.03,
// order: 'SAFEST',
// allowSwitchChain: false,
// fee: 0.05
Expand Down
8 changes: 6 additions & 2 deletions packages/widget/src/providers/SDKProvider/SDKProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ export const useLiFi = (): LIFI => useContext(SDKContext);
export const SDKProvider: React.FC<React.PropsWithChildren> = ({
children,
}) => {
const { sdkConfig, integrator } = useWidgetConfig();
const { sdkConfig, fee, integrator, routePriority, slippage } =
useWidgetConfig();
const value = useMemo(() => {
const config = {
...sdkConfig,
defaultRouteOptions: {
fee,
integrator: integrator ?? window.location.hostname,
routePriority,
slippage,
...sdkConfig?.defaultRouteOptions,
},
};
Expand All @@ -28,7 +32,7 @@ export const SDKProvider: React.FC<React.PropsWithChildren> = ({
}
lifi.setConfig(config);
return lifi;
}, [integrator, sdkConfig]);
}, [fee, integrator, routePriority, sdkConfig, slippage]);

return <SDKContext.Provider value={value}>{children}</SDKContext.Provider>;
};
1 change: 1 addition & 0 deletions packages/widget/src/types/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface WidgetConfig {
toAddress?: string;
fromAmount?: number | string;

fee?: number;
integrator?: string;

slippage?: number;
Expand Down

0 comments on commit 4ce4d7d

Please sign in to comment.