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 @@ -33,6 +33,7 @@ contract UniswapV2ExchangeAdapter {
*/


address public router;
// YOUR CODE HERE


Expand All @@ -48,7 +49,9 @@ contract UniswapV2ExchangeAdapter {
*/


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



Expand All @@ -75,7 +78,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 calldata _data
) external view returns (
address,
uint256,
bytes memory
) {


/*
Expand All @@ -85,11 +99,11 @@ contract UniswapV2ExchangeAdapter {

address[] memory path;

if (_data.length == 0){
if (_data.length == 0) {
path = new address[](2);
path[0] = _sourceToken;
path[1] = _destinationToken;
}else {
} else {
path = abi.decode(_data, (address[]));
}

Expand All @@ -99,10 +113,17 @@ contract UniswapV2ExchangeAdapter {
* Please see README.md resources for more details on the Uniswap function swapExactTokensForTokens.
*/

// 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 @@ -120,7 +141,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 @@ -81,6 +81,7 @@ export { TradeModule } from "../../typechain/TradeModule";
export { TradeAdapterMock } from "../../typechain/TradeAdapterMock";
export { Uint256ArrayUtilsMock } from "../../typechain/Uint256ArrayUtilsMock";
export { Uni } from "../../typechain/Uni";
export { UniswapV2ExchangeAdapter } from "../../typechain/UniswapV2ExchangeAdapter";
export { UniswapPairPriceAdapter } from "../../typechain/UniswapPairPriceAdapter";
export { UniswapV2IndexExchangeAdapter } from "../../typechain/UniswapV2IndexExchangeAdapter";
export { UniswapV2TransferFeeExchangeAdapter } from "../../typechain/UniswapV2TransferFeeExchangeAdapter";
Expand Down
10 changes: 10 additions & 0 deletions utils/deploys/deployAdapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
SynthetixExchangeAdapter,
CompoundBravoGovernanceAdapter,
CompClaimAdapter,
UniswapV2ExchangeAdapter
} from "../contracts";
import { convertLibraryNameToLinkId } from "../common";
import { Address, Bytes } from "./../types";
Expand All @@ -45,6 +46,7 @@ import { UniswapV2IndexExchangeAdapter__factory } from "../../typechain/factorie
import { SynthetixExchangeAdapter__factory } from "../../typechain/factories/SynthetixExchangeAdapter__factory";
import { CompoundBravoGovernanceAdapter__factory } from "../../typechain/factories/CompoundBravoGovernanceAdapter__factory";
import { CompClaimAdapter__factory } from "../../typechain";
import { UniswapV2ExchangeAdapter__factory } from "../../typechain/factories/UniswapV2ExchangeAdapter__factory";

export default class DeployAdapters {
private _deployerSigner: Signer;
Expand Down Expand Up @@ -170,4 +172,12 @@ export default class DeployAdapters {
synthetixExchangerAddress
);
}

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