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

Commit 84da126

Browse files
committed
Revert "Update docs with 1inch-contract repo"
This reverts commit 6d2e346.
1 parent 6d2e346 commit 84da126

File tree

7 files changed

+710
-626
lines changed

7 files changed

+710
-626
lines changed
Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,82 @@
1-
# Solidity API
1+
# AggregationRouterV6
22

3-
## AggregationRouterV6
43

5-
Main contract incorporates a number of routers to perform swaps and limit orders protocol to fill limit orders
64

7-
### ZeroAddress
85

9-
```solidity
10-
error ZeroAddress()
11-
```
126

13-
### constructor
147

8+
## Derives
9+
- [GenericRouter](GenericRouter.md)
10+
- [ClipperRouter](ClipperRouter.md)
11+
- [UnoswapRouter](UnoswapRouter.md)
12+
- [LimitOrderProtocolRFQ](LimitOrderProtocolRFQ.md)
13+
- [IUniswapV3SwapCallback](interfaces/IUniswapV3SwapCallback.md)
14+
- [Permitable](helpers/Permitable.md)
15+
- [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/drafts#EIP712)
16+
- [EthReceiver](helpers/EthReceiver.md)
17+
- [Ownable](https://docs.openzeppelin.com/contracts/3.x/api/access#Ownable)
18+
19+
## Functions
20+
### constructor
1521
```solidity
16-
constructor(contract IWETH weth) public
22+
function constructor(
23+
contract IWETH weth
24+
)
1725
```
1826

19-
_Sets the wrapped eth token and clipper exhange interface
20-
Both values are immutable: they can only be set once during
21-
construction._
2227

23-
### rescueFunds
28+
#### Parameters:
29+
| Name | Type | Description |
30+
| :--- | :--- | :------------------------------------------------------------------- |
31+
|`weth` | contract IWETH |
32+
2433

34+
### rescueFunds
2535
```solidity
26-
function rescueFunds(contract IERC20 token, uint256 amount) external
36+
function rescueFunds(
37+
contract IERC20 token,
38+
uint256 amount
39+
) external
2740
```
41+
Retrieves funds accidently sent directly to the contract address.
2842

29-
Retrieves funds accidently sent directly to the contract address
3043

31-
#### Parameters
44+
#### Parameters:
45+
| Name | Type | Description |
46+
| :--- | :--- | :------------------------------------------------------------------- |
47+
|`token` | contract IERC20 | ERC20 token to retrieve
48+
|`amount` | uint256 | amount to retrieve
3249

33-
| Name | Type | Description |
34-
| ---- | ---- | ----------- |
35-
| token | contract IERC20 | ERC20 token to retrieve |
36-
| amount | uint256 | amount to retrieve |
3750

3851
### destroy
39-
4052
```solidity
41-
function destroy() external
53+
function destroy(
54+
) external
4255
```
56+
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.
4357

44-
Destroys the contract and sends eth to sender. Use with caution.
45-
The only case when the use of the method is justified is if there is an exploit found.
46-
And the damage from the exploit is greater than from just an urgent contract change.
4758

48-
### _receive
4959

60+
## Events
61+
### Swapped
5062
```solidity
51-
function _receive() internal
63+
event Swapped(
64+
address sender,
65+
contract IERC20 srcToken,
66+
contract IERC20 dstToken,
67+
address dstReceiver,
68+
uint256 spentAmount,
69+
uint256 returnAmount
70+
)
5271
```
5372

73+
74+
#### Parameters:
75+
| Name | Type | Description |
76+
| :--- | :--- | :------------------------------------------------------------------- |
77+
|`sender` | address |
78+
|`srcToken` | contract IERC20 |
79+
|`dstToken` | contract IERC20 |
80+
|`dstReceiver` | address |
81+
|`spentAmount` | uint256 |
82+
|`returnAmount` | uint256 |
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# ClipperRouter
2+
3+
4+
Clipper router that allows to use `ClipperExchangeInterface` for swaps
5+
6+
7+
8+
## Derives
9+
- [EthReceiver](helpers/EthReceiver.md)
10+
11+
## Functions
12+
### constructor
13+
```solidity
14+
function constructor(contract IWETH weth)
15+
```
16+
17+
18+
#### Parameters:
19+
| Name | Type | Description |
20+
| :--- | :--- | :------------------------------------------------------------------- |
21+
|`weth` | contract IWETH |
22+
23+
24+
### clipperSwapToWithPermit
25+
```solidity
26+
function clipperSwapToWithPermit(
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)
38+
```
39+
Same as `clipperSwapTo` but calls permit first, allowing to approve token spending and make a swap in one transaction.
40+
41+
42+
#### Parameters:
43+
| Name | Type | Description |
44+
| :--- | :--- | :------------------------------------------------------------------- |
45+
|`clipperExchange` | contract IClipperExchangeInterface | Clipper pool address
46+
|`recipient` | address payable | Address that will receive swap funds
47+
|`srcToken` | contract IERC20 | Source token
48+
|`dstToken` | contract IERC20 | Destination token
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)
54+
|`permit` | bytes | Should contain valid permit that can be used in `IERC20Permit.permit` calls. See tests for examples
55+
56+
57+
#### Return values
58+
| Name | Type | Description |
59+
| :--- | :--- | :------------------------------------------------------------------- |
60+
|`returnAmount` | uint256 | Amount of destination tokens received
61+
62+
63+
### clipperSwap
64+
```solidity
65+
function clipperSwap(
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)
75+
```
76+
Same as `clipperSwapTo` but uses `msg.sender` as recipient
77+
78+
79+
#### Parameters:
80+
| Name | Type | Description |
81+
| :--- | :--- | :------------------------------------------------------------------- |
82+
|`clipperExchange` | contract IClipperExchangeInterface | Clipper pool address
83+
|`srcToken` | contract IERC20 | Source token
84+
|`dstToken` | contract IERC20 | Destination token
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
96+
97+
98+
### clipperSwapTo
99+
```solidity
100+
function clipperSwapTo(
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)
111+
```
112+
Performs swap using Clipper exchange. Wraps and unwraps ETH if required.
113+
Sending non-zero `msg.value` for anything but ETH swaps is prohibited
114+
115+
116+
#### Parameters:
117+
| Name | Type | Description |
118+
| :--- | :--- | :------------------------------------------------------------------- |
119+
|`clipperExchange` | contract IClipperExchangeInterface | Clipper pool address
120+
|`recipient` | address payable | Address that will receive swap funds
121+
|`srcToken` | contract IERC20 | Source token
122+
|`dstToken` | contract IERC20 | Destination token
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
134+
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)