Unwind Tokens (without dApp)
How to Withdraw Collateral Assets early using an atomic EIP-5792 capable wallet
Withdraw collateral assets from a Cork Pool before its expiry, by performing a redemption of both Cork Principal Token and Cork Swap Token, without using our dApp.
This operation, called an "Unwind Mint":
returns and burns shares (i.e. reduces circulating supply of cPT & cST tokens)
withdraws Collateral Asset
How to Redeem Shares via an Escrowed Unwind-Mint
Prerequisites:
An atomic EIP-5792 capable wallet such as SAFE Wallet by safe.global (previously Gnosis SAFE)
Completed a due diligence audit of the
safeUnwindMintfunction onLine 216of the escrow manager contract (CorkAdapter) at its live deployment address via either:Github: Link
The Cork Pool's market id (bytes32).
A balance of Cork Principal Token (cPT) and Cork Swap Token (cST) that pertains to this Cork Pool.
Step 1: Open your Wallet's Transaction Builder
Open the SAFE Wallet's Transaction Builder using this link: https://app.safe.global/share/safe-app?appUrl=https%3A%2F%2Fapps-portal.safe.global%2Ftx-builder
Step 2: Add Transaction #1 – Allow spending of Principal Tokens by Escrow Manager Contract
Add the 1st transaction to allow the trust-minimized escrow manager contract (CorkAdapter) to spend your Cork Principal Tokens:
Enter Address:
eth:<ERC20 token address of Cork Principal Token>Enter ABI: Copy from here
To Address:
<ERC20 token address of Cork Principal Token>Contract Method Selector:
approvespender (escrow contract):
0xCCcCcCCCcccCBaD6F772a511B337d9CCc9570407amount (of cPT): <wei amount of principal tokens to redeem>
By following these instructions:
Enter Address of Cork Principal Token to redeem
Cork Principal Token (cPT) represents a share of the Cork Pool.
Using the Cork Pool id, the cPT address and cST address may be obtained by calling CorkPoolManager.shares(poolId) using either:
Etherscan Website: Link
Blockscout Website: Link
Foundry Command Line:
cast call0xccCCcCcCCccCfAE2Ee43F0E727A8c2969d74B9eC"shares(bytes32)(address corkPrincipalToken, address corkSwapToken)"<POOL_ID>--rpc-url https://eth.drpc.org
Input the cPT address & ABI as shown below (prefixed with eth:). If the ABI does not load automatically, copy and paste the ABI from here.

Calculate the amount in wei
Cork Principal Tokens have 18 decimals (i.e. 10^18 precision). To calculate the right wei-amount of principal tokens, use a unit converter such as: https://converter.swiss-knife.xyz/eth or https://etherscan.io/unitconverter

Input the Transaction #1 Details
To Address:
<ERC20 token address of Cork Principal Token>Contract Method Selector:
approvespender (address):
0xCCcCcCCCcccCBaD6F772a511B337d9CCc9570407amount (uint256): <wei amount of cPT to redeem copied from above>

Step 3: Add Transaction #2 – Allow spending of Swap Tokens by Escrow Manager Contract
Add the 2nd transaction to allow the trust-minimized escrow manager contract (CorkAdapter) to spend your Cork Swap Tokens:
Enter Address:
eth:<ERC20 token address of Cork Swap Token>Enter ABI: Copy from here
To Address:
<ERC20 token address of Cork Swap Token>Contract Method Selector:
approvespender (escrow contract):
0xCCcCcCCCcccCBaD6F772a511B337d9CCc9570407amount (of cST): <wei amount of swap tokens to redeem>
By following these instructions:
Obtain the Cork Swap Token address
Cork Swap Token (cST) is paired with their corresponding Cork Principal Token (cPT).
Using the Cork Pool id, the cPT address and cST address may be obtained by calling CorkPoolManager.shares(poolId) using either:
Enter Address of Cork Swap Token to redeem
Input the cST address & ABI as shown below (prefixed with eth:). If the ABI does not load automatically, copy and paste the ABI from here.

