@m0-foundation/ntt-sdk-route 0.0.23 → 0.0.25

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.
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Network, routes, Chain, ChainContext, TokenId, Signer, ChainAddress, AccountAddress } from '@wormhole-foundation/sdk-connect';
2
- import { Ntt, NttWithExecutor } from '@wormhole-foundation/sdk-definitions-ntt';
3
2
  import { EvmNtt } from '@wormhole-foundation/sdk-evm-ntt';
4
3
  import { SolanaNtt } from '@wormhole-foundation/sdk-solana-ntt';
5
4
  import { EvmChains, EvmUnsignedTransaction } from '@wormhole-foundation/sdk-evm';
6
5
  import { SolanaChains, SolanaUnsignedTransaction } from '@wormhole-foundation/sdk-solana';
7
6
  import { NttRoute } from '@wormhole-foundation/sdk-route-ntt';
8
7
  import { TransactionRequest } from 'ethers';
9
- import { Keypair, PublicKey, TransactionInstruction, Connection, AddressLookupTableAccount } from '@solana/web3.js';
8
+ import { Ntt, NttWithExecutor } from '@wormhole-foundation/sdk-definitions-ntt';
9
+ import { Keypair, Connection, PublicKey, TransactionInstruction, AddressLookupTableAccount } from '@solana/web3.js';
10
10
 
11
11
  type Op = NttRoute.Options;
12
12
  type Tp = routes.TransferParams<Op>;
@@ -50,6 +50,7 @@ declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<
50
50
  track(receipt: R, timeout?: number): AsyncGenerator<R, void, unknown>;
51
51
  private getExecutorQuote;
52
52
  private requiresExecutor;
53
+ static applyScaledUiMultiplier(connection: Connection, mint: PublicKey, amount: bigint): Promise<bigint>;
53
54
  }
54
55
 
55
56
  type SvmNetwork = Exclude<Network, "Devnet">;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Network, routes, Chain, ChainContext, TokenId, Signer, ChainAddress, AccountAddress } from '@wormhole-foundation/sdk-connect';
2
- import { Ntt, NttWithExecutor } from '@wormhole-foundation/sdk-definitions-ntt';
3
2
  import { EvmNtt } from '@wormhole-foundation/sdk-evm-ntt';
4
3
  import { SolanaNtt } from '@wormhole-foundation/sdk-solana-ntt';
5
4
  import { EvmChains, EvmUnsignedTransaction } from '@wormhole-foundation/sdk-evm';
6
5
  import { SolanaChains, SolanaUnsignedTransaction } from '@wormhole-foundation/sdk-solana';
7
6
  import { NttRoute } from '@wormhole-foundation/sdk-route-ntt';
8
7
  import { TransactionRequest } from 'ethers';
9
- import { Keypair, PublicKey, TransactionInstruction, Connection, AddressLookupTableAccount } from '@solana/web3.js';
8
+ import { Ntt, NttWithExecutor } from '@wormhole-foundation/sdk-definitions-ntt';
9
+ import { Keypair, Connection, PublicKey, TransactionInstruction, AddressLookupTableAccount } from '@solana/web3.js';
10
10
 
11
11
  type Op = NttRoute.Options;
12
12
  type Tp = routes.TransferParams<Op>;
@@ -50,6 +50,7 @@ declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<
50
50
  track(receipt: R, timeout?: number): AsyncGenerator<R, void, unknown>;
51
51
  private getExecutorQuote;
52
52
  private requiresExecutor;
53
+ static applyScaledUiMultiplier(connection: Connection, mint: PublicKey, amount: bigint): Promise<bigint>;
53
54
  }
54
55
 
55
56
  type SvmNetwork = Exclude<Network, "Devnet">;
package/dist/index.js CHANGED
@@ -2,13 +2,14 @@
2
2
 
3
3
  var sdkConnect = require('@wormhole-foundation/sdk-connect');
4
4
  var sdkDefinitionsNtt = require('@wormhole-foundation/sdk-definitions-ntt');
5
+ var sdkEvmNtt = require('@wormhole-foundation/sdk-evm-ntt');
6
+ var sdkSolanaNtt = require('@wormhole-foundation/sdk-solana-ntt');
5
7
  var sdkEvm = require('@wormhole-foundation/sdk-evm');
6
8
  var sdkSolana = require('@wormhole-foundation/sdk-solana');
7
9
  var sdkRouteNtt = require('@wormhole-foundation/sdk-route-ntt');
8
10
  var ethers = require('ethers');
9
11
  var web3_js = require('@solana/web3.js');
10
12
  var splToken = require('@solana/spl-token');
11
- var sdkSolanaNtt = require('@wormhole-foundation/sdk-solana-ntt');
12
13
  var BN = require('bn.js');
13
14
  var sha2 = require('@noble/hashes/sha2');
14
15
 
@@ -1005,13 +1006,19 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
1005
1006
  if (config.paused) throw new Error("Contract is paused");
