Paraswap Docs
Search…
Smart Contracts
Allowance should be given to TokenTransferProxy contract and not to AugustusSwapper

AugustusSwapper

The contract router is responsible for making swaps.

TokenTransferProxy

The Spender contract is responsible for moving ERC20 tokens (and equivalents on side chains). To get the address, you can call getTokenTransferProxy() on Augustus.
1
pragma solidity 0.7.5;
2
3
4
interface ITokenTransferProxy {
5
6
function transferFrom(
7
address token,
8
address from,
9
address to,
10
uint256 amount
11
)
12
external;
13
}
14
Copied!

AugustusSwapper (implements IParaswap through fallback method)

ABI (merged AugustusSwapper and IParaswap ABIs)

ParaSwap_ABI.json
34KB
Code

IAugustusSwapper (generated from AugustusSwapper ABI using ABI2Solidity tool then edited to add FeeStructure)

1
interface IAugustusSwapper {
2
struct FeeStructure {
3
uint256 partnerShare;
4
bool noPositiveSlippage;
5
bool positiveSlippageToUser;
6
uint16 feePercent;
7
string partnerId;
8
bytes data;
9
}
10
11
function DEFAULT_ADMIN_ROLE ( ) external view returns ( bytes32 );
12
function ROUTER_ROLE ( ) external view returns ( bytes32 );
13
function WHITELISTED_ROLE ( ) external view returns ( bytes32 );
14
function getAdapterData ( bytes32 key ) external view returns ( bytes );
15
function getFeeWallet ( ) external view returns ( address );
16
function getImplementation ( bytes4 selector ) external view returns ( address );
17
function getPartnerFeeStructure ( address partner ) external view returns ( FeeStructure memory );
18
function getRoleAdmin ( bytes32 role ) external view returns ( bytes32 );
19
function getRoleMember ( bytes32 role, uint256 index ) external view returns ( address );
20
function getRoleMemberCount ( bytes32 role ) external view returns ( uint256 );
21
function getRouterData ( bytes32 key ) external view returns ( bytes );
22
function getTokenTransferProxy ( ) external view returns ( address );
23
function getVersion ( ) external pure returns ( string );
24
function grantRole ( bytes32 role, address account ) external;
25
function hasRole ( bytes32 role, address account ) external view returns ( bool );
26
function initializeAdapter ( address adapter, bytes data ) external;
27
function initializeRouter ( address router, bytes data ) external;
28
function isAdapterInitialized ( bytes32 key ) external view returns ( bool );
29
function isRouterInitialized ( bytes32 key ) external view returns ( bool );
30
function registerPartner ( address partner, uint256 _partnerShare, bool _noPositiveSlippage, bool _positiveSlippageToUser, uint16 _feePercent, string partnerId, bytes _data ) external;
31
function renounceRole ( bytes32 role, address account ) external;
32
function revokeRole ( bytes32 role, address account ) external;
33
function setFeeWallet ( address _feeWallet ) external;
34
function setImplementation ( bytes4 selector, address implementation ) external;
35
function transferTokens ( address token, address destination, uint256 amount ) external;
36
}
Copied!

IParaswap

