Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support flashloans in Balancer adaptor API #225

Merged
merged 10 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sommelier_steward"
version = "3.5.1"
version = "3.5.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Reference: https://www.lpalmieri.com/posts/fast-rust-docker-builds/

FROM rust:1.63 as cargo-chef-rust
FROM rust:1.65 as cargo-chef-rust
EricBolten marked this conversation as resolved.
Show resolved Hide resolved
RUN cargo install cargo-chef --version 0.1.51

FROM cargo-chef-rust as planner
Expand Down
101 changes: 0 additions & 101 deletions proto/adaptors/aave/aave_v3_debt_token.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,7 @@ package steward.v3;

option go_package = "/steward_proto";

import "adaptors/aave/a_token.proto";
import "adaptors/aave/debt_token.proto";
import "adaptors/aave/aave_v3_a_token.proto";
import "adaptors/balancer/balancer_pool.proto";
import "adaptors/compound/c_token.proto";
import "adaptors/frax/f_token.proto";
import "adaptors/morpho/morpho_aave_v2_a_token.proto";
import "adaptors/morpho/morpho_aave_v2_debt_token.proto";
import "adaptors/morpho/morpho_aave_v3_a_token_collateral.proto";
import "adaptors/morpho/morpho_aave_v3_a_token_p2p.proto";
import "adaptors/morpho/morpho_aave_v3_debt_token.proto";
import "adaptors/uniswap/uniswap_v3.proto";
import "adaptors/uniswap/swap_with_uniswap.proto";
import "adaptors/fees_and_reserves.proto";
import "adaptors/zero_x/zero_x.proto";
import "adaptors/oneinch/oneinch.proto";
import "adaptors/vesting_simple.proto";
import "adaptors/base.proto";
import "adaptors/sommelier/cellar_adaptor.proto";
import "adaptors/aave/aave_v2_enable_asset_as_collateral_adaptor.proto";
import "adaptors/sommelier/legacy_cellar_adaptor.proto";
import "adaptors/frax/debt_f_token.proto";
import "adaptors/frax/collateral_f_token.proto";

// Represents call data for the Aave Debt Token adaptor, used for borrowing and repaying debt on Aave.
message AaveV3DebtTokenAdaptorV1 {
Expand All @@ -47,8 +25,6 @@ message AaveV3DebtTokenAdaptorV1 {
RepayAaveDebt repay_aave_debt = 3;
// Represents function `repayWithATokens(ERC20 underlying, uint256 amount)`
RepayWithATokens repay_with_a_tokens = 4;
// Represents function `flashLoan(address[] loanToken, uint256[] loanAmount, bytes params)`
FlashLoan flash_loan = 5;
}

/*
Expand Down Expand Up @@ -86,83 +62,6 @@ message AaveV3DebtTokenAdaptorV1 {
// The amount to repay
string amount = 2;
}

/*
* Allows strategists to have Cellars take out flash loans
*
* Represents function `flashLoan(address[] loanToken, uint256[] loanAmount, bytes params)`
*/
message FlashLoan {
// The addresses of the ERC20 tokens to borrow
repeated string loan_tokens = 1;
// The amounts to borrow
repeated string loan_amounts = 2;
// The params to pass to the flash loan callback.
repeated AdaptorCallForAaveV3Flashloan params = 3;
}

// NOTE: FlashLoan takes an array of AdaptorCall. cellar_v2.proto defines it, but also imports this file, therefore we can't import cellar_v2.proto in order to use the AdaptorCall message here. To avoid the recursive import, we duplicate the message definition.

// Represents a call to adaptor an. The cellar must be authorized to call the target adaptor.
message AdaptorCallForAaveV3Flashloan {
// Address of the adaptor
string adaptor = 1;
// The function call data for the adaptor
oneof call_data {
// Represents function calls to the UniswapV3Adaptor V1
UniswapV3AdaptorV1Calls uniswap_v3_v1_calls = 2;
// Represents function calls to the AaveATokenAdaptor V1
AaveATokenAdaptorV1Calls aave_a_token_v1_calls = 3;
// Represents function calls to the AavaDebtTokenAdaptor V1
AaveDebtTokenAdaptorV1Calls aave_debt_token_v1_calls = 4;
// Represents function calls to the CompoundCTokenAdaptor V2
CompoundCTokenAdaptorV2Calls compound_c_token_v2_calls = 5;
// Represents function calls to the AaveATokenV2Adaptor
AaveATokenAdaptorV2Calls aave_a_token_v2_calls = 6;
// Represents function calls to the AavaDebtTokenV2Adaptor
AaveDebtTokenAdaptorV2Calls aave_debt_token_v2_calls = 7;
// Represents function calls to the AaveATokenV1Adaptor
AaveV3ATokenAdaptorV1Calls aave_v3_a_token_v1_calls = 8;
// Represents function calls to the AavaDebtTokenV1Adaptor
AaveV3DebtTokenAdaptorV1Calls aave_v3_debt_token_v1_calls = 9;
// Represents function calls to the OneInchAdaptorV1
OneInchAdaptorV1Calls one_inch_v1_calls = 10;
// Represents function calls to the FeesAndReservesAdaptorV1
FeesAndReservesAdaptorV1Calls fees_and_reserves_v1_calls = 11;
// Represents functionc alls to the ZeroXAdaptorV1
ZeroXAdaptorV1Calls zero_x_v1_calls = 12;
// Represents function calls to the SwapWithUniswapAdaptorV1
SwapWithUniswapAdaptorV1Calls swap_with_uniswap_v1_calls = 13;
// Represents function calls to VestingSimpleAdaptor
VestingSimpleAdaptorV2Calls vesting_simple_v2_calls = 14;
// Represents function calls to the CellarAdaptor
CellarAdaptorV1Calls cellar_v1_calls = 15;
// Represents function calls to the UniswapV3Adaptor V2
UniswapV3AdaptorV2Calls uniswap_v3_v2_calls = 16;
// Represents function calls to the AaveV2EnableAssetAsCollatorAdaptor V1
AaveV2EnableAssetAsCollateralAdaptorV1Calls aave_v2_enable_asset_as_collateral_v1_calls = 17;
// Represents function calls to the FTokenAdaptor V1
FTokenAdaptorV1Calls f_token_v1_calls = 18;
// Represents function calls to the MorphoAaveV2AToken V1
MorphoAaveV2ATokenAdaptorV1Calls morpho_aave_v2_a_token_v1_calls = 19;
// Represents function calls to the MorphoAaveV2DebtToken V1
MorphoAaveV2DebtTokenAdaptorV1Calls morpho_aave_v2_debt_token_v1_calls = 20;
// Represents function calls to the MorphoAaveV3ATokenCollateral V1
MorphoAaveV3ATokenCollateralAdaptorV1Calls morpho_aave_v3_a_token_collateral_v1_calls = 21;
// Represents function calls to the MorphoAaveV3ATokenP2P V1
MorphoAaveV3ATokenP2PAdaptorV1Calls morpho_aave_v3_a_token_p2p_v1_calls = 22;
// Represents function calls to the MorphoAaveV3DebtToken V1
MorphoAaveV3DebtTokenAdaptorV1Calls morpho_aave_v3_debt_token_v1_calls = 23;
// Represents function calls to the BalancerPoolAdaptor V1
BalancerPoolAdaptorV1Calls balancer_pool_v1_calls = 24;
// Represents function calls to the LegacyCellarAdaptor V1
LegacyCellarAdaptorV1Calls legacy_cellar_v1_calls = 25;
// Represents function calls to the DebtFTokenAdaptor V1
DebtFTokenAdaptorV1Calls debt_f_token_v1_calls = 26;
// Represents function calls to the CollateralFTokenAdaptor V1
CollateralFTokenAdaptorV1Calls collateral_f_token_v1_calls = 27;
}
}
}

