-
Notifications
You must be signed in to change notification settings - Fork 18
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
Pendle Adaptor Support #264
Conversation
6ed3961
to
65cfd0b
Compare
WalkthroughA new contract adaptor named "PendleAdaptorV1" was added to the project for interfacing with Pendle's functionalities like minting, swapping, and adding liquidity. The addition affects multiple modules, test setups, and protobuf definitions, ensuring comprehensive integration and testing. Some updates switch from older to newer versions of certain imports, reflecting ongoing maintenance and enhancement. Notable documentation now includes guidance on running Steward locally with Tenderly for simulation and testing. Changes
(Note: Paths have been shortened for readability.) Sequence DiagramsAdding a New Contract Adaptor (PendleAdaptorV1)sequenceDiagram
participant Developer
participant BuildRS as build.rs
participant ProtoFiles as Proto Files
participant Adaptors as Adaptor Files
participant Tests as Test Files
participant Docs as Documentation
Developer->>BuildRS: Add PendleAdaptorV1 to contract adaptors
Developer->>ProtoFiles: Add pendle.proto import and PendleAdaptorV1 messages
Developer->>Adaptors: Implement PendleAdaptorV1Calls handling
Developer->>Tests: Update tests to use corktypesv2
Developer->>Docs: Add documentation for local Steward testing with Tenderly
Logging and Simulation IntegrationsequenceDiagram
participant Developer
participant GitHubYML as .github/workflows/integration_tests.yml
participant Framework as Framework
participant DockerContainers as Docker Containers
participant Documentation as Docs
Developer->>GitHubYML: Update SOMMELIER_IMAGE to v7.0.1
GitHubYML->>DockerContainers: Add steps to log before cleaning up
Developer->>Documentation: Add simulate mode and Tenderly setup instructions
Tip AI model upgrade
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
for c in params.calls { | ||
let function = c | ||
.function | ||
.ok_or_else(|| sp_call_error("function cannot be empty".to_string()))?; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider logging errors for better traceability.
Adding logging for the error case will help in debugging issues.
for c in params.calls {
let function = c
.function
.ok_or_else(|| {
let err_msg = "function cannot be empty".to_string();
sp_call_error(err_msg.clone());
log::error!("{}", err_msg);
err_msg
})?;
spender: sp_call_parse_address(p.spender)?, | ||
}; | ||
calls.push( | ||
AbiPendleAdaptorV1Calls::RevokeApproval(call) | ||
.encode() | ||
.into(), | ||
) | ||
} | ||
Function::MintSyFromToken(p) => { | ||
let call = pendle_adaptor_v1::MintSyFromTokenCall { | ||
market: sp_call_parse_address(p.market)?, | ||
min_sy_out: string_to_u256(p.min_sy_out)?, | ||
input: convert_token_input(p.input)?, | ||
}; | ||
calls.push( | ||
AbiPendleAdaptorV1Calls::MintSyFromToken(call) | ||
.encode() | ||
.into(), | ||
) | ||
} | ||
Function::MintPyFromSy(p) => { | ||
let call = pendle_adaptor_v1::MintPyFromSyCall { | ||
market: sp_call_parse_address(p.market)?, | ||
net_sy_in: string_to_u256(p.net_sy_in)?, | ||
min_py_out: string_to_u256(p.min_py_out)?, | ||
}; | ||
calls.push(AbiPendleAdaptorV1Calls::MintPyFromSy(call).encode().into()) | ||
} | ||
Function::SwapExactPtForYt(p) => { | ||
let call = pendle_adaptor_v1::SwapExactPtForYtCall { | ||
market: sp_call_parse_address(p.market)?, | ||
min_yt_out: string_to_u256(p.min_yt_out)?, | ||
exact_pt_in: string_to_u256(p.exact_pt_in)?, | ||
guess_total_yt_to_swap: convert_approx_params(p.guess_total_yt_to_swap)?, | ||
}; | ||
calls.push( | ||
AbiPendleAdaptorV1Calls::SwapExactPtForYt(call) | ||
.encode() | ||
.into(), | ||
) | ||
} | ||
Function::SwapExactYtForPt(p) => { | ||
let call = pendle_adaptor_v1::SwapExactYtForPtCall { | ||
market: sp_call_parse_address(p.market)?, | ||
min_pt_out: string_to_u256(p.min_pt_out)?, | ||
exact_yt_in: string_to_u256(p.exact_yt_in)?, | ||
guess_total_pt_from_swap: convert_approx_params(p.guess_total_pt_to_swap)?, | ||
}; | ||
calls.push( | ||
AbiPendleAdaptorV1Calls::SwapExactYtForPt(call) | ||
.encode() | ||
.into(), | ||
) | ||
} | ||
Function::AddLiquidityDualSyAndPt(p) => { | ||
let call = pendle_adaptor_v1::AddLiquidityDualSyAndPtCall { | ||
market: sp_call_parse_address(p.market)?, | ||
net_sy_desired: string_to_u256(p.net_sy_desired)?, | ||
net_pt_desired: string_to_u256(p.net_pt_desired)?, | ||
min_lp_out: string_to_u256(p.min_lp_out)?, | ||
}; | ||
calls.push( | ||
AbiPendleAdaptorV1Calls::AddLiquidityDualSyAndPt(call) | ||
.encode() | ||
.into(), | ||
) | ||
} | ||
Function::RemoveLiquidityDualSyAndPt(p) => { | ||
let call = pendle_adaptor_v1::RemoveLiquidityDualSyAndPtCall { | ||
market: sp_call_parse_address(p.market)?, | ||
net_lp_to_remove: string_to_u256(p.net_lp_to_remove)?, | ||
min_sy_out: string_to_u256(p.min_sy_out)?, | ||
min_pt_out: string_to_u256(p.min_pt_out)?, | ||
}; | ||
calls.push( | ||
AbiPendleAdaptorV1Calls::RemoveLiquidityDualSyAndPt(call) | ||
.encode() | ||
.into(), | ||
) | ||
} | ||
Function::RedeemPyToSy(p) => { | ||
let call = pendle_adaptor_v1::RedeemPyToSyCall { | ||
market: sp_call_parse_address(p.market)?, | ||
net_py_in: string_to_u256(p.net_py_in)?, | ||
min_sy_out: string_to_u256(p.min_sy_out)?, | ||
}; | ||
calls.push(AbiPendleAdaptorV1Calls::RedeemPyToSy(call).encode().into()) | ||
} | ||
Function::RedeemSyToToken(p) => { | ||
let call = pendle_adaptor_v1::RedeemSyToTokenCall { | ||
market: sp_call_parse_address(p.market)?, | ||
net_sy_in: string_to_u256(p.net_sy_in)?, | ||
output: convert_token_output(p.output)?, | ||
}; | ||
calls.push( | ||
AbiPendleAdaptorV1Calls::RedeemSyToToken(call) | ||
.encode() | ||
.into(), | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding logging for each match arm.
Adding logging for each match arm will help in debugging and tracing the function calls.
match function {
Function::RevokeApproval(p) => {
log::info!("Encoding RevokeApproval call");
let call = pendle_adaptor_v1::RevokeApprovalCall {
asset: sp_call_parse_address(p.asset)?,
spender: sp_call_parse_address(p.spender)?,
};
calls.push(
AbiPendleAdaptorV1Calls::RevokeApproval(call)
.encode()
.into(),
)
}
Function::MintSyFromToken(p) => {
log::info!("Encoding MintSyFromToken call");
let call = pendle_adaptor_v1::MintSyFromTokenCall {
market: sp_call_parse_address(p.market)?,
min_sy_out: string_to_u256(p.min_sy_out)?,
input: convert_token_input(p.input)?,
};
calls.push(
AbiPendleAdaptorV1Calls::MintSyFromToken(call)
.encode()
.into(),
)
}
// Add similar logging for other match arms
}
src/cellars/adaptors/pendle.rs
Outdated
use abscissa_core::tracing::log::debug; | ||
use ethers::{abi::AbiEncode, types::Bytes}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import.
The log::debug
import is not used in this file.
- use abscissa_core::tracing::log::debug;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
use abscissa_core::tracing::log::debug; | |
use ethers::{abi::AbiEncode, types::Bytes}; | |
use ethers::{abi::AbiEncode, types::Bytes}; |
syntax = "proto3"; | ||
package steward.v4; | ||
|
||
option go_package = "/steward_proto"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update go_package
option.
The go_package
option should be updated to match the package name and directory structure.
- option go_package = "/steward_proto";
+ option go_package = "steward/v4";
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
option go_package = "/steward_proto"; | |
option go_package = "steward/v4"; |
This reverts commit e6db45e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
integration_tests/setup_test.go
Outdated
bz, err = tmjson.MarshalIndent(genDoc, "", " ") | ||
s.Require().NoError(err) | ||
|
||
// write the updated genesis file to each validator | ||
for _, val := range s.chain.validators { | ||
for i, val := range s.chain.validators { | ||
s.T().Log("writing genesis to val %d", i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the printf formatting directive.
The Log
call has a possible Printf formatting directive %d
. Change Log
to Logf
.
- s.T().Log("writing genesis to val %d", i)
+ s.T().Logf("writing genesis to val %d", i)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
s.T().Log("writing genesis to val %d", i) | |
s.T().Logf("writing genesis to val %d", i) |
Tools
golangci-lint
504-504: printf: (*testing.common).Log call has possible Printf formatting directive %d
(govet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (4)
docs/06-StewardForStrategists.md (4)
66-66
: Approved: New content with trailing space issue.The explanation of simulate mode features is clear and relevant. However, there is a trailing space at the end of the line.
- 1. Encode only, which simply takes a `ScheduleRequest` and returns the ABI encoded call data. + 1. Encode only, which simply takes a `ScheduleRequest` and returns the ABI encoded call data.Tools
Markdownlint
66-66: Expected: 0 or 2; Actual: 1
Trailing spaces(MD009, no-trailing-spaces)
67-67
: Approved: New content with missing preposition issue.The explanation of the second feature of simulate mode is clear and relevant. However, there is a missing preposition "to".
- This allows the strategist confirm they get the expected state changes from their call data parameters. + This allows the strategist to confirm they get the expected state changes from their call data parameters.Tools
LanguageTool
[uncategorized] ~67-~67: Possible missing preposition found.
Context: ... a contract. This allows the strategist confirm they get the expected state changes fro...(AI_HYDRA_LEO_MISSING_TO)
69-69
: Approved: New content with missing comma and repetitive phrasing issues.The explanation of requirements for using simulation features is clear and relevant. However, there is a missing comma and repetitive phrasing.
- To use the simulation features you will need to have a Tenderly account, project, and API key. + To use the simulation features, you will need a Tenderly account, project, and API key.Tools
LanguageTool
[uncategorized] ~69-~69: A comma might be missing here.
Context: ...data parameters. To use the simulation features you will need to have a Tenderly accoun...(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
[style] ~69-~69: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...b=readme-ov-file#installation). You may need to build from source if you are planning t...(REP_NEED_TO_VB)
77-77
: Approved: New paragraph with missing comma issue.The explanation of the default port for the simulate server is clear and relevant. However, there is a missing comma after "By default".
- By default this will run the simulate server on port 5734. + By default, this will run the simulate server on port 5734.
Summary by CodeRabbit
New Features
PendleAdaptorV1
for enhanced contract interactions.Bug Fixes
SOMMELIER_IMAGE
to versionv7.0.1
in workflows.Documentation
Integration Tests
v2
.Refactor
corktypesv2
.