Skip to content
Open
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 @@ -34,6 +34,7 @@ contract UniswapV2ExchangeAdapter {


// YOUR CODE HERE
address public immutable router;



Expand All @@ -49,6 +50,9 @@ contract UniswapV2ExchangeAdapter {


// YOUR CODE HERE
constructor(address _router) public {
router = _router;
}



Expand All @@ -75,7 +79,18 @@ contract UniswapV2ExchangeAdapter {
* The function will return 3 values: address of the uniswap router, 0 for Call value, trade calldata
*/

function getTradeCalldata(/*YOUR CODE HERE*/) external view returns (/*YOUR CODE HERE*/){
function getTradeCalldata(
address _sourceToken,
address _destinationToken,
address _destinationAddress,
uint256 _sourceQuantity,
uint256 _minDestinationQuantity,
bytes memory _data
) external view returns (
address,
uint256,
bytes memory
){


/*
Expand All @@ -100,9 +115,17 @@ contract UniswapV2ExchangeAdapter {
*/

// YOUR CODE HERE
bytes memory callData = abi.encodeWithSignature(
"swapExactTokensForTokens(uint256,uint256,address[],address,uint256)",
_sourceQuantity,
_minDestinationQuantity,
path,
_destinationAddress,
block.timestamp
);


return (/*YOUR CODE HERE*/);
return (router, 0, callData);

}

Expand All @@ -121,6 +144,9 @@ contract UniswapV2ExchangeAdapter {
*/

// YOUR CODE HERE
function getSpender() external view returns(address){
return router;
}

}

1 change: 1 addition & 0 deletions utils/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export { TradeAdapterMock } from "../../typechain/TradeAdapterMock";
export { Uint256ArrayUtilsMock } from "../../typechain/Uint256ArrayUtilsMock";
export { Uni } from "../../typechain/Uni";
export { UniswapPairPriceAdapter } from "../../typechain/UniswapPairPriceAdapter";
export { UniswapV2ExchangeAdapter } from "../../typechain/UniswapV2ExchangeAdapter";
export { UniswapV2IndexExchangeAdapter } from "../../typechain/UniswapV2IndexExchangeAdapter";
export { UniswapV2TransferFeeExchangeAdapter } from "../../typechain/UniswapV2TransferFeeExchangeAdapter";
export { UniswapV2Factory } from "../../typechain/UniswapV2Factory";
Expand Down
6 changes: 6 additions & 0 deletions utils/deploys/deployAdapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
CompoundWrapAdapter,
YearnWrapAdapter,
UniswapPairPriceAdapter,
UniswapV2ExchangeAdapter,
UniswapV2IndexExchangeAdapter,
UniswapV2TransferFeeExchangeAdapter,
ZeroExApiAdapter,
Expand All @@ -40,6 +41,7 @@ import { AaveWrapAdapter__factory } from "../../typechain/factories/AaveWrapAdap
import { CompoundWrapAdapter__factory } from "../../typechain/factories/CompoundWrapAdapter__factory";
import { YearnWrapAdapter__factory } from "../../typechain/factories/YearnWrapAdapter__factory";
import { UniswapPairPriceAdapter__factory } from "../../typechain/factories/UniswapPairPriceAdapter__factory";
import { UniswapV2ExchangeAdapter__factory } from "../../typechain/factories/UniswapV2ExchangeAdapter__factory";
import { UniswapV2TransferFeeExchangeAdapter__factory } from "../../typechain/factories/UniswapV2TransferFeeExchangeAdapter__factory";
import { UniswapV2IndexExchangeAdapter__factory } from "../../typechain/factories/UniswapV2IndexExchangeAdapter__factory";
import { SynthetixExchangeAdapter__factory } from "../../typechain/factories/SynthetixExchangeAdapter__factory";
Expand Down Expand Up @@ -73,6 +75,10 @@ export default class DeployAdapters {
return await new UniswapV2TransferFeeExchangeAdapter__factory(this._deployerSigner).deploy(uniswapV2Router);
}

public async deployUniswapV2ExchangeAdapter(router: Address): Promise<UniswapV2ExchangeAdapter> {
return await new UniswapV2ExchangeAdapter__factory(this._deployerSigner).deploy(router);
}

public async deployUniswapV2IndexExchangeAdapter(uniswapV2Router: Address): Promise<UniswapV2IndexExchangeAdapter> {
return await new UniswapV2IndexExchangeAdapter__factory(this._deployerSigner).deploy(uniswapV2Router);
}
Expand Down