From f0ba21b7d9ed359fcf97e985f89e6c117cf48c1e Mon Sep 17 00:00:00 2001 From: notV4l <122404722+notV4l@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:27:41 +0200 Subject: [PATCH] chore: update dojo-defi to 2.2.0 (#891) --- crates/dojo-defi/Scarb.toml | 6 ++---- crates/dojo-defi/src/market/components.cairo | 15 ++++++++------- .../src/market/constant_product_market.cairo | 4 ---- crates/dojo-defi/src/market/systems.cairo | 8 -------- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/crates/dojo-defi/Scarb.toml b/crates/dojo-defi/Scarb.toml index 316197c729..864e87ee60 100644 --- a/crates/dojo-defi/Scarb.toml +++ b/crates/dojo-defi/Scarb.toml @@ -1,5 +1,5 @@ [package] -cairo-version = "2.1.1" +cairo-version = "2.2.0" description = "Implementations of a defi primitives for the Dojo framework" name = "dojo_defi" version = "0.2.1" @@ -7,9 +7,7 @@ version = "0.2.1" [lib] [dependencies] -# Next lines to be reverted once Cubit repo is updated. -# cubit = { git = "https://github.com/influenceth/cubit" } -cubit = {git = "https://github.com/ametel01/cubit.git"} +cubit = { git = "https://github.com/influenceth/cubit" } dojo = { path = "../dojo-core" } diff --git a/crates/dojo-defi/src/market/components.cairo b/crates/dojo-defi/src/market/components.cairo index 259a89cd00..f0fd6c05d5 100644 --- a/crates/dojo-defi/src/market/components.cairo +++ b/crates/dojo-defi/src/market/components.cairo @@ -1,9 +1,5 @@ -use option::OptionTrait; use starknet::ContractAddress; -use traits::{Into, TryInto}; - -use dojo::component::StorageSize; - +use dojo::StorageSize; // Cubit fixed point math library use cubit::f128::types::fixed::Fixed; @@ -12,8 +8,13 @@ const SCALING_FACTOR: u128 = 10000; impl StorageSizeFixed of StorageSize { #[inline(always)] - fn len() -> usize { - 2 + fn unpacked_size() -> usize { + 1 + } + + #[inline(always)] + fn packed_size() -> usize { + 129 } } diff --git a/crates/dojo-defi/src/market/constant_product_market.cairo b/crates/dojo-defi/src/market/constant_product_market.cairo index cae15ff5f6..5658f8d057 100644 --- a/crates/dojo-defi/src/market/constant_product_market.cairo +++ b/crates/dojo-defi/src/market/constant_product_market.cairo @@ -1,9 +1,5 @@ -use traits::{Into, TryInto}; -use option::OptionTrait; use starknet::ContractAddress; - use dojo_defi::market::components::Market; - use cubit::f128::types::fixed::{Fixed, FixedTrait}; const SCALING_FACTOR: u128 = 10000; diff --git a/crates/dojo-defi/src/market/systems.cairo b/crates/dojo-defi/src/market/systems.cairo index 168205568c..e7bbbe0e83 100644 --- a/crates/dojo-defi/src/market/systems.cairo +++ b/crates/dojo-defi/src/market/systems.cairo @@ -1,7 +1,5 @@ #[system] mod Buy { - use traits::Into; - use array::ArrayTrait; use dojo_defi::market::components::{Item, Cash, Market}; use dojo_defi::market::constant_product_market::MarketTrait; use dojo::world::Context; @@ -40,8 +38,6 @@ mod Buy { #[system] mod Sell { - use traits::Into; - use array::ArrayTrait; use dojo_defi::market::components::{Item, Cash, Market}; use dojo_defi::market::constant_product_market::MarketTrait; use dojo::world::Context; @@ -81,8 +77,6 @@ mod Sell { #[system] mod AddLiquidity { - use traits::Into; - use array::ArrayTrait; use dojo_defi::market::components::{Item, Cash, Market, Liquidity}; use dojo_defi::market::constant_product_market::MarketTrait; use dojo::world::Context; @@ -132,8 +126,6 @@ mod AddLiquidity { #[system] mod RemoveLiquidity { - use traits::Into; - use array::ArrayTrait; use dojo_defi::market::components::{Item, Cash, Market, Liquidity}; use dojo_defi::market::constant_product_market::MarketTrait; use dojo::world::Context;