Fee collection
The goal of this task is to move tokens from an external source to the settler itself.
Task
import { environment, ERC20Token, TokenAmount } from '@mimicprotocol/lib-ts'
import { ExternalSource, inputs } from './types'
export default function main() {
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].address, tokens[i].balance, inputs.recipient)
.addMaxFee(fee)
.build()
.send()
console.log('Claimed: ' + tokens[i].toString())
}
}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