77 application methods of Chainlink in smart contracts (1)

Chainlink
本文约9021字,阅读全文需要约36分钟
This article is the first article of "77 Application Methods of Chainlink in Smart Contracts", which aims to introduce smart contracts to connect off-chain data through Chainlink and activate decentralized financial application scenarios. In th

This article is the first article of "77 Application Methods of Chainlink in Smart Contracts", which aims to introduce smart contracts to connect off-chain data through Chainlink and activate decentralized financial application scenarios. In the future, we will continue to issue follow-up articles to give you a more comprehensive understanding of how to use the Chainlink network, so stay tuned!

off-chain computation

A contract fundamentally defines the conditions and obligations for two or more independent entities to exchange value. Previously, a third-party arbitrator was usually required to determine whether these conditions were met. Now with blockchain and smart contract technology, we can replace the centralized arbitrator with a decentralized infrastructure, reduce counterparty risk and improve operational efficiency.

However, due to the unique consensus mechanism of the blockchain, smart contracts themselves cannot interact with off-chain data providers or API services, and therefore cannot verify whether events in the real world have occurred. This is often referred to as the “oracle problem” and is one of the biggest obstacles preventing the widespread adoption of blockchain smart contracts.

In order to solve the above connectivity problems, the smart contract is connected to the oracle middleware to obtain off-chain data, output the on-chain data to the off-chain system, and carry out scalable off-chain calculations. The oracle machine can not only bidirectionally connect the smart contract on the chain and the world off the chain, but also provide a security framework to prevent single point failures such as data manipulation and node offline.

The Chainlink network connects smart contracts to off-chain data and events.

  • ChainlinkOracleOracleThe network can independently provide many oracle services, including:

  • Decentralized PriceFeeds can be integrated into anyDeFiapp for high-quality, tamper-proof, up-to-date financial market data with full coverage across markets.

  • verifiable random functioncertificate of reserve

  • certificate of reserve(PoR) can audit the real off-chain reserve mortgage rate of any on-chain assets for smart contracts, such as stablecoins mortgaged by fiat currency, cross-chain tokens, and tokenized assets.

  • KeepersCross-chain Interoperability Protocol

  • Cross-chain Interoperability Protocol(CCIP) is an open source standard for cross-chain ecology, which can realize cross-chain applications and transmit messages, tokens and instructions across multiple blockchains.

  • Modular External Adapteroff-chain computation

  • off-chain computation, such as using fair ordering services to sort transactions, using DECO to ensure the privacy of TLS web session data proofs, using Arbitrum Rollups to implement scalable off-chain Solidity operations, etc.

Chainlink is a feature-rich oracle network that includes many oracle network models.

Ultimately, Chainlink provides developers with the tools they need to develop any type of oracle network, such as accessing multiple data sources, multiple oracle nodes, using different aggregation methods, penalty mechanisms, reputation systems, visualization tools, etc. . Therefore, developers can use Chainlink to develop, test and finally release various applications.

decentralized finance

decentralized finance

Currency is the common medium for measuring value and exchanging assets in today's world. Financial products provide a variety of tools for people to maximize the value of money through various methods such as hedging, speculation, interest income and mortgage loans. However, the traditional financial industry has a relatively high threshold, and institutions with strong financial resources often control currency issuance and the release and delivery of financial products. Therefore, finance cannot achieve inclusiveness, and there are also counterparty risks. Large institutions have greater influence, so there is no guarantee that financial products will be strictly implemented according to the terms agreed in advance.

currency market

currency market

and

AaveCompoundandRari CapitalIt is an on-chain currency market protocol that connects to Chainlink Price Feeds to obtain price data for dozens of different on-chain cryptocurrencies. Using real-time price data, these lending protocols can calculate each user's collateralized assets and debt valuations to determine when liquidation should occur. Money market protocols use this mechanism to guarantee sufficient collateralization ratios and protect the safety of tens of billions of user funds.

Aave connects to Chainlink Price Feeds to ensure sufficient mortgage rate

Decentralized Stablecoins

