Skip to content

Commit

Permalink
Merge pull request #381 from merofinance/shutdown-pools-support
Browse files Browse the repository at this point in the history
馃殌  Add support for shutdown pools
  • Loading branch information
chase-manning committed Jan 22, 2024
2 parents 91c3ed0 + 448ff58 commit f25357c
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
unit_test:
runs-on: ubuntu-latest
env:
TEST_LLAMA_NODES_ID: ${{ secrets.LLAMA_NODES_PROJECT_ID }}
WEB3_INFURA_PROJECT_ID: ${{ secrets.WEB3_INFURA_PROJECT_ID }}
steps:
- uses: actions/checkout@v2
- name: Setup Node
Expand Down Expand Up @@ -35,11 +35,11 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Installing Dependencies
run: yarn
- name: Building App
run: yarn run build
run: export NODE_OPTIONS=--openssl-legacy-provider && yarn run build
- name: Deploy to Preview Channel
uses: FirebaseExtended/action-hosting-deploy@v0
with:
Expand Down
1 change: 1 addition & 0 deletions src/app/hooks/use-pools-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const usePoolsPreview = (): Optional<Pool[]> => {
},
strategyInfo: null,
isPaused: false,
isShutdown: false,
};
return pool_;
});
Expand Down
4 changes: 3 additions & 1 deletion src/components/PausedSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ const PausedSnackbar = ({ pool }: Props): Optional<JSX.Element> => {
const dispatch = useDispatch();
const dismissed = useSelector(selectPausedSnackbarDismissed);

if (!pool || !pool.isPaused || dismissed) return null;
const paused = pool && (pool.isPaused || pool.isShutdown);

if (!paused || dismissed) return null;

return (
<Border>
Expand Down
6 changes: 3 additions & 3 deletions src/lib/mero.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { DUMMY_ETH_ADDRESS } from "./constants";
import { createMero } from "./factory";
import { Web3Mero } from "./mero";

const llamaId = process.env.TEST_LLAMA_NODES_ID;
if (!llamaId) throw new Error("TEST_LLAMA_NODES_ID not given");
const rpc = `https://eth.llamarpc.com/rpc/${llamaId}`;
const infuraId = process.env.WEB3_INFURA_PROJECT_ID;
if (!infuraId) throw new Error("WEB3_INFURA_PROJECT_ID not given");
const rpc = `https://mainnet.infura.io/v3/${infuraId}`;
const provider = new ethers.providers.JsonRpcProvider(rpc);
const mero = createMero(provider, { chainId: 1 }) as Web3Mero;

Expand Down
4 changes: 4 additions & 0 deletions src/lib/mero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export class Web3Mero implements Mero {
feeDecreasePeriod,
vaultAddress,
isPaused,
isShutdown,
] = await Promise.all([
pool.name(),
pool.getLpToken(),
Expand All @@ -251,6 +252,7 @@ export class Web3Mero implements Mero {
pool.withdrawalFeeDecreasePeriod(),
pool.vault(),
pool.isPaused(),
pool.isShutdown(),
]);

const vaultShutdown = vaultAddress === ZERO_ADDRESS;
Expand Down Expand Up @@ -281,6 +283,7 @@ export class Web3Mero implements Mero {
feeDecreasePeriod: new ScaledNumber(feeDecreasePeriod, 0).toPlain(),
strategyInfo,
isPaused,
isShutdown,
};
}

Expand Down Expand Up @@ -370,6 +373,7 @@ export class Web3Mero implements Mero {
feeDecreasePeriod: ScaledNumber.fromUnscaled(0, 0).toPlain(),
strategyInfo: null,
isPaused,
isShutdown: false,
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/lib/mock/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const pools: GenericPool<BigNumber>[] = [
feeDecreasePeriod: scale(10, 18),
strategyInfo: null,
isPaused: false,
isShutdown: false,
},
{
name: "bUSDC3CRV",
Expand All @@ -57,6 +58,7 @@ export const pools: GenericPool<BigNumber>[] = [
feeDecreasePeriod: scale(10, 18),
strategyInfo: null,
isPaused: false,
isShutdown: false,
},
{
name: "meroethCRV",
Expand All @@ -82,6 +84,7 @@ export const pools: GenericPool<BigNumber>[] = [
feeDecreasePeriod: scale(10, 18),
strategyInfo: null,
isPaused: false,
isShutdown: false,
},
];

Expand Down
1 change: 1 addition & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface GenericPool<T> {
underlying: Token;
strategyInfo: Optional<StrategyInfo>;
isPaused: boolean;
isShutdown: boolean;
}

export type Pool = GenericPool<ScaledNumber>;
Expand Down
1 change: 1 addition & 0 deletions src/pages/pool/PoolDeposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const PoolDeposit = ({ pool, compact }: Props): JSX.Element => {
const error = () => {
if (!pool || !poolUnderlyingBalance || !depositAmount) return "";
if (pool.isPaused) return t("amountInput.validation.poolPaused");
if (pool.isShutdown) return t("amountInput.validation.poolPaused");
if (Number(depositAmount) <= 0) return t("amountInput.validation.positive");
try {
const amount = ScaledNumber.fromUnscaled(depositAmount, pool?.underlying.decimals);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/pools/PoolsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ const PoolsPage = (): JSX.Element => {
{pools &&
pools
.filter((pool: Pool) => {
if (!pool.isPaused) return true;
const paused = pool.isPaused || pool.isShutdown;
if (!paused) return true;
if (!balances || !balances[pool.address]) return false;
return !balances[pool.address].isZero();
})
Expand Down

0 comments on commit f25357c

Please sign in to comment.