diff --git a/libs/deposits/src/lib/deposit-form.spec.tsx b/libs/deposits/src/lib/deposit-form.spec.tsx
index 8a3e3fde4..726d61211 100644
--- a/libs/deposits/src/lib/deposit-form.spec.tsx
+++ b/libs/deposits/src/lib/deposit-form.spec.tsx
@@ -58,6 +58,7 @@ beforeEach(() => {
max: new BigNumber(20),
allowance: new BigNumber(30),
deposited: new BigNumber(10),
+ exempt: false,
};
props = {
assets: [asset],
@@ -287,6 +288,7 @@ describe('Deposit form', () => {
balance,
max,
deposited,
+ exempt: false,
}}
selectedAsset={asset}
/>
diff --git a/libs/deposits/src/lib/deposit-limits.tsx b/libs/deposits/src/lib/deposit-limits.tsx
index 7b69298c4..a88beb027 100644
--- a/libs/deposits/src/lib/deposit-limits.tsx
+++ b/libs/deposits/src/lib/deposit-limits.tsx
@@ -18,6 +18,7 @@ interface DepositLimitsProps {
asset: Asset;
balance?: BigNumber;
allowance?: BigNumber;
+ exempt?: boolean;
}
export const DepositLimits = ({
@@ -26,6 +27,7 @@ export const DepositLimits = ({
asset,
balance,
allowance,
+ exempt,
}: DepositLimitsProps) => {
const limits = [
{
@@ -68,11 +70,13 @@ export const DepositLimits = ({
),
rawValue: max.minus(deposited),
- value: (
+ value: !exempt ? (
+ ) : (
+
{t('Exempt')}
),
},
{
diff --git a/libs/deposits/src/lib/use-deposit-balances.ts b/libs/deposits/src/lib/use-deposit-balances.ts
index b02974470..e8bb31c8c 100644
--- a/libs/deposits/src/lib/use-deposit-balances.ts
+++ b/libs/deposits/src/lib/use-deposit-balances.ts
@@ -3,17 +3,22 @@ import { useCallback, useEffect, useState } from 'react';
import BigNumber from 'bignumber.js';
import { useGetAllowance } from './use-get-allowance';
import { useGetBalanceOfERC20Token } from './use-get-balance-of-erc20-token';
-import { useGetDepositMaximum } from './use-get-deposit-maximum';
+import {
+ useGetDepositMaximum,
+ useIsExemptDepositor,
+} from './use-get-deposit-maximum';
import { useGetDepositedAmount } from './use-get-deposited-amount';
import { isAssetTypeERC20, localLoggerFactory } from '@vegaprotocol/utils';
import { useAccountBalance } from '@vegaprotocol/accounts';
import type { Asset } from '@vegaprotocol/assets';
+import { useWeb3React } from '@web3-react/core';
export interface DepositBalances {
balance: BigNumber; // amount in Ethereum wallet
allowance: BigNumber; // amount approved
deposited: BigNumber; // total amounted deposited over lifetime
max: BigNumber; // life time deposit cap
+ exempt: boolean; // if exempt then deposit cap doesn't matter
}
const initialState: DepositBalances = {
@@ -21,6 +26,7 @@ const initialState: DepositBalances = {
allowance: new BigNumber(0),
deposited: new BigNumber(0),
max: new BigNumber(0),
+ exempt: false,
};
/**
@@ -28,6 +34,7 @@ const initialState: DepositBalances = {
* whenever the asset changes in the form
*/
export const useDepositBalances = (asset: Asset | undefined) => {
+ const { account } = useWeb3React();
const tokenContract = useTokenContract(
isAssetTypeERC20(asset) ? asset.source.contractAddress : undefined
);
@@ -35,6 +42,7 @@ export const useDepositBalances = (asset: Asset | undefined) => {
const getAllowance = useGetAllowance(tokenContract, asset);
const getBalance = useGetBalanceOfERC20Token(tokenContract, asset);
const getDepositMaximum = useGetDepositMaximum(bridgeContract, asset);
+ const isExemptDepositor = useIsExemptDepositor(bridgeContract, account);
const getDepositedAmount = useGetDepositedAmount(asset);
const [state, setState] = useState(null);
@@ -46,11 +54,12 @@ export const useDepositBalances = (asset: Asset | undefined) => {
try {
logger.info('get deposit balances', { asset: asset.id });
setState(null);
- const [max, deposited, balance, allowance] = await Promise.all([
+ const [max, deposited, balance, allowance, exempt] = await Promise.all([
getDepositMaximum(),
getDepositedAmount(),
getBalance(),
getAllowance(),
+ isExemptDepositor(),
]);
setState({
@@ -58,12 +67,20 @@ export const useDepositBalances = (asset: Asset | undefined) => {
deposited: deposited ?? initialState.deposited,
balance: balance ?? initialState.balance,
allowance: allowance ?? initialState.allowance,
+ exempt,
});
} catch (err) {
logger.error('get deposit balances', err);
setState(null);
}
- }, [asset, getAllowance, getBalance, getDepositMaximum, getDepositedAmount]);
+ }, [
+ asset,
+ getAllowance,
+ getBalance,
+ getDepositMaximum,
+ getDepositedAmount,
+ isExemptDepositor,
+ ]);
const reset = useCallback(() => {
setState(null);
diff --git a/libs/deposits/src/lib/use-get-deposit-maximum.ts b/libs/deposits/src/lib/use-get-deposit-maximum.ts
index a81a5530a..7aa027e09 100644
--- a/libs/deposits/src/lib/use-get-deposit-maximum.ts
+++ b/libs/deposits/src/lib/use-get-deposit-maximum.ts
@@ -28,3 +28,25 @@ export const useGetDepositMaximum = (
return getDepositMaximum;
};
+
+export const useIsExemptDepositor = (
+ contract: CollateralBridge | null,
+ address: string | undefined
+) => {
+ const isExemptDepositor = useCallback(async () => {
+ if (!contract || !address) {
+ return false;
+ }
+ const logger = localLoggerFactory({ application: 'deposits' });
+ try {
+ logger.info('is exempted depositor', { address });
+ const res = await contract.is_exempt_depositor(address);
+ return res;
+ } catch (err) {
+ logger.error('is exempted depositor', err);
+ return false;
+ }
+ }, [contract, address]);
+
+ return isExemptDepositor;
+};
diff --git a/libs/smart-contracts/src/contracts/collateral-bridge.ts b/libs/smart-contracts/src/contracts/collateral-bridge.ts
index 91aae40e3..3b0ee8d22 100644
--- a/libs/smart-contracts/src/contracts/collateral-bridge.ts
+++ b/libs/smart-contracts/src/contracts/collateral-bridge.ts
@@ -35,6 +35,9 @@ export class CollateralBridge {
get_deposit_maximum(assetSource: string): Promise {
return this.contract.get_asset_deposit_lifetime_limit(assetSource);
}
+ is_exempt_depositor(address: string): Promise {
+ return this.contract.is_exempt_depositor(address);
+ }
get_multisig_control_address() {
return this.contract.get_multisig_control_address();
}