Deposit and withdraw
Deposit and encumber funds
At the commitment time, the price and the seller's deposit get locked in the protocol. The buyer's funds are transferred to the protocol alongside the commitment action, while the seller's funds should already be available in the protocol. The seller's funds can already be in the protocol as a result of previous exchanges. If there are none (since no exchange was finalised yet), the seller can deposit them into the protocol and make them available for future exchanges.
Only the seller needs the depositing functionality, and it's not allowed to deposit funds for entities of a different type.
Release and withdraw funds
When the exchange is finalised, all exchange funds are released to the recipients, depending on the final exchange state. The recipients can then withdraw them from the protocol. They can combine payouts of multiple exchanges and withdraw them all at once. Sellers can leave the funds to be used as a seller deposit for future exchanges.
The pull mechanics are used instead of push, since otherwise the malicious actors could block the finalisation of the exchange.
TypeScript SDK
Transfers the ERC20 tokens or native token to the protocol and makes it available to be used as a seller's deposit.
const sellerId = "2";
const amount = parseEther("0.01");
const tokenAddress = "0x00000000000000000000000000000000"; // native token
await coreSDK.depositFunds(sellerId, amount, tokenAddress);
Solidity
Transfers the ERC20 tokens or native token to the protocol and makes it available to be used as a seller's deposit.
IBosonFundsHandler bosonProtocol = IBosonFundsHandler(_bosonProtocolAddress);
uint256 sellerId = 2;
uint256 amount = 0.01 ether;
address tokenAddress = 0x00000000000000000000000000000000; // native token
bosonProtocol.depositFunds{ value: amount }(seller, tokenAddress, amount);
Last updated