1006
1007
  outboxItem = outboxItem ?? web3_js.Keypair.generate();
1007
1008
  const payerAddress = new sdkSolana.SolanaAddress(sender).unwrap();
1009
+ const sourceMint = new web3_js.PublicKey(sourceToken);
1010
+ amount2 = await _M0AutomaticRoute.applyScaledUiMultiplier(
1011
+ ntt.connection,
1012
+ sourceMint,
1013
+ amount2
1014
+ );
1008
1015
  const ixs = [
1009
1016
  router.getTransferExtensionBurnIx(
1010
1017
  amount2,
1011
1018
  recipient,
1012
1019
  new web3_js.PublicKey(sender.toUint8Array()),
1013
1020
  outboxItem.publicKey,
1014
- new web3_js.PublicKey(sourceToken),
1021
+ sourceMint,
1015
1022
  sdkConnect.toUniversal(recipient.chain, destinationToken).toUint8Array(),
1016
1023
  options.queue
1017
1024
  )
@@ -1165,7 +1172,26 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
1165
1172
  requiresExecutor(destination) {
1166
1173
  return sdkConnect.chainToPlatform(destination) === "Solana";
1167
1174
  }
1175
+ static async applyScaledUiMultiplier(connection, mint, amount2) {
1176
+ const mintAccountInfo = await connection.getAccountInfo(mint);
1177
+ if (!mintAccountInfo || !mintAccountInfo.owner.equals(splToken.TOKEN_2022_PROGRAM_ID)) {
1178
+ return amount2;
1179
+ }
1180
+ const mintData = splToken.unpackMint(mint, mintAccountInfo, splToken.TOKEN_2022_PROGRAM_ID);
1181
+ const scaledUiAmountConfig = splToken.getScaledUiAmountConfig(mintData);
1182
+ if (!scaledUiAmountConfig) {
1183
+ return amount2;
1184
+ }
1185
+ const now = BigInt(Math.floor(Date.now() / 1e3));
1186
+ const multiplier = now >= scaledUiAmountConfig.newMultiplierEffectiveTimestamp ? scaledUiAmountConfig.newMultiplier : scaledUiAmountConfig.multiplier;
1187
+ const PRECISION = 10n ** 12n;
1188
+ const scaledMultiplier = BigInt(Math.round(multiplier * Number(PRECISION)));
1189
+ return amount2 * scaledMultiplier / PRECISION;
1190
+ }
1168
1191
  };
1192
+ sdkDefinitionsNtt.register();
1193
+ sdkEvmNtt.register();
1194
+ sdkSolanaNtt.register();
1169
1195
  // ntt does not support gas drop-off currently
1170
1196
  _M0AutomaticRoute.NATIVE_GAS_DROPOFF_SUPPORTED = false;
1171
1197
  // USDZ token address is the same across Ethereum and Arbitrum
package/dist/index.mjs CHANGED
@@ -1,12 +1,13 @@
1
1
  import { routes, Wormhole, isSameToken, amount, finality, chainToPlatform, canonicalAddress, signSendWait, TransferState, universalAddress, toChainId, toUniversal, isSourceInitiated, isSourceFinalized, isAttested, isRedeemed, chainToChainId } from '@wormhole-foundation/sdk-connect';
2
- import { Ntt } from '@wormhole-foundation/sdk-definitions-ntt';
2
+ import { Ntt, register } from '@wormhole-foundation/sdk-definitions-ntt';
3
+ import { register as register$1 } from '@wormhole-foundation/sdk-evm-ntt';
4
+ import { register as register$2, NTT } from '@wormhole-foundation/sdk-solana-ntt';
3
5
  import { EvmAddress, EvmPlatform, addFrom, EvmUnsignedTransaction, addChainId } from '@wormhole-foundation/sdk-evm';
4
6
  import { SolanaAddress } from '@wormhole-foundation/sdk-solana';
5
7
  import { NttRoute, nttExecutorRoute } from '@wormhole-foundation/sdk-route-ntt';
6
8
  import { Contract } from 'ethers';
7
9
  import { Keypair, PublicKey, Transaction, LAMPORTS_PER_SOL, TransactionMessage, VersionedTransaction, TransactionInstruction, SystemProgram, AddressLookupTableAccount } from '@solana/web3.js';
8
- import { TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, getAssociatedTokenAddressSync, createAssociatedTokenAccountInstruction } from '@solana/spl-token';
9
- import { NTT } from '@wormhole-foundation/sdk-solana-ntt';
10
+ import { TOKEN_2022_PROGRAM_ID, unpackMint, getScaledUiAmountConfig, TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, createAssociatedTokenAccountInstruction } from '@solana/spl-token';
10
11
  import BN from 'bn.js';
11
12
  import { sha256 } from '@noble/hashes/sha2';
12
13
 
@@ -999,13 +1000,19 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
999
1000
  if (config.paused) throw new Error("Contract is paused");
