Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add usePortals #20

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Binary file modified bun.lockb
Binary file not shown.
158 changes: 79 additions & 79 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
{
"name": "yearnx",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"prettier-format": "prettier --config .prettierrc ./packages/**/**/*.{json,js,ts,tsx,css} --write",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@builtbymom/web3": "0.0.215",
"@closeio/use-abortable-effect": "^1.0.0",
"@generationsoftware/hyperstructure-client-js": "^1.12.6",
"@generationsoftware/hyperstructure-react-hooks": "^1.16.8",
"@headlessui/react": "^2.0.3",
"@rainbow-me/rainbowkit": "^2.1.3",
"@react-hookz/web": "^24.0.4",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.13",
"@tanstack/react-query": "^5.51.21",
"@wagmi/core": "^2.13.1",
"axios": "^1.6.8",
"framer-motion": "^11.1.9",
"next": "14.0.4",
"next-plausible": "^3.12.1",
"next-pwa": "^5.6.0",
"rc-input-number": "^9.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"react-paginate": "^8.2.0",
"swr": "^2.2.5",
"tailwindcss": "^3.4.3",
"tailwindcss-animate": "^1.0.7",
"usehooks-ts": "^3.1.0",
"vaul": "^0.9.1",
"viem": "^2.18.8",
"wagmi": "^2.12.2",
"web3-eth-abi": "1.10.0",
"xxhashjs": "^0.2.2",
"zod": "^3.23.8"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@total-typescript/ts-reset": "^0.5.1",
"@types/node": "^20.12.11",
"@types/nprogress": "^0.2.3",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"autoprefixer": "^10.4.19",
"babel-loader": "^9.1.3",
"bun-types": "^1.1.8",
"eslint": "8.57.0",
"eslint-config-next": "^14.2.3",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-brackets": "^0.1.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-tailwindcss": "^3.15.1",
"eslint-plugin-unused-imports": "^3.2.0",
"lint-staged": "^15.2.2",
"next-transpile-modules": "^10.0.1",
"postcss": "^8.4.38",
"postcss-import": "^16.1.0",
"postcss-nesting": "^12.1.3",
"prettier": "^3.2.5",
"sass": "^1.77.1",
"sharp": "^0.33.3",
"stylelint": "^16.5.0",
"stylelint-config-standard": "^36.0.0",
"ts-loader": "^9.5.1",
"typescript": "^5.4.5"
}
"name": "yearnx",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"prettier-format": "prettier --config .prettierrc ./packages/**/**/*.{json,js,ts,tsx,css} --write",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@builtbymom/web3": "0.0.218",
"@closeio/use-abortable-effect": "^1.0.0",
"@generationsoftware/hyperstructure-client-js": "^1.12.6",
"@generationsoftware/hyperstructure-react-hooks": "^1.16.8",
"@headlessui/react": "^2.0.3",
"@rainbow-me/rainbowkit": "^2.1.3",
"@react-hookz/web": "^24.0.4",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.13",
"@tanstack/react-query": "^5.51.21",
"@wagmi/core": "^2.13.1",
"axios": "^1.6.8",
"framer-motion": "^11.1.9",
"next": "14.0.4",
"next-plausible": "^3.12.1",
"next-pwa": "^5.6.0",
"rc-input-number": "^9.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"react-paginate": "^8.2.0",
"swr": "^2.2.5",
"tailwindcss": "^3.4.3",
"tailwindcss-animate": "^1.0.7",
"usehooks-ts": "^3.1.0",
"vaul": "^0.9.1",
"viem": "^2.18.8",
"wagmi": "^2.12.2",
"web3-eth-abi": "1.10.0",
"xxhashjs": "^0.2.2",
"zod": "^3.23.8"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@total-typescript/ts-reset": "^0.5.1",
"@types/node": "^20.12.11",
"@types/nprogress": "^0.2.3",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"autoprefixer": "^10.4.19",
"babel-loader": "^9.1.3",
"bun-types": "^1.1.8",
"eslint": "8.57.0",
"eslint-config-next": "^14.2.3",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-brackets": "^0.1.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-tailwindcss": "^3.15.1",
"eslint-plugin-unused-imports": "^3.2.0",
"lint-staged": "^15.2.2",
"next-transpile-modules": "^10.0.1",
"postcss": "^8.4.38",
"postcss-import": "^16.1.0",
"postcss-nesting": "^12.1.3",
"prettier": "^3.2.5",
"sass": "^1.77.1",
"sharp": "^0.33.3",
"stylelint": "^16.5.0",
"stylelint-config-standard": "^36.0.0",
"ts-loader": "^9.5.1",
"typescript": "^5.4.5"
}
}
17 changes: 9 additions & 8 deletions packages/lib/components/common/DepositModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function DepositModalContent(props: TDepositModalProps): ReactElement {
openAccountModal?.();
}
if (canDeposit) {
const isSuccess = await onDeposit();
const isSuccess = await onDeposit(receipt => console.info('receipt: ', receipt));
if (isSuccess) {
plausible(PLAUSIBLE_EVENTS.DEPOSIT, {
props: {
Expand All @@ -92,24 +92,25 @@ export function DepositModalContent(props: TDepositModalProps): ReactElement {
props.openSuccessModal({
isOpen: true,
description: (
<div className={'flex flex-col items-center'}>
<p className={'text-regularText/50 whitespace-nowrap'}>{'Successfully deposited'}</p>

<div className={'flex'}>
<span>
<span className={'text-regularText/50 whitespace-nowrap'}>{'Successfully deposited'}</span>
&nbsp;
<span>
{!isZapNeededForDeposit
? configuration?.tokenToSpend.amount?.display.slice(0, 7)
: formatBigIntForDisplay(
configuration?.tokenToSpend.amount?.raw ?? 0n,
configuration?.tokenToSpend.token?.decimals ?? 18,
{maximumFractionDigits: 6}
)}
<p className={'ml-1'}>{configuration?.tokenToSpend?.token?.symbol}</p>
&nbsp;
<span>{configuration?.tokenToSpend?.token?.symbol}</span>
<span className={'text-regularText/50'}>
<span className={'mx-1'}>{'to'}</span>
{configuration?.vault?.name}
</span>
</div>
</div>
</span>
</span>
)
});
}
Expand Down
26 changes: 14 additions & 12 deletions packages/lib/components/common/WithdrawModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ function ButtonComponent(props: {
onApprove?.();
return;
}
const isSuccess = await onWithdraw();

const isSuccess = await onWithdraw(receipt => console.info('receipt: ', receipt));

if (isSuccess) {
plausible(PLAUSIBLE_EVENTS.WITHDRAW, {
props: {
Expand All @@ -350,25 +352,25 @@ function ButtonComponent(props: {
props.openSuccessModal({
isOpen: true,
description: (
<div className={'flex flex-col items-center'}>
<p className={'text-regularText/50 whitespace-nowrap'}>{'Successfully withdrawn'}</p>

<div className={'flex flex-col items-center'}>
<div className={'flex'}>
<span>
<span className={'text-regularText/50 whitespace-nowrap'}>{'Successfully withdrawn'}</span>
&nbsp;
<span>
<span>
{!isZapNeededForWithdraw
? configuration?.tokenToSpend.amount?.display.slice(0, 7)
: formatBigIntForDisplay(
BigInt(quote?.minOutputAmount ?? ''),
quote?.outputTokenDecimals ?? 18,
{maximumFractionDigits: 6}
)}
<p className={'ml-1'}>{configuration?.tokenToReceive?.token?.symbol}</p>
</div>
<span className={'ml-1'}>{configuration?.tokenToReceive?.token?.symbol}</span>
</span>
<span className={'text-regularText/50'}>
<span className={'mx-1'}>{'to your wallet'}</span>
</span>
</div>
</div>
</span>
</span>
)
});
}
Expand Down Expand Up @@ -413,7 +415,7 @@ function ButtonComponent(props: {
return 'Withdraw';
}, [address, canZap, isFetchingQuote, isWalletSafe, isApproved, isZapNeededForWithdraw]);

const isWithdrawDisable =
const isWithdrawDisabled =
!props.isReady ||
!configuration?.tokenToSpend.amount ||
configuration?.tokenToSpend.amount.raw === 0n ||
Expand All @@ -423,7 +425,7 @@ function ButtonComponent(props: {
<Button
onClick={onAction}
isBusy={isFetchingQuote || isWithdrawing || isApproving}
isDisabled={isWithdrawDisable}
isDisabled={isWithdrawDisabled}
spinnerClassName={'text-background size-4 animate-spin'}
className={cl(
'text-black flex w-full justify-center regularTextspace-nowrap rounded-lg bg-regularText md:px-[34.5px] py-5 font-bold',
Expand Down
11 changes: 9 additions & 2 deletions packages/lib/contexts/useSolver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {useVanilaSolver} from '@lib/solvers/useVanilaSolver';
import {useManageVaults} from './useManageVaults';

import type {ReactElement} from 'react';
import type {TransactionReceipt} from 'viem';
import type {TPermitSignature} from '@builtbymom/web3/hooks/usePermit.types';
import type {TPortalsEstimate} from '@lib/utils/api.portals';

Expand All @@ -27,8 +28,14 @@ export type TSolverContextBase = {
permitSignature?: TPermitSignature;
quote: TPortalsEstimate | null;
onApprove: (onSuccess?: () => void, onFailure?: () => void) => Promise<boolean>;
onDeposit: (onSuccess?: () => void, onFailure?: () => void) => Promise<boolean>;
onWithdraw: (onSuccess?: () => void, onFailure?: () => void) => Promise<boolean>;
onDeposit: (
onSuccess: (receipt?: TransactionReceipt) => void,
onFailure?: (message?: string) => void
) => Promise<boolean>;
onWithdraw: (
onSuccess: (receipt?: TransactionReceipt) => void,
onFailure?: (message?: string) => void
) => Promise<boolean>;
};

/**
Expand Down
Loading