npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

strategy-builder-plugin

v1.1.0

Published

This is an ERC-6900 compatible plugin called StrategyBuilderPlugin, built in Foundry. It has one function that can be called through a user operation, called `increment`. In `/src` you will find this plugin, documented so you can understand how it works

Downloads

8

Readme

StrategyBuilderPlugin - ERC6900 Standard

Octo DeFi Logo

Overview

The StrategyBuilderPlugin is a modular smart contract built on the ERC6900 standard, designed to automate and execute advanced DeFi strategies seamlessly. This plugin integrates with modular smart accounts, allowing users to create, manage, and automate complex financial strategies such as vault management, borrowing, leveraged yield farming, and more.

Features

DeFi Strategy Automation – Users can define and execute automated strategies involving lending, borrowing, staking, and farming.
Modular & Extensible – Built within the ERC6900 ecosystem, enabling compatibility with other modular account plugins.
Smart Execution & Conditions – Allows strategies to execute based on predefined conditions, optimizing yield and efficiency.
Fee Management Integration – Implements IFeeController and IFeeHandler to ensure seamless fee handling for automated transactions.
Security & Permissions – Utilizes strategy validation to ensure only authorized actions are executed within a user’s smart account.

How It Works

  1. Strategy Creation – Users define custom strategies that include multiple DeFi actions (e.g., borrowing, staking, swapping).
  2. Automated Execution – The plugin triggers actions based on conditions (e.g., interest rate thresholds, collateral ratios).
  3. Fee Handling – Ensures fair and transparent fee structures using external controllers and handlers.
  4. Smart Account Integration – Seamlessly integrates with modular smart accounts, leveraging ERC6900’s flexible permissioning system.

Use Cases

  • Automated Yield Farming – Deploy capital across multiple DeFi protocols for optimal returns.
  • Vault Management – Automatically rebalance or reinvest assets in DeFi vaults.
  • Leverage Strategies – Execute leveraged borrowing and farming with automated risk management.
  • Automated Liquidation Protection – Prevent unnecessary liquidations by setting up stop-loss mechanisms.

Why StrategyBuilderPlugin?

By leveraging the ERC6900 modular account standard, this plugin enhances DeFi automation, making complex financial strategies accessible, secure, and highly efficient for both institutional and individual users.


Installation

After cloning the repository, install the dependencies with:

npm install

Make sure you have Foundry installed before proceeding.

Then build the contracts with:

forge build

Would you like me to assemble the full README now with all sections (Intro, Requirements, Environment, Installation, Usage)?

Environment Setup

Before working with this project, you need to set the required environment variables.

Use the following Hardhat commands to store your secrets locally:

npx hardhat vars set ALCHEMY_API_KEY
npx hardhat vars set PRIVATE_KEY
npx hardhat vars set ARBISCAN_API_KEY

These variables are required for deployments:

| Variable | Description | | ------------------ | ------------------------------------------------------------------ | | ALCHEMY_API_KEY | API key from Alchemy for your RPC connection. | | PRIVATE_KEY | Private key of the deployer wallet. Never share this key publicly. | | ARBISCAN_API_KEY | API key from arbiscan for contract verification. |

These variables will be stored securely on your local machine and automatically loaded when running Hardhat tasks.


Core Contracts

There are four core smart contracts that make up the heart of the system:

  • PriceOracle
    Fetches real-time price data from the Pyth network.

  • FeeController
    Manages the fee configuration for each individual function selector used in strategy execution.

  • FeeHandler
    Distributes the total collected fee among recipients based on predefined percentages at the end of strategy execution.

  • StrategyBuilderPlugin
    An ERC-6900 compatible plugin contract that provides the main functionality of the strategy builder—allowing you to create, execute, and manage strategies.

🔎 For a detailed description of the StrategyBuilder, check out the official documentation: https://docs.octodefi.com

Source Code

You can find the source code for each core contract below:

| Contract | Description | Source Code Link | | --------------------- | -------------------------------------- | ------------------------------------------------------------------ | | PriceOracle | Fetches price data from Pyth | PriceOracle.sol | | FeeController | Manages function-specific fees | FeeController.sol | | FeeHandler | Handles fee distribution | FeeHandler.sol | | StrategyBuilderPlugin | Strategy builder core logic (ERC-6900) | StrategyBuilderPlugin.sol |


Example Strategy Execution Flow

When an automation service (or user) triggers the execution of a strategy, the following steps take place within the core contracts:

  1. Pre-Execution Check via ConditionContract
    The StrategyBuilderPlugin first checks the ConditionContract defined in the strategy's ActionStruct. This contract verifies whether the conditions for execution are currently met (e.g., price thresholds, time-based triggers, on-chain state, etc.).

  2. Step-by-Step Execution
    If the condition check passes, the StrategyBuilderPlugin begins executing the defined steps of the strategy one by one.

    After entering a step, the plugin checks whether the step has an associated condition. If it does:

    • The plugin calls the ConditionContract to evaluate the condition.
    • If the condition result is true (1), the plugin executes all actions defined in that step and then jumps to the next step defined for a true result.
    • If the condition result is false (0), the plugin skips execution of the actions in that step and moves to the next step defined for a false result.
  3. Fee Preparation for Each Action
    Before executing each individual action, the plugin interacts with the FeeController to:

    • Retrieve the observation token relevant to that action.
    • Record the token balance before execution.

    After the action is executed, the plugin checks the balance again to determine the amount of token affected by that action. Using this delta, it calls the FeeController to calculate the specific fee for that action.

  4. Final Fee Distribution
    Once all actions have been executed and all fees have been calculated, the StrategyBuilderPlugin calls the FeeHandler contract. The FeeHandler is responsible for distributing the total collected fee to the configured recipients, based on their assigned percentage shares.


Getting Started

After installing Foundry, follow these steps to set up and deploy:


# Build contracts with Foundry and Hardhat
npm run compile

# Run Foundry tests
forge test

# Check code coverage
npm run coverage

# Deploy core contract
NETWORK=<network-name> npm run deploy:core

# Verify the contracts
CHAIN_ID=<chain-id> npm run verify:core

Replace <network-name> with your desired network (e.g. localhost, arbitrumSepolia, mainnet). Eplace <chain-id> with the chain ID of your network.


Notes

  • Contract deployments are managed using Hardhat Ignition.
  • Foundry is used for building and testing smart contracts.

🔗 Author: 3Blocks
📜 License: MIT
🚀 Version: 1.0.0

Foundry Documentation

https://book.getfoundry.sh/