Skip to content

Commit

Permalink
chore: renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
kovipu committed Jan 19, 2025
1 parent b51decc commit 8d73895
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/components/AssetsModal/PositionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const TableRow = ({ receivableShares, ticker, onWithdraw }: TableRowProps) => {
return null;
}

const totalBalance = (receivableShares * pool.totalBalance) / pool.totalShares;
const totalBalance = (receivableShares * pool.totalBalanceTokens) / pool.totalBalanceShares;

const handleWithdrawClick = () => onWithdraw(ticker);

Expand Down
2 changes: 1 addition & 1 deletion src/components/AssetsModal/WithdrawView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const WithdrawView = ({ ticker, onBack, onSuccess }: WithdrawViewProps) => {

const { receivable_shares } = positions[ticker];

const totalBalance = (receivable_shares * pool.totalBalance) / pool.totalShares;
const totalBalance = (receivable_shares * pool.totalBalanceTokens) / pool.totalBalanceShares;

const max = (totalBalance / SCALAR_7).toString();

Expand Down
18 changes: 9 additions & 9 deletions src/contexts/pool-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export type PriceRecord = {
};

export type PoolState = {
totalBalance: bigint;
availableBalance: bigint;
totalShares: bigint;
totalBalanceTokens: bigint;
totalBalanceShares: bigint;
availableBalanceTokens: bigint;
annualInterestRate: bigint;
};

Expand Down Expand Up @@ -58,18 +58,18 @@ const fetchPoolState = async (ticker: SupportedCurrency): Promise<PoolState> =>
if (result.isOk()) {
const value = result.unwrap();
return {
totalBalance: value.total_balance_tokens,
availableBalance: value.available_balance_tokens,
totalShares: value.total_balance_shares,
totalBalanceTokens: value.total_balance_tokens,
totalBalanceShares: value.total_balance_shares,
availableBalanceTokens: value.available_balance_tokens,
annualInterestRate: value.annual_interest_rate,
};
}
const error = result.unwrapErr();
console.error('Error: ', error);
return {
totalBalance: 0n,
availableBalance: 0n,
totalShares: 0n,
totalBalanceTokens: 0n,
totalBalanceShares: 0n,
availableBalanceTokens: 0n,
annualInterestRate: 0n,
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/pages/_borrow/BorrowModal/BorrowStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const BorrowStep = ({ onClose, currency }: BorrowStepProps) => {

if (!pools || !prices || !walletBalances) return null;

const { annualInterestRate, availableBalance } = pools[ticker];
const { annualInterestRate, availableBalanceTokens } = pools[ticker];

const loanBalance = walletBalances[ticker];
const collateralBalance = walletBalances[collateralTicker];
Expand Down Expand Up @@ -128,7 +128,7 @@ export const BorrowStep = ({ onClose, currency }: BorrowStepProps) => {
const isBorrowDisabled =
!isTrustline || loanAmount === '0' || collateralAmount === '0' || healthFactor < HEALTH_FACTOR_MIN_THRESHOLD;

const maxLoan = (availableBalance / 10_000_000n).toString();
const maxLoan = (availableBalanceTokens / 10_000_000n).toString();

const maxCollateral = getIntegerPart(collateralBalance.trustLine ? collateralBalance.balanceLine.balance : '0');

Expand Down
8 changes: 4 additions & 4 deletions src/pages/_borrow/BorrowableAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const BorrowableAsset = ({ currency }: BorrowableAssetCardProps) => {
.filter(([t, _b]) => t !== ticker)
.some(([_t, b]) => b.trustLine && !isBalanceZero(b.balanceLine.balance));

const borrowDisabled = !wallet || !isCollateral || !pool || pool.availableBalance === 0n;
const borrowDisabled = !wallet || !isCollateral || !pool || pool.availableBalanceTokens === 0n;

const openModal = () => {
const modalEl = document.getElementById(modalId) as HTMLDialogElement;
Expand All @@ -46,7 +46,7 @@ export const BorrowableAsset = ({ currency }: BorrowableAssetCardProps) => {

const tooltip = useMemo(() => {
if (!pool) return 'The pool is loading';
if (pool.availableBalance === 0n) return 'the pool has no assets to borrow';
if (pool.availableBalanceTokens === 0n) return 'the pool has no assets to borrow';
if (!wallet) return 'Connect a wallet first';
if (!isCollateral) return 'Another token needed for the collateral';
return 'Something odd happened.';
Expand All @@ -70,9 +70,9 @@ export const BorrowableAsset = ({ currency }: BorrowableAssetCardProps) => {

<td>
<p className="text-xl font-semibold mt-3 leading-6">
{pool ? formatAmount(pool.availableBalance) : <Loading size="xs" />}
{pool ? formatAmount(pool.availableBalanceTokens) : <Loading size="xs" />}
</p>
<p>{pool && price ? toDollarsFormatted(price, pool.availableBalance) : null}</p>
<p>{pool && price ? toDollarsFormatted(price, pool.availableBalanceTokens) : null}</p>
</td>

<td>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/_lend/LendableAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export const LendableAsset = ({ currency }: LendableAssetProps) => {

<td>
<p className="text-xl font-semibold leading-6">
{pool ? formatAmount(pool.totalBalance) : <Loading size="xs" />}
{pool ? formatAmount(pool.totalBalanceTokens) : <Loading size="xs" />}
</p>
<p>{!isNil(price) && !isNil(pool) && toDollarsFormatted(price, pool.totalBalance)}</p>
<p>{!isNil(price) && !isNil(pool) && toDollarsFormatted(price, pool.totalBalanceTokens)}</p>
</td>

<td>
Expand Down

0 comments on commit 8d73895

Please sign in to comment.