@across-protocol/contracts 4.0.11 → 4.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/scripts/svm/{enableRoute.js → createVault.js} +13 -35
  2. package/dist/scripts/svm/fakeFillWithRandomDistribution.js +9 -8
  3. package/dist/scripts/svm/nativeDeposit.js +138 -0
  4. package/dist/scripts/svm/queryEventsV2.js +3 -3
  5. package/dist/scripts/svm/{queryRoute.js → queryVault.js} +10 -25
  6. package/dist/scripts/svm/remoteHubPoolPauseDeposits.js +2 -2
  7. package/dist/scripts/svm/simpleDeposit.js +3 -12
  8. package/dist/scripts/svm/simpleFakeRelayerRepayment.js +2 -9
  9. package/dist/scripts/svm/simpleFill.js +3 -2
  10. package/dist/src/svm/assets/idl/svm_spoke.json +43 -369
  11. package/dist/src/svm/assets/svm_spoke.d.ts +40 -366
  12. package/dist/src/svm/clients/SvmSpoke/accounts/index.d.ts +0 -1
  13. package/dist/src/svm/clients/SvmSpoke/accounts/index.js +0 -1
  14. package/dist/src/svm/clients/SvmSpoke/errors/svmSpoke.d.ts +3 -1
  15. package/dist/src/svm/clients/SvmSpoke/errors/svmSpoke.js +4 -1
  16. package/dist/src/svm/clients/SvmSpoke/instructions/deposit.d.ts +21 -13
  17. package/dist/src/svm/clients/SvmSpoke/instructions/deposit.js +38 -6
  18. package/dist/src/svm/clients/SvmSpoke/instructions/depositNow.d.ts +21 -13
  19. package/dist/src/svm/clients/SvmSpoke/instructions/depositNow.js +38 -6
  20. package/dist/src/svm/clients/SvmSpoke/instructions/fillRelay.d.ts +20 -16
  21. package/dist/src/svm/clients/SvmSpoke/instructions/fillRelay.js +6 -1
  22. package/dist/src/svm/clients/SvmSpoke/instructions/index.d.ts +0 -1
  23. package/dist/src/svm/clients/SvmSpoke/instructions/index.js +0 -1
  24. package/dist/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.d.ts +21 -13
  25. package/dist/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.js +38 -6
  26. package/dist/src/svm/clients/SvmSpoke/programs/svmSpoke.d.ts +6 -10
  27. package/dist/src/svm/clients/SvmSpoke/programs/svmSpoke.js +5 -13
  28. package/dist/src/svm/clients/SvmSpoke/types/index.d.ts +0 -1
  29. package/dist/src/svm/clients/SvmSpoke/types/index.js +0 -1
  30. package/dist/src/svm/web3-v1/helpers.d.ts +114 -1
  31. package/dist/src/svm/web3-v1/helpers.js +179 -1
  32. package/dist/target/types/svm_spoke.d.ts +40 -366
  33. package/dist/test/svm/SvmSpoke.Deposit.js +143 -176
  34. package/dist/test/svm/SvmSpoke.Fill.AcrossPlus.js +20 -17
  35. package/dist/test/svm/SvmSpoke.Fill.js +52 -38
  36. package/dist/test/svm/SvmSpoke.HandleReceiveMessage.js +2 -114
  37. package/dist/test/svm/SvmSpoke.SlowFill.AcrossPlus.js +2 -2
  38. package/dist/test/svm/SvmSpoke.SlowFill.js +37 -34
  39. package/dist/test/svm/SvmSpoke.common.d.ts +2 -3
  40. package/dist/test/svm/SvmSpoke.common.js +3 -12
  41. package/package.json +1 -1
  42. package/dist/scripts/svm/remoteHubPoolSetDepositRoute.d.ts +0 -1
  43. package/dist/scripts/svm/remoteHubPoolSetDepositRoute.js +0 -252
  44. package/dist/src/svm/clients/SvmSpoke/accounts/route.d.ts +0 -27
  45. package/dist/src/svm/clients/SvmSpoke/accounts/route.js +0 -66
  46. package/dist/src/svm/clients/SvmSpoke/instructions/setEnableRoute.d.ts +0 -95
  47. package/dist/src/svm/clients/SvmSpoke/instructions/setEnableRoute.js +0 -213
  48. package/dist/src/svm/clients/SvmSpoke/types/enabledDepositRoute.d.ts +0 -21
  49. package/dist/src/svm/clients/SvmSpoke/types/enabledDepositRoute.js +0 -30
  50. package/dist/test/svm/SvmSpoke.Routes.js +0 -167
  51. /package/dist/scripts/svm/{enableRoute.d.ts → createVault.d.ts} +0 -0
  52. /package/dist/scripts/svm/{queryRoute.d.ts → nativeDeposit.d.ts} +0 -0
  53. /package/dist/{test/svm/SvmSpoke.Routes.d.ts → scripts/svm/queryVault.d.ts} +0 -0
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
- // This script is used by a chain admin to enable or disable a route for a token on the Solana Spoke Pool.
2
+ // This script can be used by a anyone to create a vault for a token on the Solana Spoke Pool. Note that this is a
3
+ // permissionless operation, only requiring the caller to spend rent-exempt deposit to create the vault account that is
4
+ // not recoverable. Similar to other chains, this enables one to deposit and fill non-whitelisted tokens.
3
5
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
6
  if (k2 === undefined) k2 = k;
