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

feat: Frax Debt/Collateral adaptors + permission updates #223

Merged
merged 6 commits into from
Sep 19, 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.4.3"
version = "3.5.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
9 changes: 9 additions & 0 deletions proto/adaptors/aave/aave_v3_debt_token.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ 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 Down Expand Up @@ -152,6 +155,12 @@ message AaveV3DebtTokenAdaptorV1 {
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;
}
}
}
Expand Down
55 changes: 55 additions & 0 deletions proto/adaptors/frax/collateral_f_token.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Protos for function calls to the Frax Collateral F Token adaptor.
*/

syntax = "proto3";
package steward.v3;

option go_package = "/steward_proto";

import "adaptors/base.proto";

// Represents call data for the Frax Collateral F Token adaptor.
message CollateralFTokenAdaptorV1 {
oneof function {
/***** BASE ADAPTOR FUNCTIONS *****/

// Represents function `revokeApproval(ERC20 asset, address spender)`
RevokeApproval revoke_approval = 1;

/***** ADAPTOR-SPECIFIC FUNCTIONS *****/

// Represents function `addCollateral(IFToken _fraxlendPair, uint256 _collateralToDeposit)`
AddCollateral add_collateral = 2;
// Represents function `removeCollateral(uint256 _collateralAmount, IFToken _fraxlendPair)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a dumb question but sanity checking: all the other Fraxlend functions start with the IFToken, is this an error or just an anomaly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they just changed the param name in the latest contracts, they are still address underneath

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to the order in the function call rather than the IFToken type.

RemoveCollateral remove_collateral = 3;
}

/*
* Allows strategists to add collateral to the respective cellar position on FraxLend, enabling borrowing.
*
* Represents function `addCollateral(IFToken _fraxlendPair, uint256 _collateralToDeposit)`
*/
message AddCollateral {
// The FraxLend pair to add collateral to.
string fraxlend_pair = 1;
// The amount of collateral to add to the cellar position.
string collateral_to_deposit = 2;
}

/*
* Allows strategists to remove collateral from the respective cellar position on FraxLend.
*
* Represents function `removeCollateral(uint256 _collateralAmount, IFToken _fraxlendPair)`
*/
message RemoveCollateral {
// The amount of collateral to remove from the cellar position.
string collateral_amount = 1;
// The FraxLend pair to remove collateral from.
string fraxlend_pair = 2;
}
}

message CollateralFTokenAdaptorV1Calls {
repeated CollateralFTokenAdaptorV1 calls = 1;
}
68 changes: 68 additions & 0 deletions proto/adaptors/frax/debt_f_token.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Protos for function calls to the Frax Debt F Token adaptor.
*/

syntax = "proto3";
package steward.v3;

option go_package = "/steward_proto";

import "adaptors/base.proto";

// Represents call data for the Frax adaptor.
message DebtFTokenAdaptorV1 {
oneof function {
/***** BASE ADAPTOR FUNCTIONS *****/

// Represents function `revokeApproval(ERC20 asset, address spender)`
RevokeApproval revoke_approval = 1;

/***** ADAPTOR-SPECIFIC FUNCTIONS *****/

// Represents function `borrowFromFraxlend(IFToken fraxlendPair, uint256 amountToBorrow)`
BorrowFromFraxlend borrow_from_fraxlend = 2;
// Represents function `repayFraxlendDebt(IFToken _fraxlendPair, uint256 _debtTokenRepayAmount)`
RepayFraxlendDebt repay_fraxlend_debt = 3;
// Represents function `callAddInterest(IFToken _fraxlendPair)`
CallAddInterest call_add_interest = 4;
}

/*
* Allows a strategist to borrow assets from Fraxlend
*
* Represents `function borrowFromFraxlend(IFToken fraxlendPair, uint256 amountToBorrow)`
*/
message BorrowFromFraxlend {
// The address of the Frax Pair to borrow from.
string fraxlend_pair = 1;
// The amount of the asset to borrow.
string amount_to_borrow = 2;
}

/*
* Allows strategists to repay loan debt on Fraxlend Pair.
* Make sure to call addInterest() beforehand to ensure we are repaying what is required.
*
* Represents `function repayFraxlendDebt(IFToken _fraxlendPair, uint256 _debtTokenRepayAmount)`
*/
message RepayFraxlendDebt {
// The address of the Frax Pair to repay debt on.
string fraxlend_pair = 1;
// The amount of the debt token to repay.
string debt_token_repay_amount = 2;
}

/*
* Allows a strategist to call `addInterest` on a Frax Pair they are using
*
* Represents `function callAddInterest(IFToken _fraxlendPair)`
*/
message CallAddInterest {
// The address of the pair to call addInterest on.
string fraxlend_pair = 1;
}
}

