Skip to content

Commit

Permalink
Feature/forced exit (#98)
Browse files Browse the repository at this point in the history
* Forced exit stubs

* Added `forced-exit` CLI command

* Forced exit flow changes

* Fix

* Fixes

* Displaying committed forced exit

* Forced exit flow

* Alerts and description for forced exit

* Forced exit flow improvements

* Minor fixes

* Cosmetic

* Getting executed forced exit data

* Removing Canceled state for FE, updating versions

* Updating client library

* Updating pool config files

* Set new client library version (5.4.0)
  • Loading branch information
EvgenKor authored Nov 10, 2023
1 parent 3a27339 commit 25864ce
Show file tree
Hide file tree
Showing 7 changed files with 881 additions and 556 deletions.
86 changes: 79 additions & 7 deletions client-config-full.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"defaultPool": "BOB-sepolia",
"defaultPool": "BOB2USDC-goerli",

"pools": {
"USDC-polygon": {
Expand Down Expand Up @@ -95,6 +95,39 @@
"feeDecimals": 2,
"depositScheme": "permit",
"ddSubgraph": "zkbob-bob-goerli-opt"
},
"USDT-shasta": {
"chainId": 2494104990,
"poolAddress": "TLTyi81NhoeGfsq8Ef1STDYs6E7HFSAruV",
"tokenAddress": "TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs",
"relayerUrls": ["https://shasta-relayer.thgkjlr.website"],
"delegatedProverUrls": [],
"coldStorageConfigPath": "",
"feeDecimals": 2,
"minTxAmount": 50000,
"depositScheme": "approve"
},
"USDT-devnet": {
"chainId": 728126428,
"poolAddress": "TVtGa6o4KWYa6pfcd6A34xQte1FuDJPFah",
"tokenAddress": "TRdunaTZCKYM9xW3HGJjJLQYV6f89UHEkD",
"relayerUrls": ["https://tron-devnet-relayer.thgkjlr.website"],
"delegatedProverUrls": [],
"coldStorageConfigPath": "",
"feeDecimals": 2,
"minTxAmount": 50000,
"depositScheme": "approve"
},
"USDT-nile": {
"chainId": 3448148188,
"poolAddress": "TT8GgygLhEDh88kYwY8mYz38iEpJWw1YLG",
"tokenAddress": "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf",
"relayerUrls": ["https://tron-nile-relayer.thgkjlr.website"],
"delegatedProverUrls": [],
"coldStorageConfigPath": "",
"feeDecimals": 2,
"minTxAmount": 50000,
"depositScheme": "approve"
}
},

Expand All @@ -113,6 +146,15 @@
},
"420": {
"rpcUrls": ["https://goerli.optimism.io"]
},
"2494104990": {
"rpcUrls": ["https://api.shasta.trongrid.io"]
},
"728126428": {
"rpcUrls": ["https://tron-devnet.zkbob.com"]
},
"3448148188": {
"rpcUrls": ["https://nile.trongrid.io"]
}
},

Expand Down Expand Up @@ -148,18 +190,33 @@
"420": {
"tx": "https://goerli-optimism.etherscan.io/tx/{{hash}}",
"address": "https://goerli-optimism.etherscan.io/address/{{addr}}"
},
"2494104990": {
"tx": "https://shasta.tronscan.org/#/transaction/{{hash}}",
"address": "https://shasta.tronscan.org/#/address/{{addr}}"
},
"728126428": {
"tx": "{{hash}}",
"address": "{{addr}}"
},
"3448148188": {
"tx": "https://nile.tronscan.org/#/transaction/{{hash}}",
"address": "https://nile.tronscan.org/#/address/{{addr}}"
}
},

