0% found this document useful (0 votes)
13 views1 page

Uniswap V3 Token Swap Contract

The document is a Solidity smart contract named 'Fees' that facilitates the swapping of loan tokens for collateral tokens using the Uniswap V3 router. It includes a constructor that initializes the contract with WETH and staking addresses, and a function 'sellProfits' that swaps specified tokens for WETH and transfers the resulting WETH to a staking address. The contract ensures that the token being swapped is not WETH itself and uses specific parameters for the swap operation.

Uploaded by

Tanishq Sharma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Uniswap V3 Token Swap Contract

The document is a Solidity smart contract named 'Fees' that facilitates the swapping of loan tokens for collateral tokens using the Uniswap V3 router. It includes a constructor that initializes the contract with WETH and staking addresses, and a function 'sellProfits' that swaps specified tokens for WETH and transfers the resulting WETH to a staking address. The contract ensures that the token being swapped is not WETH itself and uses specific parameters for the swap operation.

Uploaded by

Tanishq Sharma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.19;

import "./utils/[Link]";
import "./utils/[Link]";

import {IERC20} from "./interfaces/[Link]";

import {ISwapRouter} from "./interfaces/[Link]";

contract Fees {
address public immutable WETH;
address public immutable staking;

/// uniswap v3 router


ISwapRouter public constant swapRouter =
ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);

constructor(address _weth, address _staking) {


WETH = _weth;
staking = _staking;
}

/// @notice swap loan tokens for collateral tokens from liquidations
/// @param _profits the token to swap for WETH
function sellProfits(address _profits) public {
require(_profits != WETH, "not allowed");
uint256 amount = IERC20(_profits).balanceOf(address(this));

[Link] memory params = ISwapRouter


.ExactInputSingleParams({
tokenIn: _profits,
tokenOut: WETH,
fee: 3000,
recipient: address(this),
deadline: [Link],
amountIn: amount,
amountOutMinimum: 0,
sqrtPriceLimitX96: 0
});

amount = [Link](params);
IERC20(WETH).transfer(staking, IERC20(WETH).balanceOf(address(this)));
}
}

You might also like