Skip to content

Commit

Permalink
Fix stata deposit for new account (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
noisekit authored Jan 10, 2025
1 parent adc3945 commit 9495ca2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
19 changes: 8 additions & 11 deletions liquidity/components/DepositModal/StataDepositModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ export function StataDepositModal({
//Preparing stataUSDC Done

//Stata Approval
const stataApprovalNeeded =
liquidityPosition && liquidityPosition.availableCollateral.lt(collateralChange)
const stataApprovalNeeded = liquidityPosition
? liquidityPosition.availableCollateral.lt(collateralChange)
? collateralChange.sub(liquidityPosition.availableCollateral)
: wei(0);
: wei(0)
: collateralChange;
const { approve: approveStata, requireApproval: requireApprovalStata } = useApprove({
contractAddress: synthToken?.token?.address,
amount:
Expand All @@ -144,8 +145,8 @@ export function StataDepositModal({
newAccountId,
collateralTypeAddress: synthToken?.token?.address,
collateralChange,
currentCollateral: liquidityPosition?.collateralAmount,
availableCollateral: liquidityPosition?.availableCollateral,
currentCollateral: liquidityPosition ? liquidityPosition.collateralAmount : wei(0),
availableCollateral: liquidityPosition ? liquidityPosition.availableCollateral : wei(0),
collateralSymbol: params.collateralSymbol,
});
//Deposit done
Expand Down Expand Up @@ -257,10 +258,6 @@ export function StataDepositModal({

[ServiceNames.executeDeposit]: async () => {
try {
if (!liquidityPosition) {
throw Error('Deposit failed: not ready');
}

toast.closeAll();
toast({
title: Boolean(params.accountId)
Expand All @@ -271,8 +268,8 @@ export function StataDepositModal({
});

setTxSummary({
currentCollateral: liquidityPosition.collateralAmount,
currentDebt: liquidityPosition.debt,
currentCollateral: liquidityPosition ? liquidityPosition.collateralAmount : wei(0),
currentDebt: liquidityPosition ? liquidityPosition.debt : wei(0),
collateralChange,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,10 @@ export const useDepositBaseAndromeda = ({
ethers.utils.parseEther('1')
);

const callsPromise = Promise.all(
const calls = await Promise.all(
[wrap, synthApproval, createAccount, deposit, delegate].filter(notNil)
);

const [calls] = await Promise.all([callsPromise]);

if (priceUpdateTx) {
calls.unshift(priceUpdateTx as any);
}
Expand Down

0 comments on commit 9495ca2

Please sign in to comment.