From 4d16bd83c9c1abdf52d5bb03e438ef19d8ca9740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Wed, 27 Sep 2023 14:17:33 -0300 Subject: [PATCH 01/23] Update algorithm.rs --- src/dex/algorithm.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index a71fd79f..65b6dd02 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -23,21 +23,21 @@ use rgb_core::{Contract, ExecutionResult}; use aluvm::{Executor, Value}; struct AmmContract { - btc_balance: u64, - usdt_balance: u64, + rgb_asset_balance: u64, + rgb_asset_balance: u64, } impl AmmContract { fn new() -> Self { AmmContract { - btc_balance: 0, - usdt_balance: 0, + rgb_asset_balance: 0, + rgb_asset_balance: 0, } } - fn add_liquidity(&mut self, btc_amount: u64, usdt_amount: u64) -> ExecutionResult { - self.btc_balance += btc_amount; - self.usdt_balance += usdt_amount; + fn add_liquidity(&mut self, rgb_asset_amount: u64, rgb_asset_amount: u64) -> ExecutionResult { + self.rgb_asset_balance += rgb_asset_amount; + self.rgb_asset_balance += rgb_asset_amount; ExecutionResult::None } From 07865a7e02ef886143cda70e6ec262735eb45748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:11:20 -0300 Subject: [PATCH 02/23] Update algorithm.rs --- src/dex/algorithm.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 65b6dd02..74d1de3e 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -41,8 +41,8 @@ impl AmmContract { ExecutionResult::None } - fn swap(&mut self, btc_amount: u64, slippage: f64) -> ExecutionResult { - let usdt_amount = self.calculate_swap(btc_amount); + fn swap(&mut self, rgb_assetamount: u64, slippage: f64) -> ExecutionResult { + let usdt_amount = self.calculate_swap(rgb_asset_amount); let max_slippage = (usdt_amount as f64) * slippage; let actual_slippage = (usdt_amount as f64) - ((btc_amount as f64) * (self.usdt_balance as f64) / (self.btc_balance as f64)); @@ -76,8 +76,7 @@ fn main() { let usdt_liquidity = 100; let fee_liquidity= 0.3; amm_contract.add_liquidity(btc_liquidity, usdt_liquidity, fee_liquidity); - - // Simulate token swap + // Simulate token swap let btc_to_swap = 5; let slippage = 0.02; // 2% maximum allowable slippage From 5891945e3d48f3b08af3989335b60b1cbbe11835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 28 Sep 2023 10:08:16 -0300 Subject: [PATCH 03/23] Update algorithm.rs --- src/dex/algorithm.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 74d1de3e..32c66f3f 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -44,21 +44,20 @@ impl AmmContract { fn swap(&mut self, rgb_assetamount: u64, slippage: f64) -> ExecutionResult { let usdt_amount = self.calculate_swap(rgb_asset_amount); - let max_slippage = (usdt_amount as f64) * slippage; - let actual_slippage = (usdt_amount as f64) - ((btc_amount as f64) * (self.usdt_balance as f64) / (self.btc_balance as f64)); + let max_slippage = (rgb_asset_amount as f64) * slippage; + let actual_slippage = (rgb_asset_amount as f64) - ((rgb_asset_amount as f64) * (self.rgb_asset_balance as f64) / (self.rgb_asset_balance as f64)); if actual_slippage > max_slippage { // Revert the swap due to slippage exceeding the specified percentage ExecutionResult::None } else { - self.btc_balance += btc_amount; - self.usdt_balance -= usdt_amount; - ExecutionResult::Value(Value::U64(usdt_amount)) + self.rgb_asset_balance += rgb_asset_amount; + self.rgb_asset_balance += rgb_asset_amount; + ExecutionResult::Value(Value::U64(rgb_asset_amount)) } } fn calculate_swap(&self, btc_amount: u64) -> u64 { - // Implement your specific AMM algorithm here to calculate the USDT amount for a given BTC amount // This example uses a simple constant ratio if self.btc_balance == 0 || self.usdt_balance == 0 { 0 From 2ac541e1575b3bba76f155a8c2d256ef5d416db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 28 Sep 2023 10:13:20 -0300 Subject: [PATCH 04/23] Update algorithm.rs --- src/dex/algorithm.rs | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 32c66f3f..fa84df4e 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -58,11 +58,27 @@ impl AmmContract { } fn calculate_swap(&self, btc_amount: u64) -> u64 { + //Logic AMM + fn main() { + // Define the constant 'k' + let k = 1000000; + + // Given 'x', calculate 'y' + let x = 100; + let y = k / x; + println!("Given x = {}, y = {}", x, y); + + // Given 'y', calculate 'x' + let y = 200; + let x = k / y; + println!("Given y = {}, x = {}", y, x); +} + // This example uses a simple constant ratio - if self.btc_balance == 0 || self.usdt_balance == 0 { + if self.rgb_asset_balance == 0 || self.rgb_asset_balance == 0 { 0 } else { - (btc_amount * self.usdt_balance) / self.btc_balance + (rgb_asset_amount * self.rgb_asset_balance) / self.rgb_asset_balance } } } @@ -70,21 +86,21 @@ impl AmmContract { fn main() { let mut amm_contract = AmmContract::new(); - // Simulate liquidity provision - let btc_liquidity = 10; - let usdt_liquidity = 100; + // l iquidit provision + let rgb_asset_liquidity = 10; + let rgb_asset_liquidity = 100; let fee_liquidity= 0.3; - amm_contract.add_liquidity(btc_liquidity, usdt_liquidity, fee_liquidity); - // Simulate token swap - let btc_to_swap = 5; + amm_contract.add_liquidity(rgb_asset_liquidity, rgb_asset_liquidity, fee_liquidity); + // token swap + let rgb_asset_to_swap = 1 let slippage = 0.02; // 2% maximum allowable slippage let result = amm_contract.swap(btc_to_swap, slippage); match result { ExecutionResult::Value(value) => { - // User received USDT in exchange for BTC - println!("Received USDT: {}", value); + // User received RGB in exchange for other token + println!("Received RGB token: {}", value); } ExecutionResult::None => { // Swap reverted due to slippage exceeding the specified percentage From 52d52777a2351d200e32d0e0735673b1970ddadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 28 Sep 2023 10:26:45 -0300 Subject: [PATCH 05/23] Update algorithm.rs --- src/dex/algorithm.rs | 53 +++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index fa84df4e..32f7bab9 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -59,19 +59,46 @@ impl AmmContract { fn calculate_swap(&self, btc_amount: u64) -> u64 { //Logic AMM - fn main() { - // Define the constant 'k' - let k = 1000000; - - // Given 'x', calculate 'y' - let x = 100; - let y = k / x; - println!("Given x = {}, y = {}", x, y); - - // Given 'y', calculate 'x' - let y = 200; - let x = k / y; - println!("Given y = {}, x = {}", y, x); + struct AMM{ + k: u64, + x: u64, + y: u64, +} + +impl AMM { + fn new(k: u64, x: u64, y: u64) -> Self { + ConstantProduct { k, x, y } + } + + fn set_x(&mut self, x: u64) { + self.x = x; + self.y = self.k / self.x; + } + + fn set_y(&mut self, y: u64) { + self.y = y; + self.x = self.k / self.y; + } + + fn get_x(&self) -> u64 { + self.x + } + + fn get_y(&self) -> u64 { + self.y + } +} + +fn logic() { + let mut amm = ConstantProduct::new(1000000, 100, 0); + + println!("Initial x: {}, y: {}", amm.get_x(), amm.get_y()); + + amm.set_x(200); + println!("Given x, calculated y: x: {}, y: {}", amm.get_x(), amm.get_y()); + + amm.set_y(300); + println!("Given y, calculated x: x: {}, y: {}", amm.get_x(), amm.get_y()); } // This example uses a simple constant ratio From 468dbd186cf2402cf6d0a613d5313f44e4acdb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 28 Sep 2023 10:31:14 -0300 Subject: [PATCH 06/23] Update algorithm.rs --- src/dex/algorithm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 32f7bab9..beb6c917 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -21,6 +21,7 @@ use rgb_core::{Contract, ExecutionResult}; use aluvm::{Executor, Value}; +use strict_type::{Map}; struct AmmContract { rgb_asset_balance: u64, From f8079a3e68798cadaca823b8715414db144f16d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 28 Sep 2023 10:32:09 -0300 Subject: [PATCH 07/23] Update algorithm.rs --- src/dex/algorithm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index beb6c917..7cdaa151 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -68,7 +68,7 @@ impl AmmContract { impl AMM { fn new(k: u64, x: u64, y: u64) -> Self { - ConstantProduct { k, x, y } + ConstantAmm { k, x, y } } fn set_x(&mut self, x: u64) { @@ -91,7 +91,7 @@ impl AMM { } fn logic() { - let mut amm = ConstantProduct::new(1000000, 100, 0); + let mut amm = ConstantAmm::new(1000000, 100, 0); println!("Initial x: {}, y: {}", amm.get_x(), amm.get_y()); From c7f6a92640424d0fc9c1698d05beb862eecf96bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 28 Sep 2023 11:19:18 -0300 Subject: [PATCH 08/23] Update algorithm.rs --- src/dex/algorithm.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 7cdaa151..a32f161c 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -22,6 +22,8 @@ use rgb_core::{Contract, ExecutionResult}; use aluvm::{Executor, Value}; use strict_type::{Map}; +use dlc::{Message, OracleInfo, ContractInfo}; +use lightning::{Message, HashPayment, Invoice}; struct AmmContract { rgb_asset_balance: u64, From 233ecbbb08a4aa66423660365a8408375b588de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Mon, 2 Oct 2023 08:34:39 -0300 Subject: [PATCH 09/23] Update algorithm.rs --- src/dex/algorithm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index a32f161c..d1a3dced 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -28,6 +28,7 @@ use lightning::{Message, HashPayment, Invoice}; struct AmmContract { rgb_asset_balance: u64, rgb_asset_balance: u64, + dlc_contract_balance: u64, } impl AmmContract { From e086c76ce622e991358f6c9892314efbd276f9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Tue, 3 Oct 2023 07:40:34 -0300 Subject: [PATCH 10/23] Update Cargo.toml --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 24282467..02ca9b1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,10 @@ description = "AMM DEX on RGB Porotocol." license = "Apache-2.0" [memmbers] -"swap" -"dlc" -"algorithm" -"ldk" +swap +dlc +algorithm +ldk [dex dependencies] From a075a4175a686772cd290fdc52c8e6d27c2b516e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Tue, 3 Oct 2023 07:44:18 -0300 Subject: [PATCH 11/23] Update algorithm.rs --- src/dex/algorithm.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index d1a3dced..402747ad 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -20,7 +20,7 @@ // limitations under the License. use rgb_core::{Contract, ExecutionResult}; -use aluvm::{Executor, Value}; +use aluvm::{Executor, Value, Baid68}; use strict_type::{Map}; use dlc::{Message, OracleInfo, ContractInfo}; use lightning::{Message, HashPayment, Invoice}; @@ -29,6 +29,8 @@ struct AmmContract { rgb_asset_balance: u64, rgb_asset_balance: u64, dlc_contract_balance: u64, + lightning_balance: u64 + } impl AmmContract { From d5dbbe39da4389283874b9442ca8f328a8203fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Wed, 4 Oct 2023 07:18:06 -0300 Subject: [PATCH 12/23] Update algorithm.rs --- src/dex/algorithm.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 402747ad..4b2ff7b0 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -1,35 +1,35 @@ // Bitswap Core // -// SPDX-License-Identifier: Apache-2.0, MIT LICENSE, GNU General Public License version 3 +// SPDX-License-Identifier: +Business Source License 1.1 // -// Written in 2023 by 22388O +// Written in 2023 by 22388O and Rsync25 // // Copyright (C) 2023 Bitswap. All rights reserved. // Copyright (C) 2023 22388O. All rights reserved. +// Copyright (C) 2023 Rsync. All rights reserved. + // -// Licensed under the Apache License, Version 2.0 (the "License"); +// Licensed under the +Business Source License, 1.1(the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://mariadb.com/bsl11/ // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License).TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works, and to refer to it using the trademark “Business Source License”, as long as you comply with the Covenants of Licensor below use rgb_core::{Contract, ExecutionResult}; use aluvm::{Executor, Value, Baid68}; use strict_type::{Map}; use dlc::{Message, OracleInfo, ContractInfo}; -use lightning::{Message, HashPayment, Invoice}; +use lightning::{HashPayment, Invoice}; struct AmmContract { rgb_asset_balance: u64, rgb_asset_balance: u64, dlc_contract_balance: u64, - lightning_balance: u64 + lightning_balance: u64, } From e37de1cbe241e11d4051247014000d4dc14ba9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Wed, 4 Oct 2023 07:19:03 -0300 Subject: [PATCH 13/23] Update algorithm.rs --- src/dex/algorithm.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 4b2ff7b0..88684a9b 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -8,7 +8,6 @@ Business Source License 1.1 // Copyright (C) 2023 Bitswap. All rights reserved. // Copyright (C) 2023 22388O. All rights reserved. // Copyright (C) 2023 Rsync. All rights reserved. - // // Licensed under the Business Source License, 1.1(the "License"); @@ -38,6 +37,8 @@ impl AmmContract { AmmContract { rgb_asset_balance: 0, rgb_asset_balance: 0, + dlc_contract_balance: 0, + lightning_balance: 0, } } From a6aa18d2f38a23753a03b18a13908d1657d7533e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 5 Oct 2023 07:18:59 -0300 Subject: [PATCH 14/23] Update algorithm.rs --- src/dex/algorithm.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 88684a9b..5b9b30ca 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -42,9 +42,10 @@ impl AmmContract { } } - fn add_liquidity(&mut self, rgb_asset_amount: u64, rgb_asset_amount: u64) -> ExecutionResult { + fn add_liquidity(&mut self, rgb_asset_amount: u64, rgb_asset_amount: u64, lightning_balance: u64) -> ExecutionResult { self.rgb_asset_balance += rgb_asset_amount; self.rgb_asset_balance += rgb_asset_amount; + self.lightning_balance += lightning_balance; ExecutionResult::None } From 59e6e8829ee7c4127a673283d933019bd813114c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 5 Oct 2023 07:20:53 -0300 Subject: [PATCH 15/23] Update Cargo.toml --- Cargo.toml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1bf92f6e..5c1a69f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,16 +10,11 @@ description = "AMM DEX on RGB Porotocol." license = "Business Source License 1.1" [memmbers] - 22388o-patch-9 -swap -dlc -algorithm -ldk + swap = "algorithm, dlc" dlc = "message" algorithm = "amm contract" ldk = "invoice" -main [dex dependencies] From 5e1e347032bf01d69c5ec4638a64046eff3ce017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Fri, 6 Oct 2023 08:56:36 -0300 Subject: [PATCH 16/23] Update algorithm.rs --- src/dex/algorithm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 5b9b30ca..c38d890f 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -61,6 +61,7 @@ impl AmmContract { } else { self.rgb_asset_balance += rgb_asset_amount; self.rgb_asset_balance += rgb_asset_amount; + self.lightning_balance += lightning_balance; ExecutionResult::Value(Value::U64(rgb_asset_amount)) } } From c5c5a05c6daf39ca73b2ce61de26b7b9ee086fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 12 Oct 2023 06:34:57 -0300 Subject: [PATCH 17/23] Update algorithm.rs --- src/dex/algorithm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index c38d890f..6f63673b 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -49,8 +49,8 @@ impl AmmContract { ExecutionResult::None } - fn swap(&mut self, rgb_assetamount: u64, slippage: f64) -> ExecutionResult { - let usdt_amount = self.calculate_swap(rgb_asset_amount); + fn swap(&mut self, rgb_asset_amount: u64, slippage: f64, lightning_balance: u64) -> ExecutionResult { + let rgb_asset_amount = self.calculate_swap(rgb_asset_amount); let max_slippage = (rgb_asset_amount as f64) * slippage; let actual_slippage = (rgb_asset_amount as f64) - ((rgb_asset_amount as f64) * (self.rgb_asset_balance as f64) / (self.rgb_asset_balance as f64)); From f314a56cc0c1dbb75ae66a766e55226e8fc8b955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:07:54 -0300 Subject: [PATCH 18/23] Update algorithm.rs --- src/dex/algorithm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 6f63673b..3124e5b3 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -131,7 +131,7 @@ fn main() { let rgb_asset_to_swap = 1 let slippage = 0.02; // 2% maximum allowable slippage - let result = amm_contract.swap(btc_to_swap, slippage); + let result = amm_contract.swap(gb_asset_to_swap, slippage); match result { ExecutionResult::Value(value) => { From 946c79a79a929e64d6724064ddea37c9c97b47ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:22:56 -0300 Subject: [PATCH 19/23] Update algorithm.rs --- src/dex/algorithm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 3124e5b3..0da0b96d 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -29,6 +29,7 @@ struct AmmContract { rgb_asset_balance: u64, dlc_contract_balance: u64, lightning_balance: u64, + dlc_oracle: u64, } From 70ca23f9837ed95a3b6743663aa1aff5fb9a919a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Mon, 23 Oct 2023 18:32:27 -0300 Subject: [PATCH 20/23] Update algorithm.rs --- src/dex/algorithm.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 0da0b96d..728bedc8 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -29,7 +29,8 @@ struct AmmContract { rgb_asset_balance: u64, dlc_contract_balance: u64, lightning_balance: u64, - dlc_oracle: u64, + oracle_info: u64, + contract_info: u64, } @@ -40,6 +41,7 @@ impl AmmContract { rgb_asset_balance: 0, dlc_contract_balance: 0, lightning_balance: 0, + } } From ac826fba02136a438bc89210541376359cdedd17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 2 Nov 2023 06:53:49 -0300 Subject: [PATCH 21/23] Update algorithm.rs --- src/dex/algorithm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index 728bedc8..ea00fa7e 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -125,7 +125,7 @@ fn logic() { fn main() { let mut amm_contract = AmmContract::new(); - // l iquidit provision + // liquidity provision let rgb_asset_liquidity = 10; let rgb_asset_liquidity = 100; let fee_liquidity= 0.3; @@ -134,7 +134,7 @@ fn main() { let rgb_asset_to_swap = 1 let slippage = 0.02; // 2% maximum allowable slippage - let result = amm_contract.swap(gb_asset_to_swap, slippage); + let result = amm_contract.swap(rgb_asset_to_swap, slippage); match result { ExecutionResult::Value(value) => { From c78d0c5f376bf4f07ca2c45152341e006f4ab1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Sat, 11 Nov 2023 09:07:34 -0300 Subject: [PATCH 22/23] Update algorithm.rs --- src/dex/algorithm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index ea00fa7e..f887f619 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -19,7 +19,7 @@ Business Source License, 1.1(the "License"); // This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License).TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works, and to refer to it using the trademark “Business Source License”, as long as you comply with the Covenants of Licensor below use rgb_core::{Contract, ExecutionResult}; -use aluvm::{Executor, Value, Baid68}; +use aluvm::{Executor, Value, Baid68,Set_Failure}; use strict_type::{Map}; use dlc::{Message, OracleInfo, ContractInfo}; use lightning::{HashPayment, Invoice}; From 2c18b4790aa0f6675229974c429a7502195d925e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Mon, 13 Nov 2023 18:11:44 -0300 Subject: [PATCH 23/23] Update algorithm.rs --- src/dex/algorithm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dex/algorithm.rs b/src/dex/algorithm.rs index f887f619..f53f4154 100644 --- a/src/dex/algorithm.rs +++ b/src/dex/algorithm.rs @@ -20,7 +20,7 @@ Business Source License, 1.1(the "License"); use rgb_core::{Contract, ExecutionResult}; use aluvm::{Executor, Value, Baid68,Set_Failure}; -use strict_type::{Map}; +use strict_type::{Map, Base64, Base58}; use dlc::{Message, OracleInfo, ContractInfo}; use lightning::{HashPayment, Invoice};