message AaveV3DebtTokenAdaptorV1Calls {
Expand Down
112 changes: 112 additions & 0 deletions proto/adaptors/aave/aave_v3_debt_token_flash_loan.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
syntax = "proto3";
package steward.v3;

option go_package = "/steward_proto";

import "adaptors/aave/a_token.proto";
import "adaptors/aave/debt_token.proto";
import "adaptors/aave/aave_v3_a_token.proto";
import "adaptors/balancer/balancer_pool.proto";
import "adaptors/compound/c_token.proto";
import "adaptors/frax/f_token.proto";
import "adaptors/morpho/morpho_aave_v2_a_token.proto";
import "adaptors/morpho/morpho_aave_v2_debt_token.proto";
import "adaptors/morpho/morpho_aave_v3_a_token_collateral.proto";
import "adaptors/morpho/morpho_aave_v3_a_token_p2p.proto";
import "adaptors/morpho/morpho_aave_v3_debt_token.proto";
import "adaptors/uniswap/uniswap_v3.proto";
import "adaptors/uniswap/swap_with_uniswap.proto";
import "adaptors/fees_and_reserves.proto";
import "adaptors/zero_x/zero_x.proto";
import "adaptors/oneinch/oneinch.proto";
import "adaptors/vesting_simple.proto";
import "adaptors/sommelier/cellar_adaptor.proto";
import "adaptors/aave/aave_v2_enable_asset_as_collateral_adaptor.proto";
import "adaptors/sommelier/legacy_cellar_adaptor.proto";
import "adaptors/frax/debt_f_token.proto";
import "adaptors/frax/collateral_f_token.proto";

// Represents call data for the Aave Debt Token adaptor, used for borrowing and repaying debt on Aave.
message AaveV3DebtTokenAdaptorV1FlashLoan {
// Represents function `flashLoan(address[] loanToken, uint256[] loanAmount, bytes params)`
FlashLoan flash_loan = 1;

/*
* Allows strategists to have Cellars take out flash loans
*
* Represents function `flashLoan(address[] loanToken, uint256[] loanAmount, bytes params)`
*/
message FlashLoan {
// The addresses of the ERC20 tokens to borrow
repeated string loan_tokens = 1;
// The amounts to borrow
repeated string loan_amounts = 2;
// The params to pass to the flash loan callback.
repeated AdaptorCallForAaveV3FlashLoan params = 3;
}

// NOTE: FlashLoan takes an array of AdaptorCall. cellar_v2.proto defines it, but also imports this file, therefore we can't import cellar_v2.proto in order to use the AdaptorCall message here. To avoid the recursive import, we duplicate the message definition.

// Represents a call to adaptor an. The cellar must be authorized to call the target adaptor.
message AdaptorCallForAaveV3FlashLoan {
// Address of the adaptor
string adaptor = 1;
// The function call data for the adaptor
oneof call_data {
// Represents function calls to the UniswapV3Adaptor V1
UniswapV3AdaptorV1Calls uniswap_v3_v1_calls = 2;
// Represents function calls to the AaveATokenAdaptor V1
AaveATokenAdaptorV1Calls aave_a_token_v1_calls = 3;
// Represents function calls to the AavaDebtTokenAdaptor V1
AaveDebtTokenAdaptorV1Calls aave_debt_token_v1_calls = 4;
// Represents function calls to the CompoundCTokenAdaptor V2
CompoundCTokenAdaptorV2Calls compound_c_token_v2_calls = 5;
// Represents function calls to the AaveATokenV2Adaptor
AaveATokenAdaptorV2Calls aave_a_token_v2_calls = 6;
// Represents function calls to the AavaDebtTokenV2Adaptor
AaveDebtTokenAdaptorV2Calls aave_debt_token_v2_calls = 7;
// Represents function calls to the AaveATokenV1Adaptor
AaveV3ATokenAdaptorV1Calls aave_v3_a_token_v1_calls = 8;
// Represents function calls to the OneInchAdaptorV1
OneInchAdaptorV1Calls one_inch_v1_calls = 9;
// Represents function calls to the FeesAndReservesAdaptorV1
FeesAndReservesAdaptorV1Calls fees_and_reserves_v1_calls = 10;
// Represents functionc alls to the ZeroXAdaptorV1
ZeroXAdaptorV1Calls zero_x_v1_calls = 11;
// Represents function calls to the SwapWithUniswapAdaptorV1
SwapWithUniswapAdaptorV1Calls swap_with_uniswap_v1_calls = 12;
// Represents function calls to VestingSimpleAdaptor
VestingSimpleAdaptorV2Calls vesting_simple_v2_calls = 13;
// Represents function calls to the CellarAdaptor
CellarAdaptorV1Calls cellar_v1_calls = 14;
// Represents function calls to the UniswapV3Adaptor V2
UniswapV3AdaptorV2Calls uniswap_v3_v2_calls = 15;
// Represents function calls to the AaveV2EnableAssetAsCollatorAdaptor V1
AaveV2EnableAssetAsCollateralAdaptorV1Calls aave_v2_enable_asset_as_collateral_v1_calls = 16;
// Represents function calls to the FTokenAdaptor V1
FTokenAdaptorV1Calls f_token_v1_calls = 17;
// Represents function calls to the MorphoAaveV2AToken V1
MorphoAaveV2ATokenAdaptorV1Calls morpho_aave_v2_a_token_v1_calls = 18;
// Represents function calls to the MorphoAaveV2DebtToken V1
MorphoAaveV2DebtTokenAdaptorV1Calls morpho_aave_v2_debt_token_v1_calls = 19;
// Represents function calls to the MorphoAaveV3ATokenCollateral V1
MorphoAaveV3ATokenCollateralAdaptorV1Calls morpho_aave_v3_a_token_collateral_v1_calls = 20;
// Represents function calls to the MorphoAaveV3ATokenP2P V1
MorphoAaveV3ATokenP2PAdaptorV1Calls morpho_aave_v3_a_token_p2p_v1_calls = 21;
// Represents function calls to the MorphoAaveV3DebtToken V1
MorphoAaveV3DebtTokenAdaptorV1Calls morpho_aave_v3_debt_token_v1_calls = 22;
// Represents function calls to the BalancerPoolAdaptor V1
BalancerPoolAdaptorV1Calls balancer_pool_v1_calls = 23;
// Represents function calls to the LegacyCellarAdaptor V1
LegacyCellarAdaptorV1Calls legacy_cellar_v1_calls = 24;
// Represents function calls to the DebtFTokenAdaptor V1
DebtFTokenAdaptorV1Calls debt_f_token_v1_calls = 25;
// Represents function calls to the CollateralFTokenAdaptor V1
CollateralFTokenAdaptorV1Calls collateral_f_token_v1_calls = 26;
}
}
}

message AaveV3DebtTokenAdaptorV1FlashLoanCalls {
repeated AaveV3DebtTokenAdaptorV1FlashLoan calls = 1;
}
1 change: 0 additions & 1 deletion proto/adaptors/balancer/balancer_pool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ message BalancerPoolAdaptorV1 {
UnstakeBPT unstake_bpt = 5;
// Represents function `claimRewards(address gauge)`
ClaimRewards claim_rewards = 6;

}

// Represents the SwapKind enum defined here:
Expand Down
Loading
Loading