"minters": {
"USDC-polygon": "",
"BOB-optimism": "",
"WETH-optimism": "",
"BOB-sepolia": "",
"BOB2USDC-goerli": "",
"BOB-sepolia": "0xb9988D599A64723462955BfC8441F1Af90335796",
"BOB2USDC-goerli": "0x56c105D40f637eF3ac04905682b3DAEfF3F13D24",
"WETH-goerli": "",
"USDC-goerli": "",
"BOB-op-goerli": ""
"USDC-goerli": "0x56c105D40f637eF3ac04905682b3DAEfF3F13D24",
"BOB-op-goerli": "0x357cA353dbCad28418d5F3110727B2af62803F20",
"USDT-shasta": "",
"USDT-devnet": "TRdunaTZCKYM9xW3HGJjJLQYV6f89UHEkD",
"USDT-nile": ""
},

"cloudApi": {
Expand All @@ -170,7 +227,10 @@
"BOB2USDC-goerli": "",
"WETH-goerli": "",
"USDC-goerli": "",
"BOB-op-goerli": ""
"BOB-op-goerli": "",
"USDT-shasta": "",
"USDT-devnet": "",
"USDT-nile": ""
},

"redemptionUrls": {
Expand All @@ -181,7 +241,10 @@
"BOB2USDC-goerli": "https://staging--zkbob.netlify.app",
"WETH-goerli": "https://staging--zkbob.netlify.app",
"USDC-goerli": "https://staging--zkbob.netlify.app",
"BOB-op-goerli": "https://staging--zkbob.netlify.app"
"BOB-op-goerli": "https://staging--zkbob.netlify.app",
"USDT-shasta": "https://staging--zkbob.netlify.app",
"USDT-devnet": "https://staging--zkbob.netlify.app",
"USDT-nile": "https://staging--zkbob.netlify.app"
},

"migrations": {
Expand All @@ -193,6 +256,15 @@
"lastTimestamp": 1688651376
}
}
},
"USDC-polygon": {
"oldTokens": {
"BOB": {
"tokenAddress": "0xb0b195aefa3650a6908f15cdac7d92f8a5791b0b",
"firstTimestamp": 0,
"lastTimestamp": 1689689468
}
}
}
}
}
29 changes: 25 additions & 4 deletions client-config-stage.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"defaultPool": "USDT-devnet",
"defaultPool": "BOB2USDC-goerli",

"pools": {
"BOB-sepolia": {
Expand Down Expand Up @@ -80,6 +80,17 @@
"feeDecimals": 2,
"minTxAmount": 50000,
"depositScheme": "approve"
},
"USDT-nile": {
"chainId": 3448148188,
"poolAddress": "TT8GgygLhEDh88kYwY8mYz38iEpJWw1YLG",
"tokenAddress": "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf",
"relayerUrls": ["https://tron-nile-relayer.thgkjlr.website"],
"delegatedProverUrls": [],
"coldStorageConfigPath": "",
"feeDecimals": 2,
"minTxAmount": 50000,
"depositScheme": "approve"
}
},

Expand All @@ -98,6 +109,9 @@
},
"728126428": {
"rpcUrls": ["https://tron-devnet.zkbob.com"]
},
"3448148188": {
"rpcUrls": ["https://nile.trongrid.io"]
}
},

Expand All @@ -121,6 +135,10 @@
"728126428": {
"tx": "{{hash}}",
"address": "{{addr}}"
},
"3448148188": {
"tx": "https://nile.tronscan.org/#/transaction/{{hash}}",
"address": "https://nile.tronscan.org/#/address/{{addr}}"
}
},

Expand All @@ -136,7 +154,8 @@
"USDC-goerli": "0x56c105D40f637eF3ac04905682b3DAEfF3F13D24",
"BOB-op-goerli": "0x357cA353dbCad28418d5F3110727B2af62803F20",
"USDT-shasta": "",
"USDT-devnet": "TRdunaTZCKYM9xW3HGJjJLQYV6f89UHEkD"
"USDT-devnet": "TRdunaTZCKYM9xW3HGJjJLQYV6f89UHEkD",
"USDT-nile": ""
},

"cloudApi": {
Expand All @@ -146,7 +165,8 @@
"USDC-goerli": "",
"BOB-op-goerli": "",
"USDT-shasta": "",
"USDT-devnet": ""
"USDT-devnet": "",
"USDT-nile": ""
},

"redemptionUrls": {
Expand All @@ -156,7 +176,8 @@
"USDC-goerli": "https://staging--zkbob.netlify.app",
"BOB-op-goerli": "https://staging--zkbob.netlify.app",
"USDT-shasta": "https://staging--zkbob.netlify.app",
"USDT-devnet": "https://staging--zkbob.netlify.app"
"USDT-devnet": "https://staging--zkbob.netlify.app",
"USDT-nile": "https://staging--zkbob.netlify.app"
},

"migrations": {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zkbob-console",
"version": "3.7.0-beta9",
"version": "3.8.0",
"license": "MIT",
"author": "Dmitry Vdovin <[email protected]>",
"homepage": "https://github.com/zkBob/zkbob-console",
Expand Down Expand Up @@ -39,8 +39,8 @@
"tslib": "^2.3.1",
"uuid": "^9.0.0",
"web3": "^1.7.1",
"zkbob-support-js": "1.0.1-beta2",
"zkbob-client-js": "5.3.0"
"zkbob-client-js": "5.4.0",
"zkbob-support-js": "1.0.1"
},
"devDependencies": {
"@parcel/compressor-gzip": "^2.0.1",
Expand Down
45 changes: 44 additions & 1 deletion src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AccountConfig, ClientConfig, ProverMode,
PoolLimits, TreeState, EphemeralAddress, SyncStat, TreeNode,
ServiceVersion, accountId, DepositType, SignatureType,
deriveSpendingKeyZkBob, GiftCardProperties,
ClientStateCallback, DirectDeposit
ClientStateCallback, DirectDeposit, ForcedExitState, CommittedForcedExit, FinalizedForcedExit
} from 'zkbob-client-js';
import bip39 from 'bip39-light';
import HDWalletProvider from '@truffle/hdwallet-provider';
Expand Down Expand Up @@ -750,6 +750,49 @@ export class Account {
}
}

public async isForcedExitSupported(): Promise<boolean> {
return this.getZpClient().isForcedExitSupported();
}

public async forcedExitState(): Promise<ForcedExitState> {
return this.getZpClient().forcedExitState();
}

public async availableFundsToForcedExit(): Promise<bigint> {
return this.getZpClient().availableFundsToForcedExit();
}

public async initiateForcedExit(address?: string): Promise<CommittedForcedExit> {
const myAddress = await this.getClient().getAddress();
return this.getZpClient().requestForcedExit(
myAddress, // operator
address ?? myAddress, // to
async (tx: PreparedTransaction) =>
this.getClient().sendTransaction(tx.to, tx.amount, tx.data, tx.selector)
);
}

public async activeForcedExit(): Promise<CommittedForcedExit | undefined> {
return this.getZpClient().activeForcedExit()
}

public async executeForcedExit(): Promise<FinalizedForcedExit> {
return this.getZpClient().executeForcedExit(async (tx: PreparedTransaction) =>
this.getClient().sendTransaction(tx.to, tx.amount, tx.data, tx.selector)
);
}

public async executedForcedExit(): Promise<FinalizedForcedExit | undefined> {
return this.getZpClient().executedForcedExit()
}

public async cancelForcedExit(): Promise<FinalizedForcedExit> {
return this.getZpClient().cancelForcedExit(async (tx: PreparedTransaction) =>
this.getClient().sendTransaction(tx.to, tx.amount, tx.data, tx.selector)
);
}


public async giftCardBalance(giftCard: GiftCardProperties): Promise<bigint> {
return await this.getZpClient().giftCardBalance(giftCard);
}
Expand Down
Loading

0 comments on commit 25864ce

Please sign in to comment.