Augustus v6.2
Augustus is the exchange middleware that enables on-chain swaps
AugustusSwapper
The contract router is responsible for making swaps.
Avalanche: 0x6a000f20005980200259b80c5102003040001068
Polygon zkEVM: 0x6a000f20005980200259b80c5102003040001068
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
// Interfaces
import { IERC20 } from "@openzeppelin/token/ERC20/IERC20.sol";
/*//////////////////////////////////////////////////////////////
GENERIC SWAP DATA
//////////////////////////////////////////////////////////////*/
/// @notice Struct containg data for generic swapExactAmountIn/swapExactAmountOut
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param quotedAmount The quoted expected amount of destToken/srcToken
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
struct GenericData {
IERC20 srcToken;
IERC20 destToken;
uint256 fromAmount;
uint256 toAmount;
uint256 quotedAmount;
bytes32 metadata;
address payable beneficiary;
}
/*//////////////////////////////////////////////////////////////
UNISWAPV2
//////////////////////////////////////////////////////////////*/
/// @notice Struct for UniswapV2 swapExactAmountIn/swapExactAmountOut data
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param quotedAmount The quoted expected amount of destToken/srcToken
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
/// @param pools data consisting of concatenated token0 and token1 address for each pool with the direction flag being
/// the right most bit of the packed token0-token1 pair bytes used in the path
struct UniswapV2Data {
IERC20 srcToken;
IERC20 destToken;
uint256 fromAmount;
uint256 toAmount;
uint256 quotedAmount;
bytes32 metadata;
address payable beneficiary;
bytes pools;
}
/*//////////////////////////////////////////////////////////////
UNISWAPV3
//////////////////////////////////////////////////////////////*/
/// @notice Struct for UniswapV3 swapExactAmountIn/swapExactAmountOut data
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param quotedAmount The quoted expected amount of destToken/srcToken
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
/// @param pools data consisting of concatenated token0-
/// token1-fee bytes for each pool used in the path, with the direction flag being the left most bit of token0 in the
/// concatenated bytes
struct UniswapV3Data {
IERC20 srcToken;
IERC20 destToken;
uint256 fromAmount;
uint256 toAmount;
uint256 quotedAmount;
bytes32 metadata;
address payable beneficiary;
bytes pools;
}
/*//////////////////////////////////////////////////////////////
CURVE V1
//////////////////////////////////////////////////////////////*/
/// @notice Struct for CurveV1 swapExactAmountIn data
/// @param curveData Packed data for the Curve pool, first 160 bits is the target exchange address,
/// the 161st bit is the approve flag, bits from (162 - 163) are used for the wrap flag,
//// bits from (164 - 165) are used for the swapType flag and the last 91 bits are unused:
/// Approve Flag - a) 0 -> do not approve b) 1 -> approve
/// Wrap Flag - a) 0 -> do not wrap b) 1 -> wrap native & srcToken == eth
/// c) 2 -> unwrap and destToken == eth d) 3 - >srcToken == eth && do not wrap
/// Swap Type Flag - a) 0 -> EXCHANGE b) 1 -> EXCHANGE_UNDERLYING
/// @param curveAssets Packed uint128 index i and uint128 index j of the pool
/// The first 128 bits is the index i and the second 128 bits is the index j
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount that must be recieved
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param quotedAmount The expected amount of destToken to be recieved
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
struct CurveV1Data {
uint256 curveData;
uint256 curveAssets;
IERC20 srcToken;
IERC20 destToken;
uint256 fromAmount;
uint256 toAmount;
uint256 quotedAmount;
bytes32 metadata;
address payable beneficiary;
}
/*//////////////////////////////////////////////////////////////
CURVE V2
//////////////////////////////////////////////////////////////*/
/// @notice Struct for CurveV2 swapExactAmountIn data
/// @param curveData Packed data for the Curve pool, first 160 bits is the target exchange address,
/// the 161st bit is the approve flag, bits from (162 - 163) are used for the wrap flag,
//// bits from (164 - 165) are used for the swapType flag and the last 91 bits are unused
/// Approve Flag - a) 0 -> do not approve b) 1 -> approve
/// Approve Flag - a) 0 -> do not approve b) 1 -> approve
/// Wrap Flag - a) 0 -> do not wrap b) 1 -> wrap native & srcToken == eth
/// c) 2 -> unwrap and destToken == eth d) 3 - >srcToken == eth && do not wrap
/// Swap Type Flag - a) 0 -> EXCHANGE b) 1 -> EXCHANGE_UNDERLYING c) 2 -> EXCHANGE_UNDERLYING_FACTORY_ZAP
/// @param i The index of the srcToken
/// @param j The index of the destToken
/// The first 128 bits is the index i and the second 128 bits is the index j
/// @param poolAddress The address of the CurveV2 pool (only used for EXCHANGE_UNDERLYING_FACTORY_ZAP)
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount that must be recieved
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param quotedAmount The expected amount of destToken to be recieved
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
struct CurveV2Data {
uint256 curveData;
uint256 i;
uint256 j;
address poolAddress;
IERC20 srcToken;
IERC20 destToken;
uint256 fromAmount;
uint256 toAmount;
uint256 quotedAmount;
bytes32 metadata;
address payable beneficiary;
}
/*//////////////////////////////////////////////////////////////
BALANCER V2
//////////////////////////////////////////////////////////////*/
/// @notice Struct for BalancerV2 swapExactAmountIn data
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param quotedAmount The quoted expected amount of destToken/srcToken
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiaryAndApproveFlag The beneficiary address and approve flag packed into one uint256,
/// the first 20 bytes are the beneficiary address and the left most bit is the approve flag
struct BalancerV2Data {
uint256 fromAmount;
uint256 toAmount;
uint256 quotedAmount;
bytes32 metadata;
uint256 beneficiaryAndApproveFlag;
}
/*//////////////////////////////////////////////////////////////
MAKERPSM
//////////////////////////////////////////////////////////////*/
/// @notice Struct for Maker PSM swapExactAmountIn data
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param toll Used to calculate gem amount for the swapExactAmountIn
/// @param to18ConversionFactor Used to calculate gem amount for the swapExactAmountIn
/// @param gemJoinAddress The address of the gemJoin contract
/// @param exchange The address of the exchange contract
/// @param metadata Packed uuid and additional metadata
/// @param beneficiaryDirectionApproveFlag The beneficiary address, swap direction and approve flag packed
/// into one uint256, the first 20 bytes are the beneficiary address, the left most bit is the approve flag and the
/// second left most bit is the swap direction flag, 0 for swapExactAmountIn and 1 for swapExactAmountOut
struct MakerPSMData {
IERC20 srcToken;
IERC20 destToken;
uint256 fromAmount;
uint256 toAmount;
uint256 toll;
uint256 to18ConversionFactor;
address exchange;
address gemJoinAddress;
bytes32 metadata;
uint256 beneficiaryDirectionApproveFlag;
}
/*//////////////////////////////////////////////////////////////
AUGUSTUS RFQ
//////////////////////////////////////////////////////////////*/
/// @notice Order struct for Augustus RFQ
/// @param nonceAndMeta The nonce and meta data packed into one uint256,
/// the first 160 bits is the user address and the last 96 bits is the nonce
/// @param expiry The expiry of the order
/// @param makerAsset The address of the maker asset
/// @param takerAsset The address of the taker asset
/// @param maker The address of the maker
/// @param taker The address of the taker, if the taker is address(0) anyone can take the order
/// @param makerAmount The amount of makerAsset
/// @param takerAmount The amount of takerAsset
struct Order {
uint256 nonceAndMeta;
uint128 expiry;
address makerAsset;
address takerAsset;
address maker;
address taker;
uint256 makerAmount;
uint256 takerAmount;
}
/// @notice Struct containing order info for Augustus RFQ
/// @param order The order struct
/// @param signature The signature for the order
/// @param takerTokenFillAmount The amount of takerToken to fill
/// @param permitTakerAsset The permit data for the taker asset
/// @param permitMakerAsset The permit data for the maker asset
struct OrderInfo {
Order order;
bytes signature;
uint256 takerTokenFillAmount;
bytes permitTakerAsset;
bytes permitMakerAsset;
}
/// @notice Struct containing common data for executing swaps on Augustus RFQ
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param wrapApproveDirection The wrap, approve and direction flag packed into one uint8,
/// the first 2 bits is wrap flag (10 for wrap dest, 01 for wrap src, 00 for no wrap), the next bit is the approve flag
/// (1 for approve, 0 for no approve) and the last bit is the direction flag (0 for swapExactAmountIn and 1 for
/// swapExactAmountOut)
/// @param metadata Packed uuid and additional metadata
struct AugustusRFQData {
uint256 fromAmount;
uint256 toAmount;
uint8 wrapApproveDirection;
bytes32 metadata;
address payable beneficiary;
}
Interfaces
GenericSwapExactAmountIn
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
// Interfaces
import { IErrors } from "./IErrors.sol";
// Types
import { GenericData } from "../AugustusV6Types.sol";
/// @title IGenericSwapExactAmountIn
/// @notice Interface for executing a generic swapExactAmountIn through an Augustus executor
interface IGenericSwapExactAmountIn is IErrors {
/*//////////////////////////////////////////////////////////////
SWAP EXACT AMOUNT IN
//////////////////////////////////////////////////////////////*/
/// @notice Executes a generic swapExactAmountIn using the given executorData on the given executor
/// @param executor The address of the executor contract to use
/// @param swapData Generic data containing the swap information
/// @param partnerAndFee packed partner address and fee percentage, the first 12 bytes is the feeData and the last
/// 20 bytes is the partner address
/// @param permit The permit data
/// @param executorData The data to execute on the executor
/// @return receivedAmount The amount of destToken received after fees
/// @return paraswapShare The share of the fees for Paraswap
/// @return partnerShare The share of the fees for the partner
function swapExactAmountIn(
address executor,
GenericData calldata swapData,
uint256 partnerAndFee,
bytes calldata permit,
bytes calldata executorData
)
external
payable
returns (uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
}
GenericSwapExactAmountOut
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
// Interfaces
import { IErrors } from "./IErrors.sol";
// Types
import { GenericData } from "../AugustusV6Types.sol";
/// @title IGenericSwapExactAmountOut
/// @notice Interface for executing a generic swapExactAmountOut through an Augustus executor
interface IGenericSwapExactAmountOut is IErrors {
/*//////////////////////////////////////////////////////////////
SWAP EXACT AMOUNT OUT
//////////////////////////////////////////////////////////////*/
/// @notice Executes a generic swapExactAmountOut using the given executorData on the given executor
/// @param executor The address of the executor contract to use
/// @param swapData Generic data containing the swap information
/// @param partnerAndFee packed partner address and fee percentage, the first 12 bytes is the feeData and the last
/// 20 bytes is the partner address
/// @param permit The permit data
/// @param executorData The data to execute on the executor
/// @return spentAmount The actual amount of tokens used to swap
/// @return receivedAmount The amount of tokens received from the swap
/// @return paraswapShare The share of the fees for Paraswap
/// @return partnerShare The share of the fees for the partner
function swapExactAmountOut(
address executor,
GenericData calldata swapData,
uint256 partnerAndFee,
bytes calldata permit,
bytes calldata executorData
)
external
payable
returns (uint256 spentAmount, uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
}
Fee Vault
Avalanche: 0x00700052c0608f670705380a4900e0a8080010cc
Polygon zkEVM: 0x00700052c0608f670705380a4900e0a8080010cc
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
// Interfaces
import { IERC20 } from "@openzeppelin/token/ERC20/IERC20.sol";
/// @title IAugustusFeeVault
/// @notice Interface for the AugustusFeeVault contract
interface IAugustusFeeVault {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Error emitted when withdraw amount is zero or exceeds the stored amount
error InvalidWithdrawAmount();
/// @notice Error emmitted when caller is not an approved augustus contract
error UnauthorizedCaller();
/// @notice Error emitted when an invalid parameter length is passed
error InvalidParameterLength();
/// @notice Error emitted when batch withdraw fails
error BatchCollectFailed();
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
/// @notice Emitted when an augustus contract approval status is set
/// @param augustus The augustus contract address
/// @param approved The approval status
event AugustusApprovalSet(address indexed augustus, bool approved);
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/// @notice Struct to register fees
/// @param addresses The addresses to register fees for
/// @param token The token to register fees for
/// @param fees The fees to register
struct FeeRegistration {
address[] addresses;
IERC20 token;
uint256[] fees;
}
/*//////////////////////////////////////////////////////////////
COLLECT
//////////////////////////////////////////////////////////////*/
/// @notice Allows partners to withdraw fees allocated to them and stored in the vault
/// @param token The token to withdraw fees in
/// @param amount The amount of fees to withdraw
/// @param recipient The address to send the fees to
/// @return success Whether the transfer was successful or not
function withdrawSomeERC20(IERC20 token, uint256 amount, address recipient) external returns (bool success);
/// @notice Allows partners to withdraw all fees allocated to them and stored in the vault for a given token
/// @param token The token to withdraw fees in
/// @param recipient The address to send the fees to
/// @return success Whether the transfer was successful or not
function withdrawAllERC20(IERC20 token, address recipient) external returns (bool success);
/// @notice Allows partners to withdraw all fees allocated to them and stored in the vault for multiple tokens
/// @param tokens The tokens to withdraw fees i
/// @param recipient The address to send the fees to
/// @return success Whether the transfer was successful or not
function batchWithdrawAllERC20(IERC20[] calldata tokens, address recipient) external returns (bool success);
/// @notice Allows partners to withdraw fees allocated to them and stored in the vault
/// @param tokens The tokens to withdraw fees in
/// @param amounts The amounts of fees to withdraw
/// @param recipient The address to send the fees to
/// @return success Whether the transfer was successful or not
function batchWithdrawSomeERC20(
IERC20[] calldata tokens,
uint256[] calldata amounts,
address recipient
)
external
returns (bool success);
/*//////////////////////////////////////////////////////////////
BALANCE GETTERS
//////////////////////////////////////////////////////////////*/
/// @notice Get the balance of a given token for a given partner
/// @param token The token to get the balance of
/// @param partner The partner to get the balance for
/// @return feeBalance The balance of the given token for the given partner
function getBalance(IERC20 token, address partner) external view returns (uint256 feeBalance);
/// @notice Get the balances of a given partner for multiple tokens
/// @param tokens The tokens to get the balances of
/// @param partner The partner to get the balances for
/// @return feeBalances The balances of the given tokens for the given partner
function batchGetBalance(
IERC20[] calldata tokens,
address partner
)
external
view
returns (uint256[] memory feeBalances);
/// @notice Returns the unallocated fees for a given token
/// @param token The token to get the unallocated fees for
/// @return unallocatedFees The unallocated fees for the given token
function getUnallocatedFees(IERC20 token) external view returns (uint256 unallocatedFees);
/*//////////////////////////////////////////////////////////////
OWNER
//////////////////////////////////////////////////////////////*/
/// @notice Registers the given feeData to the vault
/// @param feeData The fee registration data
function registerFees(FeeRegistration memory feeData) external;
/// @notice Sets the augustus contract approval status
/// @param augustus The augustus contract address
/// @param approved The approval status
function setAugustusApproval(address augustus, bool approved) external;
/// @notice Sets the contract pause state
/// @param _isPaused The new pause state
function setContractPauseState(bool _isPaused) external;
}
Augustus Registry
Use AugustusRegistry to verify AugustusSwapper addresses.
Avalanche: 0xfD1E5821F07F1aF812bB7F3102Bfd9fFb279513a
Polygon zkEVM: 0x5f34ade3efb2a3f9137ae14568495e8065beea46
interface IAugustusRegistry {
function isAugustusBanned(address augustus) external view returns (bool);
function isValidAugustus(address augustus) external view returns (bool);
function getAugustusCount() external view returns (uint256);
function getLatestVersion() external view returns (string memory);
function getLatestAugustus() external view returns (address);
function getAugustusByVersion(string calldata version) external view returns (address);
}
Last updated