@across-protocol/contracts 4.0.12 → 4.0.14-alpha.1

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 (51) hide show
  1. package/README.md +186 -3
  2. package/dist/deployments/deployments.json +8 -6
  3. package/dist/scripts/svm/closeRelayerPdas.js +1 -1
  4. package/dist/scripts/svm/createVault.js +2 -2
  5. package/dist/scripts/svm/fakeFillWithRandomDistribution.js +8 -7
  6. package/dist/scripts/svm/findFillStatusPdaFromEvent.js +1 -1
  7. package/dist/scripts/svm/initialize.js +19 -5
  8. package/dist/scripts/svm/nativeDeposit.js +30 -9
  9. package/dist/scripts/svm/queryEvents.js +1 -1
  10. package/dist/scripts/svm/queryEventsV2.js +1 -1
  11. package/dist/scripts/svm/queryFills.js +1 -1
  12. package/dist/scripts/svm/simpleDeposit.js +30 -9
  13. package/dist/scripts/svm/simpleFakeRelayerRepayment.js +19 -12
  14. package/dist/scripts/svm/simpleFill.js +7 -6
  15. package/dist/scripts/svm/squadsIdlUpgrade.d.ts +1 -0
  16. package/dist/scripts/svm/squadsIdlUpgrade.js +76 -0
  17. package/dist/src/svm/assets/idl/svm_spoke.json +77 -40
  18. package/dist/src/svm/assets/svm_spoke.d.ts +77 -40
  19. package/dist/src/svm/clients/SvmSpoke/instructions/deposit.d.ts +2 -2
  20. package/dist/src/svm/clients/SvmSpoke/instructions/deposit.js +2 -2
  21. package/dist/src/svm/clients/SvmSpoke/instructions/depositNow.d.ts +2 -2
  22. package/dist/src/svm/clients/SvmSpoke/instructions/depositNow.js +2 -2
  23. package/dist/src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.d.ts +1 -1
  24. package/dist/src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.js +5 -5
  25. package/dist/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.d.ts +2 -2
  26. package/dist/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.js +2 -2
  27. package/dist/src/svm/clients/SvmSpoke/programs/svmSpoke.d.ts +2 -2
  28. package/dist/src/svm/clients/SvmSpoke/programs/svmSpoke.js +1 -1
  29. package/dist/src/svm/clients/SvmSpoke/types/filledRelay.d.ts +2 -2
  30. package/dist/src/svm/clients/SvmSpoke/types/filledRelay.js +2 -2
  31. package/dist/src/svm/clients/SvmSpoke/types/fundsDeposited.d.ts +2 -2
  32. package/dist/src/svm/clients/SvmSpoke/types/fundsDeposited.js +2 -2
  33. package/dist/src/svm/clients/SvmSpoke/types/relayData.d.ts +2 -2
  34. package/dist/src/svm/clients/SvmSpoke/types/relayData.js +2 -2
  35. package/dist/src/svm/clients/SvmSpoke/types/requestedSlowFill.d.ts +2 -2
  36. package/dist/src/svm/clients/SvmSpoke/types/requestedSlowFill.js +2 -2
  37. package/dist/src/svm/web3-v1/helpers.d.ts +6 -6
  38. package/dist/src/svm/web3-v1/helpers.js +2 -2
  39. package/dist/src/svm/web3-v1/relayHashUtils.js +3 -3
  40. package/dist/src/svm/web3-v1/solanaProgramUtils.d.ts +1 -1
  41. package/dist/src/svm/web3-v1/solanaProgramUtils.js +17 -7
  42. package/dist/src/types/svm.d.ts +3 -3
  43. package/dist/target/types/svm_spoke.d.ts +77 -40
  44. package/dist/tasks/enableL1TokenAcrossEcosystem.js +4 -4
  45. package/dist/test/svm/SvmSpoke.Deposit.js +21 -3
  46. package/dist/test/svm/SvmSpoke.Fill.AcrossPlus.js +3 -3
  47. package/dist/test/svm/SvmSpoke.Fill.js +3 -3
  48. package/dist/test/svm/SvmSpoke.SlowFill.AcrossPlus.js +3 -3
  49. package/dist/test/svm/SvmSpoke.SlowFill.js +2 -2
  50. package/dist/test/svm/SvmSpoke.common.js +1 -1
  51. package/package.json +2 -2
