Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-options-fnc
Browse files Browse the repository at this point in the history
  • Loading branch information
tensojka authored Jan 17, 2024
2 parents 8e386a1 + ecbd84c commit add6a30
Show file tree
Hide file tree
Showing 14 changed files with 705 additions and 439 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ on:
paths:
- '**.cairo'
- '.github/'
- 'Scarb.lock'
- 'Scarb.toml'

env:
SCARB_VERSION: 2.3.1
SCARB_VERSION: 2.4.0
FOUNDRY_VERSION: 0.14.0

jobs:
build:
Expand All @@ -17,7 +20,11 @@ jobs:
uses: actions/checkout@v3
- name: Install Scarb
run: curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v $SCARB_VERSION
- name: Install SnFoundryUp
run: curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/scripts/install.sh | sh
- name: Install SnFoundry
run: snfoundryup -v $FOUNDRY_VERSION
- name: Check formatting
run: scarb fmt --check
- name: Build with scarb
run: scarb build
- name: Run tests with snforge
run: snforge test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ Cargo.lock
.env

vendor/
.DS_Store
.DS_Store
.snfoundry_cache/
account*
14 changes: 14 additions & 0 deletions Scarb.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "cubit"
version = "1.3.0"
source = "git+https://github.com/akhercha/cubit.git?branch=chore%2Fcairo_upgrade#d3869a3f0c47e5ed229bbbfe2fce3fc0510cbc8a"

[[package]]
name = "governance"
version = "0.2.0"
dependencies = [
"cubit",
"snforge_std",
]

[[package]]
name = "snforge_std"
version = "0.14.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git#a1caebbfffd00e612c09ed89da006f6c48a92fd9"
16 changes: 14 additions & 2 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
name = "governance"
description = "A flexible monolithic governance contract, developed for use with Carmine Options AMM"
version = "0.2.0"
cairo-version = "2.1.1"
cairo-version = "2.4.0"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest

[dependencies]
starknet = ">=1.1.0"
cubit = { git = "https://github.com/akhercha/cubit.git", branch = "chore/cairo_upgrade" }
starknet = ">=1.3.0"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", commit = "a1caebbfffd00e612c09ed89da006f6c48a92fd9"}

[[target.starknet-contract]]

[[tool.snforge.fork]]
name = "MAINNET"
url = "http://34.22.208.73:6060/"
block_id.tag = "Latest"

[[tool.snforge.fork]]
name = "GOERLI"
url = "https://limited-rpc.nethermind.io/goerli-juno"
block_id.tag = "Latest"
16 changes: 16 additions & 0 deletions src/amm_types/basic.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use cubit::f128::types::fixed::{Fixed, FixedTrait};
use starknet::ContractAddress;
use core::option::OptionTrait;

type LPTAddress = ContractAddress;
type OptionSide = u8;
type OptionType = u8;
type Timestamp = u64; // In seconds, Block timestamps are also u64

type Int = u128;

type Maturity = felt252;

type Volatility = Fixed;
type Strike = Fixed;

17 changes: 16 additions & 1 deletion src/constants.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const NEW_PROPOSAL_QUORUM: u128 =
200; // 1/200 of totalSupply required to propose an upgrade. Quorums don't take into account investors. at all, they don't count into total eligible voters, but do vote
const PROPOSAL_VOTING_TIME_BLOCKS: u64 = 2500;
const QUORUM: u128 = 10; // 1/10 of totalSupply required to participate to pass
const MINUS_ONE: felt252 = 0x800000000000011000000000000000000000000000000000000000000000000;
const TEAM_TOKEN_BALANCE: u128 = 1000000000000000000;
Expand All @@ -9,3 +8,19 @@ const OPTION_PUT: felt252 = 1;
const TRADE_SIDE_LONG: felt252 = 0;
const TRADE_SIDE_SHORT: felt252 = 1;
const PROPOSAL_VOTING_SECONDS: u64 = consteval_int!(60 * 60 * 24 * 7);


// ADDRESSES

const USDC_ADDRESS: felt252 = 0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8;
const ETH_ADDRESS: felt252 = 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7;
const BTC_ADDRESS: felt252 = 0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac;

// CLASS HASHES

// corresponds to commit 7b7db57419fdb25b93621fbea6a845005f7725d0 in protocol-cairo1 repo, branch audit-fixes
const LP_TOKEN_CLASS_HASH: felt252 =
0x06d15bc862ce48375ec98fea84d76ca67b7ac5978d80c848fa5496108783fbc2;
const AMM_CLASS_HASH: felt252 = 0x045fb686c8875f31966e7308d71c03e9ae78f9566a61870a2b616dc225dd3313;
const OPTION_TOKEN_CLASS_HASH: felt252 =
0x07fc0b6ecc96a698cdac8c4ae447816d73bffdd9603faacffc0a8047149d02ed;
14 changes: 3 additions & 11 deletions src/contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ trait IGovernance<TContractState> {
fn get_governance_token_address(self: @TContractState) -> ContractAddress;
fn get_amm_address(self: @TContractState) -> ContractAddress;
fn apply_passed_proposal(ref self: TContractState, prop_id: felt252);
// AIRDROPS

// AIRDROPS
// in component

// in component

// OPTIONS

fn add_0911_1611_options(ref self: TContractState);
// OPTIONS / ONE-OFF
}


Expand All @@ -40,7 +37,6 @@ mod Governance {
use governance::types::ContractType;
use governance::types::PropDetails;
use governance::upgrades::Upgrades;
use governance::options::Options;
use governance::airdrop::airdrop as airdrop_component;

use starknet::ContractAddress;
Expand Down Expand Up @@ -143,9 +139,5 @@ mod Governance {
fn apply_passed_proposal(ref self: ContractState, prop_id: felt252) {
Upgrades::apply_passed_proposal(prop_id)
}

fn add_0911_1611_options(ref self: ContractState) {
Options::run_add_0911_1611_options()
}
}
}
3 changes: 3 additions & 0 deletions src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
mod airdrop;
mod amm_types {
mod basic;
}
mod constants;
mod contract;
mod merkle_tree;
Expand Down
Loading

0 comments on commit add6a30

Please sign in to comment.