diff --git a/frontend/components/common/formatters/FormatCurrency.vue b/frontend/components/common/formatters/FormatCurrency.vue index be0dbe7d3..a355ceaf5 100644 --- a/frontend/components/common/formatters/FormatCurrency.vue +++ b/frontend/components/common/formatters/FormatCurrency.vue @@ -1,7 +1,7 @@ diff --git a/frontend/components/common/formatters/FormatPercentage.vue b/frontend/components/common/formatters/FormatPercentage.vue index fef05c758..38fc18e2b 100644 --- a/frontend/components/common/formatters/FormatPercentage.vue +++ b/frontend/components/common/formatters/FormatPercentage.vue @@ -9,7 +9,7 @@ export default Vue.extend({ name: 'FormatPercentage', props: { value: { - type: Number, + type: [Number, String], required: true, }, }, diff --git a/frontend/components/common/other/AnimatedArrow.vue b/frontend/components/common/other/AnimatedArrow.vue index c3388f51d..2dd8523b1 100644 --- a/frontend/components/common/other/AnimatedArrow.vue +++ b/frontend/components/common/other/AnimatedArrow.vue @@ -6,7 +6,7 @@ import Vue from 'vue'; import UpArrow from '~/assets/icons/uparrow.svg'; -type ArrowDirections = 'up' | 'down' | 'left' | 'right'; +export type ArrowDirections = 'up' | 'down' | 'left' | 'right'; export default Vue.extend({ components: { diff --git a/frontend/components/panels/VaultLiquidationLimitsCheckPanel.vue b/frontend/components/panels/VaultLiquidationLimitsCheckPanel.vue index bc97080f0..6c40a22a8 100644 --- a/frontend/components/panels/VaultLiquidationLimitsCheckPanel.vue +++ b/frontend/components/panels/VaultLiquidationLimitsCheckPanel.vue @@ -9,31 +9,31 @@
Current global limit - The maximum allowed amount of DAI needed to cover the debt and liquidation incentives of all - active auctions. In maker terms it is called + + + The maximum allowed amount of DAI needed to cover the debt and liquidation incentives of all active + auctions. In maker terms it is called dog.Hole + > + - - The amount of DAI needed to cover the debt and liquidation incentives of all active auctions. In + + The amount of DAI needed to cover the debt and liquidation incentives of all active auctions. In maker terms it is called dog.Dirt + > + - - The amount of DAI that will be auctioned after the current liquidation plus liquidation incentives - of this auction + + The amount of DAI that will be auctioned after the current liquidation plus liquidation incentives + of this auction + =
@@ -43,31 +43,31 @@
Current {{ collateralType }} limit - The amount of DAI needed to cover the debt and liquidation incentives of active + + + The amount of DAI needed to cover the debt and liquidation incentives of active {{ collateralType }} auctions. In maker terms it is called ilk.hole + > + - - The amount of DAI needed to cover the debt and liquidation incentives of active + + The amount of DAI needed to cover the debt and liquidation incentives of active {{ collateralType }} auctions. In maker terms it is called ilk.dirt + > + - - The amount of DAI that will be auctioned after the current liquidation plus liquidation incentives - of this auction + + The amount of DAI that will be auctioned after the current liquidation plus liquidation incentives + of this auction + =
@@ -113,6 +113,10 @@ export default Vue.extend({ type: Object as Vue.PropType, required: true, }, + collateralType: { + type: String, + required: true, + }, debtDai: { type: BigNumber, required: true, @@ -125,10 +129,6 @@ export default Vue.extend({ type: BigNumber, required: true, }, - collateralType: { - type: String, - required: true, - }, isRefreshing: { type: Boolean, default: false, @@ -161,7 +161,7 @@ export default Vue.extend({ ); }, currentStateAndTitle(): PanelProps { - if (this.isGlobalLimitMissing || this.isCollateralLimitMissing) { + if (this.isGlobalLimitMissing || this.isCollateralLimitMissing || !this.debtAndIncentives) { return { name: 'inactive', title: 'Current liquidation limits are unknown', @@ -185,6 +185,14 @@ export default Vue.extend({ }; }, }, + watch: { + currentStateAndTitle: { + immediate: true, + handler(newCurrentStateAndTitle) { + this.$emit('update:isCorrect', newCurrentStateAndTitle.name === 'correct'); + }, + }, + }, methods: { format(value: BigNumber): string { return formatToAutomaticDecimalPoints(value); diff --git a/frontend/components/vault/VaultLiquidationTransactionFlow.stories.js b/frontend/components/vault/VaultLiquidationTransactionFlow.stories.js new file mode 100644 index 000000000..1a403eebf --- /dev/null +++ b/frontend/components/vault/VaultLiquidationTransactionFlow.stories.js @@ -0,0 +1,78 @@ +import { storiesOf } from '@storybook/vue'; +import faker from 'faker'; +import BigNumber from 'bignumber.js'; +import VaultLiquidationTransactionFlow from '~/components/vault/VaultLiquidationTransactionFlow'; +import { + generateFakeLiquidationLimits, + generateFakeVaultLiquidatedTransaction, + generateFakeVaultNotLiquidatedTransaction, +} from '~/helpers/generateFakeVault'; + +const common = { + components: { VaultLiquidationTransactionFlow }, + data: () => ({ + vaultTransaction: generateFakeVaultNotLiquidatedTransaction(), + liquidationLimits: generateFakeLiquidationLimits(), + + isConnectingWallet: false, + walletAddress: undefined, + + isRefreshingLimits: false, + isLiquidating: false, + }), + methods: { + connect() { + this.isConnectingWallet = true; + setTimeout(() => { + this.walletAddress = faker.finance.ethereumAddress(); + this.isConnectingWallet = false; + }, 1000); + }, + disconnect() { + this.isConnectingWallet = true; + setTimeout(() => { + this.walletAddress = undefined; + this.isConnectingWallet = false; + }, 1000); + }, + refreshLimits() { + this.isRefreshingLimits = true; + setTimeout(() => { + this.liquidationLimits = { + maximumProtocolDebtDai: new BigNumber(1000000), + maximumCollateralDebtDai: new BigNumber(1000000), + currentProtocolDebtDai: new BigNumber(0), + currentCollateralDebtDai: new BigNumber(0), + }; + this.isRefreshingLimits = false; + }, 1000); + }, + liquidate() { + this.isLiquidating = true; + setTimeout(() => { + this.vaultTransaction = generateFakeVaultLiquidatedTransaction(); + this.isLiquidating = false; + }, 1000); + }, + }, + template: ` + `, +}; + +storiesOf('Vault/VaultLiquidationTransactionFlow', module) + .add('Default', () => ({ + ...common, + })) + .add('Liquidated', () => ({ + ...common, + data: () => ({ + ...common.data(), + vaultTransaction: generateFakeVaultLiquidatedTransaction(), + }), + })); diff --git a/frontend/components/vault/VaultLiquidationTransactionFlow.vue b/frontend/components/vault/VaultLiquidationTransactionFlow.vue new file mode 100644 index 000000000..f0aab696b --- /dev/null +++ b/frontend/components/vault/VaultLiquidationTransactionFlow.vue @@ -0,0 +1,147 @@ + + + diff --git a/frontend/components/vault/VaultLiquidationTransactionTable.stories.js b/frontend/components/vault/VaultLiquidationTransactionTable.stories.js new file mode 100644 index 000000000..ab7a9e24b --- /dev/null +++ b/frontend/components/vault/VaultLiquidationTransactionTable.stories.js @@ -0,0 +1,15 @@ +import { storiesOf } from '@storybook/vue'; +import VaultLiquidationTransactionTable from '~/components/vault/VaultLiquidationTransactionTable'; +import { generateFakeVaultNotLiquidatedTransaction } from '~/helpers/generateFakeVault'; + +const common = { + components: { VaultLiquidationTransactionTable }, + data: () => ({ + vaultTransaction: generateFakeVaultNotLiquidatedTransaction(), + }), + template: '', +}; + +storiesOf('Vault/VaultLiquidationTransactionTable', module).add('Default', () => ({ + ...common, +})); diff --git a/frontend/components/vault/VaultLiquidationTransactionTable.vue b/frontend/components/vault/VaultLiquidationTransactionTable.vue new file mode 100644 index 000000000..95b19587d --- /dev/null +++ b/frontend/components/vault/VaultLiquidationTransactionTable.vue @@ -0,0 +1,125 @@ + + + diff --git a/frontend/helpers/generateFakeVault.ts b/frontend/helpers/generateFakeVault.ts index 1b006741c..cb286f7e4 100644 --- a/frontend/helpers/generateFakeVault.ts +++ b/frontend/helpers/generateFakeVault.ts @@ -67,7 +67,7 @@ export const generateFakeVault = function (): Vault { }; const generateFakeVaultTransactionFees = function (): VaultTransactionFees { - const transactionFeeLiquidationEth = new BigNumber(faker.datatype.number(0.5)); + const transactionFeeLiquidationEth = new BigNumber(faker.datatype.float({ max: 0.5 })); const transactionFeeLiquidationDai = transactionFeeLiquidationEth.multipliedBy(1600); return { @@ -120,7 +120,7 @@ export const generateFakeVaultNotLiquidatedTransaction = function (): VaultTrans const incentiveConstantDai = new BigNumber(faker.finance.amount()); const incentiveCombinedDai = incentiveRelativeDai.plus(incentiveConstantDai); - const grossProfitDai = incentiveCombinedDai.minus(fakeTransactionFees.transactionFeeLiquidationDai); + const netProfitDai = incentiveCombinedDai.minus(fakeTransactionFees.transactionFeeLiquidationDai); const debtDai = new BigNumber(faker.finance.amount()); return { @@ -134,8 +134,8 @@ export const generateFakeVaultNotLiquidatedTransaction = function (): VaultTrans incentiveRelativeDai, incentiveConstantDai, incentiveCombinedDai, - grossProfitDai, - netProfitDai: incentiveCombinedDai, + grossProfitDai: incentiveCombinedDai, + netProfitDai, debtDai, }; };