@@ -411,7 +411,11 @@ describe("svm_spoke.deposit", () => {
411
411
  });
412
412
  // Create wSOL user account.
413
413
  const createIx = (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(depositor.publicKey, depositorTA, depositor.publicKey, inputToken);
414
- const nativeDepositData = { ...depositData, inputAmount: new anchor_1.BN(nativeAmount), outputAmount: new anchor_1.BN(nativeAmount) };
414
+ const nativeDepositData = {
415
+ ...depositData,
416
+ inputAmount: new anchor_1.BN(nativeAmount),
417
+ outputAmount: (0, web3_v1_1.intToU8Array32)(nativeAmount),
418
+ };
415
419
  const depositDataValues = Object.values(nativeDepositData);
416
420
  const delegate = (0, web3_v1_1.getDepositPda)(nativeDepositData, program.programId);
417
421
  const approveIx = await (0, spl_token_1.createApproveCheckedInstruction)(depositAccounts.depositorTokenAccount, depositAccounts.mint, delegate, depositor.publicKey, BigInt(nativeAmount), nativeDecimals, undefined, tokenProgram);
@@ -443,7 +447,11 @@ describe("svm_spoke.deposit", () => {
443
447
  });
444
448
  // Sync the user token account with the native balance.
445
449
  const syncIx = (0, spl_token_1.createSyncNativeInstruction)(depositorTA);
446
- const nativeDepositData = { ...depositData, inputAmount: new anchor_1.BN(nativeAmount), outputAmount: new anchor_1.BN(nativeAmount) };
450
+ const nativeDepositData = {
451
+ ...depositData,
452
+ inputAmount: new anchor_1.BN(nativeAmount),
453
+ outputAmount: (0, web3_v1_1.intToU8Array32)(nativeAmount),
454
+ };
447
455
  const depositDataValues = Object.values(nativeDepositData);
448
456
  const delegate = (0, web3_v1_1.getDepositPda)(nativeDepositData, program.programId);
449
457
  const approveIx = await (0, spl_token_1.createApproveCheckedInstruction)(depositAccounts.depositorTokenAccount, depositAccounts.mint, delegate, depositor.publicKey, BigInt(nativeAmount), nativeDecimals, undefined, tokenProgram);
@@ -480,6 +488,16 @@ describe("svm_spoke.deposit", () => {
480
488
  const vaultAccount = await (0, spl_token_1.getAccount)(connection, vault);
481
489
  assertSE(vaultAccount.amount, depositData.inputAmount, "Vault balance should equal the deposited amount");
482
490
  });
491
+ it("Output token cannot be zero address", async () => {
492
+ const invalidDepositData = { ...depositData, outputToken: new web3_js_1.PublicKey("11111111111111111111111111111111") };
493
+ try {
494
+ await approvedDeposit(invalidDepositData);
495
+ assert.fail("Should not be able to process deposit with zero output token address");
496
+ }
497
+ catch (err) {
498
+ assert.include(err.toString(), "Error Code: InvalidOutputToken", "Expected InvalidOutputToken error");
499
+ }
500
+ });
483
501
  describe("codama client and solana kit", () => {
484
502
  it("Deposit with with solana kit and codama client", async () => {
485
503
  // typescript is not happy with the depositData object
@@ -512,7 +530,7 @@ describe("svm_spoke.deposit", () => {
512
530
  inputToken: (0, kit_1.address)(depositData.inputToken.toString()),
513
531
  outputToken: (0, kit_1.address)(depositData.outputToken.toString()),
514
532
  inputAmount: BigInt(depositData.inputAmount.toString()),
515
- outputAmount: BigInt(depositData.outputAmount.toString()),
533
+ outputAmount: new Uint8Array(depositData.outputAmount),
516
534
  destinationChainId: depositData.destinationChainId.toNumber(),
517
535
  exclusiveRelayer: (0, kit_1.address)(depositData.exclusiveRelayer.toString()),
518
536
  quoteTimestamp: depositData.quoteTimestamp.toNumber(),
@@ -103,7 +103,7 @@ describe("svm_spoke.fill.across_plus", () => {
103
103
  exclusiveRelayer: relayer.publicKey,
104
104
  inputToken: mint, // This is lazy. it should be an encoded token from a separate domain most likely.
105
105
  outputToken: mint,
106
- inputAmount: new anchor_1.BN(relayAmount),
106
+ inputAmount: (0, web3_v1_1.intToU8Array32)(relayAmount),
107
107
  outputAmount: new anchor_1.BN(relayAmount),
108
108
  originChainId: new anchor_1.BN(1),
109
109
  depositId: (0, web3_v1_1.intToU8Array32)(Math.floor(Math.random() * 1000000)), // force that we always have a new deposit id.
@@ -188,7 +188,7 @@ describe("svm_spoke.fill.across_plus", () => {
188
188
  };
189
189
  it("Max token distributions within invoked message call, regular params", async () => {
190
190
  // Larger distribution would exceed message size limits.
191
- const numberOfDistributions = 7;
191
+ const numberOfDistributions = 6;
192
192
  await fillTokenDistributions(numberOfDistributions);
193
193
  });
194
194
  it("Max token distributions within invoked message call, buffer account params", async () => {
@@ -305,7 +305,7 @@ describe("svm_spoke.fill.across_plus", () => {
305
305
  exclusiveRelayer: (0, kit_1.address)(relayData.exclusiveRelayer.toString()),
306
306
  inputToken: (0, kit_1.address)(relayData.inputToken.toString()),
307
307
  outputToken: (0, kit_1.address)(relayData.outputToken.toString()),
308
- inputAmount: relayData.inputAmount.toNumber(),
308
+ inputAmount: new Uint8Array(relayData.inputAmount),
309
309
  outputAmount: relayData.outputAmount.toNumber(),
310
310
  originChainId: relayData.originChainId.toNumber(),
311
311
  depositId: new Uint8Array(relayData.depositId),
@@ -99,7 +99,7 @@ describe("svm_spoke.fill", () => {
99
99
  exclusiveRelayer: relayer.publicKey,
100
100
  inputToken: mint, // This is lazy. it should be an encoded token from a separate domain most likely.
101
101
  outputToken: mint,
102
- inputAmount: new anchor_1.BN(relayAmount),
102
+ inputAmount: (0, web3_v1_1.intToU8Array32)(relayAmount),
103
103
  outputAmount: new anchor_1.BN(relayAmount),
104
104
  originChainId: new anchor_1.BN(1),
105
105
  depositId: (0, web3_v1_1.intToU8Array32)(Math.floor(Math.random() * 1000000)), // force that we always have a new deposit id.
@@ -493,7 +493,7 @@ describe("svm_spoke.fill", () => {
493
493
  exclusiveRelayer: (0, kit_1.address)(relayData.exclusiveRelayer.toString()),
494
494
  inputToken: (0, kit_1.address)(relayData.inputToken.toString()),
495
495
  outputToken: (0, kit_1.address)(relayData.outputToken.toString()),
496
- inputAmount: relayData.inputAmount.toNumber(),
496
+ inputAmount: new Uint8Array(relayData.inputAmount),
497
497
  outputAmount: relayData.outputAmount.toNumber(),
498
498
  originChainId: relayData.originChainId.toNumber(),
499
499
  depositId: new Uint8Array(relayData.depositId),
@@ -572,7 +572,7 @@ describe("svm_spoke.fill", () => {
572
572
  exclusiveRelayer: (0, kit_1.address)(relayData.exclusiveRelayer.toString()),
573
573
  inputToken: (0, kit_1.address)(relayData.inputToken.toString()),
574
574
  outputToken: (0, kit_1.address)(relayData.outputToken.toString()),
575
- inputAmount: relayData.inputAmount.toNumber(),
575
+ inputAmount: new Uint8Array(relayData.inputAmount),
576
576
  outputAmount: relayData.outputAmount.toNumber(),
577
577
  originChainId: relayData.originChainId.toNumber(),
578
578
  depositId: new Uint8Array(relayData.depositId),
@@ -167,7 +167,7 @@ describe("svm_spoke.slow_fill.across_plus", () => {
167
167
  exclusiveRelayer: relayer.publicKey,
168
168
  inputToken: mint, // This is lazy. it should be an encoded token from a separate domain most likely.
169
169
  outputToken: mint,
170
- inputAmount: new anchor_1.BN(relayAmount),
170
+ inputAmount: (0, web3_v1_1.intToU8Array32)(relayAmount),
171
171
  outputAmount: new anchor_1.BN(relayAmount),
172
172
  originChainId: new anchor_1.BN(1),
173
173
  depositId: (0, web3_v1_1.intToU8Array32)(Math.floor(Math.random() * 1000000)), // Unique ID for each test.
@@ -197,7 +197,7 @@ describe("svm_spoke.slow_fill.across_plus", () => {
197
197
  // Request and execute slow fill.
198
198
  const { requestIx, executeIx } = await createSlowFillIx(multicallHandlerCoder);
199
199
  await (0, web3_js_1.sendAndConfirmTransaction)(connection, new web3_js_1.Transaction().add(requestIx), [relayer]);
200
- await (0, web3_js_1.sendAndConfirmTransaction)(connection, new web3_js_1.Transaction().add(executeIx), [relayer]);
200
+ await (0, web3_v1_1.sendTransactionWithLookupTable)(connection, [executeIx], relayer);
201
201
  // Verify vault's balance after the fill
202
202
  const fVaultBal = (await (0, spl_token_1.getAccount)(connection, vault)).amount;
203
203
  assertSE(fVaultBal, iVaultBal - BigInt(relayAmount), "Vault's balance should be reduced by the relay amount");
@@ -266,7 +266,7 @@ describe("svm_spoke.slow_fill.across_plus", () => {
266
266
  };
267
267
  it("Max token distributions within invoked message call, regular params", async () => {
268
268
  // Larger distribution would exceed message size limits.
269
- const numberOfDistributions = 6;
269
+ const numberOfDistributions = 5;
270
270
  await fillTokenDistributions(numberOfDistributions);
271
271
  });
272
272
  it("Max token distributions within invoked message call, buffer account params", async () => {
@@ -86,7 +86,7 @@ describe("svm_spoke.slow_fill", () => {
86
86
  exclusiveRelayer: relayer.publicKey,
87
87
  inputToken: mint,
88
88
  outputToken: mint,
89
- inputAmount: new anchor_1.BN(relayAmount),
89
+ inputAmount: (0, web3_v1_1.intToU8Array32)(relayAmount),
90
90
  outputAmount: new anchor_1.BN(relayAmount),
91
91
  originChainId: new anchor_1.BN(1),
92
92
  depositId: (0, web3_v1_1.intToU8Array32)(Math.floor(Math.random() * 1000000)), // Unique ID for each test.
@@ -142,7 +142,7 @@ describe("svm_spoke.slow_fill", () => {
142
142
  exclusiveRelayer: relayer.publicKey,
143
143
  inputToken: mint, // This is lazy. it should be an encoded token from a separate domain most likely.
144
144
  outputToken: mint,
145
- inputAmount: new anchor_1.BN(relayAmount),
145
+ inputAmount: (0, web3_v1_1.intToU8Array32)(relayAmount),
146
146
  outputAmount: new anchor_1.BN(relayAmount),
147
147
  originChainId: new anchor_1.BN(1),
148
148
  depositId: (0, web3_v1_1.intToU8Array32)(1),
@@ -128,7 +128,7 @@ exports.common = {
128
128
  inputToken: null, // Placeholder, to be assigned in the test file
129
129
  outputToken,
130
130
  inputAmount,
131
- outputAmount,
131
+ outputAmount: (0, web3_v1_1.intToU8Array32)(outputAmount),
132
132
  destinationChainId,
133
133
  exclusiveRelayer,
134
134
  quoteTimestamp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@across-protocol/contracts",
3
- "version": "4.0.12",
3
+ "version": "4.0.14-alpha.1",
4
4
  "author": "UMA Team",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -46,7 +46,7 @@
46
46
  "pre-commit-hook": "sh scripts/preCommitHook.sh"
47
47
  },
48
48
  "dependencies": {
49
- "@across-protocol/constants": "^3.1.63",
49
+ "@across-protocol/constants": "^3.1.66",
50
50
  "@coral-xyz/anchor": "^0.31.1",
51
51
  "@defi-wonderland/smock": "^2.3.4",
52
52
  "@eth-optimism/contracts": "^0.5.40",