WIP BalancerV2SwapAdapter getLimits
This commit is contained in:
@@ -1,19 +1,67 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
pragma solidity ^0.8.13;
|
||||
|
||||
import {IERC20, ISwapAdapter} from "interfaces/ISwapAdapter.sol";
|
||||
import {IERC20, ISwapAdapter} from "src/interfaces/ISwapAdapter.sol";
|
||||
|
||||
contract BalancerV2SwapAdapter is ISwapAdapter {
|
||||
interface IVault {
|
||||
function getPoolTokens(bytes32 poolId)
|
||||
external
|
||||
view
|
||||
returns (
|
||||
IERC20[] memory tokens,
|
||||
uint256[] memory balances,
|
||||
uint256 lastChangeBlock
|
||||
);
|
||||
|
||||
constructor() {
|
||||
function swap(
|
||||
SingleSwap memory singleSwap,
|
||||
FundManagement memory funds,
|
||||
uint256 limit,
|
||||
uint256 deadline
|
||||
) external payable returns (uint256);
|
||||
|
||||
function queryBatchSwap(
|
||||
SwapKind kind,
|
||||
BatchSwapStep[] memory swaps,
|
||||
IAsset[] memory assets,
|
||||
FundManagement memory funds
|
||||
) external returns (int256[] memory assetDeltas);
|
||||
|
||||
struct SingleSwap {
|
||||
bytes32 poolId;
|
||||
SwapKind kind;
|
||||
IAsset assetIn;
|
||||
IAsset assetOut;
|
||||
uint256 amount;
|
||||
bytes userData;
|
||||
}
|
||||
|
||||
function getPairReserves(
|
||||
bytes32 pairId,
|
||||
IERC20 sellToken,
|
||||
IERC20 buyToken
|
||||
) internal view returns (uint112 r0, uint112 r1) {
|
||||
revert NotImplemented("BalancerV2SwapAdapter.getPairReserves");
|
||||
struct BatchSwapStep {
|
||||
bytes32 poolId;
|
||||
uint256 assetInIndex;
|
||||
uint256 assetOutIndex;
|
||||
uint256 amount;
|
||||
bytes userData;
|
||||
}
|
||||
|
||||
struct FundManagement {
|
||||
address sender;
|
||||
bool fromInternalBalance;
|
||||
address payable recipient;
|
||||
bool toInternalBalance;
|
||||
}
|
||||
|
||||
enum SwapKind { GIVEN_IN, GIVEN_OUT }
|
||||
}
|
||||
|
||||
interface IAsset is IERC20 {
|
||||
}
|
||||
|
||||
contract BalancerV2SwapAdapter is ISwapAdapter {
|
||||
IVault immutable vault;
|
||||
|
||||
constructor(address vault_) {
|
||||
vault = IVault(vault_);
|
||||
}
|
||||
|
||||
function price(
|
||||
@@ -49,7 +97,7 @@ contract BalancerV2SwapAdapter is ISwapAdapter {
|
||||
override
|
||||
returns (uint256[] memory limits)
|
||||
{
|
||||
revert NotImplemented("BalancerV2SwapAdapter.getLimits");
|
||||
(, limits, ) = vault.getPoolTokens(pairId);
|
||||
}
|
||||
|
||||
function getCapabilities(bytes32, IERC20, IERC20)
|
||||
@@ -73,6 +121,7 @@ contract BalancerV2SwapAdapter is ISwapAdapter {
|
||||
revert NotImplemented("BalancerV2SwapAdapter.getTokens");
|
||||
}
|
||||
|
||||
/// @dev Balancer V2 does not support listing pools.
|
||||
function getPoolIds(uint256 offset, uint256 limit)
|
||||
external
|
||||
view
|
||||
|
||||
Reference in New Issue
Block a user