5
7
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -37,59 +39,35 @@ const web3_v1_1 = require("../../src/svm/web3-v1");
37
39
  // Set up the provider
38
40
  const provider = anchor_1.AnchorProvider.env();
39
41
  anchor.setProvider(provider);
42
+ const payer = anchor.AnchorProvider.env().wallet.payer;
40
43
  const program = (0, web3_v1_1.getSpokePoolProgram)(provider);
41
44
  const programId = program.programId;
42
45
  console.log("SVM-Spoke Program ID:", programId.toString());
43
46
  // Parse arguments
44
47
  const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
45
48
  .option("seed", { type: "string", demandOption: true, describe: "Seed for the state account PDA" })
46
- .option("originToken", { type: "string", demandOption: true, describe: "Origin token public key" })
47
- .option("chainId", { type: "string", demandOption: true, describe: "Chain ID" })
48
- .option("enabled", { type: "boolean", demandOption: true, describe: "Enable or disable the route" }).argv;
49
- async function enableRoute() {
49
+ .option("originToken", { type: "string", demandOption: true, describe: "Origin token public key" }).argv;
50
+ async function createVault() {
50
51
  const resolvedArgv = await argv;
51
52
  const seed = new anchor_1.BN(resolvedArgv.seed);
52
53
  const originToken = new web3_js_1.PublicKey(resolvedArgv.originToken);
53
- const chainId = new anchor_1.BN(resolvedArgv.chainId);
54
- const enabled = resolvedArgv.enabled;
55
54
  // Define the state account PDA
56
55
  const [statePda, _] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("state"), seed.toArrayLike(Buffer, "le", 8)], programId);
57
- // Define the route account PDA
58
- const [routePda] = web3_js_1.PublicKey.findProgramAddressSync([
59
- Buffer.from("route"),
60
- originToken.toBytes(),
61
- seed.toArrayLike(Buffer, "le", 8),
62
- chainId.toArrayLike(Buffer, "le", 8),
63
- ], programId);
64
56
  // Define the signer (replace with your actual signer)
65
57
  const signer = provider.wallet.publicKey;
66
- console.log("Enabling route...");
58
+ console.log("Creating vault...");
67
59
  console.table([
68
60
  { Property: "seed", Value: seed.toString() },
69
61
  { Property: "originToken", Value: originToken.toString() },
70
- { Property: "chainId", Value: chainId.toString() },
71
- { Property: "enabled", Value: enabled },
72
62
  { Property: "programId", Value: programId.toString() },
73
63
  { Property: "providerPublicKey", Value: provider.wallet.publicKey.toString() },
74
64
  { Property: "statePda", Value: statePda.toString() },
75
- { Property: "routePda", Value: routePda.toString() },
76
65
  ]);
77
66
  // Create ATA for the origin token to be stored by state (vault).
