This repo creates a simple demo for DEX exclusive-access pools and better filters qualified users by combining off-chain and on-chain transaction data verification. This combination provides a more accurate representation of user transaction activities in a privacy-preserving way, giving applications more flexible filtering criteria. In the PancakeSwap case, a suitable exclusive-access condition could be if a user has a 30-day spot transaction volume exceeding $500 on a CEX platform and has made an on-chain transaction on the BNB Chain, making this user a target user for DEX.
In this demo, transaction proofs can be submitted from the PADO extension or utilized by PADO's MPC-TLS SDK to attest the user's on-chain and off-chain transactions. Throughout the entire process, the user’s privacy is fully protected. Whether the user meets the exclusive-access demands could be verified by this hook contract.
To be more technique-specific, for the on-chain transaction proof, Brevis' SDK is used in this demo to verify whether the user has had transactions on the BNB Chain since July 2024. For off-chain transaction proof, PADO's MPC-TLS and IZK techniques are used to verify whether the user’s 30-day spot transaction volume on CEX platforms, such as Binance or OKX, exceeds $500 or a specific amount, depending on the application’s requirements.
The Brevis integration repo: https://github.com/pado-labs/pado-brevis-onchain-transaction.
Install foundry, see https://book.getfoundry.sh/getting-started/installation.
Get the repo:
git clone --recursive https://github.com/pado-labs/pancake-transaction-oracle-hooks.git
cd pancake-transaction-oracle-hooks
forge install
forge build
The Transaction Oracle Hooks implements the beforeAddLiquidity
and beforeSwap
hooks.
- Copy
./.env.bsc-testnet
to./.env
, and set your private key (PRIVATE_KEY
). - The following parameters are already set:
- Pancake Swap (Vault, CLPoolManager, CLPositionManager, UniversalRouter).
- The arguments of Hook (EAS, EASProxy, SchemaBytes).
- Deploy Token
source .env
forge script script/DeployToken.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
output (sample):
TOKEN0=0x772F5b156EDaa4874F3f4F81c5e4479EE7E1669B
TOKEN1=0x7AA33Aa23aB75D37A9c27B0ba51bb10ed6e41a51
Add/replace the above address in .env
.
- Deploy Hook
source .env
forge script script/DeployHook.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
output (sample):
HOOK=0xd9Dd1FEaF845Dd036245A504317cCccE7Bc18f49
Add/replace the above address in .env
.
- Initialize Pool
source .env
forge script script/Test.s.sol:TestInitializeScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
This command only needs to be executed once.
- Transfer Token (Optional)
Request some tokens from the Token owner. (If necessary)
source .env
export RECEIVER=<the receiver address>
# export RECEIVER=0x...
forge script script/Transfer.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
- Token Approve
Before swap testing, need approve first.
source .env
forge script script/Approve.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
- Test AddLiquidity
source .env
forge script script/Test.s.sol:TestAddLiquidityScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
- Test Swap
source .env
forge script script/Test.s.sol:TestSwapScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast