Certora / SirenMarkets

SIREN Core Smart Contracts

Home Page:https://sirenmarkets.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SIREN logo

Siren Markets Core Smart Contracts

This repository contains the source code for the Siren Markets core smart contracts.

SIREN CI Coverage Status GitHub contributors GitHub commit activity GitHub Stars GitHub repo size GitHub

Website sirenmarkets.com Blog Docs Governance Twitter SirenProtocol

GitHub pull requests by-label GitHub Issues

Mainnet Contract List

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 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.

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.

About

SIREN Core Smart Contracts

https://sirenmarkets.com/

License:GNU General Public License v3.0


Languages

Language:TypeScript 73.8%Language:Solidity 25.1%Language:JavaScript 1.0%Language:Shell 0.1%