1
pragma solidity 0.7.5;
2
3
import "./lib/Utils.sol";
4
5
interface IParaswap {
6
event Swapped(
7
bytes16 uuid,
8
address initiator,
9
address indexed beneficiary,
10
address indexed srcToken,
11
address indexed destToken,
12
uint256 srcAmount,
13
uint256 receivedAmount,
14
uint256 expectedAmount
15
);
16
17
event Bought(
18
bytes16 uuid,
19
address initiator,
20
address indexed beneficiary,
21
address indexed srcToken,
22
address indexed destToken,
23
uint256 srcAmount,
24
uint256 receivedAmount
25
);
26
27
event FeeTaken(
28
uint256 fee,
29
uint256 partnerShare,
30
uint256 paraswapShare
31
);
32
33
function multiSwap(
34
Utils.SellData calldata data
35
)
36
external
37
payable
38
returns (uint256);
39
40
function megaSwap(
41
Utils.MegaSwapSellData calldata data
42
)
43
external
44
payable
45
returns (uint256);
46
47
function protectedMultiSwap(
48
Utils.SellData calldata data
49
)
50
external
51
payable
52
returns (uint256);
53
54
function protectedMegaSwap(
55
Utils.MegaSwapSellData calldata data
56
)
57
external
58
payable
59
returns (uint256);
60
61
function protectedSimpleSwap(
62
Utils.SimpleData calldata data
63
)
64
external
65
payable
66
returns (uint256 receivedAmount);
67
68
function protectedSimpleBuy(
69
Utils.SimpleData calldata data
70
)
71
external
72
payable;
73
74
function simpleSwap(
75
Utils.SimpleData calldata data
76
)
77
external
78
payable
79
returns (uint256 receivedAmount);
80
81
function simpleBuy(
82
Utils.SimpleData calldata data
83
)
84
external
85
payable;
86
87
function swapOnUniswap(
88
uint256 amountIn,
89
uint256 amountOutMin,
90
address[] calldata path
91
)
92
external
93
payable;
94
95
function swapOnUniswapFork(
96
address factory,
97
bytes32 initCode,
98
uint256 amountIn,
99
uint256 amountOutMin,
100
address[] calldata path
101
)
102
external
103
payable;
104
105
function buyOnUniswap(
106
uint256 amountInMax,
107
uint256 amountOut,
108
address[] calldata path
109
)
110
external
111
payable;
112
113
function buyOnUniswapFork(
114
address factory,
115
bytes32 initCode,
116
uint256 amountInMax,
117
uint256 amountOut,
118
address[] calldata path
119
)
120
external
121
payable;
122
123
function swapOnUniswapV2Fork(
124
address tokenIn,
125
uint256 amountIn,
126
uint256 amountOutMin,
127
address weth,
128
uint256[] calldata pools
129
)
130
external
131
payable;
132
133
function buyOnUniswapV2Fork(
134
address tokenIn,
135
uint256 amountInMax,
136
uint256 amountOut,
137
address weth,
138
uint256[] calldata pools
139
)
140
external
141
payable;
142
143
function swapOnZeroXv2(
144
IERC20 fromToken,
145
IERC20 toToken,
146
uint256 fromAmount,
147
uint256 amountOutMin,
148
address exchange,
149
bytes calldata payload
150
)
151
external
152
payable;
153
154
function swapOnZeroXv4(
155
IERC20 fromToken,
156
IERC20 toToken,
157
uint256 fromAmount,
158
uint256 amountOutMin,
159
address exchange,
160
bytes calldata payload
161
)
162
external
163
payable;
164
}
Copied!

Utils

1
pragma solidity 0.7.5;
2
3
library Utils {
4
/**
5
* @param fromToken Address of the source token
6
* @param fromAmount Amount of source tokens to be swapped
7
* @param toAmount Minimum destination token amount expected out of this swap
8
* @param expectedAmount Expected amount of destination tokens without slippage
9
* @param beneficiary Beneficiary address
10
* 0 then 100% will be transferred to beneficiary. Pass 10000 for 100%
11
* @param path Route to be taken for this swap to take place
12
13
*/
14
struct SellData {
15
address fromToken;
16
uint256 fromAmount;
17
uint256 toAmount;
18
uint256 expectedAmount;
19
address payable beneficiary;
20
Utils.Path[] path;
21
address payable partner;
22
uint256 feePercent;
23
bytes permit;
24
uint256 deadline;
25
bytes16 uuid;
26
}
27
28
struct MegaSwapSellData {
29
address fromToken;
30
uint256 fromAmount;
31
uint256 toAmount;
32
uint256 expectedAmount;
33
address payable beneficiary;
34
Utils.MegaSwapPath[] path;
35
address payable partner;
36
uint256 feePercent;
37
bytes permit;
38
uint256 deadline;
39
bytes16 uuid;
40
}
41
42
struct SimpleData {
43
address fromToken;
44
address toToken;
45
uint256 fromAmount;
46
uint256 toAmount;
47
uint256 expectedAmount;
48
address[] callees;
49
bytes exchangeData;
50
uint256[] startIndexes;
51
uint256[] values;
52
address payable beneficiary;
53
address payable partner;
54
uint256 feePercent;
55
bytes permit;
56
uint256 deadline;
57
bytes16 uuid;
58
}
59
60
struct Adapter {
61
address payable adapter;
62
uint256 percent;
63
uint256 networkFee;
64
Route[] route;
65
}
66
67
struct Route {
68
uint256 index;//Adapter at which index needs to be used
69
address targetExchange;
70
uint percent;
71
bytes payload;
72
uint256 networkFee;//Network fee is associated with 0xv3 trades
73
}
74
75
struct MegaSwapPath {
76
uint256 fromAmountPercent;
77
Path[] path;
78
}
79
80
struct Path {
81
address to;
82
uint256 totalNetworkFee;//Network fee is associated with 0xv3 trades
83
Adapter[] adapters;
84
}
85
}
Copied!
Last modified 2mo ago