Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "export NODE_OPTIONS='--max-old-space-size=8192' && tsc && vite build",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why drop tsc? does vite build do typecheck?

either way, I suppose it belongs in lint like in our other packages. you could put it first since it's the fastest and most likely to find a bug

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a lint:types with a warning

"build": "export NODE_OPTIONS='--max-old-space-size=8192' && vite build",
"preview": "vite preview",
"lint:types": "echo 'XXX tsc is not working, even though vite build is successful' && tsc --noEmit",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice solution

"lint": "eslint . && prettier --check .",
"lint:fix": "eslint . --fix && prettier --write .",
"test": "vitest",
Expand All @@ -23,11 +24,11 @@
"@agoric/smart-wallet": "^0.5.3",
"@agoric/ui-components": "^0.9.0",
"@agoric/wallet": "^0.18.3",
"@agoric/web-components": "^0.15.0",
"@agoric/web-components": "^0.17.0",
"@agoric/zoe": "^0.26.2",
"@endo/eventual-send": "^1.0.1",
"@endo/init": "^1.0.1",
"@endo/marshal": "^0.8.9",
"@endo/eventual-send": "*",
"@endo/init": "*",
"@endo/marshal": "*",
"@headlessui/react": "^1.6.6",
"clsx": "^1.2.1",
"framer-motion": "^7.2.1",
Expand Down
12 changes: 8 additions & 4 deletions src/components/VaultSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { calculateCurrentDebt } from '@agoric/inter-protocol/src/interest-math';
import {
ceilMultiplyBy,
makeRatioFromAmounts,
} from '@agoric/zoe/src/contractSupport';
multiplyBy,
} from '@agoric/zoe/src/contractSupport/ratio';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are all in @agoric/ertp now. since this app is going away I won't push for it

import clsx from 'clsx';
import { useAtomValue, useSetAtom } from 'jotai';
import { isLiquidationPriceBelowGivenPrice, netValue } from 'utils/vaultMath';
Expand All @@ -23,10 +24,9 @@ import {
} from 'store/adjustVault';
import { AmountMath } from '@agoric/ertp';
import CloseVaultDialog from './CloseVaultDialog';
import { multiplyBy } from '@agoric/zoe/src/contractSupport/ratio';
import { motion } from 'framer-motion';
import LeapLiquidityModal, { Direction } from './leap-elements/LiquidityModal';
import type { Brand } from '@agoric/ertp/src/types';
import type { Brand } from '@agoric/ertp';

