Mimic Protocol
  • GENERAL
    • What's Mimic Protocol
    • How it works
    • Roadmap
  • USE CASES AND EXAMPLES
    • Build a simple task
    • More examples
      • Account refilling
      • Block trade
      • Fee collection
      • Automated refunds
  • DEVELOPERS
    • Architecture
    • CLI
    • API
  • RESOURCES
    • Whitepaper
    • Glossary
    • Security
    • Press kit
    • Contact
Powered by GitBook
On this page
  • Task
  • Manifest
  1. USE CASES AND EXAMPLES
  2. More examples

Account refilling

The goal of this task is to bridge assets from L1 to L2 every time the account balance on L2 gets under some threshold.

Task

import { Environment, log } from '@mimicprotocol/lib-ts'

import { TaskInput } from './types'

export default function main(environment: Environment, input: TaskInput) {
  environment.swap(
    settler: settler, 
    to: input.recipient,
    sourceChain: input.sourceChain,
    tokenIn: input.tokenIn,
    amountIn: token.amountIn,
    destinationChain: input.destinationChain,
    tokenOut: input.tokenOut,
    minAmountOut: input.tokenIn - input.feeAmount,
    feeAmount: input.feeAmount,
  )
  log.info('Created swap intent')
}

Manifest

version: 1.0.0
name: Account Refill Task
description: Fund account bridging tokens from another chain when its balance is bellow certain threshold
trigger: balance
inputs:
  - settler: address
  - sourceChain: number
  - tokenIn: address
  - amountIn: number
  - destinationChain: number
  - tokenOut: address
  - feeAmount: number
  - recipient: address
PreviousMore examplesNextBlock trade

Last updated 2 months ago