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

WIP - Initial go request builder package #263

Merged
merged 3 commits into from
Jun 27, 2024
Merged

Conversation

cbrit
Copy link
Member

@cbrit cbrit commented Jun 27, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new adaptors for Aave V2, Aave V3, Balancer Pool, Pendle, and Uniswap, allowing for detailed interaction with these protocols.
  • Bug Fixes

    • Added comprehensive test suite for Aave V2 AToken adaptor to ensure reliable operation of approval revocation, deposit, and withdrawal methods.
  • Chores

    • Updated Go version in integration tests workflow from 1.19 to 1.22 to maintain compatibility with the latest features and improvements.

@cbrit cbrit requested a review from zmanian June 27, 2024 15:51
Copy link

coderabbitai bot commented Jun 27, 2024

Walkthrough

The latest updates primarily introduce advanced builders in the go_request_builder package for constructing specific protocol calls, such as Aave V2/V3, Balancer, Pendle, and Uniswap. Additionally, the integration tests workflow in the GitHub Actions setup has been updated to use Go 1.22. These changes enhance the flexibility and functionality for interacting with various protocols and simplify the testing infrastructure.

Changes

File(s) Summary
go_request_builder/adaptor_call.go Added method for initializing AdaptorCallBuilder.
.../adaptors/aave_v2_a_token.go Added methods for building Aave V2 AToken adaptor calls, including approval revocation, deposit, withdrawal.
.../adaptors/aave_v2_a_token_test.go Introduced test suite for AaveV2ATokenAdaptorCallBuilder.
.../adaptors/aave_v2_enable_asset_as_... Added builder for enabling assets as collateral in Aave V2, revoking approval, setting use of reserves.
.../adaptors/aave_v3_a_token.go Added builder for Aave V3 A Token calls, including approval revocation, deposit, withdrawal, and mode adjustments.
.../adaptors/aave_v3_debt_token.go Added builder for Aave V3 debt token calls, including approval revocation, borrowing, and repayment.
.../adaptors/aave_v3_debt_token_flash_... Added builder for Aave V3 debt token flash loans.
.../adaptors/balancer_pool.go Added builder for Balancer pool interactions, including staking, joining/exiting pools, and claiming rewards.
.../adaptors/pendle.go Added PendleAdaptorCallBuilder with constructor.
.../adaptors/swap_with_uniswap.go Added builder for Uniswap swaps, including UniV2 and UniV3 specific methods.
go_request_builder/cellar_call.go Added CellarCallBuilder with methods for constructing protocol-specific calls.
go_request_builder/request.go Added ScheduleRequestBuilder for building and validating schedule requests.
.github/workflows/integration_tests.yml Updated Go version from 1.19 to 1.22 in the integration tests workflow.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b7be442 and a452234.

Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
Files selected for processing (1)
  • .github/workflows/integration_tests.yml (1 hunks)
Files skipped from review due to trivial changes (1)
  • .github/workflows/integration_tests.yml

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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

Comment on lines +41 to +65
// CallOnAdaptor adds call data for the CallOnAdaptor function to the builder
func (cdb *CellarCallBuilder) CallOnAdaptor(adaptorCall *steward_proto.AdaptorCall) *CellarCallBuilder {
// search functionCalls for type steward_proto.CellarV2_5_FunctionCall_CallOnAdaptor and if
// it already exists, append to CallOnAdaptor.Data instead of creating a new CallOnAdaptor struct
found := false
for _, call := range cdb.functionCalls {
if call.GetCallOnAdaptor() != nil {
found = true
call.GetCallOnAdaptor().Data = append(call.GetCallOnAdaptor().Data, adaptorCall)
break
}
}

if !found {
cdb.functionCalls = append(cdb.functionCalls, &steward_proto.CellarV2_5_FunctionCall{
Function: &steward_proto.CellarV2_5_FunctionCall_CallOnAdaptor {
CallOnAdaptor: &steward_proto.CellarV2_5_CallOnAdaptor{
Data: []*steward_proto.AdaptorCall{adaptorCall},
},
},
})
}

return cdb
}
Copy link

Choose a reason for hiding this comment

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

Optimize the addition of function calls.

The method CallOnAdaptor checks if a specific type of function call exists before adding a new one. This could be optimized using a map for quicker lookups.

-    found := false
-    for _, call := range cdb.functionCalls {
-        if call.GetCallOnAdaptor() != nil {
-            found = true
-            call.GetCallOnAdaptor().Data = append(call.GetCallOnAdaptor().Data, adaptorCall)
-            break
-        }
-    }
+    if call, exists := cdb.functionCallMap["CallOnAdaptor"]; exists {
+        call.GetCallOnAdaptor().Data = append(call.GetCallOnAdaptor().Data, adaptorCall)
+    } else {
+        cdb.functionCalls = append(cdb.functionCalls, &steward_proto.CellarV2_5_FunctionCall{
+            Function: &steward_proto.CellarV2_5_FunctionCall_CallOnAdaptor {
+                CallOnAdaptor: &steward_proto.CellarV2_5_CallOnAdaptor{
+                    Data: []*steward_proto.AdaptorCall{adaptorCall},
+                },
+            },
+        })
+    }

This change introduces a map to track existing function calls, improving the efficiency of lookups and additions.

Committable suggestion was skipped due to low confidence.

@cbrit cbrit merged commit b739c1b into main Jun 27, 2024
5 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants