Skip to content

Commit

Permalink
Feat fact registry (#163)
Browse files Browse the repository at this point in the history
* delete old files

* upgraded scarb version in toml

* added fact registry contract and facade

* update imports and cairo version syntax

- also new scarb fmt format

* re-organized contract/repo defs

* created pricing utils for specific helpers

* refine tests.cairo module defs

* remove old test

* update tests

* update facades

* Update comments and derive statement

* switch back to first round deploying with vault

- implemented refresh_round_pricing_data` using newer facts2

* fix caller not owner bug

* Comments

* moved internal function to pricing_utils

formatting

* rm comments

* started fixing simulations and smoke tests

* added create Job Request helper

if round is open, upper bound is right before auction start date, if round is running, upper bound is right before settlement date

* added test for first round starting

* brought back time shift if auction is delayed

only if auction 1 starts later than expected

* added more tests for consecutive round refreshing

* update readme

* update mock identifiers

* formatting

* added getter for (earliest) pricing data request to fulfill

* removed fact registry

- change name `generate_job_id()` -> `generate_request_id()`

* added constants

* Change pricing data points to pricing data

* update fulfill request logic and surrounding context

* move pricing data struct to option round

* fix test bugs

* switched callback to reverting instead of returning false

* test cleaning/refining

* comments

* fix test gas
  • Loading branch information
0xDegenDeveloper authored Oct 7, 2024
1 parent 1c33f73 commit 814a6fe
Show file tree
Hide file tree
Showing 115 changed files with 7,888 additions and 3,924 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scarb 2.6.4
scarb 2.8.2
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

## Running Tests

The original codebase uses [Scarb](https://docs.swmansion.com/scarb/) (2.6.4) to build and test the contracts. Be sure to setup [asdf](https://asdf-vm.com/) as well, to handle versioning.
The original codebase uses [Scarb](https://docs.swmansion.com/scarb/) (2.8.2) to build and test the contracts. Be sure to setup [asdf](https://asdf-vm.com/) as well, to handle versioning.

To ensure you are setup, run the following command from the root of this directory and check the output matches:

```
❯ scarb --version
scarb 2.6.4 (c4c7c0bac 2024-03-19)
cairo: 2.6.3 (https://crates.io/crates/cairo-lang-compiler/2.6.3)
sierra: 1.5.0
scarb 2.8.2 (a37b4cbfc 2024-09-09)
cairo: 2.8.2 (https://crates.io/crates/cairo-lang-compiler/2.8.2)
sierra: 1.6.0
```

Once Scarb is setup, you can run the full test suite via:
Expand Down
59 changes: 54 additions & 5 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,62 @@
version = 1

[[package]]
name = "openzeppelin"
version = "0.11.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.11.0#a83f36b23f1af6e160288962be4a2701c3ecbcda"
name = "openzeppelin_access"
version = "0.16.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:b9139449e53d715992b2d9e887c0c723d886419bee7ceb5561648c70bd6d3174"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_account"
version = "0.16.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:841bb881adbe98b64fee1dc1329f6e3fbabdfbd9fa65c66ffb54c55f13764bce"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_governance"
version = "0.16.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:a9d9c983cfd4369e7bbb69433fb264edf376805ed873b1f70a287825a6bd1eaf"
dependencies = [
"openzeppelin_access",
"openzeppelin_introspection",
]

[[package]]
name = "openzeppelin_introspection"
version = "0.16.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:312bc2e531f036480ad7392dbb31042c38d875ef9dbb5578ea8de5c05e35b7d8"

[[package]]
name = "openzeppelin_token"
version = "0.16.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:7074c23fbc300b3cccff1037264dfdbe976fb11ae42ce687f4a8ce469adc552a"
dependencies = [
"openzeppelin_account",
"openzeppelin_governance",
"openzeppelin_introspection",
]

[[package]]
name = "openzeppelin_utils"
version = "0.16.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:a494aeb5f1371db7f22e922196aa41d1d1698877a766a838350c0b6ffe49fda2"

[[package]]
name = "pitch_lake_starknet"
name = "pitch_lake"
version = "0.1.0"
dependencies = [
"openzeppelin",
"openzeppelin_token",
"openzeppelin_utils",
]
14 changes: 7 additions & 7 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[package]
name = "pitch_lake_starknet"
name = "pitch_lake"
description = "Oiler PitchLake"
version = "0.1.0"
cairo-version = "2.2.0"

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

[[target.starknet-contract]]
sierra = true
casm = true

[dependencies]
starknet = "2.1.0"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.11.0" }
starknet = "2.8.2"
openzeppelin_token = "0.16.0"
openzeppelin_utils = "0.16.0"

[dev-dependencies]
cairo_test = "2.8.2"

[tool.snforge]
# exit_first = true
3 changes: 0 additions & 3 deletions cairo_project.toml

This file was deleted.

18 changes: 9 additions & 9 deletions scripts/abi/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const ABI = [
{
"type": "impl",
"name": "ERC20MixinImpl",
"interface_name": "openzeppelin::token::erc20::interface::ERC20ABI"
"interface_name": "openzeppelin_token::erc20::interface::ERC20ABI"
},
{
"type": "struct",
Expand Down Expand Up @@ -52,7 +52,7 @@ export const ABI = [
},
{
"type": "interface",
"name": "openzeppelin::token::erc20::interface::ERC20ABI",
"name": "openzeppelin_token::erc20::interface::ERC20ABI",
"items": [
{
"type": "function",
Expand Down Expand Up @@ -267,7 +267,7 @@ export const ABI = [
},
{
"type": "event",
"name": "openzeppelin::token::erc20::erc20::ERC20Component::Transfer",
"name": "openzeppelin_token::erc20::erc20::ERC20Component::Transfer",
"kind": "struct",
"members": [
{
Expand All @@ -289,7 +289,7 @@ export const ABI = [
},
{
"type": "event",
"name": "openzeppelin::token::erc20::erc20::ERC20Component::Approval",
"name": "openzeppelin_token::erc20::erc20::ERC20Component::Approval",
"kind": "struct",
"members": [
{
Expand All @@ -311,29 +311,29 @@ export const ABI = [
},
{
"type": "event",
"name": "openzeppelin::token::erc20::erc20::ERC20Component::Event",
"name": "openzeppelin_token::erc20::erc20::ERC20Component::Event",
"kind": "enum",
"variants": [
{
"name": "Transfer",
"type": "openzeppelin::token::erc20::erc20::ERC20Component::Transfer",
"type": "openzeppelin_token::erc20::erc20::ERC20Component::Transfer",
"kind": "nested"
},
{
"name": "Approval",
"type": "openzeppelin::token::erc20::erc20::ERC20Component::Approval",
"type": "openzeppelin_token::erc20::erc20::ERC20Component::Approval",
"kind": "nested"
}
]
},
{
"type": "event",
"name": "pitch_lake_starknet::library::eth::Eth::Event",
"name": "pitch_lake::library::eth::Eth::Event",
"kind": "enum",
"variants": [
{
"name": "ERC20Event",
"type": "openzeppelin::token::erc20::erc20::ERC20Component::Event",
"type": "openzeppelin_token::erc20::erc20::ERC20Component::Event",
"kind": "flat"
}
]
Expand Down
102 changes: 102 additions & 0 deletions scripts/abi/factRegistry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
export const ABI = [
{
"type": "impl",
"name": "FactRegistryImpl",
"interface_name": "pitch_lake::fact_registry::interface::IFactRegistry"
},
{
"type": "struct",
"name": "core::array::Span::<core::felt252>",
"members": [
{
"name": "snapshot",
"type": "@core::array::Array::<core::felt252>"
}
]
},
{
"type": "struct",
"name": "pitch_lake::fact_registry::interface::JobRequestParams",
"members": [
{
"name": "twap",
"type": "(core::integer::u64, core::integer::u64)"
},
{
"name": "volatility",
"type": "(core::integer::u64, core::integer::u64)"
},
{
"name": "reserve_price",
"type": "(core::integer::u64, core::integer::u64)"
}
]
},
{
"type": "struct",
"name": "pitch_lake::fact_registry::interface::JobRequest",
"members": [
{
"name": "identifiers",
"type": "core::array::Span::<core::felt252>"
},
{
"name": "params",
"type": "pitch_lake::fact_registry::interface::JobRequestParams"
}
]
},
{
"type": "interface",
"name": "pitch_lake::fact_registry::interface::IFactRegistry",
"items": [
{
"type": "function",
"name": "get_fact",
"inputs": [
{
"name": "job_id",
"type": "core::felt252"
}
],
"outputs": [
{
"type": "core::array::Span::<core::felt252>"
}
],
"state_mutability": "view"
},
{
"type": "function",
"name": "set_fact",
"inputs": [
{
"name": "job_request",
"type": "pitch_lake::fact_registry::interface::JobRequest"
},
{
"name": "job_data",
"type": "core::array::Span::<core::felt252>"
}
],
"outputs": [
{
"type": "core::felt252"
}
],
"state_mutability": "external"
}
]
},
{
"type": "constructor",
"name": "constructor",
"inputs": []
},
{
"type": "event",
"name": "pitch_lake::fact_registry::contract::FactRegistry::Event",
"kind": "enum",
"variants": []
}
] as const;
9 changes: 5 additions & 4 deletions scripts/abi/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { ABI as vaultABI} from "./vault"
export { ABI as erc20ABI} from "./erc20"
export { ABI as optionRoundABI} from "./optionRound"
export {ABI as marketAggregatorABI} from "./marketAggregator"
export { ABI as vaultABI } from "./vault";
export { ABI as erc20ABI } from "./erc20";
export { ABI as optionRoundABI } from "./optionRound";
export { ABI as factRegistryABI } from "./factRegistry";

Loading

0 comments on commit 814a6fe

Please sign in to comment.