Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into bfs-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Oct 8, 2024
2 parents 1fab8dd + d9af285 commit 7c7452c
Show file tree
Hide file tree
Showing 19 changed files with 882 additions and 284 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:

env:
DOJO_VERSION: v1.0.0-alpha.11
DOJO_VERSION: v1.0.0-alpha.14
SCARB_VERSION: 2.7.0

jobs:
Expand Down
49 changes: 29 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!-- markdownlint-disable -->
<div align="center">
<img src=".github/Origami.svg" height="128">
<img src="./docs/images/origami.svg" height="128">
</div>
<div align="center">
<br />
<!-- markdownlint-restore -->
<br />
<!-- markdownlint-restore -->

<a href="https://twitter.com/dojostarknet">
<img src="https://img.shields.io/twitter/follow/dojostarknet?style=social"/>
</a>
<a href="https://github.com/dojoengine/dojo">
<img src="https://img.shields.io/github/stars/dojoengine/dojo?style=social"/>
</a>
<a href="https://twitter.com/dojostarknet">
<img src="https://img.shields.io/twitter/follow/dojostarknet?style=social"/>
</a>
<a href="https://github.com/dojoengine/dojo">
<img src="https://img.shields.io/github/stars/dojoengine/dojo?style=social"/>
</a>

[![discord](https://img.shields.io/badge/join-dojo-green?logo=discord&logoColor=white)](https://discord.gg/PwDa2mKhR4)
![Github Actions][gha-badge] [![Telegram Chat][tg-badge]][tg-url]
Expand All @@ -22,22 +22,30 @@

</div>

# Origami - Primitives for onchain Gaming
# Origami

#### "The magic of origami is in seeing a single piece of cairo evolve into a masterpiece through careful folds" - Sensei
Origami is a collection of essential primitives designed to facilitate the development of onchain games using the Dojo engine.
It provides a set of powerful tools and libraries that enable game developers to create complex, engaging, and efficient fully onchain games.

> _The magic of origami is in seeing a single piece of cairo evolve into a masterpiece through careful folds_
>
> <p align="right">Sensei</p>
<div align="center">
<img src="./docs/videos/usage.gif" height="400">
</div>

---

### Crates

- [algebra](./crates/algebra)
- [defi](./crates/defi/)
- [map](./crates/map)
- [random](./crates/random)
- [rating](./crates/rating)
- [security](./crates/security)
- [token](./crates/token)
- [governance](./crates/governance)
- [Algebra](./crates/algebra)
- [Defi](./crates/defi/)
- [Map](./crates/map)
- Physics (WIP)
- [Random](./crates/random)
- [Rating](./crates/rating)
- [Security](./crates/security)

### Easy integration into your project

Expand All @@ -47,7 +55,8 @@ Add the following to your `[dependencies]`:

```toml
[dependencies]
origami_token = { git = "https://github.com/dojoengine/origami" }
origami_random = { git = "https://github.com/dojoengine/origami" }
origami_map = { git = "https://github.com/dojoengine/origami" }
```

Now you will be able to use origami like any other Cairo package!
Expand Down
26 changes: 9 additions & 17 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,48 @@ source = "git+https://github.com/dojoengine/cubit?branch=update_to_2.7.0#075bf5a
[[package]]
name = "dojo"
version = "1.0.0-alpha.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.11#fbff45b249e2b931f5007edf2d526beef7dc553f"
dependencies = [
"dojo_plugin",
]

[[package]]
name = "dojo_plugin"
version = "1.0.0-alpha.4"
source = "git+https://github.com/dojoengine/dojo?rev=f15def33#f15def330c0d099e79351d11c197f63e8cc1ff36"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.14#6bafcb55178888268d86aae9dccef8a1ba6e7542"

[[package]]
name = "origami_algebra"
version = "1.0.0-alpha.11"
version = "1.0.0-alpha.14"
dependencies = [
"cubit",
]

[[package]]
name = "origami_defi"
version = "1.0.0-alpha.11"
version = "1.0.0-alpha.14"
dependencies = [
"cubit",
]

[[package]]
name = "origami_governance"
version = "1.0.0-alpha.11"
version = "1.0.0-alpha.14"
dependencies = [
"dojo",
]

[[package]]
name = "origami_map"
version = "1.0.0-alpha.11"
version = "1.0.0-alpha.14"

[[package]]
name = "origami_random"
version = "1.0.0-alpha.11"
version = "1.0.0-alpha.14"

[[package]]
name = "origami_rating"
version = "1.0.0-alpha.11"
version = "1.0.0-alpha.14"

[[package]]
name = "origami_security"
version = "1.0.0-alpha.11"
version = "1.0.0-alpha.14"

[[package]]
name = "origami_token"
version = "1.0.0-alpha.11"
version = "1.0.0-alpha.14"
dependencies = [
"dojo",
]
4 changes: 2 additions & 2 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ members = [
]

[workspace.package]
version = "1.0.0-alpha.11"
version = "1.0.0-alpha.14"

[workspace.dependencies]
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.11" }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.14" }
# dojo = { path = "../dojo/crates/dojo-core" }
cubit = { git = "https://github.com/dojoengine/cubit", branch = "update_to_2.7.0" }
starknet = "^2.7.0"
Expand Down
55 changes: 55 additions & 0 deletions crates/algebra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Algebra

The Origami Algebra crate is a library that provides algebraic primitives for Dojo-based games. It offers efficient implementations of mathematical structures and operations commonly used in game development.

## Overview

The Algebra crate focuses on providing fundamental mathematical structures and operations that are essential for game development. Its primary scope includes:

- Vector operations
- Matrix operations
- Basic algebraic computations

The crate is designed to work seamlessly with the Dojo engine and other Origami crates.

## Installation

To add the Origami Algebra crate as a dependency in your project, you need to modify your Scarb.toml file. Add the following to your [dependencies] section:

```toml
[dependencies]
origami_algebra = { git = "https://github.com/dojoengine/origami" }
```

Make sure you have dojo installed and configured in your project.

## Features

The crate currently implements a 2D vector (Vec2) with various operations:

```rust
struct Vec2<T> {
x: T,
y: T
}
```

Key features of `Vec2` include:

- Construction: new and splat methods
- Dot product calculation
- Swizzle operations (xx, xy, yx, yy)
- Mask-based selection

Example usage:

```rust
let vec2a = Vec2Trait::new(1, -2);
let vec2b = Vec2Trait::new(-3, 4);
let a_dot_b = vec2a.dot(vec2b); // -11
```

## Conclusion

The Origami Algebra crate provides a solid foundation for mathematical operations in Dojo-based games. It offers efficient implementations of 2D vectors with various utility functions. As the crate evolves, more features and mathematical structures may be added to support a wider range of game development needs.
For the most up-to-date information and usage examples, refer to the crate's source code and any accompanying documentation in the Origami repository.
13 changes: 12 additions & 1 deletion crates/defi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ The process works by incrementally making more assets available for sale, splitt

It's possible to compute the purchase price for any quantity of tokens gas-efficiently, using specific mathematical expressions.

## Installation

To add the Origami DeFi crate as a dependency in your project, you need to modify your Scarb.toml file. Add the following to your [dependencies] section:

```toml
[dependencies]
origami_defi = { git = "https://github.com/dojoengine/origami" }
```

Make sure you have dojo installed and configured in your project.

## How to Use

### Discrete Gradual Dutch Auction
Expand Down Expand Up @@ -97,7 +108,7 @@ GDAs present a powerful tool for selling both fungible and non-fungible tokens i

## Overview

Variable Rate GDAs ([VRGDAs](https://www.paradigm.xyz/2022/08/vrgda)) enable the selling of tokens according to a custom schedule, raising or lowering prices based on the sales pace. VRGDA is a generalization of the GDA mechanism.
Variable Rate GDAs ([VRGDAs](https://www.paradigm.xyz/2022/08/vrgda)) enable the selling of tokens according to a custom schedule, raising or lowering prices based on the sales pace. VRGDA is a generalization of the GDA mechanism.

## How to Use

Expand Down
14 changes: 7 additions & 7 deletions crates/defi/src/auction/vrgda.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ pub impl TVRGDATrait<T, +VRGDAVarsTrait<T>, +VRGDATargetTimeTrait<T>> of VRGDATr
/// decay constant, and per-time-unit rate.
#[derive(Copy, Drop, Serde, starknet::Store)]
pub struct LinearVRGDA {
target_price: Fixed,
decay_constant: Fixed,
target_units_per_time: Fixed,
pub target_price: Fixed,
pub decay_constant: Fixed,
pub target_units_per_time: Fixed,
}


Expand Down Expand Up @@ -84,10 +84,10 @@ pub impl LinearVRGDAImpl = TVRGDATrait<LinearVRGDA>;

#[derive(Copy, Drop, Serde, starknet::Store)]
pub struct LogisticVRGDA {
target_price: Fixed,
decay_constant: Fixed,
max_sellable: Fixed,
time_scale: Fixed, // target time to sell 46% of units
pub target_price: Fixed,
pub decay_constant: Fixed,
pub max_sellable: Fixed,
pub time_scale: Fixed, // target time to sell 46% of units
}

impl LogisticVRGDAVarsImpl of VRGDAVarsTrait<LogisticVRGDA> {
Expand Down
Loading

0 comments on commit 7c7452c

Please sign in to comment.