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
Last updated