assembly/core/strategies/protocols/aave-v2/deposit-and-borrow.ts

51 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-08-22 18:32:28 +00:00
import { defineStrategy, defineInput, StrategyInputType } from "../../helpers";
2021-08-22 11:27:02 +00:00
export default defineStrategy({
name: "Deposit & Borrow",
description: "Deposit collateral & borrow asset in a single txn.",
author: "Instadapp Team",
inputs: [
2021-08-22 15:45:37 +00:00
defineInput({
2021-08-22 11:27:02 +00:00
type: StrategyInputType.INPUT_WITH_TOKEN,
name: "Debt",
placeholder: ({ input }) => `${input.token.symbol} to Payback`,
validate: ({ input }) => {
if (!input.token) {
return "Token is required";
}
if (input.token.balance < input.value) {
2021-08-22 12:54:23 +00:00
return "Your amount exceeds your maximum limit.";
}
2021-08-22 18:32:28 +00:00
},
tokenKeys: ["eth", "dai"],
tokens: [{ key: "eth", symbol: "ETH" }],
token: { key: "eth", symbol: "ETH", address : "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" }
2021-08-22 15:45:37 +00:00
}),
defineInput({
2021-08-22 11:27:02 +00:00
type: StrategyInputType.INPUT_WITH_TOKEN,
name: "Collateral",
2021-08-22 18:32:28 +00:00
placeholder: ({ input }) => `${input.token.symbol} to Withdraw`,
tokenKeys: ["eth", "dai"],
tokens: [{ key: "eth", symbol: "ETH" }],
token: { key: "dai", symbol: "DAI", address : "0x6B175474E89094C44Da98b954EedeAC495271d0F" }
2021-08-22 15:45:37 +00:00
})
2021-08-22 11:27:02 +00:00
],
2021-08-22 15:45:37 +00:00
spells: async ({ inputs }) => {
return [
{
connector: "aave_v2",
method: "deposit",
args: [inputs[0].token.address, inputs[0].value, 0, 0]
},
{
connector: "aave_v2",
method: "borrow",
2021-08-22 18:32:28 +00:00
args: [inputs[1].token.address, inputs[1].value, 1, 0, 0]
2021-08-22 15:45:37 +00:00
}
];
2021-08-22 11:27:02 +00:00
}
});