message DebtFTokenAdaptorV1Calls {
repeated DebtFTokenAdaptorV1 calls = 1;
}
50 changes: 50 additions & 0 deletions proto/adaptors/sommelier/legacy_cellar_adaptor.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Protos for depositing/withdrawing from Legacy Cellars

syntax = "proto3";
package steward.v3;

option go_package = "/steward_proto";

import "adaptors/base.proto";

message LegacyCellarAdaptorV1 {
oneof function {
/***** BASE ADAPTOR FUNCTIONS *****/

// Represents function `revokeApproval(ERC20 asset, address spender)`
RevokeApproval revoke_approval = 1;

/***** ADAPTOR-SPECIFIC FUNCTIONS *****/

// Represents function `depositToCellar(Cellar cellar, uint256 assets, address oracle)`
DepositToCellar depositToCellar = 2;
// Represents function `withdrawFromCellar(Cellar cellar, uint256 assets, address oracle)`
WithdrawFromCellar withdrawFromCellar = 3;
}

/*
* Allows strategists to deposit into Cellar positions.
*
* Represents function `depositToCellar(Cellar cellar, uint256 assets, address oracle)`
*/
message DepositToCellar {
string cellar = 1;
string assets = 2;
string oracle = 3;
}

/*
* Allows strategists to withdraw from Cellar positions.
*
* Represents function `withdrawFromCellar(Cellar cellar, uint256 assets, address oracle)`
*/
message WithdrawFromCellar {
string cellar = 1;
string assets = 2;
string oracle = 3;
}
}

message LegacyCellarAdaptorV1Calls {
repeated LegacyCellarAdaptorV1 calls = 1;
}
9 changes: 9 additions & 0 deletions proto/cellar_v2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ 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 a function call to a cellar that implements Cellar.sol
Expand Down Expand Up @@ -694,5 +697,11 @@ message AdaptorCall {
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;
}
}
2 changes: 1 addition & 1 deletion steward/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "steward"
authors = []
version = "3.4.3"
version = "3.5.0"
edition = "2018"

[dependencies]
Expand Down
27 changes: 15 additions & 12 deletions steward/src/cellars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ pub const ORACLE2: (U256, &str) = (
U256([5, 0, 0, 0]),
"c47278b65443ce71cf47e8455bb343f2db11b70e",
);
pub const ORACLE3: (U256, &str) = (
U256([5, 0, 0, 0]),
"26cde3f5db92ea91c84c838e664fe42dec1b6747",
);
pub const ALLOWED_PRICE_ORACLES: [(U256, &str); 2] = [ORACLE1, ORACLE2];
pub const ALLOWED_CACHE_PRICE_ROUTER: [&str; 1] = [CELLAR_RYETH];

// permissions

pub const ALLOWED_V2_0_SETUP_ADAPTORS: [(&str, &str); 1] = [(CELLAR_RYUSD, ADAPTOR_CELLAR_V2)];
pub const ALLOWED_V2_2_CATALOGUE_ADAPTORS: [(&str, &str); 3] = [
(CELLAR_RYETH, ADAPTOR_AAVE_V3_A_TOKEN_V1),
(CELLAR_RYBTC, ADAPTOR_AAVE_V3_A_TOKEN_V1),
(CELLAR_RYBTC, ADAPTOR_CELLAR_V1),
(CELLAR_RYBTC, ADAPTOR_LEGACY_CELLAR_V1),
EricBolten marked this conversation as resolved.
Show resolved Hide resolved
(CELLAR_RYBTC, ADAPTOR_COLLATERAL_F_TOKEN_V1),
(CELLAR_RYBTC, ADAPTOR_DEBT_F_TOKEN_V1),
];
pub const ALLOWED_V2_5_CATALOGUE_ADAPTORS: [(&str, &str); 0] = [];

