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

Check bonded ETH for operators #48

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

Check bonded ETH for operators #48

wants to merge 2 commits into from

Conversation

nkuba
Copy link
Member

@nkuba nkuba commented Sep 23, 2020

We are getting bond creation events to obtain values of bonds created for all the ECDSA operators.

@nkuba nkuba requested a review from pdyraga September 23, 2020 09:40
inspector/scripts/inspect-operators.js Outdated Show resolved Hide resolved
inspector/scripts/inspect-operators.js Outdated Show resolved Hide resolved
We are getting bond creation events to obtain values of bonds created
for all the ECDSA operators.
We need to respect bonds release and seizure in calculating currently
bonded value. What's more we need to respect the fact that value can be
deposited as a return from tBTC after seizing the whole bond and keeping
there just some part of it.
@nkuba nkuba requested a review from pdyraga September 23, 2020 15:49
@pdyraga
Copy link
Member

pdyraga commented Oct 2, 2020

I was testing this script locally with four operators:

  • 0x3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416
  • 0x7020a5556ba1ce5f92c81063a13d33512cf1305c
  • 0x524f2e0176350d950fa630d9a5a59a0a190daf48
  • 0x65ea55c1f10491038425725dc00dffeab2a1e28a

Scenario 1 ✅

  • Open keep.
  • Close keep.

Initial state:

┌─────────┬──────────────────────────────────────────────┬───────────────────┬──────────────────────────────────────────────────┬────────────────────┬────────────────────┬──────────────────┬────────────────┬─────────────────┬────────────────────────┬──────────────────────┐
│ (index) │                   address                    │ eligibleStakeKeep │                operatorBalanceEth                │ depositedAmountEth │ withdrawnAmountEth │ unbondedValueEth │ bondsAmountEth │ seizedAmountEth │ isRegisteredInTbtcPool │ isUpToDateInTbtcPool │
├─────────┼──────────────────────────────────────────────┼───────────────────┼──────────────────────────────────────────────────┼────────────────────┼────────────────────┼──────────────────┼────────────────┼─────────────────┼────────────────────────┼──────────────────────┤
│    0    │ '0x3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416' │    '20000000'     │ '999999999999999999999999999999999999.996875216' │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
│    1    │ '0x7020a5556ba1ce5f92c81063a13d33512cf1305c' │    '20000000'     │ '999999999999999999999999999999999999.996874897' │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
│    2    │ '0x524f2e0176350d950fa630d9a5a59a0a190daf48' │    '20000000'     │ '999999999999999999999999999999999999.996875535' │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
│    3    │ '0x65ea55c1f10491038425725dc00dffeab2a1e28a' │    '20000000'     │ '999999999999999999999999999999999999.883456701' │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
└─────────┴──────────────────────────────────────────────┴───────────────────┴──────────────────────────────────────────────────┴────────────────────┴────────────────────┴──────────────────┴────────────────┴─────────────────┴────────────────────────┴──────────────────────┘

Created keep 0x43293fFe178B64A7342a0346F9D57974DB22d3EC with members:

  • 524f2e0176350d950fa630d9a5a59a0a190daf48,
  • 0x7020A5556Ba1ce5f92c81063a13d33512cf1305c,
  • 0x65EA55c1f10491038425725dC00dFFEAb2A1e28A.

Intermediate state:

