Aave收益优化(无设置子流程)
高级
这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 24 个节点。主要使用 If, Code, Switch, OneShot, Telegram 等节点。 通过1Shot API和Telegram自动化钱包与Aave之间的USDC余额管理
前置要求
- •Telegram Bot Token
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "NxJjrXhk47s8zf7o",
"meta": {
"instanceId": "62f017ec8f130d172e2e5f39bbf09515036bfd403dfa60fe06f5ab14b78705d0"
},
"name": "Aave 收益优化(无设置子流程)",
"tags": [],
"nodes": [
{
"id": "068172f3-69be-4925-9f21-eceb223e92ef",
"name": "批准 USDC",
"type": "n8n-nodes-1shot.oneShotSynch",
"notes": "Point this node at the 'approve' function on USDC.",
"onError": "continueRegularOutput",
"position": [
784,
496
],
"parameters": {
"params": "={\n \"spender\": \"{{ $('Savings Configs').first().json.pool }}\",\n \"value\": \"{{ $('Calculate Excess Funds').first().json.excessFunds }}\"\n}",
"operation": "executeAsDelegator",
"additionalFields": {
"memo": "=USDC Approve: {{ $('Calculate Excess Funds').first().json.excessFunds }}"
},
"contractMethodId": "96e49453-a8c6-4ac1-b45a-ee2f3f690c44",
"delegatorWalletAddress": "0x9fead8b19c044c2f404dac38b925ea16adaa2954"
},
"credentials": {
"oneShotOAuth2Api": {
"id": "nkfF9AitCKUCrErK",
"name": "1Shot account"
}
},
"typeVersion": 1
},
{
"id": "15483cb4-3746-4d9a-8d02-e10a0411179b",
"name": "将 USDC 存入 Aave L2Pool",
"type": "n8n-nodes-1shot.oneShotSynch",
"notes": "Point this node at the 'supply' function on the Aave: Pool (Base) contract.",
"onError": "continueRegularOutput",
"position": [
1008,
416
],
"parameters": {
"params": "={\n \"asset\": \"{{ $('Savings Configs').first().json.token }}\",\n \"amount\": \"{{ $('Calculate Excess Funds').first().json.excessFunds }}\",\n \"onBehalfOf\": \"{{ $('Savings Configs').first().json.delegator }}\",\n \"referralCode\": \"0\"\n}",
"operation": "executeAsDelegator",
"additionalFields": {
"memo": "=Aave deposit: {{ $('Calculate Excess Funds').first().json.excessFunds }}",
"gasLimit": "400000"
},
"contractMethodId": "74f01f06-c0aa-40ac-80fc-6b297ef0f01c",
"delegatorWalletAddress": "0x9fead8b19c044c2f404dac38b925ea16adaa2954"
},
"credentials": {
"oneShotOAuth2Api": {
"id": "nkfF9AitCKUCrErK",
"name": "1Shot account"
}
},
"typeVersion": 1
},
{
"id": "2ee7dbb8-f524-4220-be50-6f62fedf4da2",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-560,
992
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.2
},
{
"id": "36deb2f1-5ba4-42e6-b3bd-68410889a459",
"name": "计算超额资金",
"type": "n8n-nodes-base.code",
"position": [
560,
480
],
"parameters": {
"jsCode": "const excessFunds = parseInt($('Check User\\'s USDC Balance').first().json.response) - parseInt($('Savings Configs').first().json.moveToSavingsThreshold)\n\n$input.first().json.excessFunds = excessFunds;\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "906abb69-e734-4fbe-aafd-f478cc0a7553",
"name": "存款确认",
"type": "n8n-nodes-base.telegram",
"position": [
1680,
368
],
"webhookId": "be1b7868-1626-4f44-b8d4-bec519faaace",
"parameters": {
"text": "=Excess funds in your wallet (`{{ $('Savings Configs').item.json.delegator }}`) have been moved to Aave (tx hash: `{{ $('Deposit USDC into Aave L2Pool').item.json.transactionHash }}`). \n\nYour wallet balance is now `${{ parseInt($('Confirm User\\'s USDC Balance After Deposit').item.json.response)/1000000 }}` and you have `${{ parseInt($('Confirm User\\'s Aave Savings After Deposit').item.json.response)/1000000 }}` saved in Aave.",
"chatId": "={{ $('Savings Configs').first().json.telegramChatId }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "uN6xtW1sUnA0WiMc",
"name": "@1shotdemobot"
}
},
"typeVersion": 1.2
},
{
"id": "3300fe41-4de4-4f80-a7ae-167ffe5c5f98",
"name": "计算资金不足",
"type": "n8n-nodes-base.code",
"position": [
560,
992
],
"parameters": {
"jsCode": "const fundGap = parseInt($('Savings Configs').first().json.topOffBalance) - parseInt($('Check User\\'s USDC Balance').first().json.response)\n\n// withdraw enough saving to put us halfway between the upper and lower balance settings\n// the amount must be an Integer, so floor it to be sure\nlet withdrawAmount = Math.floor((parseInt($('Savings Configs').first().json.moveToSavingsThreshold) - parseInt($('Savings Configs').first().json.topOffBalance))/2) + fundGap\n\n// if there are not enough savings, move as much as you can\nif (withdrawAmount > parseInt($('Check User\\'s Aave Savings').first().json.response)) {\n withdrawAmount = parseInt($('Check User\\'s Aave Savings').first().json.response)\n}\n\n$input.first().json.fundGap = fundGap;\n$input.first().json.withdrawAmount = withdrawAmount;\n\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "14202261-9afa-4bc3-9f2c-acff09c66ae9",
"name": "从 Aave 提款",
"type": "n8n-nodes-1shot.oneShotSynch",
"notes": "Point this node at the 'withdraw' function on the Aave: Pool (Base) contract.",
"onError": "continueRegularOutput",
"position": [
1008,
896
],
"parameters": {
"params": "={\n \"asset\": \"{{ $('Savings Configs').first().json.token }}\",\n \"amount\": \"{{ $('Calculate Insufficient Funds').first().json.withdrawAmount }}\",\n \"to\": \"{{ $('Savings Configs').first().json.delegator }}\"\n}",
"operation": "executeAsDelegator",
"additionalFields": {
"memo": "=Aave Withdraw: {{ $json.withdrawAmount }}",
"gasLimit": "500000"
},
"contractMethodId": "0f504e54-6909-4ab0-93d6-39073851c8a9",
"delegatorWalletAddress": "0x9fead8b19c044c2f404dac38b925ea16adaa2954"
},
"credentials": {
"oneShotOAuth2Api": {
"id": "nkfF9AitCKUCrErK",
"name": "1Shot account"
}
},
"typeVersion": 1
},
{
"id": "6a2ac4b0-eea0-4163-bf09-abd0703d1177",
"name": "提款确认",
"type": "n8n-nodes-base.telegram",
"position": [
1680,
800
],
"webhookId": "be1b7868-1626-4f44-b8d4-bec519faaace",
"parameters": {
"text": "=You wallet (`{{ $('Savings Configs').item.json.delegator }}`) has been topped off from your Aave savings (tx hash: `{{ $('Withdraw from Aave').item.json.transactionHash }}`).\n\nYour wallet balance is `${{ parseInt($('Confirm User\\'s USDC Balance After Withdraw').item.json.response)/1000000 }}` and you have `${{ parseInt($('Confirm User\\'s Aave Savings After Withdraw').item.json.response)/1000000 }}` in savings in Aave.",
"chatId": "={{ $('Savings Configs').first().json.telegramChatId }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "uN6xtW1sUnA0WiMc",
"name": "@1shotdemobot"
}
},
"typeVersion": 1.2
},
{
"id": "2ef97cb6-7479-4291-90d0-16b6294ff473",
"name": "储蓄配置",
"type": "n8n-nodes-base.code",
"position": [
-336,
992
],
"parameters": {
"jsCode": "// Any USDC balance above this gets stored in Aave\nconst moveToSavingsThreshold = 8564321; // set limit in atomic units (decimals)\n\n// If your balance drops below this, move funds from Aave into your account\n// IMPORTANT: this value must be less that moveToSavingsThreshold\nconst topOffBalance = 8123456; // set limit in atomic units (decimals)\n\nconst delegator = \"0x9fead8b19c044c2f404dac38b925ea16adaa2954\"; // your delegated wallet address.\nconst token = \"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913\" // USDC on Base\nconst pool = \"0xA238Dd80C259a72e81d7e4664a9801593F98d1c5\" // L2Pool on Base\nconst telegramChatId = 5034284669; // the chat id between you and your Telegram bot\n\n$input.first().json.moveToSavingsThreshold = moveToSavingsThreshold;\n$input.first().json.topOffBalance = topOffBalance;\n$input.first().json.delegator = delegator;\n$input.first().json.token = token;\n$input.first().json.pool = pool;\n$input.first().json.telegramChatId = telegramChatId;\n\nreturn $input.all();\n"
},
"typeVersion": 2
},
{
"id": "c95d9919-c82e-48b8-b2e5-3918fb11f04a",
"name": "检查用户的 Aave 储蓄",
"type": "n8n-nodes-1shot.oneShot",
"notes": "Point this node at the 'balanceOf' function on aBasUSDC.",
"position": [
112,
992
],
"parameters": {
"params": "={\n \"user\": \"{{ $('Savings Configs').item.json.delegator }}\"\n} ",
"operation": "read",
"contractMethodId": "6953085e-91a5-46d2-aff8-9267012490a6"
},
"credentials": {
"oneShotOAuth2Api": {
"id": "nkfF9AitCKUCrErK",
"name": "1Shot account"
}
},
"typeVersion": 1
},
{
"id": "ca8c9c20-db85-4d9c-8355-c1656d24ef4c",
"name": "检查用户的 USDC 余额",
"type": "n8n-nodes-1shot.oneShot",
"notes": "Point this node at the 'balanceOf' funcion on USDC.",
"position": [
-112,
992
],
"parameters": {
"params": "={\n \"account\": \"{{ $('Savings Configs').item.json.delegator }}\"\n} ",
"operation": "read",
"contractMethodId": "cb02f30e-fe92-4445-b145-15e2b0891c28"
},
"credentials": {
"oneShotOAuth2Api": {
"id": "nkfF9AitCKUCrErK",
"name": "1Shot account"
}
},
"typeVersion": 1
},
{
"id": "7016ada5-0923-47bd-a632-17fad5ddc3f0",
"name": "切换",
"type": "n8n-nodes-base.switch",
"position": [
336,
976
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "deposit",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "b2cc4c9d-6b1a-42bb-8506-cbc085b354e4",
"operator": {
"type": "number",
"operation": "gt"
},
"leftValue": "={{ parseInt($('Check User\\'s USDC Balance').item.json.response) }}",
"rightValue": "={{ $('Savings Configs').item.json.moveToSavingsThreshold }}"
}
]
},
"renameOutput": true
},
{
"outputKey": "withdraw",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "d647444f-1efd-49a8-8319-47c9780e39b1",
"operator": {
"type": "number",
"operation": "lt"
},
"leftValue": "={{ parseInt($('Check User\\'s USDC Balance').item.json.response) }}",
"rightValue": "={{ $('Savings Configs').item.json.topOffBalance }}"
}
]
},
"renameOutput": true
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"typeVersion": 3.2
},
{
"id": "8f76dfee-aa4b-46a5-87b5-5eca558312b3",
"name": "无变化,发送账户状态",
"type": "n8n-nodes-base.telegram",
"position": [
560,
1184
],
"webhookId": "be1b7868-1626-4f44-b8d4-bec519faaace",
"parameters": {
"text": "=Your current account balance is `${{ parseInt($('Check User\\'s USDC Balance').item.json.response)/1000000 }}` and you have `${{ parseInt($('Check User\\'s Aave Savings').item.json.response)/1000000 }}` saved in Aave.",
"chatId": "={{ $('Savings Configs').first().json.telegramChatId }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "uN6xtW1sUnA0WiMc",
"name": "@1shotdemobot"
}
},
"typeVersion": 1.2
},
{
"id": "5e02f8f3-5b63-43c2-a769-1c89adecc5fd",
"name": "储蓄不足警告",
"type": "n8n-nodes-base.telegram",
"position": [
1008,
1088
],
"webhookId": "be1b7868-1626-4f44-b8d4-bec519faaace",
"parameters": {
"text": "=Your current account balance is `${{ parseInt($('Check User\\'s USDC Balance').item.json.response)/1000000 }}` and you have `${{ parseInt($('Check User\\'s Aave Savings').item.json.response)/100000 }}` saved in Aave.",
"chatId": "={{ $('Savings Configs').first().json.telegramChatId }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "uN6xtW1sUnA0WiMc",
"name": "@1shotdemobot"
}
},
"typeVersion": 1.2
},
{
"id": "6c0a3011-fe89-4dbb-954a-bbce96f7615b",
"name": "存款失败通知",
"type": "n8n-nodes-base.telegram",
"position": [
1232,
576
],
"webhookId": "be1b7868-1626-4f44-b8d4-bec519faaace",
"parameters": {
"text": "Aave Deposit failed",
"chatId": "={{ $('Savings Configs').first().json.telegramChatId }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "uN6xtW1sUnA0WiMc",
"name": "@1shotdemobot"
}
},
"typeVersion": 1.2
},
{
"id": "a35baa3e-5c75-493a-947f-53b3bfb3cf98",
"name": "提款失败通知",
"type": "n8n-nodes-base.telegram",
"position": [
1232,
992
],
"webhookId": "be1b7868-1626-4f44-b8d4-bec519faaace",
"parameters": {
"text": "=❌ Aave withdraw failed. \n\nYour wallet balance is `${{ parseInt($('Check User\\'s USDC Balance').item.json.response)/1000000 }}` and you have `${{ parseInt($('Check User\\'s Aave Savings').item.json.response)/1000000 }}`",
"chatId": "={{ $('Savings Configs').first().json.telegramChatId }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "uN6xtW1sUnA0WiMc",
"name": "@1shotdemobot"
}
},
"typeVersion": 1.2
},
{
"id": "0008742f-a49d-4cc3-9b80-a51a26f91289",
"name": "确认提款后用户的 USDC 余额",
"type": "n8n-nodes-1shot.oneShot",
"notes": "Point this node at the 'balanceOf' function on USDC.",
"position": [
1232,
800
],
"parameters": {
"params": "={\n \"account\": \"{{ $('Savings Configs').item.json.delegator }}\"\n} ",
"operation": "read",
"contractMethodId": "cb02f30e-fe92-4445-b145-15e2b0891c28"
},
"credentials": {
"oneShotOAuth2Api": {
"id": "nkfF9AitCKUCrErK",
"name": "1Shot account"
}
},
"typeVersion": 1
},
{
"id": "1a2f958f-d6fe-4295-bf3f-db2639d2f6eb",
"name": "确认提款后用户的 Aave 储蓄",
"type": "n8n-nodes-1shot.oneShot",
"notes": "Point this node at the 'balanceOf' function on aBasUSDC.",
"position": [
1456,
800
],
"parameters": {
"params": "={\n \"user\": \"{{ $('Savings Configs').item.json.delegator }}\"\n} ",
"operation": "read",
"contractMethodId": "6953085e-91a5-46d2-aff8-9267012490a6"
},
"credentials": {
"oneShotOAuth2Api": {
"id": "nkfF9AitCKUCrErK",
"name": "1Shot account"
}
},
"typeVersion": 1
},
{
"id": "12fd82b4-f8db-4446-87f1-bcc6f1f8df16",
"name": "确认存款后用户的 USDC 余额",
"type": "n8n-nodes-1shot.oneShot",
"notes": "Point this node at the 'balanceOf' function on USDC.",
"position": [
1232,
368
],
"parameters": {
"params": "={\n \"account\": \"{{ $('Savings Configs').item.json.delegator }}\"\n} ",
"operation": "read",
"contractMethodId": "cb02f30e-fe92-4445-b145-15e2b0891c28"
},
"credentials": {
"oneShotOAuth2Api": {
"id": "nkfF9AitCKUCrErK",
"name": "1Shot account"
}
},
"typeVersion": 1
},
{
"id": "8691c25d-09e6-4f8d-984a-8e792ed25fb4",
"name": "确认存款后用户的 Aave 储蓄",
"type": "n8n-nodes-1shot.oneShot",
"notes": "Point this node at the 'balanceOf' function on aBasUSDC.",
"position": [
1456,
368
],
"parameters": {
"params": "={\n \"user\": \"{{ $('Savings Configs').item.json.delegator }}\"\n} ",
"operation": "read",
"contractMethodId": "6953085e-91a5-46d2-aff8-9267012490a6"
},
"credentials": {
"oneShotOAuth2Api": {
"id": "nkfF9AitCKUCrErK",
"name": "1Shot account"
}
},
"typeVersion": 1
},
{
"id": "1dc64dab-0278-46cd-b7d3-17bd8dcb168b",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-528,
672
],
"parameters": {
"width": 544,
"height": 256,
"content": "## 设置您的储蓄阈值"
},
"typeVersion": 1
},
{
"id": "00fcdb46-2934-40c0-867c-fbd04a029e05",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
0
],
"parameters": {
"width": 768,
"height": 416,
"content": "## 设置说明"
},
"typeVersion": 1
},
{
"id": "be37d49b-5bf1-4423-bbb5-4e8745b3bc49",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-944,
80
],
"parameters": {
"width": 768,
"height": 560,
"content": "## YouTube 教程"
},
"typeVersion": 1
},
{
"id": "85c55364-3b0b-46fc-b1ab-0785a427bf52",
"name": "检查用户是否有足够储蓄",
"type": "n8n-nodes-base.if",
"position": [
784,
992
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "f9c2403a-4163-4c26-8452-6d12af40115b",
"operator": {
"type": "number",
"operation": "gt"
},
"leftValue": "={{ parseInt($json.withdrawAmount) }}",
"rightValue": 0
}
]
}
},
"typeVersion": 2.2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "daccf8c8-f7c3-4e7a-99f9-c2ac8761e2e9",
"connections": {
"Switch": {
"main": [
[
{
"node": "Calculate Excess Funds",
"type": "main",
"index": 0
}
],
[
{
"node": "Calculate Insufficient Funds",
"type": "main",
"index": 0
}
],
[
{
"node": "No Change, Send Account Status",
"type": "main",
"index": 0
}
]
]
},
"approve USDC": {
"main": [
[
{
"node": "Deposit USDC into Aave L2Pool",
"type": "main",
"index": 0
}
],
[
{
"node": "Deposit Failure Notification",
"type": "main",
"index": 0
}
]
]
},
"Savings Configs": {
"main": [
[
{
"node": "Check User's USDC Balance",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Savings Configs",
"type": "main",
"index": 0
}
]
]
},
"Withdraw from Aave": {
"main": [
[
{
"node": "Confirm User's USDC Balance After Withdraw",
"type": "main",
"index": 0
}
],
[
{
"node": "Withdraw Failure Notification",
"type": "main",
"index": 0
}
]
]
},
"Calculate Excess Funds": {
"main": [
[
{
"node": "approve USDC",
"type": "main",
"index": 0
}
]
]
},
"Check User's Aave Savings": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Check User's USDC Balance": {
"main": [
[
{
"node": "Check User's Aave Savings",
"type": "main",
"index": 0
}
]
]
},
"Calculate Insufficient Funds": {
"main": [
[
{
"node": "Check User Has Sufficient Savings",
"type": "main",
"index": 0
}
]
]
},
"Deposit USDC into Aave L2Pool": {
"main": [
[
{
"node": "Confirm User's USDC Balance After Deposit",
"type": "main",
"index": 0
}
],
[
{
"node": "Deposit Failure Notification",
"type": "main",
"index": 0
}
]
]
},
"Check User Has Sufficient Savings": {
"main": [
[
{
"node": "Withdraw from Aave",
"type": "main",
"index": 0
}
],
[
{
"node": "Insufficient Savings Warning",
"type": "main",
"index": 0
}
]
]
},
"Confirm User's Aave Savings After Deposit": {
"main": [
[
{
"node": "Deposit Confirmation",
"type": "main",
"index": 0
}
]
]
},
"Confirm User's USDC Balance After Deposit": {
"main": [
[
{
"node": "Confirm User's Aave Savings After Deposit",
"type": "main",
"index": 0
}
]
]
},
"Confirm User's Aave Savings After Withdraw": {
"main": [
[
{
"node": "Withdraw Confirmation",
"type": "main",
"index": 0
}
]
]
},
"Confirm User's USDC Balance After Withdraw": {
"main": [
[
{
"node": "Confirm User's Aave Savings After Withdraw",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 内容创作, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Uniswap V3 区间交易者(第二版)
使用 Uniswap V3、Telegram 提醒和 MetaMask 委托的自动化区间交易
If
Code
Switch
+6
41 节点1Shot API
杂项
使用Uniswap V3的DCA
在Uniswap V3和1Shot API上使用美元成本平均法自动化代币购买
Code
One Shot
Telegram
+3
14 节点1Shot API
加密货币交易
完整的 B2B 销售流程:Apollo 潜在客户生成、Mailgun 外展和 AI 回复管理
完整的 B2B 销售流程:Apollo 潜在客户生成、Mailgun 外展和 AI 回复管理
If
Set
Code
+26
116 节点Paul
内容创作
n8n支付协调器与1Shot API
使用x402和1Shot API创建自托管区块链支付处理器
If
Code
Webhook
+4
27 节点1Shot API
加密货币交易
美甲沙龙:主代理V2 Telegram版
集成Telegram、Claude和GPT5-mini的多智能体沙龙预约管理系统
If
Set
Code
+19
67 节点Denis
内容创作
多链1Shot加油站
基于Li.Fi的多链代币交换中继器
If
Code
Webhook
+5
22 节点1Shot API
加密货币交易