Image for post
Image for post

How Perpetual Protocol Uses Chainlink to Bring a Perpetual Contract to Every Asset

Perpetual Protocol
Dec 23, 2020 · 4 min read

Since the launch of Perpetual Protocol, we’ve received lots of questions regarding how we use Chainlink and what the future holds for this collaboration. To better inform our users, we wrote this definitive guide that goes into the integration in more detail.

The Perpetual Protocol + Chainlink Integration

A perpetual contract is a kind of derivative similar to a futures contract but without the 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 of the contract approaches. For a perpetual contract to converge its price with the spot market, the most effective method used in the industry is called “funding”.

In the case of Perpetual Protocol, our system pulls the spot price of each underlying asset once every 1 hour from Chainlink (this price is also known as the ‘index price’). Next, our smart contract calculates the difference between the time-weighted average price (TWAP) of Perpetual’s current market price and the TWAP of the index price. If the result is positive (Market Price > Index Price), long position holders need to pay a funding payment to the short position holders to negate the excessive demand for longs on Perpetual, vice versa if the difference is negative.

Image for post
Image for post

Please check here to see the formula we use to calculate the funding payment on Perpetual Protocol

Even though Perpetual Protocol’s system design is flexible enough to support any asset with a price feed on the Ethereum blockchain as the underlying asset for a perpetual contract, at launch, we only use BTC/USD and ETH/USD price feeds from Chainlink’s Price Reference Data. The reason being that we take security very seriously and want to make sure everything works as expected before expanding to additional assets.

One thing worth mentioning is that Perpetual Protocol uses xDai Chain to offer an enhanced trading experience with faster finality and no gas fees for trades. Native Chainlink integration with the xDai chain is under active development and Perpetual Protocol looks forward to being among the first users of price feeds on xDai. Until then, we are able to leverage a Chainlink External Adapter to read Chainlink Price Feed updates on Ethereum and write them on xDAI so they can be used by Perpetual. Learn more here.

As PERP, Perpetual Protocol’s native token, becomes more distributed among different holders, we will kick-start our governance process and let stakers vote on which underlying assets supported by Chainlink’s large collection of on-chain price feeds we should use to create the next tradable perpetual contract. As such, one can expect that Perpetual Protocol will consume more and more Chainlink Price Feeds as time goes by.

“We’re excited to be working with Perpetual Protocol by providing them with secure and reliable decentralized price oracles to ensure they have a well-functioning funding payment system,” said Johann Eid, Chainlink Product Manager. “This allows users to trust in the automated rebalancing of the network, ultimately bringing more security to user funds.”

We selected Chainlink as our go-to oracle solution because it’s a proven solution on mainnet currently securing $5B+ in total value for DeFi. Its decentralized architecture ensures highly available and tamper-resistant price oracles. It also provides accurate price data sourced from high-quality data aggregators, which maintain volume-adjusted market coverage across all trading environments as opposed to any single or small group of exchanges. This is key to protecting Perpetual against data manipulation vulnerabilities such as the recent flash loan attacks on DEX-based price oracles.

Image for post
Image for post
The Chainlink ETH/USD Price Reference Data feed used by Perpetual Protocol.

As Yenwen Feng, founder of Perpetual Protocol, puts it, “DeFi has seen tremendous growth thanks to the proliferation of derivatives protocols. We’re excited to integrate with the industry leader in oracles to ensure that our funding system is highly secure and rebalances according to accurate prices that represent aggregated global market prices. By integrating Chainlink, we accelerated our launch date and will ultimately be able to scale quickly to support more assets in the future.”

Perpetual Protocol is a decentralized perpetual contract protocol that lets traders trade long-tail futures with up to 20X leverage without counterparty risk.

Perpetual Protocol’s unique, maker-free vAMM (virtual automated market maker) guarantees on-chain liquidity for new and emerging futures and sets predictable prices using a tailormade constant product curve. $PERP, the native token of Perpetual Protocol, backs the protocol’s Staking Pool, which collectively secures each market and enables maker-less trading.

To open your first trade, visit

Website | Testnet | Twitter | Telegram | Discord | Documentation | Governance

Chainlink is the most widely used and secure way to power universal smart contracts. With Chainlink, developers can connect any blockchain with high-quality data sources from other blockchains as well as real-world data. Managed by a global, decentralized community of hundreds of thousands of people, Chainlink is introducing a fairer model for contracts. Its network currently secures billions of dollars in value for smart contracts across the decentralized finance (DeFi), insurance and gaming ecosystems, among others.

Chainlink is trusted by hundreds of organizations to deliver definitive truth via secure, reliable data feeds. To learn more, visit, subscribe to the Chainlink newsletter, and follow @chainlink on Twitter.

Docs | Discord | Reddit | YouTube | Telegram | Events | GitHub | Price Feeds | DeFi | VRF

Perpetual Protocol

Decentralized Perpetual Contract for Every Asset

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store