Smart contract API
Getting started
yarn
forge install
forge test --gas-reportExample
forge install outdoteth/caviar transmissions11/solmatepragma solidity ^0.8.17;
import "caviar/Caviar.sol";
import "caviar/Pair.sol";
import "solmate/tokens/ERC721.sol";
contract ExampleSwapper {
Pair pair;
ERC721 nft;
constructor(address _nft, address _caviar) {
nft = ERC721(_nft);
pair = Pair(Caviar(_caviar).pairs(_nft, address(0), bytes32(0)));
}
function buyAndSell(uint256[] memory tokenIds, uint256 maxInput, uint256 minOutput) public payable {
// buy nfts
pair.nftBuy{value: maxInput}(tokenIds, maxInput);
// sell nfts
bytes32[][] memory proofs = new bytes32[][](0);
ReservoirOracle.Message[] memory reservoirMessages = new ReservoirOracle.Message[](0);
nft.setApprovalForAll(address(pair), true);
pair.nftSell(tokenIds, minOutput, proofs);
}
}Contracts overview
Contract
LOC
Description
Last updated