Skip to content

Commit b0343cd

Browse files
authored
Update amm_deposit_RLUSD_XRP.js
1 parent 1ca58f6 commit b0343cd

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

js/amm_deposit_RLUSD_XRP.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,52 @@ async function depositRlusd(seed, rlusdAmount = "0.5") {
2020
console.log(`🔢 Sequence: ${sequence}`);
2121

2222
// Define RLUSD details 💲
23-
const currencyHex = "524C555344000000000000000000000000000000"; // RLUSD in Hex
24-
const issuer = "rQhWct2fv4Vc4KRjRgMrxa8xPN9Zx9iLKV";
23+
const RLUSD_CURRENCY = "524C555344000000000000000000000000000000"; // RLUSD in Hex
24+
const RLUSD_ISSUER = "rQhWct2fv4Vc4KRjRgMrxa8xPN9Zx9iLKV";
25+
26+
// Convert XRP amount to drops (to also deposit XRP)
27+
const xrpAmount = "1"; // 1 XRP to deposit as well
28+
const xrpDrops = xrpl.xrpToDrops(xrpAmount); // Convert to drops
2529

2630
// Define the AMM deposit transaction 📥
31+
// For single asset deposit, use Flags: 524288 and remove Amount2 -> only Amount
32+
// For two asset deposit, use Flags: 1048576 and include both Amount and Amount2
2733
const transaction = {
2834
TransactionType: "AMMDeposit",
2935
Account: wallet.address,
30-
Amount: {
31-
currency: currencyHex,
32-
issuer: issuer,
33-
value: rlusdAmount,
34-
},
35-
Asset: {
36-
currency: currencyHex,
37-
issuer: issuer,
38-
},
36+
Asset: { currency: "XRP" },
3937
Asset2: {
40-
currency: "XRP",
38+
currency: RLUSD_CURRENCY,
39+
issuer: RLUSD_ISSUER
4140
},
42-
Flags: 1048576, // tfSingleAsset 🚩 or tfTwoAsset if you want to deposit XRP to: 2097152
41+
Amount: xrpDrops, // XRP amount in drops
42+
Amount2: {
43+
currency: RLUSD_CURRENCY,
44+
issuer: RLUSD_ISSUER,
45+
value: rlusdAmount
46+
},
47+
Flags: 1048576, // tfTwoAsset flag (to deposit both assets) or 524288 for single asset
4348
Fee: "10",
4449
Sequence: sequence,
4550
};
4651

47-
console.log("\n💰 === Depositing RLUSD to AMM ===");
52+
console.log("\n💰 === Depositing RLUSD + XRP to AMM ===");
4853
console.log(`📌 Account: ${wallet.address}`);
4954
console.log(`💵 RLUSD Amount: ${rlusdAmount} RLUSD`);
55+
console.log(`💎 XRP Amount: ${xrpAmount} XRP`);
5056

5157
try {
5258
// Prepare and sign transaction ✍️
5359
const prepared = await client.autofill(transaction);
5460
const signed = wallet.sign(prepared);
5561
console.log("🔏 Transaction signed");
62+
5663
// Submit transaction to XRPL 🔄
5764
const response = await client.submitAndWait(signed.tx_blob);
5865

5966
if (response.result.meta.TransactionResult === "tesSUCCESS") {
6067
console.log("\n🎉 Deposit successful!");
61-
console.log(`🔗 Transaction hash: ${response.result.tx_json.hash}`);
68+
console.log(`🔗 Transaction hash: ${response.result.hash}`);
6269
return response;
6370
} else {
6471
console.log("\n❌ Deposit failed");
@@ -76,7 +83,7 @@ async function depositRlusd(seed, rlusdAmount = "0.5") {
7683
}
7784

7885
(async () => {
79-
const seed = "sEd71CfChR48xigRKg5AJcarEcgFMPk";
86+
const seed = "sEd71CfChR48xigRKg5AJcarEcgFMPk"; // rMQpZ8VS2vWNqfLjLzMgJG6n4igMAYBJPQ
8087
const rlusdAmount = "0.5";
8188
try {
8289
await depositRlusd(seed, rlusdAmount);

0 commit comments

Comments
 (0)