Skip to content

Conversation

@PedroAraoz
Copy link
Member

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the examples from the older “task” concept to the newer “function” concept across code, tests, manifests, and helper scripts, and wires them to the updated Mimic SDK/lib APIs. It also adds or rewrites the AssemblyScript function implementations for each example and refreshes dependencies to newer versions (including the Mimic SDK/test harness).

Changes:

  • Replace runTask with runFunction in all example tests and rename “Task” terminology to “Function” in test descriptions, manifests, and scripts.
  • Introduce or update src/function.ts implementations for all examples (01–14) to use the new @mimicprotocol/lib-ts function-oriented builders and environment APIs.
  • Migrate config/trigger helper scripts from “config” to “trigger” semantics, and bump dependency versions in yarn.lock (including Mimic CLI, SDK, lib, and tooling packages).

Reviewed changes

Copilot reviewed 35 out of 49 changed files in this pull request and generated no comments.

Show a summary per file
File Description
yarn.lock Updates dependency graph (Mimic SDK/lib/test, tooling, TypeScript/ESLint stack) to versions compatible with the new function-based API used by the examples.
examples/14-fee-collection/tests/function.spec.ts Switches tests to runFunction, adjusts price mocks to the new { token: { address, chainId } } shape, and renames test suite artifacts from Task to Function.
examples/14-fee-collection/src/function.ts Implements the fee-collection function using environment.relevantTokensQuery and SwapBuilder, swapping all relevant tokens into USDC per-chain with slippage protection and logging.
examples/14-fee-collection/manifest.yaml Renames the manifest’s name from “Collect Task” to “Collect Function” to match the function-based example.
examples/13-bridge-and-invest-aave/tsconfig.create-trigger.json Points the helper TypeScript config at src/create-trigger.invest.ts instead of the old config script.
examples/13-bridge-and-invest-aave/tests/invest.spec.ts Updates tests to use runFunction, renames context from trigger to triggerPayload, and aligns event encoding and expectations with the new trigger payload semantics.
examples/13-bridge-and-invest-aave/tests/bridge.spec.ts Switches bridge tests from runTask to runFunction and renames taskDir to functionDir, keeping behavior expectations intact.
examples/13-bridge-and-invest-aave/src/invest.ts Adapts invest logic to read triggerPayload from context, decode the event from a preceding function, and build an EvmCallBuilder call sequence for Aave deposits using the new APIs.
examples/13-bridge-and-invest-aave/src/create-trigger.invest.ts Rewrites the helper script to fetch function manifests, use client.triggers.* instead of client.configs.*, and create per-chain Event-type triggers targeting the bridge function’s emitted events.
examples/13-bridge-and-invest-aave/package.json Updates compile flags from -t to -f for function compilation and renames the helper script from create-config:invest to create-trigger:invest.
examples/13-bridge-and-invest-aave/manifest.bridge.yaml Adjusts the bridge manifest description to refer to triggering another “function” instead of a “task”.
examples/12-dollar-cost-averaging/tests/function.spec.ts Converts the DCA tests to runFunction, updates price mocks, and aligns expectations with the new logging and slippage-handling behavior.
examples/12-dollar-cost-averaging/src/function.ts Implements the DCA function using ERC20Token, TokenAmount, and SwapBuilder to perform a slippage-protected swap with detailed logging.
examples/12-dollar-cost-averaging/manifest.yaml Updates the manifest description from a DCA “task” to a DCA “function”.
examples/11-automated-refunds/tsconfig.create-trigger.json Redirects the TS config include to src/create-trigger.ts to match the new trigger helper script.
examples/11-automated-refunds/tests/function.spec.ts Switches tests to runFunction, renames Task → Function, and otherwise keeps the automated-refund behavior checks the same.
examples/11-automated-refunds/src/function.ts Adds the refund function implementation that creates a Transfer intent based on input token/amount/maxFee and logs the operation.
examples/11-automated-refunds/src/create-trigger.ts Replaces config logic with trigger logic: uses FUNCTION_CID, client.functions.getManifest, and client.triggers.signAndCreate to set up a Cron-based one-off refund trigger.
examples/11-automated-refunds/package.json Renames create-config script to create-trigger and points it at the new TS config and helper.
examples/11-automated-refunds/.env.sample Changes env variable from TASK_CID to FUNCTION_CID to match the new function-based deployment model.
examples/10-rebalancing-tokens/tests/function.spec.ts Migrates tests to runFunction and updates price mocks, preserving detailed assertions on swap legs and logs.
examples/10-rebalancing-tokens/src/function.ts Implements a 3-token USD-based rebalancing function using environment, TokenAmount, USD, and Swap.create to move value from surplus to deficit buckets with slippage controls and logging.
examples/10-rebalancing-tokens/manifest.yaml Changes description to describe the logic as a function rather than a task.
examples/09-subgraph-query/tests/function.spec.ts Updates the subgraph example tests to call runFunction and maintain expectations around swap intents and error handling.
examples/09-subgraph-query/src/function.ts Adds the subgraph-query function that fetches Uniswap pool prices via environment.subgraphQuery, computes slippage-adjusted output, and builds a Swap intent.
examples/08-relevant-tokens-query/tests/function.spec.ts Converts tests to runFunction and keeps expectations around transfers, max-fee asset, and behavior when no relevant tokens are found.
examples/08-relevant-tokens-query/src/function.ts Implements the relevant-tokens function using environment.relevantTokensQuery and TransferBuilder to transfer all relevant balances and cap fees in USD.
examples/07-withdraw-from-aave-swap-and-transfer/tests/function.spec.ts Switches tests to runFunction and adjusts mocks to the new request shapes while preserving intent expectations for claim/swap/transfer combinations.
examples/07-withdraw-from-aave-swap-and-transfer/src/function.ts Introduces the Aave withdraw/swap/transfer loop as a function, using relevantTokensQuery, AavePool, SwapBuilder, and TransferBuilder to orchestrate the sequence.
examples/07-withdraw-from-aave-swap-and-transfer/manifest.yaml Renames the example from a loop “task” to a loop “function” and updates description wording.
examples/06-withdraw-from-aave-balance-threshold/tests/function.spec.ts Updates tests to runFunction and new price mock structure while preserving the threshold-based behavior and logging assertions.
examples/06-withdraw-from-aave-balance-threshold/src/function.ts Implements the Aave-withdraw-on-balance-threshold function using Aave token metadata, USD pricing, and SwapBuilder to top up the recipient when under threshold.
examples/06-withdraw-from-aave-balance-threshold/manifest.yaml Adjusts description to frame the withdrawal logic as a function.
examples/05-invest-aave-idle-balance/tests/function.spec.ts Migrates tests for investing idle balance into Aave to runFunction and aligns price mocks to the new format.
examples/05-invest-aave-idle-balance/src/function.ts Implements the idle-balance investment function that approves and supplies to Aave when a USD threshold is exceeded, using Mimic credits for fees.
examples/05-invest-aave-idle-balance/manifest.yaml Rewords manifest description to describe the behavior as a function.
examples/04-transfer-balance-threshold-with-oracles/tests/function.spec.ts Switches to runFunction and updates the oracle price mock shape while keeping assertions on transfer behavior and logs.
examples/04-transfer-balance-threshold-with-oracles/src/function.ts Adds the oracle-based threshold transfer function which calculates USD balance, compares with threshold, and issues a Transfer intent with max fee.
examples/04-transfer-balance-threshold-with-oracles/manifest.yaml Updates description to describe the example as an automated function.
examples/03-transfer-balance-threshold/tests/function.spec.ts Converts threshold-transfer tests to runFunction and keeps existing intent expectations intact.
examples/03-transfer-balance-threshold/src/function.ts Implements a simple threshold-based transfer function that checks on-chain balance and conditionally creates a transfer with max fee.
examples/03-transfer-balance-threshold/manifest.yaml Renames the description from task-based to function-based phrasing.
examples/02-simple-transfer-with-inputs/tests/function.spec.ts Updates the simple-transfer-with-inputs tests to runFunction and maintains intent structure and assertions.
examples/02-simple-transfer-with-inputs/src/function.ts Implements the parametric transfer function using ERC20Token and Transfer.create based on inputs.
examples/02-simple-transfer-with-inputs/manifest.yaml Adjusts the manifest description to refer to an automated function.
examples/01-simple-transfer/tests/function.spec.ts Switches the most basic example’s tests from runTask to runFunction and renames the suite accordingly.
examples/01-simple-transfer/src/function.ts Adds a minimal function that always transfers 1 USDC with a fixed fee to a fixed recipient on Optimism.
examples/01-simple-transfer/manifest.yaml Rewords the description to say “automated function” instead of “automated task”.
README.md Updates the main README to state that the repo provides working examples of “functions” instead of “tasks”, aligning top-level documentation with the code changes.
Comments suppressed due to low confidence (1)

examples/13-bridge-and-invest-aave/src/create-trigger.invest.ts:76

  • This log message still references a "config" even though this script now creates triggers via client.triggers.signAndCreate. To avoid confusion for users reading the CLI output, update the message to say "trigger" (for example, "Created trigger on chain ...").

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

alavarello
alavarello previously approved these changes Jan 28, 2026
@alavarello alavarello merged commit 8f3ff3f into main Jan 30, 2026
15 checks passed
@alavarello alavarello deleted the exmaples/rename-to-use-functions branch January 30, 2026 18:05
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.

3 participants