Skip to content

Commit

Permalink
Merge pull request #709 from threshold-network/remove-coverage-pools-…
Browse files Browse the repository at this point in the history
…references

Remove all references to coverage pools

Closes: #668 

Removes all references to coverage pools including adding it's tvl to the total tvl value. Thanks to this we can remove `@keep-network/coverage-pools` and `@threshold-network/coverage-pools` libs.

Note: `useFetchTvl.test.jsx` test is not working after our tbtc-v2.ts 2.3 integration. All non-working tests should be improved in a separate Pull Request.
  • Loading branch information
michalinacienciala authored Dec 28, 2023
2 parents aac207e + 1f189be commit 45c336c
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 236 deletions.
1 change: 0 additions & 1 deletion .github/workflows/dashboard-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jobs:
@keep-network/keep-core \
@keep-network/keep-ecdsa \
@keep-network/tbtc \
@keep-network/coverage-pools \
@keep-network/random-beacon --ignore-scripts
- name: Run postinstall script
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/reusable-build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,6 @@ jobs:
echo "random-beacon-contracts-version=${{ steps.upstream-builds-query.outputs.random-beacon-contracts-version }}" >> $GITHUB_OUTPUT
fi
# In the `package.json` there are two different versions of
# `coverage-pools` used. This is done to allow using contracts from two
# different cov pool versions on the mainnet (needed for computations of
# the TVL-related fields) - one relates to KEEP token cov pool (<2.0.0)
# and one to to T token one (>=2.0.0).
# On the testnet environmet we currently don't have the KEEP token cov
# pool deployed. The T-related cov-pool contracts will be used in all TVL
# computations (which differs from the mainnet behavior, but is acceptable
# on the test env).
- name: Resolve contracts
shell: bash
run: |
Expand All @@ -152,8 +143,6 @@ jobs:
@keep-network/keep-core@${{ inputs.environment }} \
@keep-network/keep-ecdsa@${{ inputs.environment }} \
@keep-network/tbtc@${{ inputs.environment }} \
@keep-network/coverage-pools@${{ inputs.environment }} \
@threshold-network/coverage-pools@npm:@keep-network/coverage-pools@${{ inputs.environment }} \
@keep-network/random-beacon@${{ steps.set-packages-versions.outputs.random-beacon-contracts-version }}
- name: Run postinstall script
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ ENV NODE_OPTIONS=--max_old_space_size=3072
COPY package*.json yarn.lock ./
RUN npm install -g node-gyp
RUN yarn install --ignore-scripts
RUN yarn upgrade @keep-network/coverage-pools@sepolia \
@keep-network/ecdsa@sepolia \
RUN yarn upgrade @keep-network/ecdsa@sepolia \
@keep-network/keep-core@sepolia \
@keep-network/keep-ecdsa@sepolia \
@keep-network/random-beacon@sepolia \
@keep-network/tbtc@sepolia \
@keep-network/tbtc-v2@sepolia \
@threshold-network/coverage-pools@npm:@keep-network/coverage-pools@sepolia \
@threshold-network/solidity-contracts@sepolia
RUN yarn run postinstall

Expand Down
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,20 @@ REACT_APP_MULTICALL_ADDRESS=$MULTICALL_ADDRESS
## Install Sepolia contracts

```
yarn upgrade @keep-network/coverage-pools@sepolia \
@keep-network/keep-core@sepolia \
yarn upgrade @keep-network/keep-core@sepolia \
@keep-network/keep-ecdsa@sepolia \
@keep-network/random-beacon@sepolia \
@keep-network/tbtc@sepolia \
@threshold-network/coverage-pools@npm:@keep-network/coverage-pools@sepolia \
@threshold-network/solidity-contracts@sepolia
```

**NOTE 1:** We use the same Sepolia versions for both
`@keep-network/coverage-pools` and `@threshold-network/coverage-pools`, because
we don't have the v1 version of the package on Sepolia network, only on the
Mainnet.

**NOTE 2:** If you encounter an `expected manifest` error while executing this,
**NOTE 1:** If you encounter an `expected manifest` error while executing this,
then try providing an explicit version of the `keep-core` package:
`@keep-network/[email protected]`
The error is probably caused by a bug in Yarn:
https://github.com/yarnpkg/yarn/issues/4731.