┌─────────┬──────────────────────────────────────────────┬───────────────────┬───────────────────────────────────────────────────────────┬────────────────────┬────────────────────┬─────────────────────────┬────────────────────────┬─────────────────┬────────────────────────┬──────────────────────┐
│ (index) │                   address                    │ eligibleStakeKeep │                    operatorBalanceEth                     │ depositedAmountEth │ withdrawnAmountEth │    unbondedValueEth     │     bondsAmountEth     │ seizedAmountEth │ isRegisteredInTbtcPool │ isUpToDateInTbtcPool │
├─────────┼──────────────────────────────────────────────┼───────────────────┼───────────────────────────────────────────────────────────┼────────────────────┼────────────────────┼─────────────────────────┼────────────────────────┼─────────────────┼────────────────────────┼──────────────────────┤
│    0    │ '0x3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416' │    '20000000'     │     '999999999999999999999999999999999999.996875216'      │        '50'        │        '0'         │          '50'           │          '0'           │       '0'       │          true          │         true         │
│    1    │ '0x7020a5556ba1ce5f92c81063a13d33512cf1305c' │    '20000000'     │     '999999999999999999999999999999999999.996733331'      │        '50'        │        '0'         │ '49.999999999999999996' │ '0.000000000000000004' │       '0'       │          true          │         true         │
│    2    │ '0x524f2e0176350d950fa630d9a5a59a0a190daf48' │    '20000000'     │     '999999999999999999999999999999999999.996703122'      │        '50'        │        '0'         │ '49.999999999999999996' │ '0.000000000000000004' │       '0'       │          true          │         true         │
│    3    │ '0x65ea55c1f10491038425725dc00dffeab2a1e28a' │    '20000000'     │ '999999999999999999999999999999999999.899962083444444444' │        '50'        │        '0'         │ '49.999999999999999996' │ '0.000000000000000004' │       '0'       │          true          │         true         │
└─────────┴──────────────────────────────────────────────┴───────────────────┴───────────────────────────────────────────────────────────┴────────────────────┴────────────────────┴─────────────────────────┴────────────────────────┴─────────────────┴────────────────────────┴──────────────────────┘

Closed keep 0x43293fFe178B64A7342a0346F9D57974DB22d3EC.

End state:

┌─────────┬──────────────────────────────────────────────┬───────────────────┬───────────────────────────────────────────────────────────┬────────────────────┬────────────────────┬──────────────────┬────────────────┬─────────────────┬────────────────────────┬──────────────────────┐
│ (index) │                   address                    │ eligibleStakeKeep │                    operatorBalanceEth                     │ depositedAmountEth │ withdrawnAmountEth │ unbondedValueEth │ bondsAmountEth │ seizedAmountEth │ isRegisteredInTbtcPool │ isUpToDateInTbtcPool │
├─────────┼──────────────────────────────────────────────┼───────────────────┼───────────────────────────────────────────────────────────┼────────────────────┼────────────────────┼──────────────────┼────────────────┼─────────────────┼────────────────────────┼──────────────────────┤
│    0    │ '0x3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416' │    '20000000'     │     '999999999999999999999999999999999999.996875216'      │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
│    1    │ '0x7020a5556ba1ce5f92c81063a13d33512cf1305c' │    '20000000'     │     '999999999999999999999999999999999999.996733331'      │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
│    2    │ '0x524f2e0176350d950fa630d9a5a59a0a190daf48' │    '20000000'     │     '999999999999999999999999999999999999.996703122'      │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
│    3    │ '0x65ea55c1f10491038425725dc00dffeab2a1e28a' │    '20000000'     │ '999999999999999999999999999999999999.899962083444444444' │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
└─────────┴──────────────────────────────────────────────┴───────────────────┴───────────────────────────────────────────────────────────┴────────────────────┴────────────────────┴──────────────────┴────────────────┴─────────────────┴────────────────────────┴──────────────────────┘

Scenario 2 ❌

  • Create multiple keeps.
  • Seize bonds from one of them.

Initial state:

