Skip to content

Replace TX#101

Open
hashmesan wants to merge 17 commits intoharmony-one:mainfrom
hashmesan:replacetx
Open

Replace TX#101
hashmesan wants to merge 17 commits intoharmony-one:mainfrom
hashmesan:replacetx

Conversation

@hashmesan
Copy link

WIP

hashmesan and others added 11 commits April 25, 2022 13:50
* Implicitly setting btcAmount below eligible amount makes difficult to calculate griefing amount and making the code significant more complex than necessary.
* Test case_requestReplace  passed
    ✓ Register OLD Vault with 10 Wei Collateral (94ms)
    ✓ Issue 0.5 OneBtc (836ms)
    ✓ Request Replace (116ms)
    ✓ Register NEW Vault with 10 Wei Collateral (78ms)
    ✓ Accept Replace (602ms)
    ✓ Execute Replace (95ms)
* ensure we request above dust amount (non-zero)
@hashmesan hashmesan requested a review from gupadhyaya April 29, 2022 18:04
@hashmesan
Copy link
Author

The vault state didn't look right to me after replace. So will add more tests & fix around it.

hashmesan added 3 commits May 31, 2022 09:29
* Decrease toBeRedeem on old vault on execute
* Decrease CollateralUsed oldVault after replace
* validate collateral sent amount
* increase CollateralUsed on newvault
* reduce TobeIssued after replace
* test remove collateral from old vault
* fixed tests, all passed
@hashmesan
Copy link
Author

Example test case

OLD VAULT: 0x9e4a4E1b9Cdd82c13D08a1E817Ef03f6ba31908b
NEW VAULT: 0x3fd84Bad7c88fe7fbE8d4FEd83a9B98eA5f64a8c

State of OLD VAULT (After Issued and RequestReplace)

State of Old vault after deposited 10 ONE collateral, and issued 0.5 BTC (at 1BTC to 10 ONE)
Collateral Calculation: 1.5 x (0.5 => 5 ONE ) = 7.5 ONE locked in collateral
Note: toBeRedeemed is locked by requestReplace

VaultInfo - 0x9e4a4E1b9Cdd82c13D08a1E817Ef03f6ba31908b
Collateral:  10250000000000000000  used= 7500000000000000000
btcPublicKeyX 115627532150381078150238923940297736944640480938279448097681593514424726129306
btcPublicKeyY 38282156113085318516037415530225323604487932303539007602535010876781461995286
collateral 10000000000000000000
issued 50000000
toBeIssued 0
toBeRedeemed 50000000
replaceCollateral 0
toBeReplaced 0
liquidatedCollateral 0

NEW VAULT (After executeReplace)

Collateral properly reflect:

  • The same collateral used transferred over,
  • Issued moved over
VaultInfo - 0x3fd84Bad7c88fe7fbE8d4FEd83a9B98eA5f64a8c
Collateral:  10000000000000000000  used= 7500000000000000000
btcPublicKeyX 104380179028042131067328111941147416065075608758077525076993017903970766482442
btcPublicKeyY 45429352427552440395877047812838796691107221912173079979901584569530669004902
collateral 10000000000000000000
issued 50000000
toBeIssued 0
toBeRedeemed 0
replaceCollateral 0
toBeReplaced 0
liquidatedCollateral 0

OLD VAULT (After Execute)

VaultInfo - 0x9e4a4E1b9Cdd82c13D08a1E817Ef03f6ba31908b
Collateral:  10000000000000000000  used= 0
btcPublicKeyX 115627532150381078150238923940297736944640480938279448097681593514424726129306
btcPublicKeyY 38282156113085318516037415530225323604487932303539007602535010876781461995286
collateral 10000000000000000000
issued 0
toBeIssued 0
toBeRedeemed 0
replaceCollateral 0
toBeReplaced 0
liquidatedCollateral 0

OLD VAULT (After WithdrawCollateral)

Vault owner withdraws all of 10 ONE Collateral.

VaultInfo - 0x9e4a4E1b9Cdd82c13D08a1E817Ef03f6ba31908b
Collateral:  0  used= 0
btcPublicKeyX 115627532150381078150238923940297736944640480938279448097681593514424726129306
btcPublicKeyY 38282156113085318516037415530225323604487932303539007602535010876781461995286
collateral 0
issued 0
toBeIssued 0
toBeRedeemed 0
replaceCollateral 0
toBeReplaced 0
liquidatedCollateral 0

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.

1 participant