**NOTE 3:** The `token-dashboard` package contains an indirect dependency to
**NOTE 2:** The `token-dashboard` package contains an indirect dependency to
`@summa-tx/[email protected]` package, which downloads one of its sub-dependencies
via unathenticated `git://` protocol. That protocol is no longer supported by
GitHub. This means that in certain situations installation of the package or
Expand All @@ -66,12 +59,10 @@ Ref: https://github.com/keep-network/tbtc-v2/pull/403
Instead of the goerli contracts above you can also use `dapp-development-sepolia` contracts. They offer shorter durations for some specific elements in the contracts in comparison to goerli/mainnet and also allow to manually control mint and unmint process of tbtc-v2 (for more information see please see https://github.com/keep-network/tbtc-v2/pull/403) To install sepolia-dev contracts run:

```
yarn upgrade @keep-network/coverage-pools@sepolia \
@keep-network/keep-core@sepolia \
yarn @keep-network/keep-core@sepolia \
@keep-network/keep-ecdsa@sepolia \
@keep-network/random-beacon@dapp-development-sepolia \
@keep-network/tbtc@sepolia \
@threshold-network/coverage-pools@npm:@keep-network/coverage-pools@sepolia \
@threshold-network/solidity-contracts@dapp-development-sepolia
```

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@ethersproject/constants": "^5.5.0",
"@fontsource/ibm-plex-mono": "^4.5.13",
"@fontsource/inter": "^4.5.10",
"@keep-network/coverage-pools": "development",
"@keep-network/keep-core": "development",
"@keep-network/keep-ecdsa": "development",
"@keep-network/random-beacon": "development",
Expand All @@ -23,16 +22,15 @@
"@ledgerhq/connect-kit-loader": "1.1.8",
"@ledgerhq/wallet-api-client": "^1.2.0",
"@ledgerhq/wallet-api-client-react": "^1.1.1",
"@nucypher/nucypher-contracts": "0.13.0",
"@reduxjs/toolkit": "^1.6.1",
"@rehooks/local-storage": "^2.4.4",
"@nucypher/nucypher-contracts": "0.13.0",
"@sentry/react": "^7.33.0",
"@sentry/tracing": "^7.33.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@threshold-network/components": "development",
"@threshold-network/coverage-pools": "npm:@keep-network/coverage-pools@development",
"@threshold-network/solidity-contracts": "development",
"@types/jest": "^27.0.1",
"@types/node": "^16.9.1",
Expand Down
13 changes: 1 addition & 12 deletions scripts/start_dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ KEEP_CORE_SOL_PATH="$KEEP_CORE_PATH/solidity-v1"
KEEP_ECDSA_PATH="$PWD/../keep-ecdsa"
KEEP_ECDSA_SOL_PATH="$KEEP_ECDSA_PATH/solidity"

COV_POOLS_PATH="$PWD/../coverage-pools"

TBTC_PATH="$PWD/../tbtc/"
TBTC_SOL_PATH="$TBTC_PATH/solidity"

Expand All @@ -67,8 +65,7 @@ function start_dashboard {
yarn link @threshold-network/solidity-contracts \
@keep-network/keep-core \
@keep-network/keep-ecdsa \
@keep-network/tbtc \
@keep-network/coverage-pools
@keep-network/tbtc

printf "${LOG_START}Starting dashboard...${LOG_END}"
MULTICALL_ADDRESS="${MULTICALL_ADDRESS}" yarn start
Expand Down Expand Up @@ -105,14 +102,6 @@ cd "$TBTC_PATH"
cd "$TBTC_SOL_PATH"
yarn link

cd $COV_POOLS_PATH
printf "${LOG_START}Migrating contracts for coverage pools...${LOG_END}"
yarn
yarn link @keep-network/keep-core @keep-network/tbtc
yarn deploy --network development --reset
./scripts/prepare-artifacts.sh --network development
yarn link

cd "$THRESHOLD_CONTRACTS_PATH"
printf "${LOG_START}Installing Threshold network solidity contracts dependencies...${LOG_START}"
yarn
Expand Down
1 change: 0 additions & 1 deletion src/enums/externalHref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ export enum ExternalHref {
mintersAndGuardiansDocs = "https://blog.threshold.network/minters-guardians-and-a-strong-tbtc/",
tBTCDuneDashboard = "https://dune.com/threshold/tbtc",
delight = "https://delightlabs.io",
coveragePoolsDocs = "https://docs.threshold.network/applications/tbtc-v2/coverage-pool",
runningNodeDocs = "https://docs.threshold.network/staking-and-running-a-node/running-a-node",
}
49 changes: 1 addition & 48 deletions src/hooks/__tests__/useFetchTvl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { renderHook } from "@testing-library/react-hooks"
import * as ethersUnits from "@ethersproject/units"
import { Token } from "../../enums"
import {
useAssetPoolContract,
useKeepAssetPoolContract,
useKeepBondingContract,
useKeepTokenStakingContract,
useMulticall,
Expand All @@ -20,8 +18,6 @@ import { FC } from "react"

jest.mock("../../web3/hooks", () => ({
...(jest.requireActual("../../web3/hooks") as {}),
useAssetPoolContract: jest.fn(),
useKeepAssetPoolContract: jest.fn(),
useKeepBondingContract: jest.fn(),
useKeepTokenStakingContract: jest.fn(),
useMulticall: jest.fn(),
Expand Down Expand Up @@ -66,8 +62,6 @@ describe("Test `useFetchTvl` hook", () => {
const mockedKeepBondingContract = { address: "0x0" }
const mockedTStakingContract = { address: "0x2" }
const mockedMultiCallContract = { interface: {}, address: "0x3" }
const mockedAssetPoolContract = { interface: {}, address: "0x4" }
const mockedKeepAssetPoolContract = { interface: {}, address: "0x5" }
const mockedtBTCTokenContract = { interface: {}, address: "0x6" }

const wrapper: FC = ({ children }) => (
Expand Down Expand Up @@ -96,12 +90,6 @@ describe("Test `useFetchTvl` hook", () => {
;(useMulticallContract as jest.Mock).mockReturnValue(
mockedMultiCallContract
)
;(useAssetPoolContract as jest.Mock).mockReturnValue(
mockedAssetPoolContract
)
;(useKeepAssetPoolContract as jest.Mock).mockReturnValue(
mockedKeepAssetPoolContract
)
;(useTStakingContract as jest.Mock).mockReturnValue(mockedTStakingContract)
;(useKeepTokenStakingContract as jest.Mock).mockReturnValue(
mockedKeepTokenStakingContract
Expand All @@ -115,20 +103,13 @@ describe("Test `useFetchTvl` hook", () => {
// given
const ethInKeepBonding = { raw: "10000000000000000000", format: "10.0" }
const tbtcTokenTotalSupply = { raw: "5000000000000000000", format: "5.0" }
const coveragePoolTvl = { raw: "500000000000000000000", format: "500.0" }
const keepCoveragePoolTvl = {
raw: "300000000000000000000",
format: "300.0",
}
const keepStaking = { raw: "500000000000000000000", format: "500.0" }
const tStaking = { raw: "600000000000000000000", format: "600.0" }
const tBTC = { raw: "700000000000000000000", format: "700.0" }

const multicallRequestResult = [
ethInKeepBonding.raw,
tbtcTokenTotalSupply.raw,
coveragePoolTvl.raw,
keepCoveragePoolTvl.raw,
keepStaking.raw,
tStaking.raw,
tBTC.raw,
Expand All @@ -143,8 +124,6 @@ describe("Test `useFetchTvl` hook", () => {
const _expectedResult = {
ecdsa: +ethInKeepBonding.format * mockedETHData.usdPrice,
tbtc: +tbtcTokenTotalSupply.format * tbtcv1Context.usdConversion,
coveragePool: +coveragePoolTvl.format * tContext.usdConversion,
keepCoveragePool: +keepCoveragePoolTvl.format * keepContext.usdConversion,
keepStaking: +keepStaking.format * keepContext.usdConversion,
tStaking: +tStaking.format * tContext.usdConversion,
tBTC: +tBTC.format * tBTCContext.usdConversion,
Expand All @@ -155,16 +134,12 @@ describe("Test `useFetchTvl` hook", () => {
const expectedResult = {
ecdsa: `${_expectedResult.ecdsa.toString()}.0`,
tbtcv1: `${_expectedResult.tbtc.toString()}.0`,
coveragePool: `${_expectedResult.coveragePool.toString()}.0`,
keepCoveragePool: `${_expectedResult.keepCoveragePool.toString()}.0`,
keepStaking: `${_expectedResult.keepStaking.toString()}.0`,
tStaking: `${_expectedResult.tStaking.toString()}.0`,
tBTC: `${_expectedResult.tBTC.toString()}.0`,
total: `${
_expectedResult.ecdsa +
_expectedResult.tbtc +
_expectedResult.coveragePool +
_expectedResult.keepCoveragePool +
_expectedResult.keepStaking +
_expectedResult.tStaking +
_expectedResult.tBTC
Expand All @@ -184,8 +159,6 @@ describe("Test `useFetchTvl` hook", () => {
expect(spyOnUseToken).toHaveBeenCalledWith(Token.TBTCV2)
expect(useKeepBondingContract).toHaveBeenCalled()
expect(useMulticallContract).toHaveBeenCalled()
expect(useAssetPoolContract).toHaveBeenCalled()
expect(useKeepAssetPoolContract).toHaveBeenCalled()
expect(useTStakingContract).toHaveBeenCalled()
expect(useKeepTokenStakingContract).toHaveBeenCalled()
expect(useMulticall).toHaveBeenCalledWith([
Expand All @@ -200,16 +173,6 @@ describe("Test `useFetchTvl` hook", () => {
address: tbtcv1Context.contract.address,
method: "totalSupply",
},
{
interface: mockedAssetPoolContract.interface,
address: mockedAssetPoolContract.address,
method: "totalValue",
},
{
interface: mockedKeepAssetPoolContract.interface,
address: mockedKeepAssetPoolContract.address,
method: "totalValue",
},
{
interface: keepContext.contract.interface,
address: keepContext.contract.address,
Expand Down Expand Up @@ -262,21 +225,11 @@ describe("Test `useFetchTvl` hook", () => {
)
expect(spyOnToUsdBalance).toHaveBeenNthCalledWith(
11,
coveragePoolTvl.format,
tContext.usdConversion
)
expect(spyOnToUsdBalance).toHaveBeenNthCalledWith(
12,
keepCoveragePoolTvl.format,
keepContext.usdConversion
)
expect(spyOnToUsdBalance).toHaveBeenNthCalledWith(
13,
keepStaking.format,
keepContext.usdConversion
)
expect(spyOnToUsdBalance).toHaveBeenNthCalledWith(
14,
12,
tStaking.format,
tContext.usdConversion
)
Expand Down
Loading

0 comments on commit 45c336c

Please sign in to comment.