This project implements a TicketMaster smart contract on the Starknet blockchain using the Cairo language. It leverages Ekubo's TWAMM (Time-Weighted Average Market Maker) extension to create a sophisticated, demand-based pricing mechanism for "Dungeon Tickets". The contract is an extension of OpenZeppelin's ERC20 component and includes a state machine to manage the lifecycle of token distribution.
The core functionalities include:
- Automated Market Making: Initializes a TWAMM pool on Ekubo to facilitate the sale of Dungeon Tickets.
- Dynamic Pricing: The price of tickets is determined by market demand through the TWAMM.
- Issuance Throttling: The contract can reduce the rate of ticket issuance if the market price falls below a configurable threshold, and resume when the price recovers.
- Proceeds Distribution: Proceeds from ticket sales are split between a treasury and a buyback mechanism for a different token.
The project uses Scarb for dependency management and Starknet Foundry for testing.
- Scarb v2.12.2+
- Starknet Foundry v0.49.0+
-
Clone the repository:
git clone <repo-url> cd ticket-master
-
Install dependencies:
scarb build
To compile the contract, run:
scarb buildThe project includes a comprehensive test suite using Starknet Foundry.
-
Run all tests:
snforge test -
Run tests with forking: The tests can be run against a forked mainnet or sepolia environment.
snforge test --fork mainnet snforge test --fork sepolia
The project follows the standard Cairo formatting guidelines. Use scarb fmt to format the code.
- Unit Tests: Located alongside the source code (e.g.,
src/utils.cairo). - Integration Tests: Located in the
tests/directory, covering the full contract lifecycle. - Fork Testing: Tests are run against forked environments to ensure correct integration with external contracts like Ekubo.
- Format code with
scarb fmt. - Run all tests, including fork tests.
- Update documentation and tests along with code changes.
- Follow Conventional Commits for git history (e.g.,
feat:,fix:,refactor:).