npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@autonomysdk/perpaggregator

v0.8.8

Published

This project has typescript implementation of how we can interact with contracts and use it in UI

Downloads

176

Readme

PerpAggregator

This project has typescript implementation of how we can interact with contracts and use it in UI

Sample Code


// import {  swapPath } from "./domain/synthetics/orders/swapPath";
// import { ARBITRUM, getRpcUrl } from "./config/chains";
// import { useMarketInfo } from "./domain/synthetics/markets/useMarketInfo";
// import { BigNumber, ethers } from "ethers";
// import { getGasPrice } from "./domain/synthetics/fees/useGasPrice";
// import { useGasLimits } from "./domain/synthetics/fees/useGasLimits";
// import { estimateExecuteIncreaseOrderGasLimit, getExecutionFee } from "./domain/synthetics/fees/utils/executionFee";
// import { GasLimitsConfig } from "./domain/synthetics/fees/types";
// import { createIncreaseOrder } from "./domain/synthetics/orders/createIncreaseOrder";
// import { getSwapPathStats } from "./domain/synthetics/trade/utils/swapStats";
// import { kuseSwapRoutes } from "./domain/synthetics/trade/useSwapRoute";
// import { cancelOrdersTxn } from "./domain/synthetics/orders/cancelOrder";

// async function bootstrap() {
//   const {marketsInfoData}=await useMarketInfo(ARBITRUM)
//   const marketAddress='0x47c031236e19d024b42f8AE6780E44A573170703'
//   const marketInfo = marketsInfoData[marketAddress];
//   console.log(marketInfo);
  
//   const url = getRpcUrl(ARBITRUM)?.[0];
//   const provider = new ethers.providers.JsonRpcProvider(url);
//   const privateKey = process.env.PRIVATE_KEY as string;
//   const wallet = new ethers.Wallet(privateKey, provider);
//   const execFee=await exec()
  // const swapP=['0x47c031236e19d024b42f8AE6780E44A573170703']
  // const swap= getSwapPathStats({
  //   marketsInfoData:marketsInfoData,
  //   swapPath:swapP,
  //   initialCollateralAddress:"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
  //   wrappedNativeTokenAddress:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
  //   usdIn: BigNumber.from('0x02034ea2c876458ba412da680000'),
  //   shouldApplyPriceImpact:false,
  //   shouldUnwrapNativeToken:false

  // })
 
  

  // const positionInfo ={
  //   isLong : false,
  //   sizeInUsd : BigNumber.from("188453000000000000000000000000000"),
  //   market: ethers.utils.getAddress("0x70d95587d40A2caf56bd97485aB3Eec10Bee6336"),
  //   collateralAmount:BigNumber.from("9930471606974805")
  // }
  const execFee=await exec()

  // const data   = await createClosePosition(marketInfo, wallet, ARBITRUM, positionInfo)
  // console.log('Hashs', data);

  const hashsx = await createDecreaseOrder(marketInfo, wallet, ARBITRUM,execFee)
  console.log('Hashs', hashsx);
  // const hash=await cancelOrdersTxn(ARBITRUM,wallet,['0x7d5c470655a19429153a1be5f3262b079e38025150fee56c67811a9ef5dcb1fc',
  // '0x2ac7d17d7f1f818866184ebff2a41b2788f3c635fdac308bdfac67490bfef621'],execFee)
  // console.log(hash);
  
  // const hash = await createIncreaseOrder(marketInfo,marketsInfoData, wallet, '0.0001', '10.00', ARBITRUM, '0.3', false, true,execFee,3,'0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',"40000");
  // console.log('Hash', hash);



//   const { positionsInfoData } = await usePositionsInfo(ARBITRUM, {
//     account: wallet.address,
//     marketsInfoData: marketsInfoData,
//     tokensData: tokensData,
//     pricesUpdatedAt: pricesUpdatedAt,
//     showPnlInLeverage: true,
//   });

//   const parsedPosition = [];
//   for (const key in positionsInfoData) {
//     const position = positionsInfoData[key];
//     const poolName = getMarketPoolName(position.marketInfo);
//     const indexName = getMarketIndexName(position.marketInfo);
//     console.log("PPPPPP",position);
    
//     parsedPosition.push({
//       InitialCollateral: formatUsd(position.collateralUsd),
//       PnL: formatUsd(position.pnl),
//       PnLAfterFees: formatDeltaUsd(position.pnlAfterFees, position.pnlAfterFeesPercentage),
//       Market: position.marketAddress,
//       EntryPrice: formatUsd(position.entryPrice, { displayDecimals: position?.indexToken?.priceDecimals }),
//       MarkPrice: formatUsd(position.markPrice, { displayDecimals: position?.indexToken?.priceDecimals }),
//       LiqPrice: formatUsd(position.liquidationPrice, { displayDecimals: position?.indexToken?.priceDecimals }),
//       isLong: position.isLong,
//       NetValue: formatUsd(position.netValue),
//       PoolName: poolName,
//       IndexName: indexName,
//     });
//   }

//   console.log(parsedPosition);

//   // const hashs = await createDecreaseOrder(marketInfo, wallet, ARBITRUM);
//   // console.log('hashs', hashs);
}

bootstrap();

Execution Fee

import { getGasPrice } from './domain/synthetics/fees/useGasPrice';
import { useGasLimits } from './domain/synthetics/fees/useGasLimits';
import { estimateExecuteIncreaseOrderGasLimit, getExecutionFee } from './domain/synthetics/fees/utils/executionFee';
import { GasLimitsConfig } from './domain/synthetics/fees/types';

const exec=async () => {
  const activeChain = ARBITRUM;

  const gasPrice = await getGasPrice(activeChain);
  console.log('gasPrice', gasPrice.toString());

  const gasLimits = await useGasLimits(activeChain);
  console.log('gasLimits', gasLimits);

  const { marketsInfoData, tokensData, pricesUpdatedAt } = await useMarketInfo(activeChain);

  const estimatedGas = estimateExecuteIncreaseOrderGasLimit(gasLimits.gasLimits as GasLimitsConfig, {
    swapPath: [],
  });

  const executionFee = getExecutionFee(activeChain, gasLimits.gasLimits, tokensData, estimatedGas, gasPrice);
  console.log('executionFee', executionFee.feeTokenAmount);
  return executionFee.feeTokenAmount
};