Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@perp/contract
Advanced tools
Perpetual Protocol is a decentralized perpetual contract protocol for every asset, made possible by a Virtual Automated Market Maker (henceforth referred to as a “vAMM” or “vAMMs”). >*For those who aren’t familiar with perpetual contracts: A perpetual con
Perpetual Protocol is a decentralized perpetual contract protocol for every asset, made possible by a Virtual Automated Market Maker (henceforth referred to as a “vAMM” or “vAMMs”).
For those who aren’t familiar with perpetual contracts: A perpetual contract is a derivative similar to a futures contract but without an expiry date. For conventional futures contracts such as WTI, the contract’s price will gradually converge with the underlying asset’s spot market price as the expiry date approaches. Perpetual contracts are futures contracts that automatically roll over on a given time period, e.g. 1 hour, 8 hours, etc. In order to keep the perpetual contract in line with the underlying index, one side of the market pays the other a funding rate. The funding rate effectively implies a cost of capital and the steepness of the futures curve. You can learn more about how funding works by reading our documentation.
Please refer to the Perpetual Protocol documentation for more details.
Welcome to contribute to this project. Please join our Discord to discuss.
You should have Node 12 installed. Use nvm to install it.
Clone this repository, install NodeJS dependencies, and build the source code:
git clone git@github.com:perpetual-protocol/perp-contract.git
npm i
npm run build
Deploy in the local enviroment, deployed contract addresses listed in build/system-local.json
.
npm run dev
To learn more use cases, please refer to the development guide.
To run all the test cases,
npm run test
If you only want to run partial test cases, add .only
and pass the title of test cases or test sections. For example,
describe.only("Amm Unit Test", () => { ... }
or
it.only("admin open amm", async () => { ... }
Test cases can be found in the ./tests
folder.
This is for testing the deployment or upgradability of contracts.
Two params are required:
stage
can be staging
or production
fileName
is the targeted testing file in the publish/migrations
directorynpm run simulate <stage> <fileName>
Deploy contracts on rinkeby without versioning requires two environment variables: WEB3_RINKEBY_ENDPOINT & RINKEBY_MNEMONIC.
Once these two variables are set, the deployment script is needed. For example, we want to deploy the "PerpRewardVesting" contract, and the deploy script should be similar to this code snippet:
import { ethers, upgrades } from "hardhat"
import { ContractName } from "../publish/ContractName"
async function main() {
const perpAddress = "0xaFfB148304D38947193785D194972a7d0d9b7F68"
const options = {
unsafeAllowCustomTypes: true,
}
const Vesting = await ethers.getContractFactory(ContractFullyQualifiedName.PerpRewardVesting)
const instance = await upgrades.deployProxy(Vesting, [perpAddress], options)
await instance.deployed()
}
main()
execute the below commands:
./node_modules/.bin/hardhat --network rinkeby run scripts/deploy-reward-vesting.ts
And the contract should be deployed on rinkeby, and the file ".openzeppelin/rinkeby.json" is modified with new contract addresses, but the changes can be ignored for testing purposes.
When we create a new AMM, we always need to execute addAggregator()
to add a chainlink aggregator. Still, the arguments are all hex format numbers, and pretty easy to type the wrong parameters. There is a hardhat task "check:chainlink" to show all major information. We can use this information to check on gnosis multisign.
First step: go to https://docs.chain.link/docs/ethereum-addresses to find which price feed we need for the new AMM. e.g. if you want to check SNX/USD on homestead, please execute:
$ ./node_modules/.bin/hardhat check:chainlink --network homestead --address 0xDC3EA94CD0AC27d9A86C180091e7f78C683d3699
it will print basic information for SNX/USD:
When we create a new AMM, we always need to execute `addAggregator()` to add a chainlink aggregator. Still, the arguments are all hex format numbers, and pretty easy to type wrong parameters. There is a hardhat task "check:chainlink" to show all major information. We can use this information to check on gnosis multisign.
First step: go to https://docs.chain.link/docs/ethereum-addresses to find which price feed we need for the new AMM. e.g. if you want to check SNX/USD on homestead, please execute:
$ ./node_modules/.bin/hardhat check:chainlink --network homestead --address 0xDC3EA94CD0AC27d9A86C180091e7f78C683d3699
it will print basic information for SNX/USD:
pair: SNX / USD
base symbol: SNX
quote symbol: USD
latest price: 20.69401159
price feed key: 0x534e580000000000000000000000000000000000000000000000000000000000
functionData: 0x3f0e084f534e580000000000000000000000000000000000000000000000000000000000000000000000000000000000dc3ea94cd0ac27d9a86c180091e7f78c683d3699
When you send a transaction on gnosis app, we can use functionData
to check if the transaction data is correct.
GPL3.0 or later
FAQs
Perpetual Protocol is a decentralized perpetual contract protocol for every asset, made possible by a Virtual Automated Market Maker (henceforth referred to as a “vAMM” or “vAMMs”). >*For those who aren’t familiar with perpetual contracts: A perpetual con
We found that @perp/contract demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.