┌─────────┬──────────────────────────────────────────────┬───────────────────┬───────────────────────────────────────────────────────────┬────────────────────┬────────────────────┬──────────────────┬────────────────┬─────────────────┬────────────────────────┬──────────────────────┐
│ (index) │                   address                    │ eligibleStakeKeep │                    operatorBalanceEth                     │ depositedAmountEth │ withdrawnAmountEth │ unbondedValueEth │ bondsAmountEth │ seizedAmountEth │ isRegisteredInTbtcPool │ isUpToDateInTbtcPool │
├─────────┼──────────────────────────────────────────────┼───────────────────┼───────────────────────────────────────────────────────────┼────────────────────┼────────────────────┼──────────────────┼────────────────┼─────────────────┼────────────────────────┼──────────────────────┤
│    0    │ '0x3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416' │    '20000000'     │     '999999999999999999999999999999999999.996875216'      │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
│    1    │ '0x7020a5556ba1ce5f92c81063a13d33512cf1305c' │    '20000000'     │     '999999999999999999999999999999999999.996733331'      │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
│    2    │ '0x524f2e0176350d950fa630d9a5a59a0a190daf48' │    '20000000'     │     '999999999999999999999999999999999999.996703122'      │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
│    3    │ '0x65ea55c1f10491038425725dc00dffeab2a1e28a' │    '20000000'     │ '999999999999999999999999999999999999.899962083444444444' │        '50'        │        '0'         │       '50'       │      '0'       │       '0'       │          true          │         true         │
└─────────┴──────────────────────────────────────────────┴───────────────────┴───────────────────────────────────────────────────────────┴────────────────────┴────────────────────┴──────────────────┴────────────────┴─────────────────┴────────────────────────┴──────────────────────┘

Created keep 0x6a613E21cc3Ea0D14eCa39Ac3131531F3296fDdc with members:

  • 3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416,
  • 524f2e0176350d950fa630d9a5a59a0a190daf48 ,
  • 65ea55c1f10491038425725dc00dffeab2a1e28a.

Created keep 0xddE46d893748662CE6102944f6cdA9517D0092D7 with members:

  • 7020a5556ba1ce5f92c81063a13d33512cf1305c,
  • 524f2e0176350d950fa630d9a5a59a0a190daf48,
  • 3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416.

Created keep 0xcD1C4B4e17D0Ae5fCCc9150cfe23B67cb33364Fb with members:

  • 3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416,
  • 65ea55c1f10491038425725dc00dffeab2a1e28a ,
  • 7020a5556ba1ce5f92c81063a13d33512cf1305c.

Intermediate state:

┌─────────┬──────────────────────────────────────────────┬───────────────────┬───────────────────────────────────────────────────────────┬────────────────────┬────────────────────┬─────────────────────────┬────────────────────────┬─────────────────┬────────────────────────┬──────────────────────┐
│ (index) │                   address                    │ eligibleStakeKeep │                    operatorBalanceEth                     │ depositedAmountEth │ withdrawnAmountEth │    unbondedValueEth     │     bondsAmountEth     │ seizedAmountEth │ isRegisteredInTbtcPool │ isUpToDateInTbtcPool │
├─────────┼──────────────────────────────────────────────┼───────────────────┼───────────────────────────────────────────────────────────┼────────────────────┼────────────────────┼─────────────────────────┼────────────────────────┼─────────────────┼────────────────────────┼──────────────────────┤
│    0    │ '0x3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416' │    '20000000'     │     '999999999999999999999999999999999999.996450858'      │        '50'        │        '0'         │ '49.999999999999999988' │ '0.000000000000000012' │       '0'       │          true          │         true         │
│    1    │ '0x7020a5556ba1ce5f92c81063a13d33512cf1305c' │    '20000000'     │     '999999999999999999999999999999999999.996454601'      │        '50'        │        '0'         │ '49.999999999999999992' │ '0.000000000000000008' │       '0'       │          true          │         true         │
│    2    │ '0x524f2e0176350d950fa630d9a5a59a0a190daf48' │    '20000000'     │     '999999999999999999999999999999999999.996358004'      │        '50'        │        '0'         │ '49.999999999999999992' │ '0.000000000000000008' │       '0'       │          true          │         true         │
│    3    │ '0x65ea55c1f10491038425725dc00dffeab2a1e28a' │    '20000000'     │ '999999999999999999999999999999999999.949629693777777776' │        '50'        │        '0'         │ '49.999999999999999992' │ '0.000000000000000008' │       '0'       │          true          │         true         │
└─────────┴──────────────────────────────────────────────┴───────────────────┴───────────────────────────────────────────────────────────┴────────────────────┴────────────────────┴─────────────────────────┴────────────────────────┴─────────────────┴────────────────────────┴──────────────────────┘

