Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #121 from 1inch/aggregation-protocol-V6-routers
Browse files Browse the repository at this point in the history
[SC-779] Update docs for routers in AggregationRouterV6
  • Loading branch information
galekseev authored Mar 22, 2024
2 parents 34732e6 + 2c571f0 commit ca5689f
Show file tree
Hide file tree
Showing 14 changed files with 1,883 additions and 441 deletions.
108 changes: 0 additions & 108 deletions docs/aggregation-protocol/smart-contract/AggregationRouterV5.md

This file was deleted.

84 changes: 84 additions & 0 deletions docs/aggregation-protocol/smart-contract/AggregationRouterV6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# AggregationRouterV6






## Derives
- [GenericRouter](GenericRouter.md)
- [ClipperRouter](ClipperRouter.md)
- [UnoswapRouter](UnoswapRouter.md)
- [LimitOrderProtocol](LimitOrderProtocol.md)
- [IUniswapV3SwapCallback](interfaces/IUniswapV3SwapCallback.md)
- [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/drafts#EIP712)
- [EthReceiver](helpers/EthReceiver.md)
- [Ownable](https://docs.openzeppelin.com/contracts/3.x/api/access#Ownable)
- [OnlyWethReceiver](helpers/OnlyWethReceiver.md)
- [PredicateHelper](helpers/PredicateHelper.md)
- [SeriesEpochManager](helpers/SeriesEpochManager.md)

## Functions
### constructor
```solidity
function constructor(
contract IWETH weth
)
```


#### Parameters:
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`weth` | contract IWETH |


### rescueFunds
```solidity
function rescueFunds(
contract IERC20 token,
uint256 amount
) external
```
Retrieves funds accidently sent directly to the contract address.


#### Parameters:
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`token` | contract IERC20 | ERC20 token to retrieve
|`amount` | uint256 | amount to retrieve


### destroy
```solidity
function destroy(
) external
```
Destroys the contract and sends eth to sender. Use with caution. The only case when the use of the method is justified is if there is an exploit found. And the damage from the exploit is greater than from just an urgent contract change.



## Events
### Swapped
```solidity
event Swapped(
address sender,
contract IERC20 srcToken,
contract IERC20 dstToken,
address dstReceiver,
uint256 spentAmount,
uint256 returnAmount
)
```


#### Parameters:
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`sender` | address |
|`srcToken` | contract IERC20 |
|`dstToken` | contract IERC20 |
|`dstReceiver` | address |
|`spentAmount` | uint256 |
|`returnAmount` | uint256 |
102 changes: 69 additions & 33 deletions docs/aggregation-protocol/smart-contract/ClipperRouter.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,82 +6,108 @@ Clipper router that allows to use `ClipperExchangeInterface` for swaps


## Derives
- [Permitable](helpers/Permitable.md)
- [EthReceiver](helpers/EthReceiver.md)

## Functions
### constructor
```solidity
function constructor(
address weth,
contract IClipperExchangeInterface clipperExchange
) public
function constructor(contract IWETH weth)
```


#### Parameters:
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`weth` | address |
|`clipperExchange` | contract IClipperExchangeInterface |
|`weth` | contract IWETH |


### clipperSwapToWithPermit
```solidity
function clipperSwapToWithPermit(
address payable recipient,
contract IERC20 srcToken,
contract IERC20 dstToken,
uint256 amount,
uint256 minReturn,
bytes permit
) external returns (uint256 returnAmount)
contract IClipperExchangeInterface clipperExchange,
address payable recipient,
contract IERC20 srcToken,
contract IERC20 dstToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 expiryWithFlags,
bytes32 r,
bytes32 vs,
bytes calldata permit
) external returns(uint256 returnAmount)
```
Same as `clipperSwapTo` but calls permit first,
allowing to approve token spending and make a swap in one transaction.
Same as `clipperSwapTo` but calls permit first, allowing to approve token spending and make a swap in one transaction.


#### Parameters:
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`clipperExchange` | contract IClipperExchangeInterface | Clipper pool address
|`recipient` | address payable | Address that will receive swap funds
|`srcToken` | contract IERC20 | Source token
|`dstToken` | contract IERC20 | Destination token
|`amount` | uint256 | Amount of source tokens to swap
|`minReturn` | uint256 | Minimal allowed returnAmount to make transaction commit
|`inputAmount` | uint256 | Amount of source tokens to swap
|`outputAmount` | uint256 | Amount of destination tokens to receive
|`expiryWithFlags` | uint256 | Timestamp until the swap will be valid with permit2 flag
|`r` | bytes32 | Clipper order signature (r part)
|`vs` | bytes32 | Clipper order signature (vs part)
|`permit` | bytes | Should contain valid permit that can be used in `IERC20Permit.permit` calls. See tests for examples


#### Return values
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`returnAmount` | uint256 | Amount of destination tokens received


### clipperSwap
```solidity
function clipperSwap(
contract IERC20 srcToken,
contract IERC20 dstToken,
uint256 amount,
uint256 minReturn
) external returns (uint256 returnAmount)
contract IClipperExchangeInterface clipperExchange,
contract IERC20 srcToken,
contract IERC20 dstToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 expiryWithFlags,
bytes32 r,
bytes32 vs
) external payable returns(uint256 returnAmount)
```
Same as `clipperSwapTo` but uses `msg.sender` as recipient


#### Parameters:
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`clipperExchange` | contract IClipperExchangeInterface | Clipper pool address
|`srcToken` | contract IERC20 | Source token
|`dstToken` | contract IERC20 | Destination token
|`amount` | uint256 | Amount of source tokens to swap
|`minReturn` | uint256 | Minimal allowed returnAmount to make transaction commit
|`inputAmount` | uint256 | Amount of source tokens to swap
|`outputAmount` | uint256 | Amount of destination tokens to receive
|`expiryWithFlags` | uint256 | Timestamp until the swap will be valid with permit2 flag
|`r` | bytes32 | Clipper order signature (r part)
|`vs` | bytes32 | Clipper order signature (vs part)


#### Return values
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`returnAmount` | uint256 | Amount of destination tokens received


### clipperSwapTo
```solidity
function clipperSwapTo(
address payable recipient,
contract IERC20 srcToken,
contract IERC20 dstToken,
uint256 amount,
uint256 minReturn
) public returns (uint256 returnAmount)
contract IClipperExchangeInterface clipperExchange,
address payable recipient,
contract IERC20 srcToken,
contract IERC20 dstToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 expiryWithFlags,
bytes32 r,
bytes32 vs
) public payable returns(uint256 returnAmount)
```
Performs swap using Clipper exchange. Wraps and unwraps ETH if required.
Sending non-zero `msg.value` for anything but ETH swaps is prohibited
Expand All @@ -90,9 +116,19 @@ Sending non-zero `msg.value` for anything but ETH swaps is prohibited
#### Parameters:
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`clipperExchange` | contract IClipperExchangeInterface | Clipper pool address
|`recipient` | address payable | Address that will receive swap funds
|`srcToken` | contract IERC20 | Source token
|`dstToken` | contract IERC20 | Destination token
|`amount` | uint256 | Amount of source tokens to swap
|`minReturn` | uint256 | Minimal allowed returnAmount to make transaction commit
|`inputAmount` | uint256 | Amount of source tokens to swap
|`outputAmount` | uint256 | Amount of destination tokens to receive
|`expiryWithFlags` | uint256 | Timestamp until the swap will be valid with permit2 flag
|`r` | bytes32 | Clipper order signature (r part)
|`vs` | bytes32 | Clipper order signature (vs part)


#### Return values
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`returnAmount` | uint256 | Amount of destination tokens received

37 changes: 37 additions & 0 deletions docs/aggregation-protocol/smart-contract/GenericRouter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# GenericRouter


Router that allows to use `IAggregationExecutor` for swaps



## Derives
- [EthReceiver](helpers/EthReceiver.md)

## Functions
### swap
```solidity
function swap(
contract IAggregationExecutor executor,
contract SwapDescription calldata desc,
bytes calldata permit,
bytes calldata data
) external payable returns (uint256 returnAmount, uint256 spentAmount)
```
Performs a swap, delegating all calls encoded in `data` to `executor`. See tests for usage examples


#### Parameters:
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`executor` | contract IAggregationExecutore | Aggregation executor that executes calls described in `data`
|`desc` | contract SwapDescription | Swap description
|`permit` | bytes | Should contain valid permit that can be used in `IERC20Permit.permit` calls
|`data` | bytes | Encoded calls that `caller` should execute in between of swaps


#### Return values
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`returnAmount` | uint256 | Resulting token amount
|`spentAmount` | uint256 | Source token amount
Loading

0 comments on commit ca5689f

Please sign in to comment.