Skip to content

Commit 81efcf5

Browse files
committed
💱 DEX code examples setup
No known existing community opinions or best practices on the java syntax per https://discord.com/channels/897514728459468821/966788672164855829/1314630372042084534 in re stellar#1044. I know some of the existing pages have been loosely casted, but there seem to be a lot of new users complaining about Docs examples not compiling or running locally given test data.
1 parent ddd80c6 commit 81efcf5

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed
+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
---
2-
title: Payment Liquidity
2+
title: Conversion Liquidity
33
sidebar_position: 90
44
---
55

66
import DocCardList from "@theme/DocCardList";
77

8-
{_/ Opt. do as "Conversion" liquidirty _/}
9-
10-
Native network markets, liquidity, and conversions for all assets.
8+
Native network markets, liquidity, and exchange for all assets.
119

1210
<DocCardList />

‎docs/learn/encyclopedia/sdex/liquidity-on-stellar-sdex-liquidity-pools.mdx

+30-18
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ server = Server("https://horizon-testnet.stellar.org")
4444
privateKey = "SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB"
4545
publicKey = "GBRPYHIL2CI3R5N4A7WMBETDZQ24DXFQGNCJWHXPFRGFWZHJZZBDTWR2"
4646

47-
# Asset config
47+
# Asset setup
4848
astroDollar = Asset("AstroDollar", "GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7")
4949
astroPeso = Asset("AstroPeso", "GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5")
5050

@@ -72,7 +72,7 @@ const server = new Server("https://horizon-testnet.stellar.org");
7272
const privateKey = "SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB";
7373
const publicKey = "GBRPYHIL2CI3R5N4A7WMBETDZQ24DXFQGNCJWHXPFRGFWZHJZZBDTWR2";
7474

75-
// Asset config
75+
// Asset setup
7676
const astroDollar = new Asset(
7777
"AstroDollar",
7878
"GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7",
@@ -82,25 +82,39 @@ const astroPeso = new Asset(
8282
"GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5",
8383
);
8484

85-
// pending newTxEnvelope(..)
85+
function newTxBuilder(source, signer, ...ops) {
86+
let tx = new sdk.TransactionBuilder(source, {
87+
fee: sdk.BASE_FEE,
88+
networkPassphrase: sdk.Networks.TESTNET,
89+
});
90+
ops.forEach((op) => tx.addOperation(op));
91+
tx = tx.setTimeout(360).build();
92+
tx.sign(signer);
93+
return tx;
94+
}
8695
```
8796

8897
```java
8998
import org.stellar.sdk.*;
9099
import org.stellar.sdk.responses.AccountResponse;
91100
import org.stellar.sdk.responses.SubmitTransactionResponse;
92101

93-
94102
public class Liquidity {
95103
static final Server server = new Server("https://horizon-testnet.stellar.org");
96104

97105
// Account setup
98106
static String privateKey = "SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB";
99107
static String publicKey = "GBRPYHIL2CI3R5N4A7WMBETDZQ24DXFQGNCJWHXPFRGFWZHJZZBDTWR2";
100108

101-
// Asset config
102-
Asset astroDollar = new AssetTypeCreditAlphaNum4("AstroDollar", "GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7");
103-
Asset astroPeso = new AssetTypeCreditAlphaNum4("AstroPeso", "GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5");
109+
// Asset setup
110+
Asset astroDollar = new AssetTypeCreditAlphaNum4(
111+
"AstroDollar",
112+
"GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7"
113+
);
114+
Asset astroPeso = new AssetTypeCreditAlphaNum4(
115+
"AstroPeso",
116+
"GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5"
117+
);
104118

105119
public static Transaction.Builder newTxBuilder(KeyPair source) {
106120
AccountResponse sourceAccount = server.accounts().account(source.getAccountId());
@@ -112,6 +126,15 @@ public class Liquidity {
112126
```
113127

114128
```go
129+
import (
130+
"fmt"
131+
"strconv"
132+
"github.com/stellar/go/keypair"
133+
"github.com/stellar/go/txnbuild"
134+
"github.com/stellar/go/clients/horizonclient"
135+
"github.com/stellar/go/network"
136+
)
137+
115138
func main() {
116139
// Account setup
117140
privateKey := "SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB"
@@ -819,17 +842,6 @@ const [A, B] = orderAssets(
819842
new sdk.Asset("B", kp0.publicKey()),
820843
);
821844

822-
function newTxBuilder(source, signer, ...ops) {
823-
let tx = new sdk.TransactionBuilder(source, {
824-
fee: sdk.BASE_FEE,
825-
networkPassphrase: sdk.Networks.TESTNET,
826-
});
827-
ops.forEach((op) => tx.addOperation(op));
828-
tx = tx.setTimeout(360).build();
829-
tx.sign(signer);
830-
return tx;
831-
}
832-
833845
// Establishes trustlines and funds `recipientKps` for all `assets`
834846
function distributeAssets(issuerKp, recipientKps, ...assets) {
835847
return server.loadAccount(issuerKp.publicKey()).then((issuer) => {

0 commit comments

Comments
 (0)