Input the Transaction #2 Details
To Address:
<ERC20 token address of Cork Swap Token>Contract Method Selector:
approvespender (address):
0xCCcCcCCCcccCBaD6F772a511B337d9CCc9570407amount (uint256): <wei amount of cST to redeem, copied from the wei amount of cPT in the previous step>

Step 4: Add Transaction #3 – Request an escrowed Unwind-Mint
Add the 3rd transaction to withdraw collateral assets from a Cork Pool by redeeming both cPT (Cork Principal Token) and cST (Cork Swap Token):
Enter Address:
eth:0xCCcCcCCCcccCBaD6F772a511B337d9CCc9570407Enter ABI: Copied from here
To Address:
0xCCcCcCCCcccCBaD6F772a511B337d9CCc9570407Contract Method Selector:
safeUnwindMintparams:
[comma separated values as below...]"<poolId>",
The cork pool market id
"<cptAndCstSharesIn>",
The wei amount of shares to redeem. Copied from the previous step.
"<ownerAddress>",
Your wallet address (or the address that owns the cPT and cST shares to be burned).
"<receiverAddress>",
Your wallet address (or the address to which collateral assets and any excess shares will be sent).
"<minCollateralAssetsOut>",
The minimum wei amount of collateral assets to receive from the unwind operation. From unit-converter.
"<deadline>"
The numeric deadline by which the transaction must be completed. From epoch-converter.
Example params:
By following these instructions:
Enter Address or ENS Name of CorkAdapter address
Input the CorkAdapter contract address & ABI as shown below. If the ABI does not load automatically, copy and paste the ABI from here.

Calculate the deadline in seconds since epoch
Choose a future timestamp using an epoch-converter. We recommend setting it at least 1 hour from now to allow sufficient time for cosigning. Since the batch executes atomically, offline ERC-20 permits are unnecessary, allowing this deadline to be set as far in the future as desired. Use this timestamp as the deadline in the next step.

If missing, scroll to the right of the page to see the copy button:

Input the Transaction #3 Details
To Address:
0xCCcCcCCCcccCBaD6F772a511B337d9CCc9570407Contract Method Selector:
safeUnwindMintparams:
[comma separated values as below...]"<poolId>",
The cork pool market id
"<cptAndCstSharesIn>",
The wei amount of shares to redeem. Copied from the previous step.
"<ownerAddress>",
Your wallet address (or the address that owns the cPT and cST shares to be burned).
"<receiverAddress>",
Your wallet address (or the address to which collateral assets and any excess shares will be sent).
"<minCollateralAssetsOut>",
The minimum wei amount of collateral assets to receive from the unwind operation. From unit-converter.
"<deadline>"
The numeric deadline by which the transaction must be completed. From epoch-converter.

Step 4: Create, Review & Simulate Batch
Press [Create Batch] and follow these instructions:
Review and Confirm batch
Make sure that you see this "Review and Confirm" screen.
Important: Enable atomic batch if asked by your EIP-5792 capable wallet. Using non-atomic batch mode can lead to lost of funds!

Step 5: Sign and Execute transaction
Ask each co-signer/co-owner to follow these instructions:
Verify the Calldata of each transaction in the batch
Each cosigner copies the calldata of each transaction into a safe decoder, and verifies that the decoded data contains the correct amounts and addresses.
DO NOT CONTINUE if they do not match!
Step 6: Wait for Confirmation and Verify token balances
Once the batch transaction is confirmed, follow your wallet-specific instructions to check your collateral asset balance.
Using the Cork Pool id, the Collateral asset (CA) address and Reference asset (REF) address may be obtained by calling CorkPoolManager.assets(poolId) using either:
Etherscan Website: Link
Blockscout Website: Link
Foundry Command Line:
cast call0xccCCcCcCCccCfAE2Ee43F0E727A8c2969d74B9eC"assets(bytes32)(address collateralAsset, address referenceAsset)"<POOL_ID>--rpc-url https://eth.drpc.org
Last updated









