The following is an example of a settlement contract which determines the outcome of an Ante based on an asset price fetched from a Chainlink oracle.
The settle function takes some data that is decoded to a Chainlink oracle address (can be found here) and a price threshold. You need to make sure the threshold value takes into account the asset decimals.
This data value passed as a parameter when you create the Ante. This value doesn't get changed after creation and the AnteMetaPool smart contract will use it to call the settlement contract when the time comes.
If the fetched price is equal to the set threshold, the Ante will be marked as having no winner. At this point both parties can withdraw their initial stake.
If the fetched price is greater than the set threshold, A side is considered the winner.
If the fetched price is less than the set threshold, B side is considered the winner.
IMPORTANT! If you are the Ante author, you will automatically be assigned to side A. In order to stake behind a claim saying that an asset will be under a threshold, you will have to update the condition block accordingly.
link to repo
Full contract code
// SPDX-License-Identifier: GPL-3.0-onlypragmasolidity 0.8.21;/// @title The interface for a AnteSettlement smart contractinterface IAnteSettlement {enumWinningSide { NONE, A, B }/// @notice Settles the outcome of a given commitment/// @param data Arbitrary data used to determine the outcome/// @return the winning sidefunctionsettle(bytesmemory data) externalreturns (WinningSide);}// Chainlink Aggragator interface// import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";interface AggregatorV3Interface {functionlatestRoundData()externalviewreturns (uint80 roundId,int256 answer,uint256 startedAt,uint256 updatedAt,uint80 answeredInRound);}/** * Contract used for settling a commitment with a given Chainlink feed and * a given price threshold. * These values are set when the commitment is created. */contractAnteSettlementByTokenPriceisIAnteSettlement {functionsettle(bytesmemory data) externalviewreturns (WinningSide) { (address feedAddr,int priceThreshold) = abi.decode(data, (address,int)); AggregatorV3Interface dataFeed =AggregatorV3Interface(feedAddr);// prettier-ignore (/* uint80 roundID */,int price,/*uint startedAt*/,/*uint timeStamp*/,/*uint80 answeredInRound*/ ) = dataFeed.latestRoundData();if (price == priceThreshold) {return WinningSide.NONE; } elseif (price > priceThreshold) {return WinningSide.A; } else {return WinningSide.B; } }}