From 81efcf599e00dc601c886bc928bdad7c09b05e1c Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Sun, 8 Dec 2024 09:18:15 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=B1=20DEX=20code=20examples=20setup=20?= =?UTF-8?q?No=20known=20existing=20community=20opinions=20or=20best=20prac?= =?UTF-8?q?tices=20on=20the=20java=20syntax=20per=20https://discord.com/ch?= =?UTF-8?q?annels/897514728459468821/966788672164855829/131463037204208453?= =?UTF-8?q?4=20in=20re=20#1044.=20I=20know=20some=20of=20the=20existing=20?= =?UTF-8?q?pages=20have=20been=20loosely=20casted,=20but=20there=20seem=20?= =?UTF-8?q?to=20be=20a=20lot=20of=20new=20users=20complaining=20about=20Do?= =?UTF-8?q?cs=20examples=20not=20compiling=20or=20running=20locally=20give?= =?UTF-8?q?n=20test=20data.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/learn/encyclopedia/sdex/README.mdx | 6 +-- ...uidity-on-stellar-sdex-liquidity-pools.mdx | 48 ++++++++++++------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/docs/learn/encyclopedia/sdex/README.mdx b/docs/learn/encyclopedia/sdex/README.mdx index e7fe52e39..a7e42ce89 100644 --- a/docs/learn/encyclopedia/sdex/README.mdx +++ b/docs/learn/encyclopedia/sdex/README.mdx @@ -1,12 +1,10 @@ --- -title: Payment Liquidity +title: Conversion Liquidity sidebar_position: 90 --- import DocCardList from "@theme/DocCardList"; -{_/ Opt. do as "Conversion" liquidirty _/} - -Native network markets, liquidity, and conversions for all assets. +Native network markets, liquidity, and exchange for all assets. diff --git a/docs/learn/encyclopedia/sdex/liquidity-on-stellar-sdex-liquidity-pools.mdx b/docs/learn/encyclopedia/sdex/liquidity-on-stellar-sdex-liquidity-pools.mdx index 244996c63..7261e77a1 100644 --- a/docs/learn/encyclopedia/sdex/liquidity-on-stellar-sdex-liquidity-pools.mdx +++ b/docs/learn/encyclopedia/sdex/liquidity-on-stellar-sdex-liquidity-pools.mdx @@ -44,7 +44,7 @@ server = Server("https://horizon-testnet.stellar.org") privateKey = "SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB" publicKey = "GBRPYHIL2CI3R5N4A7WMBETDZQ24DXFQGNCJWHXPFRGFWZHJZZBDTWR2" -# Asset config +# Asset setup astroDollar = Asset("AstroDollar", "GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7") astroPeso = Asset("AstroPeso", "GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5") @@ -72,7 +72,7 @@ const server = new Server("https://horizon-testnet.stellar.org"); const privateKey = "SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB"; const publicKey = "GBRPYHIL2CI3R5N4A7WMBETDZQ24DXFQGNCJWHXPFRGFWZHJZZBDTWR2"; -// Asset config +// Asset setup const astroDollar = new Asset( "AstroDollar", "GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7", @@ -82,7 +82,16 @@ const astroPeso = new Asset( "GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5", ); -// pending newTxEnvelope(..) +function newTxBuilder(source, signer, ...ops) { + let tx = new sdk.TransactionBuilder(source, { + fee: sdk.BASE_FEE, + networkPassphrase: sdk.Networks.TESTNET, + }); + ops.forEach((op) => tx.addOperation(op)); + tx = tx.setTimeout(360).build(); + tx.sign(signer); + return tx; +} ``` ```java @@ -90,7 +99,6 @@ import org.stellar.sdk.*; import org.stellar.sdk.responses.AccountResponse; import org.stellar.sdk.responses.SubmitTransactionResponse; - public class Liquidity { static final Server server = new Server("https://horizon-testnet.stellar.org"); @@ -98,9 +106,15 @@ public class Liquidity { static String privateKey = "SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB"; static String publicKey = "GBRPYHIL2CI3R5N4A7WMBETDZQ24DXFQGNCJWHXPFRGFWZHJZZBDTWR2"; - // Asset config - Asset astroDollar = new AssetTypeCreditAlphaNum4("AstroDollar", "GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7"); - Asset astroPeso = new AssetTypeCreditAlphaNum4("AstroPeso", "GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5"); + // Asset setup + Asset astroDollar = new AssetTypeCreditAlphaNum4( + "AstroDollar", + "GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7" + ); + Asset astroPeso = new AssetTypeCreditAlphaNum4( + "AstroPeso", + "GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5" + ); public static Transaction.Builder newTxBuilder(KeyPair source) { AccountResponse sourceAccount = server.accounts().account(source.getAccountId()); @@ -112,6 +126,15 @@ public class Liquidity { ``` ```go +import ( + "fmt" + "strconv" + "github.com/stellar/go/keypair" + "github.com/stellar/go/txnbuild" + "github.com/stellar/go/clients/horizonclient" + "github.com/stellar/go/network" +) + func main() { // Account setup privateKey := "SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB" @@ -819,17 +842,6 @@ const [A, B] = orderAssets( new sdk.Asset("B", kp0.publicKey()), ); -function newTxBuilder(source, signer, ...ops) { - let tx = new sdk.TransactionBuilder(source, { - fee: sdk.BASE_FEE, - networkPassphrase: sdk.Networks.TESTNET, - }); - ops.forEach((op) => tx.addOperation(op)); - tx = tx.setTimeout(360).build(); - tx.sign(signer); - return tx; -} - // Establishes trustlines and funds `recipientKps` for all `assets` function distributeAssets(issuerKp, recipientKps, ...assets) { return server.loadAccount(issuerKp.publicKey()).then((issuer) => {