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

@predy/v2-contracts

v1.0.3

Published

![](https://github.com/predyprotocol/v2-contracts/workflows/Test/badge.svg) [![codecov](https://codecov.io/gh/predyprotocol/v2-contracts/branch/main/graph/badge.svg?token=yJ8DEr8Gck)](https://codecov.io/gh/predyprotocol/v2-contracts)

Downloads

7

Readme

Predy v2 contracts

codecov

Overview

Predy V2 is AMM(Automated Market Maker) for Perpetual Contracts. It supports portfolio margin trading of Squared perpetual and Perpetual future. Portfolio Margin is a margin method that utilizes the unrealized profits of other positions in the relevant asset to avoid liquidations on the positions using the same settlement asset. As a result, Predy's margin requirements for perpetual positions are significantly reduced compared to traditional policy rules.

Contracts

PerpetualMarket.sol is entry point of traders and liquidity providers. It manages traders' vault storage and holds funds from traders and liquidity providers.

PerpetualMarketCore.sol is the contract to manage perpetual pool positions and calculate amount of collaterals. It inherits ERC20 Token representing liquidity provider token.

FlashHedge.sol is the contract helps to swap underlying assets and USDC tokens with Uniswap for delta hedging.

Libraries

lib/TraderVaultLib.sol has functions to calculate position value and minimum collateral for implementing margin wallet.

lib/NettingLib.sol has functions to calculate pool's required collateral.

lib/SpreadLib.sol has functions to manage spread. It is to protect AMM from short-term volatility.

lib/IndexPricer.sol has functions to calculate index price, delta and gamma of Squared perpetual and Perpetual future.

lib/EntryPriceMath.sol has functions to calculate new entry price and profit from previous entry price and trade price for implementing margin wallet.

lib/Math.sol has functions for basic mathematical calculation.

Reference

Docs

Audit

Development

Run typechain

npm run typechain

Run all tests

npm test

Check contract size

npx hardhat size-contracts

Deploy

To deploy contract on testnet or mainnet, you'll need to provide an infura key to connect to an infura node. Copy .env.example file as .env and specify your keys there.

npx hardhat run --network rinkebyArbitrum ./scripts/deploy.ts

Call Contracts

Gets vault status.

npx hardhat vault --network rinkebyArbitrum

Using foundry

forge install openzeppelin/[email protected]
forge install uniswap/[email protected]
forge install uniswap/v3-periphery
forge install smartcontractkit/chainlink
forge install foundry-rs/forge-std
forge build --hardhat

Testing

forge test

# specify test case
forge test --match-path test/foundry/PerpetualMarketCore.t.sol

# verbose mode
forge test -vvv --match-path test/foundry/PerpetualMarketCore.t.sol