mirror of
https://github.com/Instadapp/assembly.git
synced 2024-07-29 22:37:06 +00:00
add close trove strategy for Liquity
This commit is contained in:
parent
90d0379510
commit
0b8eeab3ee
|
@ -1,11 +1,11 @@
|
|||
import AaveV2 from "./protocols/aave-v2"
|
||||
import Compound from "./protocols/compound"
|
||||
import Liquity from "./protocols/liquity"
|
||||
import AaveV2 from "./protocols/aave-v2";
|
||||
import Compound from "./protocols/compound";
|
||||
import Liquity from "./protocols/liquity";
|
||||
|
||||
export const protocolStrategies = {
|
||||
aaveV2 : AaveV2,
|
||||
compound : Compound,
|
||||
liquity : Liquity,
|
||||
}
|
||||
aaveV2: AaveV2,
|
||||
compound: Compound,
|
||||
liquity: Liquity
|
||||
};
|
||||
|
||||
export * from "./helpers"
|
||||
export * from "./helpers";
|
||||
|
|
59
core/strategies/protocols/liquity/close-trove.ts
Normal file
59
core/strategies/protocols/liquity/close-trove.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
import { defineStrategy, StrategyProtocol } from "../../helpers";
|
||||
|
||||
export default defineStrategy({
|
||||
protocol: StrategyProtocol.LIQUITY,
|
||||
name: "Close Trove",
|
||||
description:
|
||||
"Close trove: Payback debt, withdraw Collateral & Liquidation Reserve.",
|
||||
author: "Instadapp Team",
|
||||
|
||||
submitText: "Close Trove",
|
||||
|
||||
details: `<p class="text-center">This strategy executes:</p>
|
||||
<ul>
|
||||
<li>Close Trove</li>
|
||||
</ul>`,
|
||||
|
||||
inputs: [],
|
||||
|
||||
validate: async ({
|
||||
position,
|
||||
positionExtra,
|
||||
toBN,
|
||||
getTokenByKey,
|
||||
dsaBalances
|
||||
}) => {
|
||||
const troveOpened =
|
||||
!toBN(position.collateral).isZero() && !toBN(position.debt).isZero();
|
||||
|
||||
if (!troveOpened) {
|
||||
return "You should open new trove first";
|
||||
}
|
||||
|
||||
const troveOverallDetails = positionExtra["troveOverallDetails"];
|
||||
|
||||
const netDebt = toBN(position.debt).minus(
|
||||
troveOverallDetails.liquidationReserve
|
||||
);
|
||||
|
||||
const debtToken = getTokenByKey("lusd");
|
||||
const debtTokenBalance = dsaBalances[debtToken.address].balance;
|
||||
|
||||
if (toBN(position.debt).gt(debtTokenBalance)) {
|
||||
const lackOfBalance = netDebt.minus(debtTokenBalance).toPrecision(6, 0);
|
||||
return `You need ${lackOfBalance} ${debtToken.symbol} more to close your Trove.`;
|
||||
}
|
||||
},
|
||||
|
||||
spells: async () => {
|
||||
const setId = 0;
|
||||
|
||||
return [
|
||||
{
|
||||
connector: "LIQUITY-A",
|
||||
method: "close",
|
||||
args: [setId]
|
||||
}
|
||||
];
|
||||
}
|
||||
});
|
|
@ -1,8 +1,10 @@
|
|||
import depositAndBorrow from "./deposit-and-borrow"
|
||||
import paybackAndWithdraw from "./payback-and-withdraw"
|
||||
import closeTrove from "./close-trove"
|
||||
|
||||
export default [
|
||||
depositAndBorrow,
|
||||
paybackAndWithdraw,
|
||||
closeTrove,
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user