Skip to content

Commit

Permalink
feat: add feature flag enable_unwrapWETH9_call (#2139)
Browse files Browse the repository at this point in the history
Co-authored-by: iGroza <[email protected]>
  • Loading branch information
iGroza and iGroza authored Oct 14, 2024
1 parent 4daa240 commit 3d7f946
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/models/provider/provider-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export class ProviderConfigModel {
get wethSymbol() {
return this.config?.weth_symbol ?? '';
}
get enableUnwrapWETH9Call() {
return this.config?.enable_unwrapWETH9_call ?? false;
}

/**
* Get the EVM explorer URL template for an address.
Expand Down
7 changes: 5 additions & 2 deletions src/screens/SwapStack/swap-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -864,10 +864,13 @@ export const SwapScreen = observer(() => {
) as string;

// if token1 is native, we need to unwrap it
if (toke1IsNative) {
if (
toke1IsNative &&
Provider.selectedProvider.config.enableUnwrapWETH9Call
) {
const encodedUnwrap = swapRouter.interface.encodeFunctionData(
'unwrapWETH9',
['0x0', currentWallet.address],
[minReceivedAmount?.toHex() || 0, currentWallet.address],
);

txData = swapRouter.interface.encodeFunctionData('multicall', [
Expand Down
1 change: 1 addition & 0 deletions src/services/indexer/indexer.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type SushiPoolEstimateRequest = {
};

export type ProviderConfig = {
enable_unwrapWETH9_call?: boolean;
nft_exists?: boolean;
bech32_exists?: boolean;
swap_enabled: boolean;
Expand Down

0 comments on commit 3d7f946

Please sign in to comment.