https://github.com/sirenmarkets/core
SIREN Core Smart Contracts
https://github.com/sirenmarkets/core
blockchain dapp defi derivatives ethereum options smart-contracts
Last synced: 3 months ago
JSON representation
SIREN Core Smart Contracts
- Host: GitHub
- URL: https://github.com/sirenmarkets/core
- Owner: sirenmarkets
- License: gpl-3.0
- Created: 2020-11-13T21:34:46.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-03-05T16:04:51.000Z (over 2 years ago)
- Last Synced: 2025-05-19T09:53:51.886Z (5 months ago)
- Topics: blockchain, dapp, defi, derivatives, ethereum, options, smart-contracts
- Language: TypeScript
- Homepage: https://sirenmarkets.com/
- Size: 7.18 MB
- Stars: 41
- Watchers: 5
- Forks: 12
- Open Issues: 50
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Siren Markets Core Smart Contracts
This repository contains the source code for the Siren Markets core smart contracts.

[](https://coveralls.io/github/sirenmarkets/core?branch=master)
[](https://github.com/sirenmarkets/core/graphs/contributors)
[](https://github.com/sirenmarkets/core/graphs/contributors)
[](https://github.com/sirenmarkets/core/stargazers)

[](https://github.com/sirenmarkets/core/blob/master/LICENSE)[](https://sirenmarkets.com)
[](http://sirenmarkets.medium.com/)
[](https://docs.sirenmarkets.com/)
[](https://gov.sirenmarkets.com/)
[](https://twitter.com/sirenprotocol)[](https://github.com/sirenmarkets/core/pulls)
[](https://github.com/sirenmarkets/core/issues)## Mainnet Contract List
- [AmmFactory](https://docs.sirenmarkets.com/developers/amm-factory)
- [SeriesController](https://docs.sirenmarkets.com/developers/series-controller)
- [SeriesVault](https://docs.sirenmarkets.com/developers/series-vault)
- [ERC1155Controller](https://docs.sirenmarkets.com/developers/erc1155-controller)
- [PriceOracle](https://docs.sirenmarkets.com/developers/price-oracle)## Build and test
```
$ npm install
$ npm test
```## Design Goals
- Build a fully unit tested system with 100% code coverage, including error scenarios and event logging
- Allow the Siren system to be upgradeable over time by the governance system to include new functionality not included in the initial launch, without requiring migration to a new token (e.g. Augur)
- Minimize gas by deploying proxy contracts whenever possible instead of full logic contracts
- Utilize Open Zeppelin contracts whenever possible instead of rolling our own version
- Fully comment the codebase so new developers can quickly grok the protocol and contribute## Protocol Overview
See the [technical documentation](https://docs.sirenmarkets.com/developers/contract-architecture) for more details on the protocol
## Series Lifecycle Example
Below is one of the unit tests showing the flow for, minting options, exercising an option, and claiming the remaining series' collateral.
```typescript
it("Allows claiming after expiration with full redemptions", async () => {
// Amount we will be minting
const MINT_AMOUNT = 100// Give Alice 100 tokens
await collateralToken.mint(aliceAccount, MINT_AMOUNT)// Save off the tokens
const bTokenIndex = await deployedSeriesController.bTokenIndex(seriesId)// approve the amount and mint alice some options - wBTC collateral will be locked into series contract
await collateralToken.approve(deployedSeriesController.address, MINT_AMOUNT, {
from: aliceAccount,
})
await deployedSeriesController.mintOptions(seriesId, MINT_AMOUNT, {
from: aliceAccount,
})// Send the bTokens from alice to Bob - simulates alice selling option
await deployedERC1155Controller.safeTransferFrom(
aliceAccount,
bobAccount,
bTokenIndex,
MINT_AMOUNT,
"0x0",
{ from: aliceAccount },
)// Move the block time into the future so the contract is expired
await time.increaseTo(expiration + ONE_DAY)// Bob exercises
await deployedERC1155Controller.setApprovalForAll(
deployedSeriesController.address,
true,
{ from: bobAccount },
)
await deployedSeriesController.exerciseOption(seriesId, MINT_AMOUNT, true, {
from: bobAccount,
})// Should succeed from Alice claiming leftover collateral
await deployedERC1155Controller.setApprovalForAll(
deployedSeriesController.address,
true,
{ from: aliceAccount },
)
await deployedSeriesController.claimCollateral(seriesId, MINT_AMOUNT, {
from: aliceAccount,
})// Bob should own his share of collateral tokens
assertBNEq(
await collateralToken.balanceOf(bobAccount),
"17",
"bob should have his collateral",
)// Alice should own her share of collateral tokens
assertBNEq(
await collateralToken.balanceOf(aliceAccount),
"83",
"alice should have her collateral",
)
})
```## Development
This repo will generate TS clients for the contracts on install. When updating the contracts, the TS definitions can be manually updated by:
1. Running `npm run compile`
2. Running `npm run build`The compiled JSON ABI files should be commited after deployment so that the deployment metadata is available in the repo.