From 7ab11f093d3cd90edb892c3a4f928e69523fb83b Mon Sep 17 00:00:00 2001 From: Matias Poblete Date: Mon, 13 May 2024 02:29:23 -0400 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=8D=EF=B8=8FAdd=20cross=20contract=20?= =?UTF-8?q?calls=20in=20the=20router=20technical=20reference?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-technical-reference/04-SoroswapRouter.md | 75 +++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/03-technical-reference/04-SoroswapRouter.md b/03-technical-reference/04-SoroswapRouter.md index 62b0102..880b216 100644 --- a/03-technical-reference/04-SoroswapRouter.md +++ b/03-technical-reference/04-SoroswapRouter.md @@ -142,3 +142,78 @@ fn router_get_amounts_in(e: Env, amount_out: i128, path: Vec
) -> Vec[!Note] +>You can see all avaliable methods in the [Soroswap/core repo](https://github.com/soroswap/core/blob/main/contracts/router/src/lib.rs). + + +``` rust +use soroban_sdk::token::Client as TokenClient; + +// Import the router contract as .wasm +soroban_sdk::contractimport!( + file = "./soroswap_router.optimized.wasm" +); + +pub type SoroswapRouterClient<'a> = Client<'a>; + +fn my_function( + e: Env, + //{...} any other args required for your function + ) -> Result<(i128, i128, i128), ContractError> { + /* + Define the call parameters here... + */ + + //Create an instance of the router client + let soroswap_router_client = SoroswapRouterClient::new(&e, &soroswap_router_address); + //Calls the swap function + let swap = soroswap_router_client.swap_exact_tokens_for_tokens( + &amount_in, + &amount_out_min, + &path, + &to, + &deadline, + ) + + //Calls the add_liquidity function + let add_liquidty = soroswap_router_client.add_liquidity( + &token_a, + &token_b, + &amount_a, + &amount_b, + &0, + &0, + ¤t_contract, + &deadline, + ); + + //Calls the remove_liquidity function + let remove_liquidty = soroswap_router_client.remove_liquidity( + &token_a, + &token_b, + &liquidity, + &amount_a_min, + &amount_b_min, + &to, + &deadline, + ); +} +``` \ No newline at end of file From 2b8581d45cdd4660c2ec2b4c09c8b5bddea1a34e Mon Sep 17 00:00:00 2001 From: Matias Poblete Date: Mon, 13 May 2024 16:11:42 -0400 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=8D=EF=B8=8FFixed=20dependency=20name?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-technical-reference/09-using-soroswap-with-TypeScript.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/03-technical-reference/09-using-soroswap-with-TypeScript.md b/03-technical-reference/09-using-soroswap-with-TypeScript.md index 35a7f6f..c1663ab 100644 --- a/03-technical-reference/09-using-soroswap-with-TypeScript.md +++ b/03-technical-reference/09-using-soroswap-with-TypeScript.md @@ -20,13 +20,13 @@ In this guide, we will be using the ` ^11.2.2 ` version of Stellar SDK, availab To do this, we will install it as follows: ```bash -npm i soroswap-router-sdk@11.2.2 +npm i stellar-sdk@11.2.2 ``` or ```bash -yarn add soroswap-router-sdk@11.2.2 +yarn add stellar-sdk@11.2.2 ``` ### Building the transaction: From eec28be918cbe84d720622644b59c8627e20229a Mon Sep 17 00:00:00 2001 From: Matias Poblete Date: Tue, 4 Jun 2024 18:43:24 -0400 Subject: [PATCH 3/4] =?UTF-8?q?=E2=99=BB=EF=B8=8FFix=20install=20stellar?= =?UTF-8?q?=20sdk=20snippet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-technical-reference/09-using-soroswap-with-TypeScript.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/03-technical-reference/09-using-soroswap-with-TypeScript.md b/03-technical-reference/09-using-soroswap-with-TypeScript.md index c1663ab..728e62a 100644 --- a/03-technical-reference/09-using-soroswap-with-TypeScript.md +++ b/03-technical-reference/09-using-soroswap-with-TypeScript.md @@ -4,7 +4,7 @@ The Soroswap protocol allows you to interact with Stellar's smart contract platf ### Prerequisites: -Before starting, it is necessary to clarify that to understand what we are doing here, you need to have a good understanding of TypeScript, smart contracts, and how a blockchain works. In addition, you need to know how to use [stellar-sdk](https://stellar.github.io/js-stellar-sdk/#usage) since we will use its [TransactionBuilder](https://stellar.github.io/js-stellar-sdk/TransactionBuilder.html) class to create operations, simulate, sign, and send transactions. Additionally, some types and functions for transforming values. +Before starting, it is necessary to clarify that to understand what we are doing here, you need to have a good understanding of TypeScript, smart contracts, and how a blockchain works. In addition, you need to know how to use [@stellar/stellar-sdk](https://stellar.github.io/js-stellar-sdk/#usage) since we will use its [TransactionBuilder](https://stellar.github.io/js-stellar-sdk/TransactionBuilder.html) class to create operations, simulate, sign, and send transactions. Additionally, some types and functions for transforming values. >[!Tip] If you need practical examples of how to create a transaction builder or how to use the SDK in general, you can guide yourself from our projects [soroswap/core](https://github.com/soroswap/core/tree/main/scripts) and [paltalabs/mercury-client.](https://github.com/paltalabs/mercury-client) @@ -20,13 +20,13 @@ In this guide, we will be using the ` ^11.2.2 ` version of Stellar SDK, availab To do this, we will install it as follows: ```bash -npm i stellar-sdk@11.2.2 +npm i @stellar/stellar-sdk@11.2.2 ``` or ```bash -yarn add stellar-sdk@11.2.2 +yarn add @stellar/stellar-sdk@11.2.2 ``` ### Building the transaction: From b90768d5c87e669ef6dd6bf77150a04c708ab23a Mon Sep 17 00:00:00 2001 From: Matias Poblete <86752543+MattPoblete@users.noreply.github.com> Date: Thu, 21 Aug 2025 15:19:42 -0400 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=9D=20Recomend=20latest=20version?= =?UTF-8?q?=20of=20stellar=20sdk=20in=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../09-using-soroswap-with-typescript.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/01-protocol-overview/03-technical-reference/09-using-soroswap-with-typescript.md b/01-protocol-overview/03-technical-reference/09-using-soroswap-with-typescript.md index 7a95692..f9291fb 100644 --- a/01-protocol-overview/03-technical-reference/09-using-soroswap-with-typescript.md +++ b/01-protocol-overview/03-technical-reference/09-using-soroswap-with-typescript.md @@ -14,16 +14,16 @@ Before starting, it is necessary to clarify that to understand what we are doing #### Installing Stellar SDK -In this guide, we will be using the `^11.2.2` version of Stellar SDK, available through npm or yarn as["@stellar/stellar-sdk"](https://www.npmjs.com/package/@stellar/stellar-sdk). To do this, we will install it as follows: +In this guide, we will be using the `latest` version of Stellar SDK, available through npm or yarn as["@stellar/stellar-sdk"](https://www.npmjs.com/package/@stellar/stellar-sdk). To do this, we will install it as follows: ```bash -npm i @stellar/stellar-sdk@11.2.2 +npm i @stellar/stellar-sdk@latest ``` or ```bash -yarn add @stellar/stellar-sdk@11.2.2 +yarn add @stellar/stellar-sdk@latest ``` ### Building the transaction: