-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Bal7hazar/feat/add-presets-and-examples
✨ Introduce examples
- Loading branch information
Showing
41 changed files
with
7,014 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
mod vec2; | ||
mod vector; | ||
mod matrix; | ||
mod matrix; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Code generated by scarb DO NOT EDIT. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "cubit" | ||
version = "1.2.0" | ||
source = "git+https://github.com/influenceth/cubit?rev=b459053#b4590530d5aeae9aabd36740cc2a3d9e6adc5fde" | ||
|
||
[[package]] | ||
name = "dojo" | ||
version = "0.3.3" | ||
source = "git+https://github.com/dojoengine/dojo.git?tag=v0.3.3#3c9f109e667ca5d12739e6553fdb8261378f4ecf" | ||
dependencies = [ | ||
"dojo_plugin", | ||
] | ||
|
||
[[package]] | ||
name = "dojo_plugin" | ||
version = "0.3.3" | ||
|
||
[[package]] | ||
name = "market" | ||
version = "0.0.0" | ||
dependencies = [ | ||
"cubit", | ||
"dojo", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "market" | ||
version = "0.0.0" | ||
description = "Example of defi crate usage." | ||
homepage = "https://github.com/dojoengine/origami/tree/examples/market" | ||
|
||
[dependencies] | ||
cubit = { git = "https://github.com/influenceth/cubit", rev = "b459053" } | ||
dojo.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mod models { | ||
mod cash; | ||
mod item; | ||
mod liquidity; | ||
mod market; | ||
} | ||
|
||
mod systems { | ||
mod liquidity; | ||
mod trade; | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
mod setup; | ||
mod trade; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Starknet imports | ||
|
||
use starknet::ContractAddress; | ||
|
||
#[derive(Model, Copy, Drop, Serde)] | ||
struct Cash { | ||
#[key] | ||
player: ContractAddress, | ||
amount: u128, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Starknet imports | ||
|
||
use starknet::ContractAddress; | ||
|
||
#[derive(Model, Copy, Drop, Serde)] | ||
struct Item { | ||
#[key] | ||
player: ContractAddress, | ||
#[key] | ||
item_id: u32, | ||
quantity: u128, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Starknet imports | ||
|
||
use starknet::ContractAddress; | ||
|
||
// Dojo imports | ||
|
||
use dojo::database::schema::{Struct, Ty, SchemaIntrospection, Member, serialize_member}; | ||
|
||
// External imports | ||
|
||
use cubit::f128::types::fixed::Fixed; | ||
|
||
// Constants | ||
|
||
const SCALING_FACTOR: u128 = 10000; | ||
|
||
impl SchemaIntrospectionFixed of SchemaIntrospection<Fixed> { | ||
#[inline(always)] | ||
fn size() -> usize { | ||
2 | ||
} | ||
|
||
#[inline(always)] | ||
fn layout(ref layout: Array<u8>) { | ||
layout.append(128); | ||
layout.append(1); | ||
} | ||
|
||
#[inline(always)] | ||
fn ty() -> Ty { | ||
Ty::Struct( | ||
Struct { | ||
name: 'Fixed', | ||
attrs: array![].span(), | ||
children: array![ | ||
serialize_member( | ||
@Member { name: 'mag', ty: Ty::Primitive('u128'), attrs: array![].span() } | ||
), | ||
serialize_member( | ||
@Member { name: 'sign', ty: Ty::Primitive('bool'), attrs: array![].span() } | ||
) | ||
] | ||
.span() | ||
} | ||
) | ||
} | ||
} | ||
|
||
#[derive(Model, Copy, Drop, Serde)] | ||
struct Liquidity { | ||
#[key] | ||
player: ContractAddress, | ||
#[key] | ||
item_id: u32, | ||
shares: Fixed, | ||
} |
Oops, something went wrong.