Skip to content

Commit dcbdd52

Browse files
JFWooten4ElliotFriend
authored andcommitted
💱 Optimize, clarify global declarations
It could be prudent to globalize the accounts so that we can walk through the other limit order examples
1 parent 35866ad commit dcbdd52

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
2-
title: Trading Liquidity
2+
title: Payment Liquidity
33
sidebar_position: 90
44
---
55

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

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

1012
<DocCardList />

docs/learn/fundamentals/liquidity-on-stellar-sdex-liquidity-pools.mdx

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import org.stellar.sdk.*;
9595
import org.stellar.sdk.responses.AccountResponse;
9696
import org.stellar.sdk.responses.SubmitTransactionResponse;
9797

98+
9899
public class Liquidity {
99100
static final Server server = new Server("https://horizon-testnet.stellar.org");
100101

@@ -116,20 +117,6 @@ public class Liquidity {
116117
```
117118

118119
```go
119-
package main
120-
121-
import (
122-
"fmt"
123-
"github.com/stellar/go/build"
124-
"github.com/stellar/go/clients/horizonclient"
125-
"github.com/stellar/go/keypair"
126-
"github.com/stellar/go/network"
127-
"github.com/stellar/go/protocols/horizon"
128-
"github.com/stellar/go/txnbuild"
129-
)
130-
131-
var server = horizonclient.DefaultTestNetClient
132-
133120
func main() {
134121
// Account setup
135122
privateKey := "SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB"
@@ -164,6 +151,7 @@ func newTxBuilder(pubKey string) (*txnbuild.Transaction, error) {
164151
<CodeExample>
165152

166153
```python
154+
# rpl with the txBuilderHerlperEnv
167155
transaction = TransactionBuilder(
168156
source_account = account,
169157
network_passphrase = Network.TESTNET_NETWORK_PASSPHRASE,
@@ -175,8 +163,8 @@ transaction = TransactionBuilder(
175163
price = "20.0" # 20 Pesos per Dollar
176164
).set_timeout(360).build()
177165

178-
keypair = Keypair.from_secret(privateKey) transaction.sign(keypair)
179-
166+
keypair = Keypair.from_secret(privateKey)
167+
transaction.sign(keypair)
180168
response = server.submit_transaction(transaction)
181169

182170
print(f"Transaction successful: {response['successful']}")
@@ -219,6 +207,8 @@ print(f"Offer ID: {response['result_xdr']}")
219207

220208
```java
221209

210+
211+
main{{
222212
AccountResponse account = server.accounts().account(publicKey);
223213

224214
Transaction transaction = new TransactionBuilder(account, Network.TESTNET)
@@ -243,6 +233,8 @@ print(f"Offer ID: {response['result_xdr']}")
243233
```
244234

245235
```go
236+
237+
main {{?
246238
request := horizonclient.AccountRequest{AccountID: publicKey}
247239
account, err := server.AccountDetail(request)
248240
check(err)
@@ -1147,7 +1139,7 @@ public static SubmitTransactionResponse addLiquidity(
11471139
KeyPair source,
11481140
String poolId,
11491141
String maxReserveA,
1150-
String maxReserveB
1142+
String maxReserveB,
11511143
) throws Exception {
11521144
double exactPrice = Double.parseDouble(maxReserveA) / Double.parseDouble(maxReserveB);
11531145
double minPrice = exactPrice - exactPrice * 0.1;
@@ -1551,12 +1543,12 @@ public static void main(String[] args) throws Exception {
15511543
balance ->
15521544
"liquidity_pool_shares".equals(balance.getAssetType()) &&
15531545
poolId.equals(balance.getLiquidityPoolId())
1554-
)å
1546+
)
15551547
.mapToDouble(balance -> Double.parseDouble(balance.getBalance()))
15561548
.findFirst();
15571549
if (!balance.isPresent()) {
15581550
throw new Exception("No liquidity pool shares found for kp1");
1559-
1551+
}
15601552
removeLiquidity(kp1, poolId, balance);
15611553
getSpotPrice();
15621554
}

0 commit comments

Comments
 (0)