Expand Down Expand Up @@ -66,14 +70,11 @@ pub const ALLOWED_V2_0_POSITIONS: [(&str, u32); 20] = [
(CELLAR_RYUSD, 28),
(CELLAR_RYUSD, 29),
];
pub const ALLOWED_V2_2_CATALOGUE_POSITIONS: [(&str, u32); 7] = [
(CELLAR_RYETH, 188),
(CELLAR_RYETH, 189),
(CELLAR_RYETH, 190),
(CELLAR_RYETH, 191),
(CELLAR_RYBTC, 192),
(CELLAR_RYBTC, 193),
(CELLAR_RYBTC, 194),
pub const ALLOWED_V2_2_CATALOGUE_POSITIONS: [(&str, u32); 4] = [
(CELLAR_RYBTC, 195),
(CELLAR_RYBTC, 196),
(CELLAR_RYBTC, 197),
(CELLAR_RYBTC, 198),
];
pub const ALLOWED_V2_5_CATALOGUE_POSITIONS: [(&str, u32); 0] = [];

Expand Down Expand Up @@ -130,8 +131,10 @@ pub const ADAPTOR_COMPOUND_C_TOKEN_V1: &str = "26dba82495f6189dde7648ae88bead46c
// adaptors

pub const ADAPTOR_AAVE_V3_A_TOKEN_V1: &str = "76cef5606c8b6ba38fe2e3c639e1659afa530b47";
pub const ADAPTOR_CELLAR_V1: &str = "1e22adf9e63ef8f2a3626841ddddd19683e31068";
pub const ADAPTOR_CELLAR_V2: &str = "3b5ca5de4d808cd793d3a7b3a731d3e67e707b27";
pub const ADAPTOR_COLLATERAL_F_TOKEN_V1: &str = "0055cf6a99eba1405d100c7dfaa88a35521a0037";
pub const ADAPTOR_DEBT_F_TOKEN_V1: &str = "50d8f70a5da95021dab86579db4751a863c1b87c";
pub const ADAPTOR_LEGACY_CELLAR_V1: &str = "1e22adf9e63ef8f2a3626841ddddd19683e31068";
pub const ADAPTOR_MORPHO_AAVE_V2_A_TOKEN_V1: &str = "1a4cb53edb8c65c3df6aa9d88c1ab4cf35312b73";
pub const ADAPTOR_MORPHO_AAVE_V2_DEBT_TOKEN_V1: &str = "407d5489f201013ee6a6ca20fccb05047c548138";
pub const ADAPTOR_MORPHO_AAVE_V3_A_TOKEN_COLLATERAL_V1: &str =
Expand Down
2 changes: 1 addition & 1 deletion steward/src/cellars/adaptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pub mod aave_v2_collateral;
pub mod aave_v3;
pub mod balancer_pool;
pub mod compound;
pub mod f_token;
pub mod fees_and_reserves;
pub mod frax;
pub mod morpho;
pub mod oneinch;
pub mod sommelier;
Expand Down
11 changes: 10 additions & 1 deletion steward/src/cellars/adaptors/aave_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ fn get_encoded_adaptor_calls(
)?,
),
FTokenV1Calls(params) => {
calls.extend(adaptors::f_token::f_token_adaptor_v1_calls(params)?)
calls.extend(adaptors::frax::f_token_adaptor_v1_calls(params)?)
}
MorphoAaveV2ATokenV1Calls(params) => calls.extend(
adaptors::morpho::morpho_aave_v2_a_token_adaptor_v1_calls(params)?,
Expand All @@ -253,6 +253,15 @@ fn get_encoded_adaptor_calls(
BalancerPoolV1Calls(params) => calls.extend(
adaptors::balancer_pool::balancer_pool_adaptor_v1_calls(params)?,
),
LegacyCellarV1Calls(params) => {
calls.extend(adaptors::sommelier::legacy_cellar_adaptor_v1_calls(params)?)
}
DebtFTokenV1Calls(params) => {
calls.extend(adaptors::frax::debt_f_token_adaptor_v1_calls(params)?)
}
CollateralFTokenV1Calls(params) => {
calls.extend(adaptors::frax::collateral_f_token_adaptor_v1_calls(params)?)
}
};

result.push(AbiAdaptorCall {
Expand Down
Loading
Loading