NashPoint
NashPoint
  • Introduction
    • Introduction To Nashpoint
    • Current Features & Capabilities
    • Post Launch Roadmap
  • User Documentation
    • Node Contract Overview
    • Node Owner & Rebalancer Roles
    • Portfolio Management
    • Rebalancing & Strategy Execution
    • User Deposits & Shares
    • Asynchronous Redemptions
      • Two Step Process
    • Swing Pricing
    • Processing User Redemptions
    • Management & Execution Fees
  • Developer Documentation
    • Overview
    • Role-Based Access Control
    • Smart Contract Architecture
  • Routers
    • ERC-4626 Router
    • ERC-7540 Router
    • Router Tolerance
  • Creating A Node
  • Asynchronous Redemptions
  • Managing a Node
    • Adding & Removing Components
    • Updating Component Allocations
    • Rebalance Window & Cooldown
    • Rebalancing a Node
    • Managing Rebalancers
    • Processing User Redemptions
      • Reserve vs Component Fulfillment
    • Reserve Management
    • Fees Configuration
    • Liquidation Queue Configuration
    • Max Deposit Limits
    • Operator Permissions
    • Emergency Controls
  • Upgrading a Node
    • Adding Quoters & Routers
    • Custom Router Development
    • Multi-Tier Permissioning
  • Cached Data & Gas Efficiency
  • Swing Pricing Calculations
  • Adding Routers and Components - Step by Step Guide
  • Node Execute Function
  • Resources
    • FAQ
    • Glossary
    • Supported Networks & Protocols
    • Deployments
    • Audits
    • GitHub
    • Telegram
    • NashPoint
  • Node Strategies
    • Test Node A
Powered by GitBook
On this page
Edit on GitHub

Node Execute Function

The execute function enables valid Routers to make arbitrary contract calls on behalf of the Node, allowing for complex DeFi interactions while maintaining security controls.

function execute(address target, bytes calldata data)
    external
    onlyRouter
    onlyWhenRebalancing
    returns (bytes memory)
{
    if (target == address(0)) revert ErrorsLib.ZeroAddress();
    bytes memory result = target.functionCall(data);
    emit EventsLib.Execute(target, data, result);
    return result;
}

Security Controls

  • Only whitelisted routers can call execute

  • Only works during rebalance window

  • Target address cannot be zero

  • Emits event with full call data and result

Common Usage

// Example: Approve spending in router
function _safeApprove(address node, address token, address spender, uint256 amount) internal {
    bytes memory data = INode(node).execute(
        token, 
        abi.encodeCall(IERC20.approve, (spender, amount))
    );
    if (!(data.length == 0 || abi.decode(data, (bool)))) revert ErrorsLib.SafeApproveFailed();
}

Use Cases

  • Token approvals

  • Vault deposits/withdrawals

  • Protocol-specific interactions

  • Multi-step DeFi operations

All interactions must be implemented in the router contract, maintaining security through the whitelisting system.

PreviousAdding Routers and Components - Step by Step GuideNextFAQ

Last updated 2 months ago