@parallel-protocol/cli 0.2.0 → 0.2.2

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 (2) hide show
  1. package/dist/index.js +33 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8079,15 +8079,34 @@ function slippageDown(amount) {
8079
8079
  return amount - amount * SLIPPAGE_BPS / 10000n;
8080
8080
  }
8081
8081
  async function readTokenDomain(chain, token) {
8082
+ return readTokenDomainFull(chain, token);
8083
+ }
8084
+ async function readTokenDomainFull(chain, token) {
8082
8085
  const client = getClient(chain);
8083
- const name = await client.readContract({
8084
- address: token,
8085
- abi: ERC20_ABI,
8086
- functionName: "name"
8087
- });
8086
+ const versionAbi = [
8087
+ {
8088
+ name: "version",
8089
+ type: "function",
8090
+ stateMutability: "view",
8091
+ inputs: [],
8092
+ outputs: [{ type: "string" }]
8093
+ }
8094
+ ];
8095
+ const [name, version] = await Promise.all([
8096
+ client.readContract({
8097
+ address: token,
8098
+ abi: ERC20_ABI,
8099
+ functionName: "name"
8100
+ }),
8101
+ client.readContract({
8102
+ address: token,
8103
+ abi: versionAbi,
8104
+ functionName: "version"
8105
+ }).catch(() => "1")
8106
+ ]);
8088
8107
  return {
8089
8108
  name,
8090
- version: "1",
8109
+ version,
8091
8110
  chainId: client.chain.id,
8092
8111
  verifyingContract: token
8093
8112
  };
@@ -8432,14 +8451,15 @@ async function prepareRouteE(chain, senderAddress, amount, recipient) {
8432
8451
  const usdcAddress = getUSDCAddress(chain);
8433
8452
  if (!usdcAddress) throw new Error(`USDC not configured on ${chain}`);
8434
8453
  const parallelizer = getParallelizerAddress(chain);
8435
- const amountInWei = parseUnits(amount, 6);
8436
- const expectedUSDpOut = await quoteSwapIn(
8454
+ const amountOutWei = parseUnits(amount, 18);
8455
+ const usdcNeeded = await quoteSwapOut(
8437
8456
  chain,
8438
- amountInWei,
8457
+ amountOutWei,
8439
8458
  usdcAddress,
8440
8459
  usdpAddress
8441
8460
  );
8442
- const amountOutMin = slippageDown(expectedUSDpOut);
8461
+ const amountInWei = slippageUp(usdcNeeded);
8462
+ const amountOutMin = amountOutWei;
8443
8463
  const { validAfter, validBefore } = buildTiming();
8444
8464
  const userSalt = generateNonce();
8445
8465
  const derived = derivedNonceExactInput(
@@ -8499,8 +8519,8 @@ async function prepareRouteE(chain, senderAddress, amount, recipient) {
8499
8519
  }
8500
8520
  },
8501
8521
  quote: {
8502
- amountIn: amount,
8503
- amountOut: formatUnits(expectedUSDpOut, 18),
8522
+ amountIn: formatUnits(amountInWei, 6),
8523
+ amountOut: amount,
8504
8524
  slippageBps: Number(SLIPPAGE_BPS)
8505
8525
  },
8506
8526
  typedData,
@@ -14541,7 +14561,7 @@ var package_default = {
14541
14561
 
14542
14562
  // package.json
14543
14563
  var package_default2 = {
14544
- version: "0.2.0"};
14564
+ version: "0.2.2"};
14545
14565
 
14546
14566
  // src/commands/version.ts
14547
14567
  function versionCommand() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallel-protocol/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [