@@ -95,6 +95,7 @@ import org.stellar.sdk.*;
9595import org.stellar.sdk.responses.AccountResponse ;
9696import org.stellar.sdk.responses.SubmitTransactionResponse ;
9797
98+
9899public 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-
133120func 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
167155transaction = 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)
180168response = server.submit_transaction(transaction)
181169
182170print (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