Stablecoins are on-chain tokens that are pegged one-to-one with fiat currencies, usually pegged to the U.S. dollar. Holders of stablecoins do not have to suffer from large price fluctuations. Centralized stablecoins are mortgaged by legal currency in off-chain bank accounts, while decentralized stablecoins are mortgaged by on-chain cryptocurrencies, usually with a mortgage rate of more than 100%, and access to price data is required to ensure a sufficient mortgage rate (For example, the value of the user's mortgage assets exceeds 150% of the actual loan value).

DeFiDollar is a typical decentralized meta-stablecoin (meta-stablecoin, referring to a stablecoin supported by multiple stablecoins), which is connected to Chainlink Price Feeds to track the prices of various underlying assets including sUSD, USDT, DAI and USDC . Once one or more of the tokens deviates from the one-to-one anchor price with the U.S. dollar, it will automatically trigger the rebalancing of the four assets to adjust the DUSD price back to sync with the U.S. dollar.

Algorithmic Stablecoins

Algorithmic Stablecoins

Centralized stablecoins are collateralized by dollars in bank accounts; decentralized stablecoins are over-collateralized by on-chain cryptocurrencies; and similarly, algorithmic stablecoins are designed to anchor another currency, such as the U.S. dollar. However, unlike the previous two, algorithmic stablecoins use an automatic reward and punishment mechanism to maintain the anchor price. Stablecoins are destroyed when the anchor price is lower than the anchor price, and new stablecoins are minted when the anchor price is higher.

Fei ProtocolIt is an algorithmic stable currency that accesses Chainlink Price Feeds as a reference price, and sets a value bonding curve controlled by the agreement for the FEI/ETH liquidity pool on Uniswap to maintain the anchor price of FEI tokens. After Fei Protocol is connected to the ETH/USD price feed covering all markets, it can guarantee the accuracy of the bonding curve exchange rate.

How Fei Protocol uses Chainlink Price Feeds to maintain the anchor price of its algorithmic stablecoin FEI.

futures

and

dYdXandMCDEXIt is this type of futures contract on the chain, and its perpetual contract is connected to Chainlink Price Feeds (Note: Perpetual contract refers to a futures contract that will never expire). These protocols integrate the Chainlink oracle machine, which can obtain real-time price data to judge when to liquidate, and dynamically adjust the financing rate to hedge risks, thus ensuring the solvency of the platform.

options

options

Like futures contracts, option contracts are a kind of financial derivatives, and traders have the right to buy or sell a certain amount of certain assets at a certain point in the future. In the off-chain world, option contracts are basically underwritten by centralized institutions; on the blockchain, a peer-to-peer decentralized model can be realized.

andOpynandThales, these protocols are connected to Chainlink Price Feeds to calculate the valuation of encrypted assets, and users can create and trade option contracts by themselves. In addition, Chainlink oracle nodes (such as:dxFeed) can provide the implied volatility data (Implied Volatility) of various encrypted assets, allowing contract creators to calculate the contract premium of options in a decentralized and tamper-proof way.

synthetic assets

synthetic assets

Synthetic assets are a class of financial instruments that allow traders to trade certain types of assets (such as indices or commodities) without owning the physical asset. Synthetic assets based on smart contracts allow traders to build advanced non-custodial trading strategies and have the opportunity to trade traditional assets off-chain.

Synthetix is ​​a typical synthetic asset derivatives protocol. It accesses Chainlink Price Feeds to create various synthetic assets, allowing traders to trade various assets such as cryptocurrencies, fiat currencies, commodities, indices, and stocks on the chain. Users can directly trade with contracts, exchange synthetic asset tokens, and access Chainlink Price Feeds to ensure zero slippage.

Synthetix accesses Chainlink Price Feeds to deliver price data for various synthetic assets.

credit default swap

A credit default swap (CDS) is a financial agreement that a borrower can use to hedge against the risk of a lender defaulting. If the lender defaults, the entity that issues and underwrites the CDS will compensate the borrower the amount that the lender defaults on.

Opium.Exchange is such an on-chain protocol that accesses Chainlink Price Feeds to deliver various financial instruments. One of the products is the CDS protocol for the centralized stablecoin USDT. Traders can hedge the risk of USDT deviating from the peg price of the US dollar.

bond

A bond is a financial agreement that can be issued to provide short-term financing and to repay the debt at a later date. Traditional bond contracts can be connected to Chainlink oracles to become automatically executed smart contracts. Chainlink oracles can provide smart contracts with various data such as interest rates, debt scores, and fiat currency payments.

Chainlink is already connected to SWIFT, proving the concept works. It is possible to aggregate interest rate data from the five major banks through the oracle machine, obtain debt scoring data from S&P, and pay interest based on the ISO20022 SWIFT payment standard. Bonds are an industry worth several trillion dollars, and migrating them to the blockchain will greatly reduce counterparty risks and operating costs.

The bond smart contract integrates Chainlink oracles and SWIFT's ISO20022 standard.

Tokenized Portfolio Management

A unique use case for smart contracts is non-custodial “smart portfolios,” where contracts execute trades on behalf of users based on predetermined conditions to automatically balance portfolios. This can provide users with advanced financial products that can be programmed to manage portfolios based on current market prices of assets and tokens. These trading strategies can be represented by tokens, and users can transfer and use these tokens in other smart contract applications.

Tokensets is one of the representative applications, which connects to Chainlink Price Feeds to generate "Set tokens" (tokenized positions), and executes transactions in the name of users. These Set tokens are based on various technical analysis indicators such as RSI or moving averages to capture the most critical price trends. In addition, users can also use Set tokens as mortgages in other protocols, for example, they can mortgage Set tokens in the Aave currency market to improve capital efficiency.

On-chain proof of reserves

Wrapped cross-chain assets (wrapped cross-chain assets) refer to the tokens that were originally on one blockchain locked in a smart contract, and then "unlocked" on another blockchain. This model is becoming more and more popular now because it can enrich the types of mortgage assets in the DeFi ecosystem. However, in order to ensure the security of DeFi applications that support packaging asset reserves, it is necessary to use the reserve proof reference contract to provide data on the real mortgage rate of assets on the chain.

Both BitGo’s WBTC and Ren Protocol’s renBTC tap into Chainlink’s proof-of-reserve reference data, the two protocols covering the majority of wrapped Bitcoin on the Ethereum blockchain worth billions of dollars. The reserve proof reference data provides the required data for the DeFi protocol, which can verify the mortgage reserve and ensure that the mortgage rate of users' funds is sufficient. The reserve proof reference data can also be used to track the mortgage rate of assets other than cross-chain tokens, such as stablecoins and off-chain commodities, further enriching the types of mortgage assets in the DeFi ecosystem.

Chainlink’s Proof-of-Reserve provides smart contracts with the Bitcoin collateralization rate behind BitGo’s wrapped Bitcoin.

Off-chain proof of reserves

Putting off-chain assets on the blockchain can effectively activate the DeFi economy, such as stablecoins anchored to fiat currencies. However, this requires the mortgage assets to be hosted by a third-party centralized entity, thus severing the link between the on-chain token and the off-chain underlying assets. Through Chainlink's proof of reserve, the smart contract can automatically verify the off-chain asset mortgage rate of the token, thereby protecting users from the impact of black swan events.

Such use cases include Proof of Reserves from Paxos for PAX and PAXG, and Proof of Reserves from TrustToken for TUSD. The latter provides DeFi applications with USD reserve data of TrustToken off-chain custodian bank accounts, which is the collateral reserve of the TUSD stablecoin, and the results are audited by Armanino, a top 25 audit firm in the United States. The mortgage data can be compared with the total amount of TUSD tokens circulating on each blockchain (the total amount of TUSD circulation is provided by the TUSD supply certificate) to determine the mortgage rate of TrustToken TUSD.

TrustToken is connected to the Chainlink reserve certificate to provide the smart contract with the off-chain legal currency reserve certificate of the TUSD stable currency.

Automated Asset Management

Smart contracts can be used to automatically execute transactions at a predefined frequency. However, a range of variables can affect the profitability of a transaction, the most important of which is gas costs. Therefore, traders in the automated trading system need to obtain reliable data through the oracle machine to ensure that the transaction continues to be profitable.

Visor Finance has integrated decentralized transaction automation service Chainlink Keepers, which will automatically rebalance Uniswap V3 positions when a predefined threshold is reached. Old and new capital can be strategically reallocated into liquidity positions and asset limit orders in order for the protocol to maintain optimal asset utilization.

revenue sharing

As more and more DeFi products adopt the DAO (Decentralized Autonomous Organization) governance model, developers and community members need to distribute the benefits generated by the DeFi protocol in a decentralized and real-time manner. After DAO integrates Chainlink oracle nodes, it can distribute cryptocurrency income proportionally according to different indicators, including the number of pledged tokens, participation in governance, developer activity, or any other customized indicators.

Synthetix is ​​a DeFi platform that integrates Chainlink Keepers to automatically distribute transaction fees and staking rewards to users on a weekly basis. Chainlink Keepers monitor the smart contract status off-chain and automatically call the allocation function in the feePools smart contract after the fee period ends.

Liquidity mining

Liquidity mining

Liquidity mining is an innovative financial model in the DeFi ecosystem. Its role is to stimulate platform liquidity and ensure that the protocol’s governance tokens can be distributed fairly. In most liquidity mining applications, users who provide liquidity will be rewarded with platform-native governance tokens, which can also be seen as a subsidy to stimulate platform growth.

Both protocols, Plasm and StrongBlock, are connected to the Chainlink oracle machine to realize the liquidity mining function. Plasm knows the amount locked by the user in the agreement through the Chainlink price oracle, and distributes rewards accordingly. StrongBlock, on the other hand, calculates the dollar value locked in the community pool every 24 hours.

StrongBlock accesses the Chainlink oracle to calculate the reward amount based on the reliability of the miners.

Leveraged Liquidity Mining

Users can use the leveraged liquidity mining protocol to improve income and capital efficiency. Depositors can take out low-mortgage loans, and the mortgage rate is determined by the agreement. Lenders can maximize asset value through various liquidity mining mechanisms, and borrowers can also obtain passive income from lenders. A currency market dedicated to liquidity mining can be established for specific applications.

The Alpaca Finance protocol is connected to Chainlink Price Feeds, and users can add leverage to their positions on PancakeSwap and WaultSwap. The price feed in the financial market can be used to calculate the loan-to-collateralization ratio and perform liquidation to ensure that the agreement is solvent in the long run and can operate normally even when there are severe fluctuations in the valuation of mortgage assets.

Alpaca Finance integrates Chainlink Price Feeds in lending and liquidation process

Cross-chain Liquidity Mining

Cross-chain Interoperability ProtocolCross-chain Interoperability Protocol(CCIP) is an open source standard for secure cross-chain message and token transmission, which can solve the above problems and provide developers with a tamper-proof infrastructure to create a cross-chain liquidity mining platform.

Celsius is a leading cryptocurrency liquidity mining platform with nearly 1 million users and a total lockup of over $16 billion. Celsius will integrate CCIP to create a future-oriented platform and realize the cross-chain revenue aggregation function. Celsius has also connected Chainlink Price Feeds at the back end to determine the loan interest rate when users deposit mortgage assets, further improving the level of decentralization of the platform.

Celsius will integrate CCIP to achieve high yields for billions of dollars worth of user deposits on the platform.

Loan agreement with automatic repayment

The loan agreement with automatic repayment is an innovative DeFi financial product. Users can deposit assets as collateral, and borrow or mint synthetic assets to obtain operating funds. The deposited mortgage assets are put into a liquidity mining agreement, and the proceeds are used for automatic loan repayment to improve the capital efficiency of loans.

Alchemix is ​​one such innovative financial product. It is connected to Chainlink Price Feeds and Chainlink Keepers to provide users with the benefits generated by overdrafting DAI and ETH deposits in advance. Price Feeds can be used to originate loans at fair market prices and maintain healthy mortgage rates. Keepers are used to trigger the aggregation and flushing of treasury income every day, automatic loan repayment, and reallocation of new deposits to Yearn Finance to generate income.

Alchemix Connects to Chainlink Price Feeds to Realize Automatic Repayment Function

Fuse mechanism

In the case of violent price fluctuations, asset prices on cryptocurrency exchanges may not reflect true market prices. This can lead to funds being taken away by arbitrageurs, or being liquidated at wrong prices due to users increasing their leveraged positions. Such incidents may affect users' trust in exchanges. The exchange can establish a circuit breaker mechanism that will be triggered once the price deviates.

decentralized exchange

decentralized exchange

A decentralized exchange is a blockchain trading platform on which users can trade cryptocurrencies without having to keep the assets traded or disclose personal information to a centralized institution. Decentralized exchanges are gradually being favored by more and more people, so some people begin to hope to move the trading strategies and advanced functions of traditional centralized exchanges to the blockchain.

Bamboo Relay is such a decentralized exchange, which is connected to Chainlink Price Feeds to realize the stop loss order function (note: the function of executing conditional transactions according to asset prices). The stop loss orders of each trader aggregate the market through the Chainlink oracle machine Price data, the stop loss transaction will be executed only when the asset market price exceeds the preset value, which can avoid market manipulation attacks caused by wrongly executed transactions.

automated market maker

automated market maker

Automated market makers (AMMs) are a type of decentralized exchange that is gaining traction. Automated market makers abandon the traditional order book model and instead use on-chain liquidity pools to trade assets based on predefined price formulas. Liquidity providers can pool funds together to obtain passive income, and traders can also obtain the required liquidity.

Equity pledge

Equity pledge

Many protocols have adopted the equity pledge mechanism (note: pledge cryptocurrency in smart contracts) to ensure the security of their encrypted economic network. Staking can provide a clearer understanding of reward and punishment mechanisms (i.e. punishing malicious behavior under certain conditions through algorithmic logic).

For example, AdEx requires its verification nodes to pledge their rights and interests to ensure high availability. AdEx is connected to the Chainlink node to monitor the online time of the node. If any node fails to meet the online time requirement, a penalty mechanism will be triggered. This mechanism can ensure that only high-quality node operators remain in the network, and they will further enhance the security of the entire platform.

Flexible Finance (Rebasing)

Elastic finance is an innovative financial mechanism in the DeFi field, which can automatically adjust the token supply chain to maintain the anchor price with assets such as the US dollar. If the token price exceeds the anchor price during the rebase process, more tokens will be automatically issued and distributed to all token holders in proportion to reduce the price of each token. On the contrary, if the token price is lower than the anchor price, a certain percentage of tokens held by each token holder will be destroyed to increase the token price.

Ampleforth is such a DeFi protocol, which is connected to Chainlink Price Feeds to realize the automatic adjustment function. Total AMPL issuance is adjusted daily to track the current Consumer Price Index (CPI), an index published by the Bureau of Economic Analysis for the current inflation-adjusted value of the U.S. dollar. The weighted average price and CPI index of AMPL are transmitted to the Ampleforth protocol by the Chainlink oracle.

Ampleforth accesses the Chainlink oracle to adjust the supply of AMPL tokens every 24 hours.

Connect assets in the real world

to liquidate

to liquidate

The blockchain currency market usually adopts an over-collateralization mechanism, which can guarantee the normal liquidation of loans when the value of mortgage assets falls or the value of loans rises, so as to protect the safety of users' funds. However, since the default state of the smart contract is "dormant", the liquidation function needs to be "woke up" by an external party in order to repay the loan and close the position. This process needs to have a high degree of reliability in case the loan is not repaid.

Aave is one such use case. It has tens of billions of dollars in user assets and is connected to Chainlink Keepers to automatically liquidate user positions. Chainlink Keepers will monitor the mortgage rate of the user's position. If the position is lower than the predefined mortgage rate (for example: 150%), the decentralized Chainlink Keeper network will call the liquidation function and close the position, even if the market fluctuates severely or the blockchain It can also work normally even when the network is severely congested.

Aave will use Chainlink Keepers to automatically liquidate undercollateralized loans.