const cardVariant = {
active: {
Expand Down Expand Up @@ -550,7 +550,11 @@ const VaultSummary = ({ vaultKey }: Props) => {
/>
<TableRow
left="Collateralization Ratio"
right={`${displayPercent(collateralizationRatio, 0)}%`}
right={
collateralizationRatio
? `${displayPercent(collateralizationRatio, 0)}%`
: '--'
}
/>
</tbody>
);
Expand Down
5 changes: 1 addition & 4 deletions src/service/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import {
ChainConnection,
} from 'store/app';
import { toast } from 'react-toastify';
import {
makeAgoricWalletConnection,
AgoricKeplrConnectionErrors as Errors,
} from '@agoric/web-components';
import { makeAgoricWalletConnection, Errors } from '@agoric/web-components';
import type { Id as ToastId, ToastContent, ToastOptions } from 'react-toastify';

const watchPurses = (chainConnection: ChainConnection) => {
Expand Down
6 changes: 2 additions & 4 deletions src/store/adjustVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { calculateCurrentDebt } from '@agoric/inter-protocol/src/interest-math';
import {
ceilMultiplyBy,
makeRatioFromAmounts,
} from '@agoric/zoe/src/contractSupport';
import {
floorMultiplyBy,
ratioGTE,
} from '@agoric/zoe/src/contractSupport/ratio';
} from '@agoric/zoe/src/contractSupport';
import { atom } from 'jotai';
import {
debtAfterChange,
Expand All @@ -24,7 +22,7 @@ import type {
VaultPhase,
PriceDescription,
} from './vaults';
import type { Amount, NatValue } from '@agoric/ertp/src/types';
import type { Amount, NatValue } from '@agoric/ertp';

type VaultToAdjust = {
totalLockedValue: Amount<'nat'>;
Expand Down
10 changes: 6 additions & 4 deletions src/store/createVault.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { atom } from 'jotai';
import { vaultStoreAtom } from './vaults';
import { makeRatioFromAmounts } from '@agoric/zoe/src/contractSupport';
import {
makeRatioFromAmounts,
ratioGTE,
} from '@agoric/zoe/src/contractSupport';
import {
collateralizationRatio,
computeToLock,
debtAfterChange,
istAvailable,
} from 'utils/vaultMath';
import { pursesAtom } from './app';
import { ratioGTE } from '@agoric/zoe/src/contractSupport/ratio';
import { AmountMath } from '@agoric/ertp';
import type { Amount, NatValue } from '@agoric/ertp/src/types';
import type { Amount, NatValue } from '@agoric/ertp';
import type { Getter } from 'jotai';
import { DebtAction } from './adjustVault';
import { displayFunctionsAtom } from './app';
Expand Down Expand Up @@ -203,7 +205,7 @@ export const inputErrorsAtom = atom<VaultCreationErrors>(get => {
debtAfterChange(
DebtAction.Mint,
mintFee,
AmountMath.makeEmpty(mintedAvailable.brand),
AmountMath.makeEmpty(mintedAvailable.brand, 'nat'),
AmountMath.make(mintedAvailable.brand, valueToReceive),
),
)
Expand Down
12 changes: 6 additions & 6 deletions src/utils/vaultMath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
floorDivideBy,
floorMultiplyBy,
makeRatioFromAmounts,
ratioGTE,
} from '@agoric/zoe/src/contractSupport';
import { AmountMath } from '@agoric/ertp';
import { CollateralAction, DebtAction } from 'store/adjustVault';
import { calculateCurrentDebt } from '@agoric/inter-protocol/src/interest-math';
import { ratioGTE } from '@agoric/zoe/src/contractSupport/ratio';
import type {
DebtSnapshot,
PriceDescription,
Expand All @@ -19,7 +19,7 @@ import type {
VaultMetrics,
VaultParams,
} from 'store/vaults';
import type { Amount, Brand, NatValue } from '@agoric/ertp/src/types';
import type { Amount, Brand, NatValue } from '@agoric/ertp';

export const isLiquidationPriceBelowGivenPrice = (
locked: Amount<'nat'>,
Expand Down Expand Up @@ -107,7 +107,7 @@ export const debtAfterChange = (
return AmountMath.subtract(totalDebt, debtChange);
}

return AmountMath.makeEmpty(totalDebt.brand);
return AmountMath.makeEmpty(totalDebt.brand, 'nat');
};

export const lockedAfterChange = (
Expand All @@ -127,7 +127,7 @@ export const lockedAfterChange = (
return AmountMath.subtract(locked, lockedChange);
}

return AmountMath.makeEmpty(locked.brand);
return AmountMath.makeEmpty(locked.brand, 'nat');
};

const lowestPrice = (priceA: Ratio, priceB?: Ratio) =>
Expand All @@ -139,7 +139,7 @@ export const istAvailable = (
): Amount<'nat'> =>
AmountMath.isGTE(debtLimit, totalDebt)
? AmountMath.subtract(debtLimit, totalDebt)
: AmountMath.makeEmpty(debtLimit.brand);
: AmountMath.makeEmpty(debtLimit.brand, 'nat');

export const maxIstToMintFromVault = (
debtLimit: Amount<'nat'>,
Expand Down Expand Up @@ -177,7 +177,7 @@ export const maxIstToMintFromVault = (
currentDebt,
)
? AmountMath.subtract(currentDebtCeiling, currentDebt)
: AmountMath.makeEmpty(currentDebt.brand);
: AmountMath.makeEmpty(currentDebt.brand, 'nat');

const maxDebtDeltaBeforeMintFee = floorDivideBy(
maxDebtDeltaAfterMintFee,
Expand Down
Loading