Seized bonds from keep 0xcD1C4B4e17D0Ae5fCCc9150cfe23B67cb33364Fb.

End state:

┌─────────┬──────────────────────────────────────────────┬───────────────────┬───────────────────────────────────────────────────────────┬────────────────────┬────────────────────┬─────────────────────────┬────────────────────────┬─────────────────┬────────────────────────┬──────────────────────┐
│ (index) │                   address                    │ eligibleStakeKeep │                    operatorBalanceEth                     │ depositedAmountEth │ withdrawnAmountEth │    unbondedValueEth     │     bondsAmountEth     │ seizedAmountEth │ isRegisteredInTbtcPool │ isUpToDateInTbtcPool │
├─────────┼──────────────────────────────────────────────┼───────────────────┼───────────────────────────────────────────────────────────┼────────────────────┼────────────────────┼─────────────────────────┼────────────────────────┼─────────────────┼────────────────────────┼──────────────────────┤
│    0    │ '0x3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416' │    '20000000'     │     '999999999999999999999999999999999999.996450858'      │        '50'        │        '0'         │ '49.999999999999999988' │ '0.000000000000000008' │       '0'       │          true          │         true         │
│    1    │ '0x7020a5556ba1ce5f92c81063a13d33512cf1305c' │    '20000000'     │     '999999999999999999999999999999999999.996454601'      │        '50'        │        '0'         │ '49.999999999999999992' │ '0.000000000000000004' │       '0'       │          true          │         true         │
│    2    │ '0x524f2e0176350d950fa630d9a5a59a0a190daf48' │    '20000000'     │     '999999999999999999999999999999999999.996358004'      │        '50'        │        '0'         │ '49.999999999999999992' │ '0.000000000000000008' │       '0'       │          true          │         true         │
│    3    │ '0x65ea55c1f10491038425725dc00dffeab2a1e28a' │    '20000000'     │ '999999999999999999999999999999999999.949629693777777776' │        '50'        │        '0'         │ '49.999999999999999992' │ '0.000000000000000004' │       '0'       │          true          │         true         │
└─────────┴──────────────────────────────────────────────┴───────────────────┴───────────────────────────────────────────────────────────┴────────────────────┴────────────────────┴─────────────────────────┴────────────────────────┴─────────────────┴────────────────────────┴──────────────────────┘

Problem: Please see that seizedAmountEth shows 0. I thought it's a precision issue and removed all fromWei calls for seized bonds but it still shows 0.

Scenario 3 ❌

  • Return seized bonds.

Initial state:

