Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

## Content

This repository provides working examples of tasks that can be automated using Mimic Protocol.
This repository provides working examples of functions that can be automated using Mimic Protocol.

## Setup

Expand Down
2 changes: 1 addition & 1 deletion examples/01-simple-transfer/manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version: 1.0.0
name: Simple transfer
description: Automated task to execute transfers of 1 USDC with 0.1 USDC fee
description: Automated function to execute transfers of 1 USDC with 0.1 USDC fee
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { OpType } from '@mimicprotocol/sdk'
import { Context, runTask, Transfer } from '@mimicprotocol/test-ts'
import { Context, runFunction, Transfer } from '@mimicprotocol/test-ts'
import { expect } from 'chai'

describe('Task', () => {
const taskDir = './build'
describe('Function', () => {
const functionDir = './build'

const context: Context = {
user: '0x756f45e3fa69347a9a973a725e3c98bc4db0b5a0',
Expand All @@ -12,7 +12,7 @@ describe('Task', () => {
}

it('produces the expected intents', async () => {
const result = await runTask(taskDir, context)
const result = await runFunction(functionDir, context)
expect(result.success).to.be.true
expect(result.timestamp).to.be.equal(context.timestamp)

Expand Down
2 changes: 1 addition & 1 deletion examples/02-simple-transfer-with-inputs/manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 1.0.0
name: Simple transfer with inputs
description: Automated task to execute parameterized transfers
description: Automated function to execute parameterized transfers
inputs:
- chainId: uint32
- token: address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { fp, OpType, randomEvmAddress } from '@mimicprotocol/sdk'
import { Context, EvmCallQueryMock, runTask, Transfer } from '@mimicprotocol/test-ts'
import { Context, EvmCallQueryMock, runFunction, Transfer } from '@mimicprotocol/test-ts'
import { expect } from 'chai'
import { Interface } from 'ethers'

import ERC20Abi from '../abis/ERC20.json'

const ERC20Interface = new Interface(ERC20Abi)

describe('Task', () => {
const taskDir = './build'
describe('Function', () => {
const functionDir = './build'

const context: Context = {
user: randomEvmAddress(),
Expand Down Expand Up @@ -36,7 +36,7 @@ describe('Task', () => {
]

it('produces the expected intents', async () => {
const result = await runTask(taskDir, context, { inputs, calls })
const result = await runFunction(functionDir, context, { inputs, calls })
expect(result.success).to.be.true
expect(result.timestamp).to.be.equal(context.timestamp)

Expand Down
2 changes: 1 addition & 1 deletion examples/03-transfer-balance-threshold/manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 1.0.0
name: Transfer based on threshold
description: Automated task to execute parameterized transfers based on balance threshold
description: Automated function to execute parameterized transfers based on balance threshold
inputs:
- chainId: uint32
- token: address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { fp, OpType, randomEvmAddress } from '@mimicprotocol/sdk'
import { Context, EvmCallQueryMock, runTask, Transfer } from '@mimicprotocol/test-ts'
import { Context, EvmCallQueryMock, runFunction, Transfer } from '@mimicprotocol/test-ts'
import { expect } from 'chai'
import { Interface } from 'ethers'

import ERC20Abi from '../abis/ERC20.json'

const ERC20Interface = new Interface(ERC20Abi)

describe('Task', () => {
const taskDir = './build'
describe('Function', () => {
const functionDir = './build'

const context: Context = {
user: randomEvmAddress(),
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('Task', () => {
const calls = buildCalls(balance)

it('produces the expected intents', async () => {
const result = await runTask(taskDir, context, { inputs, calls })
const result = await runFunction(functionDir, context, { inputs, calls })
expect(result.success).to.be.true
expect(result.timestamp).to.be.equal(context.timestamp)

Expand All @@ -77,7 +77,7 @@ describe('Task', () => {
const calls = buildCalls(balance)

it('does not produce any intent', async () => {
const result = await runTask(taskDir, context, { inputs, calls })
const result = await runFunction(functionDir, context, { inputs, calls })
expect(result.success).to.be.true
expect(result.intents).to.be.empty
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 1.0.0
name: Transfer based on USD threshold
description: Automated task to execute parameterized transfers based on balance threshold in USD
description: Automated function to execute parameterized transfers based on balance threshold in USD
inputs:
- chainId: uint32
- token: address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { fp, OpType, randomEvmAddress } from '@mimicprotocol/sdk'
import { Context, EvmCallQueryMock, runTask, TokenPriceQueryMock, Transfer } from '@mimicprotocol/test-ts'
import { Context, EvmCallQueryMock, runFunction, TokenPriceQueryMock, Transfer } from '@mimicprotocol/test-ts'
import { expect } from 'chai'
import { Interface } from 'ethers'

import ERC20Abi from '../abis/ERC20.json'

const ERC20Interface = new Interface(ERC20Abi)

describe('Task', () => {
const taskDir = './build'
describe('Function', () => {
const functionDir = './build'

const context: Context = {
user: randomEvmAddress(),
Expand All @@ -27,7 +27,7 @@ describe('Task', () => {

const prices: TokenPriceQueryMock[] = [
{
request: { token: inputs.token, chainId: inputs.chainId },
request: { token: { address: inputs.token, chainId: inputs.chainId } },
response: ['1000000000000000000'], // 1 token = 1 USD
},
]
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('Task', () => {
const calls = buildCalls(balance)

it('produces the expected intents', async () => {
const result = await runTask(taskDir, context, { inputs, calls, prices })
const result = await runFunction(functionDir, context, { inputs, calls, prices })
expect(result.success).to.be.true
expect(result.timestamp).to.be.equal(context.timestamp)

Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Task', () => {
const calls = buildCalls(balance)

it('does not produce any intent', async () => {
const result = await runTask(taskDir, context, { inputs, calls, prices })
const result = await runFunction(functionDir, context, { inputs, calls, prices })
expect(result.success).to.be.true
expect(result.intents).to.be.empty

Expand Down
2 changes: 1 addition & 1 deletion examples/05-invest-aave-idle-balance/manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 1.0.0
name: Invest in AAVE idle balance
description: Automated task to invest in AAVE idle balance above certain threshold in USD
description: Automated function to invest in AAVE idle balance above certain threshold in USD
inputs:
- chainId: uint32
- aToken: address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EvmCallIntent, OpType, randomEvmAddress } from '@mimicprotocol/sdk'
import { Context, EvmCallQueryMock, runTask, TokenPriceQueryMock } from '@mimicprotocol/test-ts'
import { Context, EvmCallQueryMock, runFunction, TokenPriceQueryMock } from '@mimicprotocol/test-ts'
import { expect } from 'chai'
import { Interface } from 'ethers'

Expand All @@ -11,8 +11,8 @@ const AavePoolInterface = new Interface(AavePool)
const AaveTokenInterface = new Interface(AaveToken)
const ERC20Interface = new Interface(ERC20Abi)

describe('Task', () => {
const taskDir = './build'
describe('Function', () => {
const functionDir = './build'

const context: Context = {
user: randomEvmAddress(),
Expand All @@ -33,11 +33,11 @@ describe('Task', () => {

const prices: TokenPriceQueryMock[] = [
{
request: { token: inputs.aToken, chainId: inputs.chainId },
request: { token: { address: inputs.aToken, chainId: inputs.chainId } },
response: ['1000000000000000000'], // 1 aOptUSDC = 1 USD
},
{
request: { token: underlyingToken, chainId: inputs.chainId },
request: { token: { address: underlyingToken, chainId: inputs.chainId } },
response: ['1000000000000000000'], // 1 USDC = 1 USD
},
]
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('Task', () => {
const calls = buildCalls(balance)

it('does not produce any intent', async () => {
const result = await runTask(taskDir, context, { inputs, calls, prices })
const result = await runFunction(functionDir, context, { inputs, calls, prices })
expect(result.success).to.be.true
expect(result.intents).to.be.empty

Expand All @@ -124,7 +124,7 @@ describe('Task', () => {
const calls = buildCalls(balance)

it('produces the expected intents', async () => {
const result = await runTask(taskDir, context, { inputs, calls, prices })
const result = await runFunction(functionDir, context, { inputs, calls, prices })
expect(result.success).to.be.true
expect(result.timestamp).to.be.equal(context.timestamp)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 1.0.0
name: Withdraw from AAVE based on balance threshold
description: Automated task to withdraw from AAVE based on balance threshold in USD
description: Automated function to withdraw from AAVE based on balance threshold in USD
inputs:
- chainId: uint32
- aToken: address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OpType, randomEvmAddress } from '@mimicprotocol/sdk'
import { Context, EvmCallQueryMock, runTask, Swap, TokenPriceQueryMock } from '@mimicprotocol/test-ts'
import { Context, EvmCallQueryMock, runFunction, Swap, TokenPriceQueryMock } from '@mimicprotocol/test-ts'
import { expect } from 'chai'
import { Interface } from 'ethers'

Expand All @@ -9,8 +9,8 @@ import ERC20Abi from '../abis/ERC20.json'
const AaveTokenInterface = new Interface(AaveToken)
const ERC20Interface = new Interface(ERC20Abi)

describe('Task', () => {
const taskDir = './build'
describe('Function', () => {
const functionDir = './build'

const context: Context = {
user: randomEvmAddress(),
Expand All @@ -30,11 +30,11 @@ describe('Task', () => {

const prices: TokenPriceQueryMock[] = [
{
request: { token: inputs.aToken, chainId: inputs.chainId },
request: { token: { address: inputs.aToken, chainId: inputs.chainId } },
response: ['1000000000000000000'], // 1 aOptUSDC = 1 USD
},
{
request: { token: underlyingToken, chainId: inputs.chainId },
request: { token: { address: underlyingToken, chainId: inputs.chainId } },
response: ['1000000000000000000'], // 1 USDC = 1 USD
},
]
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('Task', () => {
const calls = buildCalls(recipientBalance, userBalance)

it('produces the expected intents', async () => {
const result = await runTask(taskDir, context, { inputs, calls, prices })
const result = await runFunction(functionDir, context, { inputs, calls, prices })
expect(result.success).to.be.true
expect(result.timestamp).to.be.equal(context.timestamp)

Expand Down Expand Up @@ -144,7 +144,7 @@ describe('Task', () => {
const calls = buildCalls(recipientBalance, userBalance)

it('does not produce any intent', async () => {
const result = await runTask(taskDir, context, { inputs, calls, prices })
const result = await runFunction(functionDir, context, { inputs, calls, prices })
expect(result.success).to.be.true
expect(result.intents).to.be.empty

Expand All @@ -160,7 +160,7 @@ describe('Task', () => {
const calls = buildCalls(recipientBalance, '0') // `userBalance` does not matter

it('does not produce any intent', async () => {
const result = await runTask(taskDir, context, { inputs, calls, prices })
const result = await runFunction(functionDir, context, { inputs, calls, prices })
expect(result.success).to.be.true
expect(result.intents).to.be.empty

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 1.0.0
name: Claim-Swap-Transfer Loop Task
description: This task is for demo purposes. It withdraws from AAVE, swaps for an AAVE token and transfer to deposit in loop
name: Claim-Swap-Transfer Loop Function
description: This function is for demo purposes. It withdraws from AAVE, swaps for an AAVE token and transfer to deposit in loop
inputs:
- maxFeeUsdt: string # e.g., '0.5' = 0.5 USDT
- smartAccount: address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Context,
EvmCallQueryMock,
RelevantTokensQueryMock,
runTask,
runFunction,
Swap,
TokenPriceQueryMock,
Transfer,
Expand All @@ -18,8 +18,8 @@ import ERC20Abi from '../abis/ERC20.json'
const AavePoolInterface = new Interface(AavePool)
const ERC20Interface = new Interface(ERC20Abi)

describe('Task', () => {
const taskDir = './build'
describe('Function', () => {
const functionDir = './build'

const chainId = Chains.Optimism

Expand Down Expand Up @@ -50,15 +50,15 @@ describe('Task', () => {

const prices: TokenPriceQueryMock[] = [
{
request: { token: tokens.aUSDC, chainId },
request: { token: { address: tokens.aUSDC, chainId } },
response: ['1000000'],
},
{
request: { token: tokens.USDC, chainId },
request: { token: { address: tokens.USDC, chainId } },
response: ['1000000'],
},
{
request: { token: tokens.USDT, chainId },
request: { token: { address: tokens.USDT, chainId } },
response: ['1000000'],
},
]
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('Task', () => {
})

it('produces claim, swap, and transfer', async () => {
const result = await runTask(taskDir, context, { inputs, relevantTokens, prices, calls })
const result = await runFunction(functionDir, context, { inputs, relevantTokens, prices, calls })

const claimIntent = result.intents.find((i) => i.op === OpType.EvmCall)
const swapIntent = result.intents.find((i) => i.op === OpType.Swap)
Expand All @@ -140,7 +140,7 @@ describe('Task', () => {
})

it('only produces a claim intent', async () => {
const result = await runTask(taskDir, context, { inputs, relevantTokens, prices, calls })
const result = await runFunction(functionDir, context, { inputs, relevantTokens, prices, calls })
expect(result.success).to.be.true
expect(result.timestamp).to.be.equal(context.timestamp)

Expand Down Expand Up @@ -170,7 +170,7 @@ describe('Task', () => {
})

it('only produces a swap intent', async () => {
const result = await runTask(taskDir, context, { inputs, relevantTokens, prices, calls })
const result = await runFunction(functionDir, context, { inputs, relevantTokens, prices, calls })
expect(result.success).to.be.true
expect(result.timestamp).to.be.equal(context.timestamp)

Expand All @@ -194,7 +194,7 @@ describe('Task', () => {
})

it('only produces a transfer intent', async () => {
const result = await runTask(taskDir, context, { inputs, relevantTokens, prices, calls })
const result = await runFunction(functionDir, context, { inputs, relevantTokens, prices, calls })
expect(result.success).to.be.true
expect(result.timestamp).to.be.equal(context.timestamp)

Expand All @@ -216,7 +216,7 @@ describe('Task', () => {
})

it('does not produce any intents', async () => {
const result = await runTask(taskDir, context, { inputs, relevantTokens, prices, calls })
const result = await runFunction(functionDir, context, { inputs, relevantTokens, prices, calls })
expect(result.success).to.be.true
expect(result.intents).to.be.empty
})
Expand Down
Loading
Loading