1000
1001
  outboxItem = outboxItem ?? Keypair.generate();
1001
1002
  const payerAddress = new SolanaAddress(sender).unwrap();
1003
+ const sourceMint = new PublicKey(sourceToken);
1004
+ amount2 = await _M0AutomaticRoute.applyScaledUiMultiplier(
1005
+ ntt.connection,
1006
+ sourceMint,
1007
+ amount2
1008
+ );
1002
1009
  const ixs = [
1003
1010
  router.getTransferExtensionBurnIx(
1004
1011
  amount2,
1005
1012
  recipient,
1006
1013
  new PublicKey(sender.toUint8Array()),
1007
1014
  outboxItem.publicKey,
1008
- new PublicKey(sourceToken),
1015
+ sourceMint,
1009
1016
  toUniversal(recipient.chain, destinationToken).toUint8Array(),
1010
1017
  options.queue
1011
1018
  )
@@ -1159,7 +1166,26 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
1159
1166
  requiresExecutor(destination) {
1160
1167
  return chainToPlatform(destination) === "Solana";
1161
1168
  }
1169
+ static async applyScaledUiMultiplier(connection, mint, amount2) {
1170
+ const mintAccountInfo = await connection.getAccountInfo(mint);
1171
+ if (!mintAccountInfo || !mintAccountInfo.owner.equals(TOKEN_2022_PROGRAM_ID)) {
1172
+ return amount2;
1173
+ }
1174
+ const mintData = unpackMint(mint, mintAccountInfo, TOKEN_2022_PROGRAM_ID);
1175
+ const scaledUiAmountConfig = getScaledUiAmountConfig(mintData);
1176
+ if (!scaledUiAmountConfig) {
1177
+ return amount2;
1178
+ }
1179
+ const now = BigInt(Math.floor(Date.now() / 1e3));
1180
+ const multiplier = now >= scaledUiAmountConfig.newMultiplierEffectiveTimestamp ? scaledUiAmountConfig.newMultiplier : scaledUiAmountConfig.multiplier;
1181
+ const PRECISION = 10n ** 12n;
1182
+ const scaledMultiplier = BigInt(Math.round(multiplier * Number(PRECISION)));
1183
+ return amount2 * scaledMultiplier / PRECISION;
1184
+ }
1162
1185
  };
1186
+ register();
1187
+ register$1();
1188
+ register$2();
1163
1189
  // ntt does not support gas drop-off currently
1164
1190
  _M0AutomaticRoute.NATIVE_GAS_DROPOFF_SUPPORTED = false;
1165
1191
  // USDZ token address is the same across Ethereum and Arbitrum
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m0-foundation/ntt-sdk-route",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",
@@ -21,9 +21,9 @@
21
21
  "dist"
22
22
  ],
23
23
  "devDependencies": {
24
- "@changesets/cli": "^2.28.1",
24
+ "@changesets/cli": "^2.29.8",
25
25
  "@types/bn.js": "^5.2.0",
26
- "@types/node": "~20.17.17",
26
+ "@types/node": "~20.17.58",
27
27
  "ts-node": "^10.9.2",
28
28
  "tsup": "~8.3.6",
29
29
  "typescript": "~5.6.3"
@@ -33,18 +33,18 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@noble/hashes": "^1.8.0",
36
- "@solana/spl-token": "^0.4.13",
37
- "@solana/web3.js": "^1.98.2",
38
- "@wormhole-foundation/sdk": "3.4.7",
39
- "@wormhole-foundation/sdk-connect": "3.4.7",
40
- "@wormhole-foundation/sdk-definitions-ntt": "2.0.5",
41
- "@wormhole-foundation/sdk-evm": "3.4.7",
42
- "@wormhole-foundation/sdk-evm-ntt": "2.0.5",
43
- "@wormhole-foundation/sdk-route-ntt": "2.0.5",
44
- "@wormhole-foundation/sdk-solana": "3.4.7",
45
- "@wormhole-foundation/sdk-solana-ntt": "2.0.5",
36
+ "@solana/spl-token": "^0.4.14",
37
+ "@solana/web3.js": "^1.98.4",
38
+ "@wormhole-foundation/sdk": "4.9.1",
39
+ "@wormhole-foundation/sdk-connect": "4.9.1",
40
+ "@wormhole-foundation/sdk-definitions-ntt": "4.0.14",
41
+ "@wormhole-foundation/sdk-evm": "4.9.1",
42
+ "@wormhole-foundation/sdk-evm-ntt": "4.0.14",
43
+ "@wormhole-foundation/sdk-route-ntt": "4.0.14",
44
+ "@wormhole-foundation/sdk-solana": "4.9.1",
45
+ "@wormhole-foundation/sdk-solana-ntt": "4.0.14",
46
46
  "bn.js": "^5.2.2",
47
- "ethers": "^6.5.1"
47
+ "ethers": "^6.16.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "$npm_execpath tsup --clean",