┌─────────┬──────────────────────────────────────────────┬───────────────────┬───────────────────────────────────────────────────────────┬────────────────────┬────────────────────┬─────────────────────────┬────────────────────────┬─────────────────┬────────────────────────┬──────────────────────┐
│ (index) │                   address                    │ eligibleStakeKeep │                    operatorBalanceEth                     │ depositedAmountEth │ withdrawnAmountEth │    unbondedValueEth     │     bondsAmountEth     │ seizedAmountEth │ isRegisteredInTbtcPool │ isUpToDateInTbtcPool │
├─────────┼──────────────────────────────────────────────┼───────────────────┼───────────────────────────────────────────────────────────┼────────────────────┼────────────────────┼─────────────────────────┼────────────────────────┼─────────────────┼────────────────────────┼──────────────────────┤
│    0    │ '0x3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416' │    '20000000'     │     '999999999999999999999999999999999999.996450858'      │        '50'        │        '0'         │ '49.999999999999999988' │ '0.000000000000000008' │       '0'       │          true          │         true         │
│    1    │ '0x7020a5556ba1ce5f92c81063a13d33512cf1305c' │    '20000000'     │     '999999999999999999999999999999999999.996454601'      │        '50'        │        '0'         │ '49.999999999999999992' │ '0.000000000000000004' │       '0'       │          true          │         true         │
│    2    │ '0x524f2e0176350d950fa630d9a5a59a0a190daf48' │    '20000000'     │     '999999999999999999999999999999999999.996358004'      │        '50'        │        '0'         │ '49.999999999999999992' │ '0.000000000000000008' │       '0'       │          true          │         true         │
│    3    │ '0x65ea55c1f10491038425725dc00dffeab2a1e28a' │    '20000000'     │ '999999999999999999999999999999999999.949629693777777776' │        '50'        │        '0'         │ '49.999999999999999992' │ '0.000000000000000004' │       '0'       │          true          │         true         │
└─────────┴──────────────────────────────────────────────┴───────────────────┴───────────────────────────────────────────────────────────┴────────────────────┴────────────────────┴─────────────────────────┴────────────────────────┴─────────────────┴────────────────────────┴──────────────────────┘

Note that seizedAmountEth value is not accurate - see the previous scenario.

Returned 12 wei to keep 0xcD1C4B4e17D0Ae5fCCc9150cfe23B67cb33364Fb.

End state:

┌─────────┬──────────────────────────────────────────────┬───────────────────┬───────────────────────────────────────────────────────────┬─────────────────────────┬────────────────────┬─────────────────────────┬────────────────────────┬─────────────────┬────────────────────────┬──────────────────────┐
│ (index) │                   address                    │ eligibleStakeKeep │                    operatorBalanceEth                     │   depositedAmountEth    │ withdrawnAmountEth │    unbondedValueEth     │     bondsAmountEth     │ seizedAmountEth │ isRegisteredInTbtcPool │ isUpToDateInTbtcPool │
├─────────┼──────────────────────────────────────────────┼───────────────────┼───────────────────────────────────────────────────────────┼─────────────────────────┼────────────────────┼─────────────────────────┼────────────────────────┼─────────────────┼────────────────────────┼──────────────────────┤
│    0    │ '0x3365d0ed0e526d3b1d8b417fc0fde5b1cef2f416' │    '20000000'     │     '999999999999999999999999999999999999.996450858'      │ '50.000000000000000004' │        '0'         │ '49.999999999999999992' │ '0.000000000000000008' │       '0'       │          true          │         true         │
│    1    │ '0x7020a5556ba1ce5f92c81063a13d33512cf1305c' │    '20000000'     │     '999999999999999999999999999999999999.996454601'      │ '50.000000000000000004' │        '0'         │ '49.999999999999999996' │ '0.000000000000000004' │       '0'       │          true          │         true         │
│    2    │ '0x524f2e0176350d950fa630d9a5a59a0a190daf48' │    '20000000'     │     '999999999999999999999999999999999999.996358004'      │          '50'           │        '0'         │ '49.999999999999999992' │ '0.000000000000000008' │       '0'       │          true          │         true         │
│    3    │ '0x65ea55c1f10491038425725dc00dffeab2a1e28a' │    '20000000'     │ '999999999999999999999999999999999999.949629693777777776' │ '50.000000000000000004' │        '0'         │ '49.999999999999999996' │ '0.000000000000000004' │       '0'       │          true          │         true         │
└─────────┴──────────────────────────────────────────────┴───────────────────┴───────────────────────────────────────────────────────────┴─────────────────────────┴────────────────────┴─────────────────────────┴────────────────────────┴─────────────────┴────────────────────────┴──────────────────────┘

Problem: Please see that the depositedAmountEth increased. It should never be higher than the initial 50 ETH.

@nkuba nkuba mentioned this pull request Oct 30, 2020
2 tasks
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.

2 participants