Skip to content

Commit

Permalink
fix lp supply storage issue
Browse files Browse the repository at this point in the history
  • Loading branch information
xieqiancaosissi committed Jan 1, 2024
1 parent a85eb19 commit 31ecec4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions components/Modal/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import { getSelectedValues, getAssetData } from "../../redux/appSelectors";
import { trackActionButton, trackUseAsCollateral } from "../../utils/telemetry";
import { useDegenMode } from "../../hooks/hooks";
import { SubmitButton, AlertWarning } from "./components";
import { getAccountPortfolio } from "../../redux/accountSelectors";

export default function Action({ maxBorrowAmount, healthFactor, collateralType }) {
const [loading, setLoading] = useState(false);
const { amount, useAsCollateral, isMax } = useAppSelector(getSelectedValues);
const dispatch = useAppDispatch();
const asset = useAppSelector(getAssetData);
const portfolio = useAppSelector(getAccountPortfolio);
const { action = "Deposit", tokenId, isLpToken, decimals } = asset;
const { isRepayFromDeposits } = useDegenMode();

Expand Down Expand Up @@ -59,12 +61,16 @@ export default function Action({ maxBorrowAmount, healthFactor, collateralType }
if (tokenId === nearTokenId) {
await deposit({ amount, useAsCollateral, isMax });
} else if (isLpToken) {
const isRegistered = !!(
portfolio?.supplied?.[tokenId] || portfolio?.positions?.[tokenId]?.collateral?.[tokenId]
);
await shadow_action_supply({
tokenId,
decimals: +(decimals || 0) + +extraDecimals,
useAsCollateral,
amount,
isMax,
isRegistered,
});
} else {
await supply({
Expand Down
4 changes: 3 additions & 1 deletion store/actions/shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ export async function shadow_action_supply({
useAsCollateral,
amount,
isMax,
isRegistered,
}: {
tokenId: string;
decimals: number;
useAsCollateral: boolean;
amount: string;
isMax: boolean;
isRegistered: boolean;
}): Promise<void> {
const transactions: Transaction[] = [];
const { refv1Contract } = await getBurrow();
Expand All @@ -45,7 +47,7 @@ export async function shadow_action_supply({
...(isMax ? {} : { amount: expandAmount }),
msg: useAsCollateral ? JSON.stringify({ Execute: collateralActions }) : "",
},
attachedDeposit: new BN(1),
attachedDeposit: new BN(isRegistered ? 1 : expandToken(0.003, NEAR_DECIMALS)),
},
],
});
Expand Down

0 comments on commit 31ecec4

Please sign in to comment.