Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NuCypher tvl #86

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

NuCypher tvl #86

wants to merge 3 commits into from

Conversation

r-czajkowski
Copy link
Collaborator

@r-czajkowski r-czajkowski commented Feb 9, 2022

Depends on: #85

This PR adds support for computing the NU TVL. Implemented based on the nucypher-monitor source code.

Note

This implementation works only on mainnet network. We need to figure out how to get the NuCypherStakingEscrow and NuCypherWorkLock contracts from package for mainnet, ropsten and local network. Would be great if we could have hardhat deployment scripts in https://github.com/nucypher/nucypher-contracts repo to deploy contracts locally and npm packages for mainnet and ropsten contracts. cc @cygnusv @Battenfield.

Run the dapp on mainnet

  1. Set correct packages versions in package.json:
"@keep-network/coverage-pools": "1.0.0",
"@keep-network/keep-core": "1.7.0",
"@keep-network/keep-ecdsa": "1.8.0",
"@keep-network/tbtc": "1.1.0",
"@threshold-network/solidity-contracts": "1.1.0",
  1. Update .env file:
REACT_APP_SUPPORTED_CHAIN_ID=1
REACT_APP_ETH_HOSTNAME_HTTP=https://mainnet.infura.io/v3/<your project ID here>
REACT_APP_ETH_HOSTNAME_WS=wss://mainnet.infura.io/ws/v3/<your project ID here>
REACT_APP_MULTICALL_ADDRESS=$MULTICALL_ADDRESS
  1. Run yarn
  2. Run yarn start

This only work on a mainnet. We need to figure out how to use these
contracts on ropsten and local network.
@github-actions
Copy link

github-actions bot commented Feb 9, 2022

{
contract: nu.contract!,
method: "balanceOf",
args: [nuStakingEscrow?.address],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify why we're tracking here the NU balance of staking escrow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I implemented based on the https://github.com/nucypher/nucypher-monitor/blob/main/monitor/dashboard.py#L146-L163. Any tips on how to calculate NU TVL correctly would be appreciated 🙂

const stakedNU = FixedNumber.fromString(nuInEscrow)
.subUnsafe(
FixedNumber.fromString(nuTotalSupply).subUnsafe(
FixedNumber.fromString(nuCurrenctPeriodSupply)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This equation seems a bit complex and I'm not sure if this yields a correct figure. Depending on what's the goal, i think there are other endpoints that are simpler as input.

Extract some hooks to separate files.
Make calculations more readable.
@r-czajkowski r-czajkowski marked this pull request as ready for review February 15, 2022 11:17
@github-actions
Copy link

Base automatically changed from tvl to main February 15, 2022 18:46
type: "function",
},
]
const ESCROW_ADDRESS = "0xbbD3C0C794F40c4f993B03F65343aCC6fcfCb2e2"
Copy link
Contributor

@georgeweiler georgeweiler Feb 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about placing this in our .env? might be better so that we can just add ropsten & local address when they become available? Our env has the supported chainId, so we can be sure to use the correct one based on the env.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a nice idea 👍 , but hopefully, we can get artifacts for mainnet/ropsten/local network from the package like we do for other contracts. So let's hold for a while and we will see if we can get a separate package for ropsten network.


// TODO: Get contract abi from the package and figure out how to use these
// contracts on ropsten and local network. This only works on mainnet.
const WORK_LOCK_ADDRESS = "0xe9778E69a961e64d3cdBB34CF6778281d34667c2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@cygnusv
Copy link
Member

cygnusv commented Feb 15, 2022

Would be great if we could have hardhat deployment scripts in https://github.com/nucypher/nucypher-contracts repo to deploy contracts locally and npm packages for mainnet and ropsten contracts.

We recently published an NPM package for this. Check out https://www.npmjs.com/package/@nucypher/nucypher-contracts, the artifacts directory contains the addresses and ABIs of some NU contracts. Let me know if you need something else there (perhaps WorkLock?)

@r-czajkowski
Copy link
Collaborator Author

r-czajkowski commented Feb 16, 2022

Would be great if we could have hardhat deployment scripts in https://github.com/nucypher/nucypher-contracts repo to deploy contracts locally and npm packages for mainnet and ropsten contracts.

We recently published an NPM package for this. Check out https://www.npmjs.com/package/@nucypher/nucypher-contracts, the artifacts directory contains the addresses and ABIs of some NU contracts. Let me know if you need something else there (perhaps WorkLock?)

Nice thanks! As I can see it only contains the mainnet addresses. Could we have a separate npm package for Ropsten? Something like we have in threshold contracts pacakge? https://www.npmjs.com/package/@threshold-network/solidity-contracts/v/1.1.0-ropsten.0. It will help and simplify the T dapp deployment process on Ropsten network.

Would be great if we could add WorkLock artifact to the package 🙂.

@cygnusv
Copy link
Member

cygnusv commented Feb 16, 2022

Would be great if we could have hardhat deployment scripts in https://github.com/nucypher/nucypher-contracts repo to deploy contracts locally and npm packages for mainnet and ropsten contracts.

We recently published an NPM package for this. Check out https://www.npmjs.com/package/@nucypher/nucypher-contracts, the artifacts directory contains the addresses and ABIs of some NU contracts. Let me know if you need something else there (perhaps WorkLock?)

Nice thanks! As I can see it only contains the mainnet addresses. Could we have a separate npm package for Ropsten? Something like we have in threshold contracts pacakge? https://www.npmjs.com/package/@threshold-network/solidity-contracts/v/1.1.0-ropsten.0. It will help and simplify the T dapp deployment process on Ropsten network.

Would be great if we could add WorkLock artifact to the package 🙂.

I'm afraid we don't have a Ropsten deployment of NuCypher contracts. At some point I deployed just the token to facilitate integration of the Vending Machines, but we can't redeploy the whole set of contracts. I think for Ropsten you'd have to mock it somehow.

For mainnet, yes, we can add the WorkLock artifact to the package.

@pdyraga
Copy link
Member

pdyraga commented Feb 16, 2022

I'm afraid we don't have a Ropsten deployment of NuCypher contracts. At some point I deployed just the token to facilitate integration of the Vending Machines, but we can't redeploy the whole set of contracts. I think for Ropsten you'd have to mock it somehow.

Why can't we have them redeployed? It's just for Ropsten and they would exist under new -ropsten version, example here: https://www.npmjs.com/package/@threshold-network/solidity-contracts/v/1.1.0-ropsten.0
Alternatively, deploy just WorkLock and whatever is needed and append the new artifacts to the existing package.

@r-czajkowski
Copy link
Collaborator Author

^ @cygnusv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants