Fee collection
The goal of this task is to move tokens from an external source to the settler itself.
Task
import { environment, ERC20Token, log, TokenAmount } from '@mimicprotocol/lib-ts'
import { ExternalSource, inputs } from './types'
export default function main(): void {
const tokens = environment.getRelevantTokens(inputs.source, [inputs.chainId])
const feeToken = ERC20Token.fromAddress(inputs.feeToken, inputs.chainId)
const fee = TokenAmount.fromBigInt(feeToken, inputs.feeAmount)
for (let i = 0; i < tokens.length; i++) {
new ExternalSource(inputs.target, inputs.chainId)
.claim(tokens[i].token.address, tokens[i].amount, inputs.recipient)
.addMaxFee(fee)
.build()
.send()
log.info('Claimed: {}', [tokens[i]])
}
}Manifest
version: 1.0.0
name: Collect Task
description: Collects all tokens from an external source to a recipient
inputs:
- chainId: uint32
- target: address
- source: address
- recipient: address
- feeToken: address
- feeAmount: uint256
abis:
- ExternalSource: './abis/ExternalSource.json'Last updated