Skip to content

Commit

Permalink
Cellar.sol v2.5 support (#217)
Browse files Browse the repository at this point in the history
* Balancer pool adaptor

* review items 1

* Rework pool ID parsing

* Fmt

* Clippy

* Add Cellar.sol 2.5 protos

* Add Cellar.sol 2.5 ABI and bindings

* Add CellarWithShareLockPeriod abi and bindings

* Cellar.sol v2.5 handlers

* Bump to v3.4.0
  • Loading branch information
cbrit committed Aug 17, 2023
1 parent 48de065 commit 7668856
Show file tree
Hide file tree
Showing 20 changed files with 22,708 additions and 472 deletions.
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.3.2"
version = "3.4.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
225 changes: 225 additions & 0 deletions proto/cellar_v2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,231 @@ message CellarV2_2 {
}
}

message CellarV2_5 {
oneof call_type {
// Represents a single function call
FunctionCall function_call = 1;
// Represents multiple, ordered function calls
Multicall multicall = 2;
}

// The function you wish to execute on the target cellar
message FunctionCall {
oneof function {
// Represents function `addPosition(uint256 index, address position)`
AddPosition add_position = 1;
// Represents function `callOnAdaptor(AdaptorCall[] memory data)`
CallOnAdaptor call_on_adaptor = 2;
// Represents function `removePosition(uint256 index)`
RemovePosition remove_position = 3;
// Represents function `setHoldingPosition(uint32 position_id)`
SetHoldingPosition set_holding_position = 4;
// Represents function `setStrategistPayoutAddress(address payout)`
SetStrategistPayoutAddress set_strategist_payout_address = 5;
// Represents function `swapPositions(uint256 index1, uint256 index2)`
SwapPositions swap_positions = 6;
// Represents function `setRebalanceDeviation(uint265)`
SetRebalanceDeviation set_rebalance_deviation = 7;
// Represents function `setShareLockPeriod(uint256 newLock)`
SetShareLockPeriod set_share_lock_period = 8;
// Represents function `initiateShutdown()`
InitiateShutdown initiate_shutdown = 9;
// Represents function `setStrategistPlatformCut(uint64 cut)`
SetStrategistPlatformCut set_strategist_platform_cut = 10;
// Represents function `liftShutdown()`
LiftShutdown lift_shutdown = 11;
// Represents function `addAdaptorToCatalogue(address adaptor)`
AddAdaptorToCatalogue add_adaptor_to_catalogue = 12;
// Represents function `addPositionToCatalogue(uint32 positionId)`
AddPositionToCatalogue add_position_to_catalogue = 13;
// Represents function `removeAdaptorFromCatalogue(address adaptor)`
RemoveAdaptorFromCatalogue remove_adaptor_from_catalogue = 14;
// Represents function `removePositionFromCatalogue(uint32 positionId)`
RemovePositionFromCatalogue remove_position_from_catalogue = 15;
// Represents function `increaseShareSupplyCap(uint192)
IncreaseShareSupplyCap increase_share_supply_cap = 16;
// Represents function `decreaseShareSupplyCap(uint192)
DecreaseShareSupplyCap decrease_share_supply_cap = 17;
}
}

/*
* Insert a trusted position to the list of positions used by the cellar at a given index.
*
* Represents function `addPosition(uint32 index, uint32 positionId, bytes configurationData, bool inDebtArray)`
*/
message AddPosition {
// Index at which to add the position
uint32 index = 1;
// The position's ID in the cellar registry
uint32 position_id = 2;
// Data used to configure how the position behaves
bytes configuration_data = 3;
// Whether to add position in the debt array, or the credit array.
bool in_debt_array = 4;
}

/*
* Allows strategists to manage their Cellar using arbitrary logic calls to adaptors.
*
* Represents function `callOnAdaptor(AdaptorCall[] memory data)`
*/
message CallOnAdaptor {
repeated AdaptorCall data = 1;
}

/*
* Remove the position at a given index from the list of positions used by the cellar.
*
* Represents function `removePosition(uint32 index, bool inDebtArray)`
*/
message RemovePosition {
// Index at which to remove the position
uint32 index = 1;
// Whether to remove position from the debt array, or the credit array.
bool in_debt_array = 2;
}

/*
* Set the holding position used of the cellar.
*
* Represents function `setHoldingIndex(uint8 index)`
*/
message SetHoldingPosition {
// ID (index) of the new holding position to use
uint32 position_id = 1;
}

/*
* Sets the Strategists payout address.
*
* Represents function `setStrategistPayoutAddress(address payout)`
*/
message SetStrategistPayoutAddress {
string payout = 1;
}

/*
* Swap the positions at two given indeces.
*
* Represents function `swapPositions(uint32 index1, uint32 index2)`
*/
message SwapPositions {
// Index of the first position
uint32 index_1 = 1;
// Index of the second position
uint32 index_2 = 2;
// Whether to switch positions in the debt array, or the credit array.
bool in_debt_array = 3;
}

/*
* Allows share lock period to be updated.
*
* Represents function `setShareLockPeriod()`
*/
message SetShareLockPeriod {
string new_lock = 1;
}

/*
* Changes the cellar's allowed rebalance deviation, which is the percent the total assets of a cellar may deviate
* during a `callOnAdaptor`(rebalance) call. The maximum allowed deviation is 100000000000000000 (0.1e18), or 10%.
*
* Represents function `setRebalanceDeviation(uint256)`
*/
message SetRebalanceDeviation {
string new_deviation = 1;
}

/*
* Shutdown the cellar. Used in an emergency or if the cellar has been deprecated.
*
* Represents function `initiateShutdown()`
*/
message InitiateShutdown {}

/*
* Allows strategist to set the platform cut for the cellar.
*
* Represents function `setStrategistPlatformCut(uint64 cut)`
*/
message SetStrategistPlatformCut {
// The new strategist platform cut
uint64 new_cut = 1;
}

/*
* Allows the owner to restart a shut down Cellar
*
* Represents function `liftShutdown()`
*/
message LiftShutdown {}

/*
* Allows the owner to add an adaptor to the Cellar's adaptor catalogue
*
* Represents function `addAdaptorToCatalogue(address adaptor)`
*/
message AddAdaptorToCatalogue {
string adaptor = 1;
}

/*
* Allows caller to call multiple functions in a single TX.
*
* Represents function `multicall(bytes[] data)`
*/
message Multicall {
repeated FunctionCall function_calls = 1;
}

/*
* Allows the owner to add a position to the Cellar's position catalogue
*
* Represents function `addPositionToCatalogue(uint32 positionId)`
*/
message AddPositionToCatalogue {
uint32 position_id = 1;
}

/*
* Allows callers to remove adaptors from this cellar's catalogue
*
* Represents function `removeAdaptorFromCatalogue(address adaptor)`
*/
message RemoveAdaptorFromCatalogue {
string adaptor = 1;
}

/*
* Allows caller to remove positions from this cellar's catalogue
*
* Represents function `removePositionFromCatalogue(uint32 positionId)`
*/
message RemovePositionFromCatalogue {
uint32 position_id = 1;
}

/*
* Allows strategist to increase the share supply cap
*
* Represents function `increaseShareSupplyCap(uint192)`
*/
message IncreaseShareSupplyCap {
string new_cap = 1;
}

/*
* Allows strategist to decrease the share supply cap
*
* Represents function `decreaseShareSupplyCap(uint192)`
*/
message DecreaseShareSupplyCap {
string new_cap = 1;
}
}

// Represents a call to adaptor an. The cellar must be authorized to call the target adaptor.
message AdaptorCall {
// Address of the adaptor
Expand Down
1 change: 1 addition & 0 deletions proto/steward.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ message SubmitRequest {
CellarV1 cellar_v1 = 3;
CellarV2 cellar_v2 = 4;
CellarV2_2 cellar_v2dot2 = 5;
CellarV2_5 cellar_v2dot5 = 6;
}
}

Expand Down
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.3.2"
version = "3.4.0"
edition = "2018"

[dependencies]
Expand Down
1 change: 1 addition & 0 deletions steward/src/cellars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub(crate) mod adaptors;
pub(crate) mod cellar_v1;
pub(crate) mod cellar_v2;
pub(crate) mod cellar_v2_2;
pub(crate) mod cellar_v2_5;

// constants
// addresses are normalized by removing the 0x prefix and converting to lowercase for reliable comparison
Expand Down
Loading

0 comments on commit 7668856

Please sign in to comment.