@storknetwork/stork_chainlink_adapter
v1.0.6
Published
EVM Solidity contracts to adapt Stork price feeds to Chainlink's AggregatorV3 Interface
Readme
Stork Chainlink Adapter
This is the Stork Chainlink Adapter for EVM-compatible chains. This package is maintained by Stork Labs.
It is available on npm.
This package can be used as an SDK to build contracts that interact with Stork price feeds using Chainlink's familiar AggregatorV3Interface, or deployed as a standalone contract.
Chainlink Compatibility
The adapter implements Chainlink's AggregatorV3Interface, allowing existing Chainlink-integrated applications to seamlessly integrate withStork price feeds with minimal code changes.
Note: All timestamps are returned in nanoseconds (not seconds) to maintain Stork's high precision.
Usage as SDK
Install the package in your Solidity project:
npm install @storknetwork/stork_chainlink_adapterImport and use in your contract:
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.8.24 <0.9.0;
import "@storknetwork/stork_chainlink_adapter/contracts/StorkChainlinkAdapter.sol";
contract YourContract {
StorkChainlinkAdapter public priceAdapter;
constructor(address storkContract, bytes32 priceId) {
priceAdapter = new StorkChainlinkAdapter(storkContract, priceId);
}
function getLatestPrice() external view returns (int256) {
(, int256 price, , , ) = priceAdapter.latestRoundData();
return price;
}
}A complete working example can be found in the stork-external repository.
Deploying
To deploy the contract, clone down the repo and run the following commands from this contract's directory:
npm installnpx hardhat compile- Set the
storkContractandencodedAssetIdin theignition/parameters.jsonfile. Stork contract addresses and encoded asset ids can be found in the Stork Documentation. - Deploy the contract with
npx hardhat --network <network> ignition deploy ignition/modules/StorkChainlinkAdapter.ts --deployment-id chain-<chainId>-<assetId> --parameters ignition/parameters.json