78
- const vault = (0, spl_token_1.getAssociatedTokenAddressSync)(originToken, statePda, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
79
- const tx = await program.methods.setEnableRoute(originToken, chainId, enabled)
80
- .accounts({
81
- signer: signer,
82
- payer: signer,
83
- state: statePda,
84
- route: routePda,
85
- vault: vault,
86
- originTokenMint: originToken,
87
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
88
- associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
89
- systemProgram: web3_js_1.SystemProgram.programId,
90
- })
91
- .rpc();
92
- console.log("Transaction signature:", tx);
67
+ const vault = await (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, originToken, statePda, true, "confirmed", {
68
+ commitment: "confirmed",
69
+ }, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
70
+ console.log("Created vault:", vault.address.toString());
93
71
  }
94
- // Run the enableRoute function
95
- enableRoute();
72
+ // Run the createVault function
73
+ createVault();
@@ -58,7 +58,7 @@ const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
58
58
  .option("repaymentAddress", { type: "string", demandOption: false, description: "Repayment address" })
59
59
  .option("distributionCount", { type: "number", demandOption: false, describe: "Distribution count" })
60
60
  .option("bufferParams", { type: "boolean", demandOption: false, describe: "Use buffer account for params" }).argv;
61
- async function fillV3RelayToRandom() {
61
+ async function fillRelayToRandom() {
62
62
  const resolvedArgv = await argv;
63
63
  const depositor = new web3_js_1.PublicKey(resolvedArgv.depositor);
64
64
  const handler = new web3_js_1.PublicKey(resolvedArgv.handler);
@@ -120,7 +120,7 @@ async function fillV3RelayToRandom() {
120
120
  exclusivityDeadline,
121
121
  message: encodedMessage,
122
122
  };
123
- console.log("Filling V3 Relay with handler...");
123
+ console.log("Filling Relay with handler...");
124
124
  // Define the state account PDA
125
125
  const [statePda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("state"), seed.toArrayLike(Buffer, "le", 8)], programId);
126
126
  // Fetch the state from the on-chain program to get chainId
@@ -151,17 +151,18 @@ async function fillV3RelayToRandom() {
151
151
  // Delegate state PDA to pull relayer tokens.
152
152
  const approveInstruction = await (0, spl_token_1.createApproveCheckedInstruction)(relayerTokenAccount, outputToken, statePda, signer.publicKey, BigInt(relayData.outputAmount.toString()), tokenDecimals, undefined, spl_token_1.TOKEN_PROGRAM_ID);
153
153
  // Prepare fill instruction as we will need to use Address Lookup Table (ALT).
154
- const fillV3RelayValues = [relayHash, relayData, repaymentChain, repaymentAddress];
154
+ const fillRelayValues = [relayHash, relayData, repaymentChain, repaymentAddress];
155
155
  if (bufferParams) {
156
- await (0, web3_v1_1.loadFillRelayParams)(program, signer, fillV3RelayValues[1], fillV3RelayValues[2], fillV3RelayValues[3]);
156
+ await (0, web3_v1_1.loadFillRelayParams)(program, signer, fillRelayValues[1], fillRelayValues[2], fillRelayValues[3]);
157
157
  }
158
- const fillV3RelayParams = bufferParams ? [fillV3RelayValues[0], null, null, null] : fillV3RelayValues;
158
+ const fillRelayParams = bufferParams ? [fillRelayValues[0], null, null, null] : fillRelayValues;
159
159
  const [instructionParams] = bufferParams
160
160
  ? web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("instruction_params"), signer.publicKey.toBuffer()], program.programId)
161
161
  : [program.programId];
162
162
  const fillAccounts = {
163
163
  state: statePda,
164
164
  signer: signer.publicKey,
165
+ delegate: (0, web3_v1_1.getFillRelayDelegatePda)(relayHashUint8Array, repaymentChain, repaymentAddress, program.programId).pda,
165
166
  instructionParams,
166
167
  mint: outputToken,
167
168
  relayerTokenAccount,
@@ -177,7 +178,7 @@ async function fillV3RelayToRandom() {
177
178
  ...multicallHandlerCoder.compiledKeyMetas,
178
179
  ];
179
180
  const fillInstruction = await program.methods
180
- .fillRelay(...fillV3RelayParams)
181
+ .fillRelay(...fillRelayParams)
181
182
  .accounts(fillAccounts)
182
183
  .remainingAccounts(remainingAccounts)
183
184
  .instruction();
@@ -185,5 +186,5 @@ async function fillV3RelayToRandom() {
185
186
  const { txSignature } = await (0, web3_v1_1.sendTransactionWithLookupTable)(provider.connection, [approveInstruction, fillInstruction], signer);
186
187
  console.log("Transaction signature:", txSignature);
187
188
  }
188
- // Run the fillV3RelayToRandom function
189
- fillV3RelayToRandom();
189
+ // Run the fillRelayToRandom function
190
+ fillRelayToRandom();
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ // This script is used to initiate a native token Solana deposit. useful in testing.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ const anchor = __importStar(require("@coral-xyz/anchor"));
31
+ const anchor_1 = require("@coral-xyz/anchor");
32
+ const spl_token_1 = require("@solana/spl-token");
33
+ const web3_js_1 = require("@solana/web3.js");
34
+ const yargs_1 = __importDefault(require("yargs"));
35
+ const helpers_1 = require("yargs/helpers");
36
+ const web3_v1_1 = require("../../src/svm/web3-v1");
37
+ // Set up the provider
38
+ const provider = anchor_1.AnchorProvider.env();
39
+ anchor.setProvider(provider);
40
+ const program = (0, web3_v1_1.getSpokePoolProgram)(provider);
41
+ const programId = program.programId;
42
+ console.log("SVM-Spoke Program ID:", programId.toString());
43
+ // Parse arguments
44
+ const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
45
+ .option("recipient", { type: "string", demandOption: true, describe: "Recipient public key" })
46
+ .option("outputToken", { type: "string", demandOption: true, describe: "Output token public key" })
47
+ .option("inputAmount", { type: "number", demandOption: true, describe: "Input amount" })
48
+ .option("outputAmount", { type: "number", demandOption: true, describe: "Output amount" })
49
+ .option("destinationChainId", { type: "string", demandOption: true, describe: "Destination chain ID" })
50
+ .option("integratorId", { type: "string", demandOption: false, describe: "integrator ID" }).argv;
51
+ async function nativeDeposit() {
52
+ const resolvedArgv = await argv;
53
+ const seed = web3_v1_1.SOLANA_SPOKE_STATE_SEED;
54
+ const recipient = new web3_js_1.PublicKey(resolvedArgv.recipient);
55
+ const inputToken = spl_token_1.NATIVE_MINT;
56
+ const outputToken = new web3_js_1.PublicKey(resolvedArgv.outputToken);
57
+ const inputAmount = new anchor_1.BN(resolvedArgv.inputAmount);
58
+ const outputAmount = new anchor_1.BN(resolvedArgv.outputAmount);
59
+ const destinationChainId = new anchor_1.BN(resolvedArgv.destinationChainId);
60
+ const exclusiveRelayer = web3_js_1.PublicKey.default;
61
+ const quoteTimestamp = Math.floor(Date.now() / 1000) - 1;
62
+ const fillDeadline = quoteTimestamp + 3600; // 1 hour from now
63
+ const exclusivityDeadline = 0;
64
+ const message = Buffer.from([]); // Convert to Buffer
65
+ const integratorId = resolvedArgv.integratorId || "";
66
+ // Define the state account PDA
67
+ const [statePda, _] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("state"), seed.toArrayLike(Buffer, "le", 8)], programId);
68
+ // Define the signer (replace with your actual signer)
69
+ const signer = provider.wallet.payer;
70
+ // Find ATA for the input token to be stored by state (vault).
71
+ const vault = (0, spl_token_1.getAssociatedTokenAddressSync)(inputToken, statePda, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
72
+ const userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(inputToken, signer.publicKey);
73
+ const userTokenAccountInfo = await provider.connection.getAccountInfo(userTokenAccount);
74
+ const existingTokenAccount = userTokenAccountInfo !== null && userTokenAccountInfo.owner.equals(spl_token_1.TOKEN_PROGRAM_ID);
75
+ console.log("Depositing...");
76
+ console.table([
77
+ { property: "seed", value: seed.toString() },
78
+ { property: "recipient", value: recipient.toString() },
79
+ { property: "inputToken", value: inputToken.toString() },
80
+ { property: "outputToken", value: outputToken.toString() },
81
+ { property: "inputAmount", value: inputAmount.toString() },
82
+ { property: "outputAmount", value: outputAmount.toString() },
83
+ { property: "destinationChainId", value: destinationChainId.toString() },
84
+ { property: "quoteTimestamp", value: quoteTimestamp.toString() },
85
+ { property: "fillDeadline", value: fillDeadline.toString() },
86
+ { property: "exclusivityDeadline", value: exclusivityDeadline.toString() },
87
+ { property: "message", value: message.toString("hex") },
88
+ { property: "integratorId", value: integratorId },
89
+ { property: "programId", value: programId.toString() },
90
+ { property: "providerPublicKey", value: provider.wallet.publicKey.toString() },
91
+ { property: "statePda", value: statePda.toString() },
92
+ { property: "vault", value: vault.toString() },
93
+ { property: "userTokenAccount", value: userTokenAccount.toString() },
94
+ { property: "existingTokenAccount", value: existingTokenAccount },
95
+ ]);
96
+ const tokenDecimals = (await (0, spl_token_1.getMint)(provider.connection, inputToken, undefined, spl_token_1.TOKEN_PROGRAM_ID)).decimals;
97
+ // Will need to add rent exemption to the deposit amount if the user token account does not exist.
98
+ const rentExempt = existingTokenAccount ? 0 : await (0, spl_token_1.getMinimumBalanceForRentExemptAccount)(provider.connection);
99
+ const transferIx = web3_js_1.SystemProgram.transfer({
100
+ fromPubkey: signer.publicKey,
101
+ toPubkey: userTokenAccount,
102
+ lamports: BigInt(inputAmount.toString()) + BigInt(rentExempt),
103
+ });
104
+ // Create wSOL user account if it doesn't exist, otherwise sync its native balance.
105
+ const syncOrCreateIx = existingTokenAccount
106
+ ? (0, spl_token_1.createSyncNativeInstruction)(userTokenAccount)
107
+ : (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(signer.publicKey, userTokenAccount, signer.publicKey, inputToken);
108
+ // Close the user token account if it did not exist before.
109
+ const lastIxs = existingTokenAccount
110
+ ? []
111
+ : [(0, spl_token_1.createCloseAccountInstruction)(userTokenAccount, signer.publicKey, signer.publicKey)];
112
+ // Delegate state PDA to pull depositor tokens.
113
+ const approveIx = await (0, spl_token_1.createApproveCheckedInstruction)(userTokenAccount, inputToken, statePda, signer.publicKey, BigInt(inputAmount.toString()), tokenDecimals, undefined, spl_token_1.TOKEN_PROGRAM_ID);
114
+ const depositIx = await program.methods.deposit(signer.publicKey, recipient, inputToken, outputToken, inputAmount, outputAmount, destinationChainId, exclusiveRelayer, quoteTimestamp, fillDeadline, exclusivityDeadline, message)
115
+ .accounts({
116
+ state: statePda,
117
+ signer: signer.publicKey,
118
+ userTokenAccount,
119
+ vault: vault,
120
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
121
+ mint: inputToken,
122
+ })
123
+ .instruction();
124
+ // Create the deposit transaction
125
+ const depositTx = new web3_js_1.Transaction().add(transferIx, syncOrCreateIx, approveIx, depositIx, ...lastIxs);
126
+ if (integratorId !== "") {
127
+ const MemoIx = new web3_js_1.TransactionInstruction({
128
+ keys: [{ pubkey: signer.publicKey, isSigner: true, isWritable: true }],
129
+ data: Buffer.from(integratorId, "utf-8"),
130
+ programId: new web3_js_1.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"), // Memo program ID
131
+ });
132
+ depositTx.add(MemoIx);
133
+ }
134
+ const tx = await (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, depositTx, [signer]);
135
+ console.log("Transaction signature:", tx);
136
+ }
137
+ // Run the nativeDeposit function
138
+ nativeDeposit();
@@ -20,8 +20,8 @@ const argvPromise = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
20
20
  describe: "Name of the event to query",
21
21
  choices: [
22
22
  "any",
23
- "FilledV3Relay",
24
- "V3FundsDeposited",
23
+ "FilledRelay",
24
+ "FundsDeposited",
25
25
  "EnabledDepositRoute",
26
26
  "RelayedRootBundle",
27
27
  "ExecutedRelayerRefundRoot",
@@ -30,7 +30,7 @@ const argvPromise = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
30
30
  "PausedFills",
31
31
  "SetXDomainAdmin",
32
32
  "EmergencyDeletedRootBundle",
33
- "RequestedV3SlowFill",
33
+ "RequestedSlowFill",
34
34
  "ClaimedRelayerRefund",
35
35
  "TokensBridged",
36
36
  ],
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // This script fetches route information for a given spoke pool, originToken and chainId.
2
+ // This script fetches vault information for a given spoke pool and originToken.
3
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
4
  if (k2 === undefined) k2 = k;
5
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -43,51 +43,36 @@ console.log("SVM-Spoke Program ID:", programId.toString());
43
43
  // Parse arguments
44
44
  const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
45
45
  .option("seed", { type: "string", demandOption: true, describe: "Seed for the state account PDA" })
46
- .option("originToken", { type: "string", demandOption: true, describe: "Origin token public key" })
47
- .option("chainId", { type: "string", demandOption: true, describe: "Chain ID" }).argv;
48
- async function queryRoute() {
46
+ .option("originToken", { type: "string", demandOption: true, describe: "Origin token public key" }).argv;
47
+ async function queryVault() {
49
48
  const resolvedArgv = await argv;
50
49
  const seed = new anchor_1.BN(resolvedArgv.seed);
51
50
  const originToken = Array.from(new web3_js_1.PublicKey(resolvedArgv.originToken).toBytes());
52
- const chainId = new anchor_1.BN(resolvedArgv.chainId);
53
51
  // Define the state account PDA
54
52
  const [statePda, _] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("state"), seed.toArrayLike(Buffer, "le", 8)], programId);
55
- // Define the route account PDA
56
- const [routePda] = web3_js_1.PublicKey.findProgramAddressSync([
57
- Buffer.from("route"),
58
- Buffer.from(originToken),
59
- seed.toArrayLike(Buffer, "le", 8),
60
- chainId.toArrayLike(Buffer, "le", 8),
61
- ], programId);
62
53
  // Compute the vault address
63
54
  const vault = (0, spl_token_1.getAssociatedTokenAddressSync)(new web3_js_1.PublicKey(originToken), statePda, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
64
- console.log("Querying route...");
55
+ console.log("Querying vault...");
65
56
  console.table([
66
57
  { Property: "seed", Value: seed.toString() },
67
58
  { Property: "originToken", Value: new web3_js_1.PublicKey(originToken).toString() },
68
- { Property: "chainId", Value: chainId.toString() },
69
59
  { Property: "programId", Value: programId.toString() },
70
60
  { Property: "statePda", Value: statePda.toString() },
71
- { Property: "routePda", Value: routePda.toString() },
72
61
  { Property: "vault", Value: vault.toString() },
73
62
  ]);
74
63
  try {
75
- const route = await program.account.route.fetch(routePda);
76
64
  const vaultAccount = await (0, spl_token_1.getAccount)(provider.connection, vault);
77
- console.log("Route fetched successfully:");
78
- console.table([
79
- { Property: "Enabled", Value: route.enabled },
80
- { Property: "vaultBalance", Value: vaultAccount.amount.toString() },
81
- ]);
65
+ console.log("Vault fetched successfully:");
66
+ console.table([{ Property: "vaultBalance", Value: vaultAccount.amount.toString() }]);
82
67
  }
83
68
  catch (error) {
84
69
  if (error.message.includes("Account does not exist or has no data")) {
85
- console.log("No route has been created for the given origin token and chain ID.");
70
+ console.log("No vault has been created for the given origin token.");
86
71
  }
87
72
  else {
88
- console.error("An error occurred while fetching the route:", error);
73
+ console.error("An error occurred while fetching the vault:", error);
89
74
  }
90
75
  }
91
76
  }
92
- // Run the queryRoute function
93
- queryRoute();
77
+ // Run the queryVault function
78
+ queryVault();
@@ -74,7 +74,7 @@ async function remoteHubPoolPauseDeposit() {
74
74
  const irisApiUrl = isDevnet ? web3_v1_1.CIRCLE_IRIS_API_URL_DEVNET : web3_v1_1.CIRCLE_IRIS_API_URL_MAINNET;
75
75
  const hubPool = typechain_1.HubPool__factory.connect(hubPoolAddress, ethersProvider);
76
76
  const spokePoolIface = new ethers_1.ethers.utils.Interface(["function pauseDeposits(bool pause)"]);
77
- console.log("Remotely configuring deposit route...");
77
+ console.log("Remotely pausing deposits...");
78
78
  console.table([
79
79
  { Property: "seed", Value: seed.toString() },
80
80
  { Property: "chainId", Value: chainId.toString() },
@@ -176,7 +176,7 @@ async function remoteHubPoolPauseDeposit() {
176
176
  console.log("\nReceived remote message");
177
177
  console.log("Your transaction signature", receiveMessageTx);
178
178
  let stateAccount = await svmSpokeProgram.account.state.fetch(statePda);
179
- console.log("Updated deposit route state to: pausedDeposits =", stateAccount.pausedDeposits);
179
+ console.log("Updated deposit state to: pausedDeposits =", stateAccount.pausedDeposits);
180
180
  }
181
181
  remoteHubPoolPauseDeposit()
182
182
  .then(() => {
@@ -68,18 +68,11 @@ async function deposit() {
68
68
  const integratorId = resolvedArgv.integratorId || "";
69
69
  // Define the state account PDA
70
70
  const [statePda, _] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("state"), seed.toArrayLike(Buffer, "le", 8)], programId);
71
- // Define the route account PDA
72
- const [routePda] = web3_js_1.PublicKey.findProgramAddressSync([
73
- Buffer.from("route"),
74
- inputToken.toBytes(),
75
- seed.toArrayLike(Buffer, "le", 8),
76
- destinationChainId.toArrayLike(Buffer, "le", 8),
77
- ], programId);
78
71
  // Define the signer (replace with your actual signer)
79
72
  const signer = provider.wallet.payer;
80
- // Find ATA for the input token to be stored by state (vault). This was created when the route was enabled.
73
+ // Find ATA for the input token to be stored by state (vault). This should have been created before the deposit is attempted.
81
74
  const vault = (0, spl_token_1.getAssociatedTokenAddressSync)(inputToken, statePda, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
82
- console.log("Depositing V3...");
75
+ console.log("Depositing...");
83
76
  console.table([
84
77
  { property: "seed", value: seed.toString() },
85
78
  { property: "recipient", value: recipient.toString() },
@@ -96,7 +89,6 @@ async function deposit() {
96
89
  { property: "programId", value: programId.toString() },
97
90
  { property: "providerPublicKey", value: provider.wallet.publicKey.toString() },
98
91
  { property: "statePda", value: statePda.toString() },
99
- { property: "routePda", value: routePda.toString() },
100
92
  { property: "vault", value: vault.toString() },
101
93
  ]);
102
94
  const userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(inputToken, signer.publicKey);
@@ -106,7 +98,6 @@ async function deposit() {
106
98
  const depositIx = await program.methods.deposit(signer.publicKey, recipient, inputToken, outputToken, inputAmount, outputAmount, destinationChainId, exclusiveRelayer, quoteTimestamp, fillDeadline, exclusivityDeadline, message)
107
99
  .accounts({
108
100
  state: statePda,
109
- route: routePda,
110
101
  signer: signer.publicKey,
111
102
  userTokenAccount,
112
103
  vault: vault,
@@ -127,5 +118,5 @@ async function deposit() {
127
118
  const tx = await (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, depositTx, [signer]);
128
119
  console.log("Transaction signature:", tx);
129
120
  }
130
- // Run the depositV3 function
121
+ // Run the deposit function
131
122
  deposit();
@@ -55,10 +55,6 @@ async function testBundleLogic() {
55
55
  const signer = provider.wallet.payer;
56
56
  console.log("Running from signer: ", signer.publicKey.toString());
57
57
  const [statePda, _] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("state"), seed.toArrayLike(Buffer, "le", 8)], programId);
58
- // This assumes that the destination chain Id 11155111 has been enabled. This is the sepolia chain ID.
59
- // I.e this test assumes that enableRoute has been called with destinationChainId 11155111 and inputToken.
60
- const [routePda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("route"), inputToken.toBytes(), statePda.toBytes(), new anchor_1.BN(11155111).toArrayLike(Buffer, "le", 8)], // Assuming destinationChainId is 1
61
- programId);
62
58
  const vault = (0, spl_token_1.getAssociatedTokenAddressSync)(inputToken, statePda, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
63
59
  console.table([
64
60
  { property: "seed", value: seed.toString() },
@@ -66,19 +62,18 @@ async function testBundleLogic() {
66
62
  { property: "inputToken", value: inputToken.toString() },
67
63
  { property: "signer", value: signer.publicKey.toString() },
68
64
  { property: "statePda", value: statePda.toString() },
69
- { property: "routePda", value: routePda.toString() },
70
65
  { property: "vault", value: vault.toString() },
71
66
  ]);
72
67
  const userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(inputToken, signer.publicKey);
73
68
  const tokenDecimals = (await (0, spl_token_1.getMint)(provider.connection, inputToken, undefined, spl_token_1.TOKEN_PROGRAM_ID)).decimals;
74
- // Use program.methods.depositV3 to send tokens to the spoke. note this is NOT a valid deposit, we just want to
69
+ // Use program.methods.deposit to send tokens to the spoke. note this is NOT a valid deposit, we just want to
75
70
  // seed tokens into the spoke to test repayment.
76
71
  // Delegate state PDA to pull depositor tokens.
77
72
  const inputAmount = amounts.reduce((acc, amount) => acc.add(amount), new anchor_1.BN(0));
78
73
  const approveIx = await (0, spl_token_1.createApproveCheckedInstruction)(userTokenAccount, inputToken, statePda, signer.publicKey, BigInt(inputAmount.toString()), tokenDecimals, undefined, spl_token_1.TOKEN_PROGRAM_ID);
79
74
  const depositIx = await program.methods.deposit(signer.publicKey, signer.publicKey, // recipient is the signer for this example
80
75
  inputToken, inputToken, // Re-use inputToken as outputToken. does not matter for this deposit.
81
- inputAmount, new anchor_1.BN(0), new anchor_1.BN(11155111), // destinationChainId. assumed to be enabled, as with routePDA
76
+ inputAmount, new anchor_1.BN(0), new anchor_1.BN(11155111), // destinationChainId.
82
77
  web3_js_1.PublicKey.default, // exclusiveRelayer
83
78
  Math.floor(Date.now() / 1000) - 1, // quoteTimestamp
84
79
  Math.floor(Date.now() / 1000) + 3600, // fillDeadline
@@ -87,7 +82,6 @@ async function testBundleLogic() {
87
82
  )
88
83
  .accounts({
89
84
  state: statePda,
90
- route: routePda,
91
85
  signer: signer.publicKey,
92
86
  userTokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(inputToken, signer.publicKey),
93
87
  vault: vault,
@@ -132,7 +126,6 @@ async function testBundleLogic() {
132
126
  const [rootBundle] = web3_js_1.PublicKey.findProgramAddressSync(seeds, programId);
133
127
  console.table([
134
128
  { property: "State PDA", value: statePda.toString() },
135
- { property: "Route PDA", value: routePda.toString() },
136
129
  { property: "Root Bundle PDA", value: rootBundle.toString() },
137
130
  { property: "Signer", value: signer.publicKey.toString() },
138
131
  ]);
@@ -85,7 +85,7 @@ async function fillRelay() {
85
85
  };
86
86
  // Define the signer (replace with your actual signer)
87
87
  const signer = provider.wallet.payer;
88
- console.log("Filling V3 Relay...");
88
+ console.log("Filling Relay...");
89
89
  // Define the state account PDA
90
90
  const [statePda, _] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("state"), seed.toArrayLike(Buffer, "le", 8)], programId);
91
91
  // Fetch the state from the on-chain program to get chainId
@@ -129,6 +129,7 @@ async function fillRelay() {
129
129
  const fillAccounts = {
130
130
  state: statePda,
131
131
  signer: signer.publicKey,
132
+ delegate: (0, web3_v1_1.getFillRelayDelegatePda)(relayHashUint8Array, chainId, signer.publicKey, program.programId).pda,
132
133
  instructionParams: program.programId,
133
134
  mint: outputToken,
134
135
  relayerTokenAccount: relayerTokenAccount,
@@ -148,5 +149,5 @@ async function fillRelay() {
148
149
  const tx = await (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, fillTx, [signer]);
149
150
  console.log("Transaction signature:", tx);
150
151
  }
151
- // Run the fillV3Relay function
152
+ // Run the fillRelay function
152
153
  fillRelay();