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

Commit ca5689f

Browse files
authored
Merge pull request #121 from 1inch/aggregation-protocol-V6-routers
[SC-779] Update docs for routers in AggregationRouterV6
2 parents 34732e6 + 2c571f0 commit ca5689f

14 files changed

+1883
-441
lines changed

docs/aggregation-protocol/smart-contract/AggregationRouterV5.md

Lines changed: 0 additions & 108 deletions
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# AggregationRouterV6
2+
3+
4+
5+
6+
7+
8+
## Derives
9+
- [GenericRouter](GenericRouter.md)
10+
- [ClipperRouter](ClipperRouter.md)
11+
- [UnoswapRouter](UnoswapRouter.md)
12+
- [LimitOrderProtocol](LimitOrderProtocol.md)
13+
- [IUniswapV3SwapCallback](interfaces/IUniswapV3SwapCallback.md)
14+
- [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/drafts#EIP712)
15+
- [EthReceiver](helpers/EthReceiver.md)
16+
- [Ownable](https://docs.openzeppelin.com/contracts/3.x/api/access#Ownable)
17+
- [OnlyWethReceiver](helpers/OnlyWethReceiver.md)
18+
- [PredicateHelper](helpers/PredicateHelper.md)
19+
- [SeriesEpochManager](helpers/SeriesEpochManager.md)
20+
21+
## Functions
22+
### constructor
23+
```solidity
24+
function constructor(
25+
contract IWETH weth
26+
)
27+
```
28+
29+
30+
#### Parameters:
31+
| Name | Type | Description |
32+
| :--- | :--- | :------------------------------------------------------------------- |
33+
|`weth` | contract IWETH |
34+
35+
36+
### rescueFunds
37+
```solidity
38+
function rescueFunds(
39+
contract IERC20 token,
40+
uint256 amount
41+
) external
42+
```
43+
Retrieves funds accidently sent directly to the contract address.
44+
45+
46+
#### Parameters:
47+
| Name | Type | Description |
48+
| :--- | :--- | :------------------------------------------------------------------- |
49+
|`token` | contract IERC20 | ERC20 token to retrieve
50+
|`amount` | uint256 | amount to retrieve
51+
52+
53+
### destroy
54+
```solidity
55+
function destroy(
56+
) external
57+
```
58+
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.
59+
60+
61+
62+
## Events
63+
### Swapped
64+
```solidity
65+
event Swapped(
66+
address sender,
67+
contract IERC20 srcToken,
68+
contract IERC20 dstToken,
69+
address dstReceiver,
70+
uint256 spentAmount,
71+
uint256 returnAmount
72+
)
73+
```
74+
75+
76+
#### Parameters:
77+
| Name | Type | Description |
78+
| :--- | :--- | :------------------------------------------------------------------- |
79+
|`sender` | address |
80+
|`srcToken` | contract IERC20 |
81+
|`dstToken` | contract IERC20 |
82+
|`dstReceiver` | address |
83+
|`spentAmount` | uint256 |
84+
|`returnAmount` | uint256 |

docs/aggregation-protocol/smart-contract/ClipperRouter.md

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,82 +6,108 @@ Clipper router that allows to use `ClipperExchangeInterface` for swaps
66

77

88
## Derives
9-
- [Permitable](helpers/Permitable.md)
109
- [EthReceiver](helpers/EthReceiver.md)
1110

1211
## Functions
1312
### constructor
1413
```solidity
15-
function constructor(
16-
address weth,
17-
contract IClipperExchangeInterface clipperExchange
18-
) public
14+
function constructor(contract IWETH weth)
1915
```
2016

2117

2218
#### Parameters:
2319
| Name | Type | Description |
2420
| :--- | :--- | :------------------------------------------------------------------- |
25-
|`weth` | address |
26-
|`clipperExchange` | contract IClipperExchangeInterface |
21+
|`weth` | contract IWETH |
2722

2823

2924
### clipperSwapToWithPermit
3025
```solidity
3126
function clipperSwapToWithPermit(
32-
address payable recipient,
33-
contract IERC20 srcToken,
34-
contract IERC20 dstToken,
35-
uint256 amount,
36-
uint256 minReturn,
37-
bytes permit
38-
) external returns (uint256 returnAmount)
27+
contract IClipperExchangeInterface clipperExchange,
28+
address payable recipient,
29+
contract IERC20 srcToken,
30+
contract IERC20 dstToken,
31+
uint256 inputAmount,
32+
uint256 outputAmount,
33+
uint256 expiryWithFlags,
34+
bytes32 r,
35+
bytes32 vs,
36+
bytes calldata permit
37+
) external returns(uint256 returnAmount)
3938
```
40-
Same as `clipperSwapTo` but calls permit first,
41-
allowing to approve token spending and make a swap in one transaction.
39+
Same as `clipperSwapTo` but calls permit first, allowing to approve token spending and make a swap in one transaction.
4240

4341

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

5456

57+
#### Return values
58+
| Name | Type | Description |
59+
| :--- | :--- | :------------------------------------------------------------------- |
60+
|`returnAmount` | uint256 | Amount of destination tokens received
61+
62+
5563
### clipperSwap
5664
```solidity
5765
function clipperSwap(
58-
contract IERC20 srcToken,
59-
contract IERC20 dstToken,
60-
uint256 amount,
61-
uint256 minReturn
62-
) external returns (uint256 returnAmount)
66+
contract IClipperExchangeInterface clipperExchange,
67+
contract IERC20 srcToken,
68+
contract IERC20 dstToken,
69+
uint256 inputAmount,
70+
uint256 outputAmount,
71+
uint256 expiryWithFlags,
72+
bytes32 r,
73+
bytes32 vs
74+
) external payable returns(uint256 returnAmount)
6375
```
6476
Same as `clipperSwapTo` but uses `msg.sender` as recipient
6577

6678

6779
#### Parameters:
6880
| Name | Type | Description |
6981
| :--- | :--- | :------------------------------------------------------------------- |
82+
|`clipperExchange` | contract IClipperExchangeInterface | Clipper pool address
7083
|`srcToken` | contract IERC20 | Source token
7184
|`dstToken` | contract IERC20 | Destination token
72-
|`amount` | uint256 | Amount of source tokens to swap
73-
|`minReturn` | uint256 | Minimal allowed returnAmount to make transaction commit
85+
|`inputAmount` | uint256 | Amount of source tokens to swap
86+
|`outputAmount` | uint256 | Amount of destination tokens to receive
87+
|`expiryWithFlags` | uint256 | Timestamp until the swap will be valid with permit2 flag
88+
|`r` | bytes32 | Clipper order signature (r part)
89+
|`vs` | bytes32 | Clipper order signature (vs part)
90+
91+
92+
#### Return values
93+
| Name | Type | Description |
94+
| :--- | :--- | :------------------------------------------------------------------- |
95+
|`returnAmount` | uint256 | Amount of destination tokens received
7496

7597

7698
### clipperSwapTo
7799
```solidity
78100
function clipperSwapTo(
79-
address payable recipient,
80-
contract IERC20 srcToken,
81-
contract IERC20 dstToken,
82-
uint256 amount,
83-
uint256 minReturn
84-
) public returns (uint256 returnAmount)
101+
contract IClipperExchangeInterface clipperExchange,
102+
address payable recipient,
103+
contract IERC20 srcToken,
104+
contract IERC20 dstToken,
105+
uint256 inputAmount,
106+
uint256 outputAmount,
107+
uint256 expiryWithFlags,
108+
bytes32 r,
109+
bytes32 vs
110+
) public payable returns(uint256 returnAmount)
85111
```
86112
Performs swap using Clipper exchange. Wraps and unwraps ETH if required.
87113
Sending non-zero `msg.value` for anything but ETH swaps is prohibited
@@ -90,9 +116,19 @@ Sending non-zero `msg.value` for anything but ETH swaps is prohibited
90116
#### Parameters:
91117
| Name | Type | Description |
92118
| :--- | :--- | :------------------------------------------------------------------- |
119+
|`clipperExchange` | contract IClipperExchangeInterface | Clipper pool address
93120
|`recipient` | address payable | Address that will receive swap funds
94121
|`srcToken` | contract IERC20 | Source token
95122
|`dstToken` | contract IERC20 | Destination token
96-
|`amount` | uint256 | Amount of source tokens to swap
97-
|`minReturn` | uint256 | Minimal allowed returnAmount to make transaction commit
123+
|`inputAmount` | uint256 | Amount of source tokens to swap
124+
|`outputAmount` | uint256 | Amount of destination tokens to receive
125+
|`expiryWithFlags` | uint256 | Timestamp until the swap will be valid with permit2 flag
126+
|`r` | bytes32 | Clipper order signature (r part)
127+
|`vs` | bytes32 | Clipper order signature (vs part)
128+
129+
130+
#### Return values
131+
| Name | Type | Description |
132+
| :--- | :--- | :------------------------------------------------------------------- |
133+
|`returnAmount` | uint256 | Amount of destination tokens received
98134

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# GenericRouter
2+
3+
4+
Router that allows to use `IAggregationExecutor` for swaps
5+
6+
7+
8+
## Derives
9+
- [EthReceiver](helpers/EthReceiver.md)
10+
11+
## Functions
12+
### swap
13+
```solidity
14+
function swap(
15+
contract IAggregationExecutor executor,
16+
contract SwapDescription calldata desc,
17+
bytes calldata permit,
18+
bytes calldata data
19+
) external payable returns (uint256 returnAmount, uint256 spentAmount)
20+
```
21+
Performs a swap, delegating all calls encoded in `data` to `executor`. See tests for usage examples
22+
23+
24+
#### Parameters:
25+
| Name | Type | Description |
26+
| :--- | :--- | :------------------------------------------------------------------- |
27+
|`executor` | contract IAggregationExecutore | Aggregation executor that executes calls described in `data`
28+
|`desc` | contract SwapDescription | Swap description
29+
|`permit` | bytes | Should contain valid permit that can be used in `IERC20Permit.permit` calls
30+
|`data` | bytes | Encoded calls that `caller` should execute in between of swaps
31+
32+
33+
#### Return values
34+
| Name | Type | Description |
35+
| :--- | :--- | :------------------------------------------------------------------- |
36+
|`returnAmount` | uint256 | Resulting token amount
37+
|`spentAmount` | uint256 | Source token amount

0 commit comments

Comments
 (0)