A front-end contract for interacting with the Ethereum Swarm bonding curve for buying and selling BZZ.
Please note that contracts within this repository are experimental and unaudited.
-
Gasless approve for DAI -> BZZ exchange (uses DAI permit function).
-
Bridging to Gnosis Chain
- Send direct to a
beenode's wallet - Direct top-up of a postage batch
- Send direct to a
-
Fee collection for maintenance / development (see deployed site for more information).
This a foundry forge project. You can run tests:
forge test -f http://url.to.archive.node:8545 -vvvTo also generate coverage information use forge coverage instead.
This repo currently uses forge as the linter. It can be called through forge:
forge fmtTo generate typechain bindings use:
npx typechain --target ethers-v5 --out-dir ./typechain './out/**/*.json'This will generate the typechain bindings in the typechain/ directory. This requires typechain to be installed and is actually best done in the consuming package (web app).
Swap is deployed on the following networks:
| Network | Name | Contract |
|---|---|---|
| Mainnet | Exchange | 0x69defd0bdcdca696042ed75b00c10276c6d32a33 |
| Gnosis | BzzRouter | 0xEd469d6aa0658b71B9dE75c2fe401924FCf0534d |
Exchange is a simple contract that interacts with the bonding curve, allowing buying or selling of BZZ from/to the curve.
The Exchange contract interacts with DAI and BZZ. Therefore the following approve methods are available:
- DAI:
approve()andpermit() - BZZ:
approve()
Therefore, when transacting from DAI to BZZ, it is possible to do single transactions without requiring an approval.
NOTE: It may appear similar to there being two transactions, but the first is actually a signing request for signing the DAI permit, with the second pop-up being the actual transaction.
As Swarm mainnet's incentive contracts / accounting layer runs on the Gnosis Chain blockchain, and the bonding curve presides on Ethereum mainnet, there is a potential need for bridging between mainnet and Gnosis Chain.
For example, if a user wanted to purchase BZZ from the Bonding Curve to top-up a stamp, they would have to:
- Approve DAI for use on the bonding curve to purchase BZZ.
- Exchange DAI for BZZ on the bonding curve.
- Approve the Gnosis Chain omnibridge for spending BZZ for bridging.
- Bridge BZZ from mainnet to Gnosis Chain using the omnibridge.
- Transfer the BZZ to their node's wallet.
- Execute the top up transaction from their node.
This exchange contract drastically streamlines the user experience, allowing a single transaction to complete all of the above.
Depending on the bridge_cd parameter passed to the buy function, a user may:
- Purchase BZZ tokens and send them directly to an address on Gnosis Chain.
- Purchase BZZ tokens, send them to Gnosis Chain and directly top-up a stamp.
BzzRouter is a small utility contract that resides on Gnosis Chain and is responsible for redirecting BZZ. This router will:
- Redirect
BZZthat has been bridged, using theonTokenBridgedcallback fromHomeBridge. - Redirect
BZZthat has been transferred, using theonTokenTransfercallback forERC677transfers.
No fees are deducted by this utility contract.