diff --git a/projects/subgraph-beanft/package.json b/projects/subgraph-beanft/package.json index 6a7f6291dc..9b5e1b4f9f 100644 --- a/projects/subgraph-beanft/package.json +++ b/projects/subgraph-beanft/package.json @@ -5,7 +5,7 @@ "codegen": "rm -rf ./generated && graph codegen", "build": "yarn codegen && graph build", "test": "graph test", - "testd": "docker run -it --rm --mount type=bind,source=\"$(pwd)\"/matchstick.yaml.docker,target=/matchstick/matchstick.yaml --mount type=bind,source=\"$(pwd)\"/../../,target=/matchstick/repo-mounted/ matchstick", + "testd": "docker run -it --rm --mount type=bind,source=\"$(pwd)\"/matchstick-docker.yaml,target=/matchstick/matchstick.yaml --mount type=bind,source=\"$(pwd)\"/../../,target=/matchstick/repo-mounted/ matchstick", "testd-named": "../subgraph-core/tests/scripts/docker-run-named.sh", "create-local": "graph create --node http://localhost:8020/ beanft", "remove-local": "graph remove --node http://localhost:8020/ beanft", diff --git a/projects/subgraph-beanstalk/schema.graphql b/projects/subgraph-beanstalk/schema.graphql index c13bc08547..aa8d569dbb 100644 --- a/projects/subgraph-beanstalk/schema.graphql +++ b/projects/subgraph-beanstalk/schema.graphql @@ -11,8 +11,8 @@ enum MarketStatus { enum PlotSource { SOW - HARVEST TRANSFER + MARKET } enum EmaWindow { @@ -669,28 +669,28 @@ type Plot @entity { field: Field! "Farmer who owns this plot" farmer: Farmer! - "Transaction source for this plot" + "Transaction source for this plot. Not the same as creationHash which can include plots splitting from transfer or harvest without the owner changing" source: PlotSource! + "Transaction hash corresponding to source" + sourceHash: String! "Associated plot listing" listing: PodListing "Season when created" season: Int! - "Creation transaction hash" + "Transaction hash of when this plot entity was created" creationHash: String! "Timestamp of creation" createdAt: BigInt! "Timestamp when updated" updatedAt: BigInt! + "Block when updated" + updatedAtBlock: BigInt! "Plot Index" index: BigInt! - "Beans used to sow, if any" - beans: BigInt! "Total pods in plot" pods: BigInt! - "Total pods that were sown, if any" - sownPods: BigInt! - "Temperature when the plot was sown" - temperature: Int! + "Number of beans spent for each pod, whether through sowing or on the marketplace" + beansPerPod: BigInt! "Number of pods harvestable" harvestablePods: BigInt! "Number of pods harvested" @@ -704,10 +704,10 @@ type PodMarketplace @entity { id: ID! "Current season of the marketplace" season: Int! - "Indexes of actively listed plots" - listingIndexes: [BigInt!]! - "Active pod order IDs" - orders: [PodOrder!]! + "Information about the active pod listings. Each entry of the form 'account-index-expiry'" + activeListings: [String!]! + "Information about the active pod orders. Each entry of the form 'orderId-maxPlaceInLine'" + activeOrders: [String!]! "All historical listings" allListings: [PodListing!]! @derivedFrom(field: "podMarketplace") "All historical orders" @@ -716,20 +716,24 @@ type PodMarketplace @entity { fills: [PodFill!]! @derivedFrom(field: "podMarketplace") "Current cumulative pods listed for sale" listedPods: BigInt! + "Current amount of total pods listed" + availableListedPods: BigInt! "Current cumulative pod listings filled" filledListedPods: BigInt! "Current cumulative pod listings that expired" expiredListedPods: BigInt! "Current cumulative pod listings that were cancelled" cancelledListedPods: BigInt! - "Current amount of total pods listed" - availableListedPods: BigInt! - "Current cumulative pod orders created" - orderedPods: BigInt! + "Current cumulative beans in pod orders created" + orderBeans: BigInt! + "Current amount of total beans in pod orders" + availableOrderBeans: BigInt! + "Current cumulative filled beans in pod orders" + filledOrderBeans: BigInt! "Current cumulative pod orders filled" filledOrderedPods: BigInt! - "Current cumulative pod orders cancelled" - cancelledOrderedPods: BigInt! + "Current cumulative beans in pod orders cancelled" + cancelledOrderBeans: BigInt! "Cumulative pod volume between listings and orders" podVolume: BigInt! "Cumulative bean volume between listings and orders" @@ -749,40 +753,48 @@ type PodMarketplaceHourlySnapshot @entity { podMarketplace: PodMarketplace! "Point in time current cumulative pods listed for sale" listedPods: BigInt! + "Point in time current amount of total pods listed" + availableListedPods: BigInt! "Point in time current cumulative pod listings filled" filledListedPods: BigInt! "Point in time current cumulative pod listings that expired" expiredListedPods: BigInt! "Point in time current cumulative pod listings that were cancelled" cancelledListedPods: BigInt! - "Point in time current amount of total pods listed" - availableListedPods: BigInt! - "Point in time current cumulative pod orders created" - orderedPods: BigInt! - "Point in time current cumulative pod orders filled" + "Current cumulative beans in pod orders created" + orderBeans: BigInt! + "Current amount of total beans in pod orders" + availableOrderBeans: BigInt! + "Current cumulative filled beans in pod orders" + filledOrderBeans: BigInt! + "Current cumulative pod orders filled" filledOrderedPods: BigInt! - "Point in time current cumulative pod orders cancelled" - cancelledOrderedPods: BigInt! + "Current cumulative beans in pod orders cancelled" + cancelledOrderBeans: BigInt! "Point in time current cumulative pod volume between listings and orders" podVolume: BigInt! "Point in time current cumulative bean volume between listings and orders" beanVolume: BigInt! "Point in time current delta pods listed for sale" deltaListedPods: BigInt! + "Point in time current delta of total pods listed" + deltaAvailableListedPods: BigInt! "Point in time current delta pod listings filled" deltaFilledListedPods: BigInt! "Point in time current delta pod listings that expired" deltaExpiredListedPods: BigInt! "Point in time current delta pod listings that were cancelled" deltaCancelledListedPods: BigInt! - "Point in time current delta of total pods listed" - deltaAvailableListedPods: BigInt! - "Point in time current delta pod orders created" - deltaOrderedPods: BigInt! + "Point in time current delta ordered beans in pod orders created" + deltaOrderBeans: BigInt! + "Point in time current delta available ordered beans in pod orders" + deltaAvailableOrderBeans: BigInt! + "Point in time current delta filled ordered beans in pod orders" + deltaFilledOrderBeans: BigInt! "Point in time current delta pod orders filled" deltaFilledOrderedPods: BigInt! - "Point in time current delta pod orders cancelled" - deltaCancelledOrderedPods: BigInt! + "Point in time current delta cancelled ordered beans in pod orders" + deltaCancelledOrderBeans: BigInt! "Point in time current delta pod volume between listings and orders" deltaPodVolume: BigInt! "Point in time current delta bean volume between listings and orders" @@ -802,40 +814,48 @@ type PodMarketplaceDailySnapshot @entity { podMarketplace: PodMarketplace! "Point in time current cumulative pods listed for sale" listedPods: BigInt! + "Point in time current amount of total pods listed" + availableListedPods: BigInt! "Point in time current cumulative pod listings filled" filledListedPods: BigInt! "Point in time current cumulative pod listings that expired" expiredListedPods: BigInt! "Point in time current cumulative pod listings that were cancelled" cancelledListedPods: BigInt! - "Point in time current amount of total pods listed" - availableListedPods: BigInt! - "Point in time current cumulative pod orders created" - orderedPods: BigInt! - "Point in time current cumulative pod orders filled" + "Current cumulative beans in pod orders created" + orderBeans: BigInt! + "Current amount of total beans in pod orders" + availableOrderBeans: BigInt! + "Current cumulative filled beans in pod orders" + filledOrderBeans: BigInt! + "Current cumulative pod orders filled" filledOrderedPods: BigInt! - "Point in time current cumulative pod orders cancelled" - cancelledOrderedPods: BigInt! + "Current cumulative beans in pod orders cancelled" + cancelledOrderBeans: BigInt! "Point in time current cumulative pod volume between listings and orders" podVolume: BigInt! "Point in time current cumulative bean volume between listings and orders" beanVolume: BigInt! "Point in time current delta pods listed for sale" deltaListedPods: BigInt! + "Point in time current delta of total pods listed" + deltaAvailableListedPods: BigInt! "Point in time current delta pod listings filled" deltaFilledListedPods: BigInt! "Point in time current delta pod listings that expired" deltaExpiredListedPods: BigInt! "Point in time current delta pod listings that were cancelled" deltaCancelledListedPods: BigInt! - "Point in time current delta of total pods listed" - deltaAvailableListedPods: BigInt! - "Point in time current delta pod orders created" - deltaOrderedPods: BigInt! + "Point in time current delta ordered beans in pod orders created" + deltaOrderBeans: BigInt! + "Point in time current delta available ordered beans in pod orders" + deltaAvailableOrderBeans: BigInt! + "Point in time current delta filled ordered beans in pod orders" + deltaFilledOrderBeans: BigInt! "Point in time current delta pod orders filled" deltaFilledOrderedPods: BigInt! - "Point in time current delta pod orders cancelled" - deltaCancelledOrderedPods: BigInt! + "Point in time current delta cancelled ordered beans in pod orders" + deltaCancelledOrderBeans: BigInt! "Point in time current delta pod volume between listings and orders" deltaPodVolume: BigInt! "Point in time current delta bean volume between listings and orders" @@ -981,11 +1001,6 @@ type PodListing @entity { """ filledAmount: BigInt! - """ - The number of Pods that were remaining in *this* PodListing when it was Cancelled. - """ - cancelledAmount: BigInt! - ######################## Activity ######################## "Any Fills associated with this PodListing." @@ -1072,21 +1087,16 @@ type PodOrder @entity { ######################## Amounts ######################## """ - The original number of Pods requested by this PodOrder. + The original number of Beans locked in the PodOrder. Does NOT change as Fills occur. - Not deterministic for PodOrders with pricingType = DYNAMIC. - - If pricingType = FIXED: - Set to the number of Pods which can be purchased by the Order. - If FIXED (V1): `amount` field emitted in PodOrderCreated. - If FIXED (V2): `amount / pricePerPod` fields emitted in PodOrderCreated. + Always deterministic, since the Farmer must lock Beans for PodOrder fulfillment. - If pricingType = DYNAMIC: - Set to `0`. The number of Pods that will be provided is unknown, since - the price is calculated based on the place in line of supplied Pods. + If FIXED (V1): `amount * pricePerPod` fields emitted in PodOrderCreated. + If FIXED (V2): `amount` field emitted in PodOrderCreated. + If DYNAMIC (V2): `amount` field emitted in PodOrderCreated. """ - podAmount: BigInt! + beanAmount: BigInt! """ The current number of Pods that have been purchased by this PodOrder. @@ -1099,18 +1109,6 @@ type PodOrder @entity { """ podAmountFilled: BigInt! - """ - The original number of Beans locked in the PodOrder. - - Does NOT change as Fills occur. - Always deterministic, since the Farmer must lock Beans for PodOrder fulfillment. - - If FIXED (V1): `amount * pricePerPod` fields emitted in PodOrderCreated. - If FIXED (V2): `amount` field emitted in PodOrderCreated. - If DYNAMIC (V2): `amount` field emitted in PodOrderCreated. - """ - beanAmount: BigInt! - """ The current number of Beans spent to acquire Pods. @@ -1152,18 +1150,20 @@ type PodFill @entity { listing: PodListing "Associated order, if any" order: PodOrder - "Account fulfilling the order" + "Account that is sending pods" from: String! # These are already referenced via the listing and order entities. - "Account filling the order" + "Account that is receiving pods" to: Farmer! "Number of pods filled" amount: BigInt! + "Where these pods were in line when filled" + placeInLine: BigInt! "Index of plot transferred" index: BigInt! "Start of plot transferred" start: BigInt! "Total beans used to fill listing/order" - costInBeans: BigInt + costInBeans: BigInt! } ################################## @@ -1548,6 +1548,8 @@ type PodListingCreated implements MarketplaceEvent @entity(immutable: true) { historyID: String! " Account creating the listing" account: String! + "Where these pods were in line when listed" + placeInLine: BigInt! " Index of the plot listed" index: BigInt! " Start value of the plot listed " @@ -1587,6 +1589,8 @@ type PodListingFilled implements MarketplaceEvent @entity(immutable: true) { from: String! "Account buying pods" to: String! + "Where these pods were in line when filled" + placeInLine: BigInt! "Index of the plot transferred" index: BigInt! "Start of the plot transferred" @@ -1614,6 +1618,8 @@ type PodListingCancelled implements MarketplaceEvent @entity(immutable: true) { historyID: String! " Account cancelling listing" account: String! + "Where these pods were in line when cancelled" + placeInLine: BigInt! " Index of plot listing being cancelled" index: BigInt! " Block number of this event " @@ -1672,6 +1678,8 @@ type PodOrderFilled implements MarketplaceEvent @entity(immutable: true) { from: String! "Account buying pods" to: String! + "Where these pods were in line when filled" + placeInLine: BigInt! "Index of the plot transferred" index: BigInt! "Start of the plot transferred" diff --git a/projects/subgraph-beanstalk/src/FieldHandler.ts b/projects/subgraph-beanstalk/src/FieldHandler.ts index 6e5d37d6d6..5c16d48342 100644 --- a/projects/subgraph-beanstalk/src/FieldHandler.ts +++ b/projects/subgraph-beanstalk/src/FieldHandler.ts @@ -11,13 +11,14 @@ import { } from "../generated/Field/Beanstalk"; import { Harvest as HarvestEntity } from "../generated/schema"; import { BEANSTALK, BEANSTALK_FARMS } from "../../subgraph-core/utils/Constants"; -import { ZERO_BI } from "../../subgraph-core/utils/Decimals"; +import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { loadFarmer } from "./utils/Farmer"; import { handleRateChange, loadField, loadFieldDaily, loadFieldHourly } from "./utils/Field"; import { loadPlot } from "./utils/Plot"; import { savePodTransfer } from "./utils/PodTransfer"; -import { loadSeason } from "./utils/Season"; +import { getCurrentSeason, getHarvestableIndex, loadSeason } from "./utils/Season"; import { loadBeanstalk } from "./utils/Beanstalk"; +import { expirePodListingIfExists } from "./utils/PodListing"; export function handleWeatherChange(event: WeatherChange): void { handleRateChange(event.address, event.block, event.params.season, event.params.caseId, event.params.change); @@ -72,14 +73,14 @@ export function handleSow(event: Sow): void { plot.farmer = event.params.account.toHexString(); plot.source = "SOW"; + plot.sourceHash = event.transaction.hash.toHexString(); plot.season = field.season; plot.creationHash = event.transaction.hash.toHexString(); plot.createdAt = event.block.timestamp; plot.updatedAt = event.block.timestamp; - plot.beans = event.params.beans; + plot.updatedAtBlock = event.block.number; plot.pods = event.params.pods; - plot.sownPods = event.params.pods; - plot.temperature = field.temperature; + plot.beansPerPod = event.params.beans.times(BI_10.pow(6)).div(plot.pods); plot.save(); // Increment protocol amounts @@ -103,6 +104,8 @@ export function handleHarvest(event: Harvest): void { // Plot should exist let plot = loadPlot(event.address, event.params.plots[i]); + expirePodListingIfExists(event.address, plot.farmer, plot.index, event.block.timestamp); + let harvestablePods = season.harvestableIndex.minus(plot.index); if (harvestablePods >= plot.pods) { @@ -168,15 +171,16 @@ export function handleHarvest(event: Harvest): void { let remainingPlot = loadPlot(event.address, remainingIndex); remainingPlot.farmer = plot.farmer; - remainingPlot.source = "HARVEST"; + remainingPlot.source = plot.source; + remainingPlot.sourceHash = plot.sourceHash; remainingPlot.season = beanstalk.lastSeason; remainingPlot.creationHash = event.transaction.hash.toHexString(); remainingPlot.createdAt = event.block.timestamp; remainingPlot.updatedAt = event.block.timestamp; + remainingPlot.updatedAtBlock = event.block.number; remainingPlot.index = remainingIndex; - remainingPlot.beans = ZERO_BI; remainingPlot.pods = remainingPods; - remainingPlot.temperature = plot.temperature; + remainingPlot.beansPerPod = plot.beansPerPod; remainingPlot.save(); plot.harvestedPods = harvestablePods; @@ -214,8 +218,8 @@ export function handleHarvest(event: Harvest): void { } export function handlePlotTransfer(event: PlotTransfer): void { - let beanstalk = loadBeanstalk(BEANSTALK); - let season = loadSeason(event.address, BigInt.fromI32(beanstalk.lastSeason)); + const currentSeason = getCurrentSeason(event.address); + const currentHarvestable = getHarvestableIndex(event.address); // Ensure both farmer entites exist loadFarmer(event.params.from); @@ -224,7 +228,7 @@ export function handlePlotTransfer(event: PlotTransfer): void { // Update farmer field data updateFieldTotals( event.params.from, - beanstalk.lastSeason, + currentSeason, ZERO_BI, ZERO_BI, ZERO_BI, @@ -236,7 +240,7 @@ export function handlePlotTransfer(event: PlotTransfer): void { ); updateFieldTotals( event.params.to, - beanstalk.lastSeason, + currentSeason, ZERO_BI, ZERO_BI, ZERO_BI, @@ -287,7 +291,7 @@ export function handlePlotTransfer(event: PlotTransfer): void { } }; - let transferredHarvestable = calcHarvestable(event.params.id, event.params.pods, season.harvestableIndex); + let transferredHarvestable = calcHarvestable(event.params.id, event.params.pods, currentHarvestable); // log.debug("\nPodTransfer: ===================\n", []); // log.debug("\nPodTransfer: Transfer Season - {}\n", [field.season.toString()]); @@ -303,10 +307,17 @@ export function handlePlotTransfer(event: PlotTransfer): void { // Actually transfer the plots if (sourcePlot.pods == event.params.pods) { // Sending full plot + const isMarket = sourcePlot.source == "MARKET" && sourcePlot.sourceHash == event.transaction.hash.toHexString(); + if (!isMarket) { + sourcePlot.source = "TRANSFER"; + sourcePlot.sourceHash = event.transaction.hash.toHexString(); + sourcePlot.beansPerPod = sourcePlot.beansPerPod; + } sourcePlot.farmer = event.params.to.toHexString(); sourcePlot.updatedAt = event.block.timestamp; + sourcePlot.updatedAtBlock = event.block.number; sourcePlot.save(); - log.debug("\nPodTransfer: Sending full plot\n", []); + // log.debug("\nPodTransfer: Sending full plot\n", []); } else if (sourceIndex == event.params.id) { // We are only needing to split this plot once to send // Start value of zero @@ -314,22 +325,33 @@ export function handlePlotTransfer(event: PlotTransfer): void { let remainderPlot = loadPlot(event.address, remainderIndex); sortedPlots.push(remainderIndex); + const isMarket = sourcePlot.source == "MARKET" && sourcePlot.sourceHash == event.transaction.hash.toHexString(); + if (!isMarket) { + // When sending the start of the plot via market, these cannot be derived from sourcePlot. + remainderPlot.source = sourcePlot.source; + remainderPlot.sourceHash = sourcePlot.sourceHash; + remainderPlot.beansPerPod = sourcePlot.beansPerPod; + + sourcePlot.source = "TRANSFER"; + sourcePlot.sourceHash = event.transaction.hash.toHexString(); + sourcePlot.beansPerPod = sourcePlot.beansPerPod; + } sourcePlot.farmer = event.params.to.toHexString(); sourcePlot.updatedAt = event.block.timestamp; + sourcePlot.updatedAtBlock = event.block.number; sourcePlot.pods = event.params.pods; - sourcePlot.harvestablePods = calcHarvestable(sourcePlot.index, sourcePlot.pods, season.harvestableIndex); + sourcePlot.harvestablePods = calcHarvestable(sourcePlot.index, sourcePlot.pods, currentHarvestable); sourcePlot.save(); remainderPlot.farmer = event.params.from.toHexString(); - remainderPlot.source = "TRANSFER"; remainderPlot.season = field.season; remainderPlot.creationHash = event.transaction.hash.toHexString(); remainderPlot.createdAt = event.block.timestamp; remainderPlot.updatedAt = event.block.timestamp; + remainderPlot.updatedAtBlock = event.block.number; remainderPlot.index = remainderIndex; remainderPlot.pods = sourceEndIndex.minus(transferEndIndex); - remainderPlot.harvestablePods = calcHarvestable(remainderPlot.index, remainderPlot.pods, season.harvestableIndex); - remainderPlot.temperature = sourcePlot.temperature; + remainderPlot.harvestablePods = calcHarvestable(remainderPlot.index, remainderPlot.pods, currentHarvestable); remainderPlot.save(); // log.debug("\nPodTransfer: sourceIndex == transferIndex\n", []); @@ -343,20 +365,26 @@ export function handlePlotTransfer(event: PlotTransfer): void { sortedPlots.push(event.params.id); sourcePlot.updatedAt = event.block.timestamp; + sourcePlot.updatedAtBlock = event.block.number; sourcePlot.pods = sourcePlot.pods.minus(event.params.pods); - sourcePlot.harvestablePods = calcHarvestable(sourcePlot.index, sourcePlot.pods, season.harvestableIndex); + sourcePlot.harvestablePods = calcHarvestable(sourcePlot.index, sourcePlot.pods, currentHarvestable); sourcePlot.save(); + const isMarket = toPlot.source == "MARKET" && toPlot.sourceHash == event.transaction.hash.toHexString(); + if (!isMarket) { + toPlot.source = "TRANSFER"; + toPlot.sourceHash = event.transaction.hash.toHexString(); + toPlot.beansPerPod = sourcePlot.beansPerPod; + } toPlot.farmer = event.params.to.toHexString(); - toPlot.source = "TRANSFER"; toPlot.season = field.season; toPlot.creationHash = event.transaction.hash.toHexString(); toPlot.createdAt = event.block.timestamp; toPlot.updatedAt = event.block.timestamp; + toPlot.updatedAtBlock = event.block.number; toPlot.index = event.params.id; toPlot.pods = event.params.pods; - toPlot.harvestablePods = calcHarvestable(toPlot.index, toPlot.pods, season.harvestableIndex); - toPlot.temperature = sourcePlot.temperature; + toPlot.harvestablePods = calcHarvestable(toPlot.index, toPlot.pods, currentHarvestable); toPlot.save(); // log.debug("\nPodTransfer: sourceEndIndex == transferEndIndex\n", []); @@ -371,32 +399,40 @@ export function handlePlotTransfer(event: PlotTransfer): void { sortedPlots.push(remainderIndex); sourcePlot.updatedAt = event.block.timestamp; + sourcePlot.updatedAtBlock = event.block.number; sourcePlot.pods = event.params.id.minus(sourcePlot.index); - sourcePlot.harvestablePods = calcHarvestable(sourcePlot.index, sourcePlot.pods, season.harvestableIndex); + sourcePlot.harvestablePods = calcHarvestable(sourcePlot.index, sourcePlot.pods, currentHarvestable); sourcePlot.save(); + const isMarket = toPlot.source == "MARKET" && toPlot.sourceHash == event.transaction.hash.toHexString(); + if (!isMarket) { + toPlot.source = "TRANSFER"; + toPlot.sourceHash = event.transaction.hash.toHexString(); + toPlot.beansPerPod = sourcePlot.beansPerPod; + } toPlot.farmer = event.params.to.toHexString(); - toPlot.source = "TRANSFER"; toPlot.season = field.season; toPlot.creationHash = event.transaction.hash.toHexString(); toPlot.createdAt = event.block.timestamp; toPlot.updatedAt = event.block.timestamp; + toPlot.updatedAtBlock = event.block.number; toPlot.index = event.params.id; toPlot.pods = event.params.pods; - toPlot.harvestablePods = calcHarvestable(toPlot.index, toPlot.pods, season.harvestableIndex); - toPlot.temperature = sourcePlot.temperature; + toPlot.harvestablePods = calcHarvestable(toPlot.index, toPlot.pods, currentHarvestable); toPlot.save(); remainderPlot.farmer = event.params.from.toHexString(); - remainderPlot.source = "TRANSFER"; + remainderPlot.source = sourcePlot.source; + remainderPlot.sourceHash = sourcePlot.sourceHash; remainderPlot.season = field.season; remainderPlot.creationHash = event.transaction.hash.toHexString(); remainderPlot.createdAt = event.block.timestamp; remainderPlot.updatedAt = event.block.timestamp; + remainderPlot.updatedAtBlock = event.block.number; remainderPlot.index = remainderIndex; remainderPlot.pods = sourceEndIndex.minus(transferEndIndex); - remainderPlot.harvestablePods = calcHarvestable(remainderPlot.index, remainderPlot.pods, season.harvestableIndex); - remainderPlot.temperature = sourcePlot.temperature; + remainderPlot.harvestablePods = calcHarvestable(remainderPlot.index, remainderPlot.pods, currentHarvestable); + remainderPlot.beansPerPod = sourcePlot.beansPerPod; remainderPlot.save(); // log.debug("\nPodTransfer: split source twice\n", []); @@ -413,7 +449,7 @@ export function handlePlotTransfer(event: PlotTransfer): void { if (transferredHarvestable != ZERO_BI) { updateFieldTotals( event.params.from, - beanstalk.lastSeason, + currentSeason, ZERO_BI, ZERO_BI, ZERO_BI, @@ -425,7 +461,7 @@ export function handlePlotTransfer(event: PlotTransfer): void { ); updateFieldTotals( event.params.to, - beanstalk.lastSeason, + currentSeason, ZERO_BI, ZERO_BI, ZERO_BI, diff --git a/projects/subgraph-beanstalk/src/MarketplaceHandler.ts b/projects/subgraph-beanstalk/src/MarketplaceHandler.ts index 860c141b01..f6f0d11348 100644 --- a/projects/subgraph-beanstalk/src/MarketplaceHandler.ts +++ b/projects/subgraph-beanstalk/src/MarketplaceHandler.ts @@ -1,4 +1,4 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Address, BigInt, Bytes, ethereum, log } from "@graphprotocol/graph-ts"; import { PodListingCancelled, PodListingCreated as PodListingCreated_v1, @@ -23,15 +23,64 @@ import { PodOrderCreated as PodOrderCreatedEvent, PodOrderFilled as PodOrderFilledEvent, PodOrderCancelled as PodOrderCancelledEvent, - PodOrder + PodOrder, + PodListing } from "../generated/schema"; -import { toDecimal, ZERO_BI } from "../../subgraph-core/utils/Decimals"; +import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { loadFarmer } from "./utils/Farmer"; -import { loadPlot } from "./utils/Plot"; import { loadPodFill } from "./utils/PodFill"; import { createHistoricalPodListing, loadPodListing } from "./utils/PodListing"; -import { loadPodMarketplace, loadPodMarketplaceDailySnapshot, loadPodMarketplaceHourlySnapshot } from "./utils/PodMarketplace"; +import { + MarketplaceAction, + updateActiveListings, + updateActiveOrders, + updateMarketListingBalances, + updateMarketOrderBalances +} from "./utils/PodMarketplace"; import { createHistoricalPodOrder, loadPodOrder } from "./utils/PodOrder"; +import { getHarvestableIndex } from "./utils/Season"; +import { loadPlot } from "./utils/Plot"; + +class PodListingCreatedParams { + event: ethereum.Event; + account: Address; + index: BigInt; + start: BigInt; + amount: BigInt; + pricePerPod: i32; + maxHarvestableIndex: BigInt; + mode: i32; // in v1, its called toWallet + // v2 + minFillAmount: BigInt; // for v1, always 0 + pricingFunction: Bytes | null; + pricingType: i32; // for v1, always 0 +} + +class PodOrderCreatedParams { + event: ethereum.Event; + account: Address; + id: Bytes; + beanAmount: BigInt; + pricePerPod: i32; + maxPlaceInLine: BigInt; + // v2 + minFillAmount: BigInt; // for v1, always 0 + pricingFunction: Bytes | null; + pricingType: i32; // for v1, always 0 +} + +// This one is the same for both listing/order fills. +class MarketFillParams { + event: ethereum.Event; + from: Address; + to: Address; + id: Bytes | null; // For pod order + index: BigInt; + start: BigInt; + amount: BigInt; + // v2; for v1, it can be computed and provided that way + costInBeans: BigInt; +} /* ------------------------------------ * POD MARKETPLACE V1 @@ -43,306 +92,110 @@ import { createHistoricalPodOrder, loadPodOrder } from "./utils/PodOrder"; */ export function handlePodListingCreated(event: PodListingCreated_v1): void { - let plotCheck = Plot.load(event.params.index.toString()); - if (plotCheck == null) { - return; - } - let plot = loadPlot(event.address, event.params.index); - - /// Upsert pod listing - let listing = loadPodListing(event.params.account, event.params.index); - if (listing.createdAt !== ZERO_BI) { - createHistoricalPodListing(listing); - listing.status = "ACTIVE"; - listing.createdAt = ZERO_BI; - listing.fill = null; - listing.filled = ZERO_BI; - listing.filledAmount = ZERO_BI; - listing.cancelledAmount = ZERO_BI; - } - - // Identifiers - listing.historyID = listing.id + "-" + event.block.timestamp.toString(); - listing.plot = plot.id; - - // Configuration - listing.start = event.params.start; - listing.mode = event.params.toWallet === true ? 0 : 1; - - // Constraints - listing.maxHarvestableIndex = event.params.maxHarvestableIndex; - - // Pricing - listing.pricePerPod = event.params.pricePerPod; - - // Amounts [Relative to Original] - listing.originalIndex = event.params.index; - listing.originalAmount = event.params.amount; - - // Amounts [Relative to Child] - listing.amount = event.params.amount; // in Pods - listing.remainingAmount = listing.originalAmount; - - // Metadata - listing.createdAt = listing.createdAt == ZERO_BI ? event.block.timestamp : listing.createdAt; - listing.updatedAt = event.block.timestamp; - listing.creationHash = event.transaction.hash.toHexString(); - listing.save(); - - /// Update plot - plot.listing = listing.id; - plot.save(); - - /// Update market totals - updateMarketListingBalances(event.address, plot.index, event.params.amount, ZERO_BI, ZERO_BI, ZERO_BI, event.block.timestamp); - - /// Save raw event data - let id = "podListingCreated-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); - let rawEvent = new PodListingCreatedEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); - rawEvent.historyID = listing.historyID; - rawEvent.account = event.params.account.toHexString(); - rawEvent.index = event.params.index; - rawEvent.start = event.params.start; - rawEvent.amount = event.params.amount; - rawEvent.pricePerPod = event.params.pricePerPod; - rawEvent.maxHarvestableIndex = event.params.maxHarvestableIndex; - rawEvent.minFillAmount = ZERO_BI; - rawEvent.mode = event.params.toWallet; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; - rawEvent.save(); + podListingCreated({ + event: event, + account: event.params.account, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + pricePerPod: event.params.pricePerPod, + maxHarvestableIndex: event.params.maxHarvestableIndex, + mode: event.params.toWallet ? 0 : 1, + minFillAmount: ZERO_BI, + pricingFunction: null, + pricingType: 0 + }); } export function handlePodListingCancelled(event: PodListingCancelled): void { - let listing = loadPodListing(event.params.account, event.params.index); - - updateMarketListingBalances(event.address, event.params.index, ZERO_BI, ZERO_BI, ZERO_BI, listing.remainingAmount, event.block.timestamp); - - listing.status = "CANCELLED"; - listing.cancelledAmount = listing.remainingAmount; - listing.remainingAmount = ZERO_BI; - listing.updatedAt = event.block.timestamp; - listing.save(); - - // Save the raw event data - let id = "podListingCancelled-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); - let rawEvent = new PodListingCancelledEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); - rawEvent.historyID = listing.historyID; - rawEvent.account = event.params.account.toHexString(); - rawEvent.index = event.params.index; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; - rawEvent.save(); + let listing = PodListing.load(event.params.account.toHexString() + "-" + event.params.index.toString()); + if (listing !== null && listing.status == "ACTIVE") { + updateActiveListings( + event.address, + MarketplaceAction.CANCELLED, + event.params.account.toHexString(), + listing.index, + listing.maxHarvestableIndex + ); + updateMarketListingBalances(event.address, ZERO_BI, listing.remainingAmount, ZERO_BI, ZERO_BI, event.block.timestamp); + + listing.status = listing.filled == ZERO_BI ? "CANCELLED" : "CANCELLED_PARTIAL"; + listing.updatedAt = event.block.timestamp; + listing.save(); + + // Save the raw event data + let id = "podListingCancelled-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); + let rawEvent = new PodListingCancelledEvent(id); + rawEvent.hash = event.transaction.hash.toHexString(); + rawEvent.logIndex = event.logIndex.toI32(); + rawEvent.protocol = event.address.toHexString(); + rawEvent.historyID = listing.historyID; + rawEvent.account = event.params.account.toHexString(); + rawEvent.placeInLine = event.params.index.plus(listing.start).minus(getHarvestableIndex(event.address)); + rawEvent.index = event.params.index; + rawEvent.blockNumber = event.block.number; + rawEvent.createdAt = event.block.timestamp; + rawEvent.save(); + } } export function handlePodListingFilled(event: PodListingFilled_v1): void { let listing = loadPodListing(event.params.from, event.params.index); - - let beanAmount = BigInt.fromI32(listing.pricePerPod).times(event.params.amount).div(BigInt.fromI32(1000000)); - - updateMarketListingBalances(event.address, event.params.index, ZERO_BI, ZERO_BI, event.params.amount, beanAmount, event.block.timestamp); - - listing.filledAmount = event.params.amount; - listing.remainingAmount = listing.remainingAmount.minus(event.params.amount); - listing.filled = listing.filled.plus(event.params.amount); - listing.updatedAt = event.block.timestamp; - - let originalHistoryID = listing.historyID; - if (listing.remainingAmount == ZERO_BI) { - listing.status = "FILLED"; - } else { - let market = loadPodMarketplace(event.address); - - listing.status = "FILLED_PARTIAL"; - let remainingListing = loadPodListing(Address.fromString(listing.farmer), listing.index.plus(event.params.amount).plus(listing.start)); - - remainingListing.historyID = remainingListing.id + "-" + event.block.timestamp.toString(); - remainingListing.plot = listing.index.plus(event.params.amount).plus(listing.start).toString(); - remainingListing.createdAt = listing.createdAt; - remainingListing.updatedAt = event.block.timestamp; - remainingListing.originalIndex = listing.originalIndex; - remainingListing.start = ZERO_BI; - remainingListing.amount = listing.remainingAmount; - remainingListing.originalAmount = listing.originalAmount; - remainingListing.filled = listing.filled; - remainingListing.remainingAmount = listing.remainingAmount; - remainingListing.pricePerPod = listing.pricePerPod; - remainingListing.maxHarvestableIndex = listing.maxHarvestableIndex; - remainingListing.mode = listing.mode; - remainingListing.creationHash = event.transaction.hash.toHexString(); - remainingListing.save(); - market.listingIndexes.push(remainingListing.index); - market.save(); - } - - /// Save pod fill - let fill = loadPodFill(event.address, event.params.index, event.transaction.hash.toHexString()); - fill.createdAt = event.block.timestamp; - fill.listing = listing.id; - fill.from = event.params.from.toHexString(); - fill.to = event.params.to.toHexString(); - fill.amount = event.params.amount; - fill.index = event.params.index; - fill.start = event.params.start; - fill.costInBeans = beanAmount; - fill.save(); - - listing.fill = fill.id; - listing.save(); - - // Save the raw event data - let id = "podListingFilled-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); - let rawEvent = new PodListingFilledEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); - rawEvent.historyID = originalHistoryID; - rawEvent.from = event.params.from.toHexString(); - rawEvent.to = event.params.to.toHexString(); - rawEvent.index = event.params.index; - rawEvent.start = event.params.start; - rawEvent.amount = event.params.amount; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; - rawEvent.save(); + const beanAmount = BigInt.fromI32(listing.pricePerPod).times(event.params.amount).div(BigInt.fromI32(1000000)); + + podListingFilled({ + event: event, + from: event.params.from, + to: event.params.to, + id: null, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + costInBeans: beanAmount + }); } export function handlePodOrderCreated(event: PodOrderCreated_v1): void { - let order = loadPodOrder(event.params.id); - let farmer = loadFarmer(event.params.account); - - if (order.status != "") { - createHistoricalPodOrder(order); - } - - order.historyID = order.id + "-" + event.block.timestamp.toString(); - order.farmer = event.params.account.toHexString(); - order.createdAt = event.block.timestamp; - order.updatedAt = event.block.timestamp; - order.status = "ACTIVE"; - order.podAmount = event.params.amount; - order.beanAmount = event.params.amount.times(BigInt.fromI32(event.params.pricePerPod)).div(BigInt.fromString("1000000")); - order.podAmountFilled = ZERO_BI; - order.maxPlaceInLine = event.params.maxPlaceInLine; - order.pricePerPod = event.params.pricePerPod; - order.creationHash = event.transaction.hash.toHexString(); - order.save(); - - updateMarketOrderBalances( - event.address, - order.id, - event.params.amount, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - event.block.timestamp - ); - - // Save the raw event data - let id = "podOrderCreated-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); - let rawEvent = new PodOrderCreatedEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); - rawEvent.historyID = order.historyID; - rawEvent.account = event.params.account.toHexString(); - rawEvent.orderId = event.params.id.toHexString(); - rawEvent.amount = event.params.amount; - rawEvent.pricePerPod = event.params.pricePerPod; - rawEvent.maxPlaceInLine = event.params.maxPlaceInLine; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; - rawEvent.save(); + const beanAmount = event.params.amount.times(BigInt.fromI32(event.params.pricePerPod)).div(BigInt.fromString("1000000")); + podOrderCreated({ + event: event, + account: event.params.account, + id: event.params.id, + beanAmount: beanAmount, + pricePerPod: event.params.pricePerPod, + maxPlaceInLine: event.params.maxPlaceInLine, + minFillAmount: ZERO_BI, + pricingFunction: null, + pricingType: 0 + }); } export function handlePodOrderFilled(event: PodOrderFilled_v1): void { let order = loadPodOrder(event.params.id); - let fill = loadPodFill(event.address, event.params.index, event.transaction.hash.toHexString()); - let beanAmount = BigInt.fromI32(order.pricePerPod).times(event.params.amount).div(BigInt.fromI32(1000000)); - order.updatedAt = event.block.timestamp; - order.podAmountFilled = order.podAmountFilled.plus(event.params.amount); - order.beanAmountFilled = order.beanAmountFilled.plus(beanAmount); - order.status = order.podAmount == order.podAmountFilled ? "FILLED" : "ACTIVE"; - let newFills = order.fills; - newFills.push(fill.id); - order.fills = newFills; - order.save(); - - fill.createdAt = event.block.timestamp; - fill.order = order.id; - fill.from = event.params.from.toHexString(); - fill.to = event.params.to.toHexString(); - fill.amount = event.params.amount; - fill.index = event.params.index; - fill.start = event.params.start; - fill.costInBeans = beanAmount; - fill.save(); - - updateMarketOrderBalances( - event.address, - order.id, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - event.params.amount, - beanAmount, - event.block.timestamp - ); - - if (order.podAmountFilled == order.podAmount) { - let market = loadPodMarketplace(event.address); - - let orderIndex = market.orders.indexOf(order.id); - if (orderIndex !== -1) { - market.orders.splice(orderIndex, 1); - } - market.save(); - } - - // Save the raw event data - let id = "podOrderFilled-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); - let rawEvent = new PodOrderFilledEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); - rawEvent.historyID = order.historyID; - rawEvent.from = event.params.from.toHexString(); - rawEvent.to = event.params.to.toHexString(); - rawEvent.index = event.params.index; - rawEvent.start = event.params.start; - rawEvent.amount = event.params.amount; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; - rawEvent.save(); + podOrderFilled({ + event: event, + from: event.params.from, + to: event.params.to, + id: event.params.id, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + costInBeans: beanAmount + }); } -let historyID = ""; - export function handlePodOrderCancelled(event: PodOrderCancelled): void { - let orderCheck = PodOrder.load(event.params.id.toHexString()); - if (orderCheck !== null) { - let order = loadPodOrder(event.params.id); - + let order = PodOrder.load(event.params.id.toHexString()); + if (order !== null && order.status == "ACTIVE") { order.status = order.podAmountFilled == ZERO_BI ? "CANCELLED" : "CANCELLED_PARTIAL"; order.updatedAt = event.block.timestamp; order.save(); + updateActiveOrders(event.address, MarketplaceAction.CANCELLED, order.id, order.maxPlaceInLine); updateMarketOrderBalances( event.address, - order.id, - ZERO_BI, - order.podAmount.minus(order.podAmountFilled), ZERO_BI, order.beanAmount.minus(order.beanAmountFilled), ZERO_BI, @@ -350,20 +203,19 @@ export function handlePodOrderCancelled(event: PodOrderCancelled): void { event.block.timestamp ); - historyID = order.historyID; + // Save the raw event data + let id = "podOrderCancelled-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); + let rawEvent = new PodOrderCancelledEvent(id); + rawEvent.hash = event.transaction.hash.toHexString(); + rawEvent.logIndex = event.logIndex.toI32(); + rawEvent.protocol = event.address.toHexString(); + rawEvent.historyID = order.historyID; + rawEvent.account = event.params.account.toHexString(); + rawEvent.orderId = event.params.id.toHexString(); + rawEvent.blockNumber = event.block.number; + rawEvent.createdAt = event.block.timestamp; + rawEvent.save(); } - // Save the raw event data - let id = "podOrderCancelled-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); - let rawEvent = new PodOrderCancelledEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); - rawEvent.historyID = historyID; - rawEvent.account = event.params.account.toHexString(); - rawEvent.orderId = event.params.id.toHexString(); - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; - rawEvent.save(); } /* ------------------------------------ @@ -372,131 +224,135 @@ export function handlePodOrderCancelled(event: PodOrderCancelled): void { * When Beanstalk was Replanted, `event.params.mode` was changed from * `bool` to `uint8`. * - * Proposal: ... - * Deployed: ... at block 15277986 + * Proposal: BIP-21 + * Deployed: 08/05/2022 at block 15278963 * ------------------------------------ */ export function handlePodListingCreated_v1_1(event: PodListingCreated_v1_1): void { - let plotCheck = Plot.load(event.params.index.toString()); - if (plotCheck == null) { - return; - } - let plot = loadPlot(event.address, event.params.index); - - /// Upsert pod listing - let listing = loadPodListing(event.params.account, event.params.index); - if (listing.createdAt !== ZERO_BI) { - createHistoricalPodListing(listing); - listing.status = "ACTIVE"; - listing.createdAt = ZERO_BI; - listing.fill = null; - listing.filled = ZERO_BI; - listing.filledAmount = ZERO_BI; - listing.cancelledAmount = ZERO_BI; - } - - listing.historyID = listing.id + "-" + event.block.timestamp.toString(); - listing.plot = plot.id; - - listing.start = event.params.start; - listing.mode = event.params.mode; - - listing.pricePerPod = event.params.pricePerPod; - listing.maxHarvestableIndex = event.params.maxHarvestableIndex; - - listing.originalIndex = event.params.index; - listing.originalAmount = event.params.amount; - - listing.amount = event.params.amount; - listing.remainingAmount = listing.originalAmount; + podListingCreated({ + event: event, + account: event.params.account, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + pricePerPod: event.params.pricePerPod, + maxHarvestableIndex: event.params.maxHarvestableIndex, + mode: event.params.mode, + minFillAmount: ZERO_BI, + pricingFunction: null, + pricingType: 0 + }); +} - listing.status = "ACTIVE"; - listing.createdAt = listing.createdAt == ZERO_BI ? event.block.timestamp : listing.createdAt; - listing.updatedAt = event.block.timestamp; - listing.creationHash = event.transaction.hash.toHexString(); +/* ------------------------------------ + * POD MARKETPLACE V2 + * + * Proposal: BIP-29 https://bean.money/bip-29 + * Deployed: 11/12/2022 @ block 15951072 + * ------------------------------------ + */ - listing.save(); +export function handlePodListingCreated_v2(event: PodListingCreated_v2): void { + podListingCreated({ + event: event, + account: event.params.account, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + pricePerPod: event.params.pricePerPod, + maxHarvestableIndex: event.params.maxHarvestableIndex, + mode: event.params.mode, + minFillAmount: event.params.minFillAmount, + pricingFunction: event.params.pricingFunction, + pricingType: event.params.pricingType + }); +} - /// Update plot - plot.listing = listing.id; - plot.save(); +export function handlePodListingFilled_v2(event: PodListingFilled_v2): void { + podListingFilled({ + event: event, + from: event.params.from, + to: event.params.to, + id: null, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + costInBeans: event.params.costInBeans + }); +} - /// Update market totals - updateMarketListingBalances(event.address, plot.index, event.params.amount, ZERO_BI, ZERO_BI, ZERO_BI, event.block.timestamp); +export function handlePodOrderCreated_v2(event: PodOrderCreated_v2): void { + podOrderCreated({ + event: event, + account: event.params.account, + id: event.params.id, + beanAmount: event.params.amount, + pricePerPod: event.params.pricePerPod, + maxPlaceInLine: event.params.maxPlaceInLine, + minFillAmount: event.params.minFillAmount, + pricingFunction: event.params.pricingFunction, + pricingType: event.params.priceType + }); +} - /// Save raw event data - let id = "podListingCreated-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); - let rawEvent = new PodListingCreatedEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); - rawEvent.historyID = listing.historyID; - rawEvent.account = event.params.account.toHexString(); - rawEvent.index = event.params.index; - rawEvent.start = event.params.start; - rawEvent.amount = event.params.amount; - rawEvent.pricePerPod = event.params.pricePerPod; - rawEvent.maxHarvestableIndex = event.params.maxHarvestableIndex; - rawEvent.maxHarvestableIndex = ZERO_BI; - rawEvent.minFillAmount = ZERO_BI; - rawEvent.mode = event.params.mode; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; - rawEvent.save(); +export function handlePodOrderFilled_v2(event: PodOrderFilled_v2): void { + podOrderFilled({ + event: event, + from: event.params.from, + to: event.params.to, + id: event.params.id, + index: event.params.index, + start: event.params.start, + amount: event.params.amount, + costInBeans: event.params.costInBeans + }); } /* ------------------------------------ - * POD MARKETPLACE V2 - * - * Proposal: BIP-29 https://bean.money/bip-29 - * Deployed: 11/12/2022 @ block 15277986 + * SHARED FUNCTIONS * ------------------------------------ */ -export function handlePodListingCreated_v2(event: PodListingCreated_v2): void { - let plotCheck = Plot.load(event.params.index.toString()); - if (plotCheck == null) { +function podListingCreated(params: PodListingCreatedParams): void { + let plot = Plot.load(params.index.toString()); + if (plot == null) { return; } - let plot = loadPlot(event.address, event.params.index); /// Upsert PodListing - let listing = loadPodListing(event.params.account, event.params.index); + let listing = loadPodListing(params.account, params.index); if (listing.createdAt !== ZERO_BI) { // Re-listed prior plot with new info createHistoricalPodListing(listing); - listing.status = "ACTIVE"; - listing.createdAt = ZERO_BI; listing.fill = null; listing.filled = ZERO_BI; listing.filledAmount = ZERO_BI; - listing.cancelledAmount = ZERO_BI; } - listing.historyID = listing.id + "-" + event.block.timestamp.toString(); + listing.historyID = listing.id + "-" + params.event.block.timestamp.toString() + "-" + params.event.logIndex.toString(); listing.plot = plot.id; - listing.start = event.params.start; - listing.mode = event.params.mode; + listing.start = params.start; + listing.mode = params.mode; - listing.minFillAmount = event.params.minFillAmount; - listing.maxHarvestableIndex = event.params.maxHarvestableIndex; + listing.minFillAmount = params.minFillAmount; + listing.maxHarvestableIndex = params.maxHarvestableIndex; - listing.pricingType = event.params.pricingType; - listing.pricePerPod = event.params.pricePerPod; - listing.pricingFunction = event.params.pricingFunction; + listing.pricingType = params.pricingType; + listing.pricePerPod = params.pricePerPod; + listing.pricingFunction = params.pricingFunction; - listing.originalIndex = event.params.index; - listing.originalAmount = event.params.amount; + listing.originalIndex = params.index; + listing.originalAmount = params.amount; - listing.amount = event.params.amount; + listing.amount = params.amount; listing.remainingAmount = listing.originalAmount; listing.status = "ACTIVE"; - listing.createdAt = listing.createdAt == ZERO_BI ? event.block.timestamp : listing.createdAt; - listing.updatedAt = event.block.timestamp; - listing.creationHash = event.transaction.hash.toHexString(); + listing.createdAt = params.event.block.timestamp; + listing.updatedAt = params.event.block.timestamp; + listing.creationHash = params.event.transaction.hash.toHexString(); listing.save(); @@ -505,61 +361,67 @@ export function handlePodListingCreated_v2(event: PodListingCreated_v2): void { plot.save(); /// Update market totals - updateMarketListingBalances(event.address, plot.index, event.params.amount, ZERO_BI, ZERO_BI, ZERO_BI, event.block.timestamp); + updateActiveListings( + params.event.address, + MarketplaceAction.CREATED, + params.account.toHexString(), + listing.index, + listing.maxHarvestableIndex + ); + updateMarketListingBalances(params.event.address, params.amount, ZERO_BI, ZERO_BI, ZERO_BI, params.event.block.timestamp); /// Save raw event data - let id = "podListingCreated-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); + let id = "podListingCreated-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodListingCreatedEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); + rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.logIndex = params.event.logIndex.toI32(); + rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = listing.historyID; - rawEvent.account = event.params.account.toHexString(); - rawEvent.index = event.params.index; - rawEvent.start = event.params.start; - rawEvent.amount = event.params.amount; - rawEvent.pricePerPod = event.params.pricePerPod; - rawEvent.maxHarvestableIndex = event.params.maxHarvestableIndex; - rawEvent.minFillAmount = event.params.minFillAmount; - rawEvent.mode = event.params.mode; - rawEvent.pricingFunction = event.params.pricingFunction; - rawEvent.pricingType = event.params.pricingType; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; + rawEvent.account = params.account.toHexString(); + rawEvent.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex(params.event.address)); + rawEvent.index = params.index; + rawEvent.start = params.start; + rawEvent.amount = params.amount; + rawEvent.pricePerPod = params.pricePerPod; + rawEvent.maxHarvestableIndex = params.maxHarvestableIndex; + rawEvent.minFillAmount = params.minFillAmount; + rawEvent.mode = params.mode; + rawEvent.pricingFunction = params.pricingFunction; + rawEvent.pricingType = params.pricingType; + rawEvent.blockNumber = params.event.block.number; + rawEvent.createdAt = params.event.block.timestamp; rawEvent.save(); } -export function handlePodListingFilled_v2(event: PodListingFilled_v2): void { - let listing = loadPodListing(event.params.from, event.params.index); +function podListingFilled(params: MarketFillParams): void { + let listing = loadPodListing(params.from, params.index); - updateMarketListingBalances( - event.address, - event.params.index, - ZERO_BI, - ZERO_BI, - event.params.amount, - event.params.costInBeans, - event.block.timestamp - ); + updateMarketListingBalances(params.event.address, ZERO_BI, ZERO_BI, params.amount, params.costInBeans, params.event.block.timestamp); - listing.filledAmount = event.params.amount; - listing.remainingAmount = listing.remainingAmount.minus(event.params.amount); - listing.filled = listing.filled.plus(event.params.amount); - listing.updatedAt = event.block.timestamp; + listing.filledAmount = params.amount; + listing.remainingAmount = listing.remainingAmount.minus(params.amount); + listing.filled = listing.filled.plus(params.amount); + listing.updatedAt = params.event.block.timestamp; let originalHistoryID = listing.historyID; if (listing.remainingAmount == ZERO_BI) { listing.status = "FILLED"; + updateActiveListings( + params.event.address, + MarketplaceAction.FILLED_FULL, + params.from.toHexString(), + listing.index, + listing.maxHarvestableIndex + ); } else { - let market = loadPodMarketplace(event.address); - listing.status = "FILLED_PARTIAL"; - let remainingListing = loadPodListing(Address.fromString(listing.farmer), listing.index.plus(event.params.amount).plus(listing.start)); - remainingListing.historyID = remainingListing.id + "-" + event.block.timestamp.toString(); - remainingListing.plot = listing.index.plus(event.params.amount).plus(listing.start).toString(); + let remainingListing = loadPodListing(Address.fromString(listing.farmer), listing.index.plus(params.amount).plus(listing.start)); + remainingListing.historyID = + remainingListing.id + "-" + params.event.block.timestamp.toString() + "-" + params.event.logIndex.toString(); + remainingListing.plot = listing.index.plus(params.amount).plus(listing.start).toString(); remainingListing.createdAt = listing.createdAt; - remainingListing.updatedAt = event.block.timestamp; + remainingListing.updatedAt = params.event.block.timestamp; remainingListing.originalIndex = listing.originalIndex; remainingListing.start = ZERO_BI; remainingListing.amount = listing.remainingAmount; @@ -569,295 +431,179 @@ export function handlePodListingFilled_v2(event: PodListingFilled_v2): void { remainingListing.pricePerPod = listing.pricePerPod; remainingListing.maxHarvestableIndex = listing.maxHarvestableIndex; remainingListing.mode = listing.mode; - remainingListing.creationHash = event.transaction.hash.toHexString(); + remainingListing.creationHash = params.event.transaction.hash.toHexString(); remainingListing.minFillAmount = listing.minFillAmount; remainingListing.save(); - market.listingIndexes.push(remainingListing.index); - market.save(); + + // Process the partial fill on the prev listing, and the new listing + updateActiveListings( + params.event.address, + MarketplaceAction.FILLED_PARTIAL, + params.from.toHexString(), + listing.index, + listing.maxHarvestableIndex + ); + updateActiveListings( + params.event.address, + MarketplaceAction.CREATED, + params.from.toHexString(), + remainingListing.index, + remainingListing.maxHarvestableIndex + ); } - let fill = loadPodFill(event.address, event.params.index, event.transaction.hash.toHexString()); - fill.createdAt = event.block.timestamp; + let fill = loadPodFill(params.event.address, params.index, params.event.transaction.hash.toHexString()); + fill.createdAt = params.event.block.timestamp; fill.listing = listing.id; - fill.from = event.params.from.toHexString(); - fill.to = event.params.to.toHexString(); - fill.amount = event.params.amount; - fill.index = event.params.index; - fill.start = event.params.start; - fill.costInBeans = event.params.costInBeans; + fill.from = params.from.toHexString(); + fill.to = params.to.toHexString(); + fill.amount = params.amount; + fill.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex(params.event.address)); + fill.index = params.index; + fill.start = params.start; + fill.costInBeans = params.costInBeans; fill.save(); listing.fill = fill.id; listing.save(); + setBeansPerPodAfterFill(params.event, fill.index, fill.start, fill.amount, fill.costInBeans); + // Save the raw event data - let id = "podListingFilled-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); + let id = "podListingFilled-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodListingFilledEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); + rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.logIndex = params.event.logIndex.toI32(); + rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = originalHistoryID; - rawEvent.from = event.params.from.toHexString(); - rawEvent.to = event.params.to.toHexString(); - rawEvent.index = event.params.index; - rawEvent.start = event.params.start; - rawEvent.amount = event.params.amount; - rawEvent.costInBeans = event.params.costInBeans; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; + rawEvent.from = params.from.toHexString(); + rawEvent.to = params.to.toHexString(); + rawEvent.placeInLine = fill.placeInLine; + rawEvent.index = params.index; + rawEvent.start = params.start; + rawEvent.amount = params.amount; + rawEvent.costInBeans = params.costInBeans; + rawEvent.blockNumber = params.event.block.number; + rawEvent.createdAt = params.event.block.timestamp; rawEvent.save(); } -export function handlePodOrderCreated_v2(event: PodOrderCreated_v2): void { - let order = loadPodOrder(event.params.id); - let farmer = loadFarmer(event.params.account); +function podOrderCreated(params: PodOrderCreatedParams): void { + let order = loadPodOrder(params.id); + loadFarmer(params.account); if (order.status != "") { createHistoricalPodOrder(order); } - // Store the pod amount if the order is a FIXED pricingType - if (event.params.priceType == 0) { - order.podAmount = event.params.amount.times(BigInt.fromI32(1000000)).div(BigInt.fromI32(event.params.pricePerPod)); - } - - order.historyID = order.id + "-" + event.block.timestamp.toString(); - order.farmer = event.params.account.toHexString(); - order.createdAt = event.block.timestamp; - order.updatedAt = event.block.timestamp; + order.historyID = order.id + "-" + params.event.block.timestamp.toString() + "-" + params.event.logIndex.toString(); + order.farmer = params.account.toHexString(); + order.createdAt = params.event.block.timestamp; + order.updatedAt = params.event.block.timestamp; order.status = "ACTIVE"; - order.beanAmount = event.params.amount; + order.beanAmount = params.beanAmount; order.beanAmountFilled = ZERO_BI; - order.minFillAmount = event.params.minFillAmount; - order.maxPlaceInLine = event.params.maxPlaceInLine; - order.pricePerPod = event.params.pricePerPod; - order.pricingFunction = event.params.pricingFunction; - order.pricingType = event.params.priceType; - order.creationHash = event.transaction.hash.toHexString(); + order.podAmountFilled = ZERO_BI; + order.minFillAmount = params.minFillAmount; + order.maxPlaceInLine = params.maxPlaceInLine; + order.pricePerPod = params.pricePerPod; + order.pricingFunction = params.pricingFunction; + order.pricingType = params.pricingType; + order.creationHash = params.event.transaction.hash.toHexString(); + order.fills = []; order.save(); - updateMarketOrderBalances( - event.address, - order.id, - ZERO_BI, - ZERO_BI, - event.params.amount, - ZERO_BI, - ZERO_BI, - ZERO_BI, - event.block.timestamp - ); + updateActiveOrders(params.event.address, MarketplaceAction.CREATED, order.id, order.maxPlaceInLine); + updateMarketOrderBalances(params.event.address, params.beanAmount, ZERO_BI, ZERO_BI, ZERO_BI, params.event.block.timestamp); // Save the raw event data - let id = "podOrderCreated-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); + let id = "podOrderCreated-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodOrderCreatedEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); + rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.logIndex = params.event.logIndex.toI32(); + rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = order.historyID; - rawEvent.account = event.params.account.toHexString(); - rawEvent.orderId = event.params.id.toHexString(); - rawEvent.amount = event.params.amount; - rawEvent.pricePerPod = event.params.pricePerPod; - rawEvent.maxPlaceInLine = event.params.maxPlaceInLine; - rawEvent.pricingFunction = event.params.pricingFunction; - rawEvent.pricingType = event.params.priceType; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; + rawEvent.account = params.account.toHexString(); + rawEvent.orderId = params.id.toHexString(); + rawEvent.amount = params.beanAmount; + rawEvent.pricePerPod = params.pricePerPod; + rawEvent.maxPlaceInLine = params.maxPlaceInLine; + rawEvent.pricingFunction = params.pricingFunction; + rawEvent.pricingType = params.pricingType; + rawEvent.blockNumber = params.event.block.number; + rawEvent.createdAt = params.event.block.timestamp; rawEvent.save(); } -export function handlePodOrderFilled_v2(event: PodOrderFilled_v2): void { - let order = loadPodOrder(event.params.id); - let fill = loadPodFill(event.address, event.params.index, event.transaction.hash.toHexString()); +function podOrderFilled(params: MarketFillParams): void { + let order = loadPodOrder(params.id!); + let fill = loadPodFill(params.event.address, params.index, params.event.transaction.hash.toHexString()); - order.updatedAt = event.block.timestamp; - order.beanAmountFilled = order.beanAmountFilled.plus(event.params.costInBeans); - order.podAmountFilled = order.podAmountFilled.plus(event.params.amount); + order.updatedAt = params.event.block.timestamp; + order.beanAmountFilled = order.beanAmountFilled.plus(params.costInBeans); + order.podAmountFilled = order.podAmountFilled.plus(params.amount); order.status = order.beanAmount == order.beanAmountFilled ? "FILLED" : "ACTIVE"; let newFills = order.fills; newFills.push(fill.id); order.fills = newFills; order.save(); - fill.createdAt = event.block.timestamp; + fill.createdAt = params.event.block.timestamp; fill.order = order.id; - fill.from = event.params.from.toHexString(); - fill.to = event.params.to.toHexString(); - fill.amount = event.params.amount; - fill.index = event.params.index; - fill.start = event.params.start; - fill.costInBeans = event.params.costInBeans; + fill.from = params.from.toHexString(); + fill.to = params.to.toHexString(); + fill.amount = params.amount; + fill.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex(params.event.address)); + fill.index = params.index; + fill.start = params.start; + fill.costInBeans = params.costInBeans; fill.save(); - updateMarketOrderBalances( - event.address, - order.id, - ZERO_BI, - ZERO_BI, - ZERO_BI, - ZERO_BI, - event.params.amount, - event.params.costInBeans, - event.block.timestamp - ); - - if (order.beanAmountFilled == order.beanAmount) { - let market = loadPodMarketplace(event.address); + setBeansPerPodAfterFill(params.event, fill.index, fill.start, fill.amount, fill.costInBeans); - let orderIndex = market.orders.indexOf(order.id); - if (orderIndex !== -1) { - market.orders.splice(orderIndex, 1); - } - market.save(); + if (order.status == "FILLED") { + updateActiveOrders(params.event.address, MarketplaceAction.FILLED_FULL, order.id, order.maxPlaceInLine); } + updateMarketOrderBalances(params.event.address, ZERO_BI, ZERO_BI, params.amount, params.costInBeans, params.event.block.timestamp); + // Save the raw event data - let id = "podOrderFilled-" + event.transaction.hash.toHexString() + "-" + event.logIndex.toString(); + let id = "podOrderFilled-" + params.event.transaction.hash.toHexString() + "-" + params.event.logIndex.toString(); let rawEvent = new PodOrderFilledEvent(id); - rawEvent.hash = event.transaction.hash.toHexString(); - rawEvent.logIndex = event.logIndex.toI32(); - rawEvent.protocol = event.address.toHexString(); + rawEvent.hash = params.event.transaction.hash.toHexString(); + rawEvent.logIndex = params.event.logIndex.toI32(); + rawEvent.protocol = params.event.address.toHexString(); rawEvent.historyID = order.historyID; - rawEvent.from = event.params.from.toHexString(); - rawEvent.to = event.params.to.toHexString(); - rawEvent.index = event.params.index; - rawEvent.start = event.params.start; - rawEvent.amount = event.params.amount; - rawEvent.costInBeans = event.params.costInBeans; - rawEvent.blockNumber = event.block.number; - rawEvent.createdAt = event.block.timestamp; + rawEvent.from = params.from.toHexString(); + rawEvent.to = params.to.toHexString(); + rawEvent.placeInLine = params.index.plus(params.start).minus(getHarvestableIndex(params.event.address)); + rawEvent.index = params.index; + rawEvent.start = params.start; + rawEvent.amount = params.amount; + rawEvent.costInBeans = params.costInBeans; + rawEvent.blockNumber = params.event.block.number; + rawEvent.createdAt = params.event.block.timestamp; rawEvent.save(); } -/* ------------------------------------ - * SHARED FUNCTIONS - * ------------------------------------ - */ - -function updateMarketListingBalances( - marketAddress: Address, - plotIndex: BigInt, - newPodAmount: BigInt, - cancelledPodAmount: BigInt, - filledPodAmount: BigInt, - filledBeanAmount: BigInt, - timestamp: BigInt -): void { - let market = loadPodMarketplace(marketAddress); - let marketHourly = loadPodMarketplaceHourlySnapshot(marketAddress, market.season, timestamp); - let marketDaily = loadPodMarketplaceDailySnapshot(marketAddress, timestamp); - - // Update Listing indexes - if (newPodAmount > ZERO_BI) { - market.listingIndexes.push(plotIndex); - market.listingIndexes.sort(); - } - if (cancelledPodAmount > ZERO_BI || filledPodAmount > ZERO_BI) { - let listingIndex = market.listingIndexes.indexOf(plotIndex); - market.listingIndexes.splice(listingIndex, 1); +function setBeansPerPodAfterFill(event: ethereum.Event, plotIndex: BigInt, start: BigInt, length: BigInt, costInBeans: BigInt): void { + // Load the plot that is being sent. It may or may not have been created already, depending + // on whether the PlotTransfer event has already been processed (sometims its emitted after the market transfer). + let fillPlot = loadPlot(event.address, plotIndex.plus(start)); + + if (start == ZERO_BI && length < fillPlot.pods) { + // When sending the start of a plot via market, these cannot be set in any subsequent transfer, + // since the start plot has already been modified. + let remainderPlot = loadPlot(event.address, plotIndex.plus(length)); + remainderPlot.sourceHash = fillPlot.sourceHash; + remainderPlot.beansPerPod = fillPlot.beansPerPod; + remainderPlot.source = fillPlot.source; + remainderPlot.save(); } - market.listedPods = market.listedPods.plus(newPodAmount); - market.availableListedPods = market.availableListedPods.plus(newPodAmount).minus(cancelledPodAmount).minus(filledPodAmount); - market.cancelledListedPods = market.cancelledListedPods.plus(cancelledPodAmount); - market.filledListedPods = market.filledListedPods.plus(filledPodAmount); - market.podVolume = market.podVolume.plus(filledPodAmount); - market.beanVolume = market.beanVolume.plus(filledBeanAmount); - market.save(); - - marketHourly.season = market.season; - marketHourly.deltaListedPods = marketHourly.deltaListedPods.plus(newPodAmount); - marketHourly.listedPods = market.listedPods; - marketHourly.deltaCancelledListedPods = marketHourly.deltaCancelledListedPods.plus(cancelledPodAmount); - marketHourly.cancelledListedPods = market.cancelledListedPods; - marketHourly.deltaAvailableListedPods = marketHourly.deltaAvailableListedPods - .plus(newPodAmount) - .minus(cancelledPodAmount) - .minus(filledPodAmount); - marketHourly.availableListedPods = market.availableListedPods; - marketHourly.deltaFilledListedPods = marketHourly.deltaFilledListedPods.plus(filledPodAmount); - marketHourly.filledListedPods = market.filledListedPods; - marketHourly.deltaPodVolume = marketHourly.deltaPodVolume.plus(filledPodAmount); - marketHourly.podVolume = market.podVolume; - marketHourly.deltaBeanVolume = marketHourly.deltaBeanVolume.plus(filledBeanAmount); - marketHourly.beanVolume = market.beanVolume; - marketHourly.updatedAt = timestamp; - marketHourly.save(); - - marketDaily.season = market.season; - marketDaily.deltaListedPods = marketDaily.deltaListedPods.plus(newPodAmount); - marketDaily.listedPods = market.listedPods; - marketDaily.deltaCancelledListedPods = marketDaily.deltaCancelledListedPods.plus(cancelledPodAmount); - marketDaily.cancelledListedPods = market.cancelledListedPods; - marketDaily.deltaAvailableListedPods = marketDaily.deltaAvailableListedPods - .plus(newPodAmount) - .minus(cancelledPodAmount) - .minus(filledPodAmount); - marketDaily.availableListedPods = market.availableListedPods; - marketDaily.deltaFilledListedPods = marketDaily.deltaFilledListedPods.plus(filledPodAmount); - marketDaily.filledListedPods = market.filledListedPods; - marketDaily.deltaPodVolume = marketDaily.deltaPodVolume.plus(filledPodAmount); - marketDaily.podVolume = market.podVolume; - marketDaily.deltaBeanVolume = marketDaily.deltaBeanVolume.plus(filledBeanAmount); - marketDaily.beanVolume = market.beanVolume; - marketDaily.updatedAt = timestamp; - marketDaily.save(); -} -function updateMarketOrderBalances( - marketAddress: Address, - orderID: string, - newPodAmount: BigInt, - cancelledPodAmount: BigInt, - newBeanAmount: BigInt, - cancelledBeanAmount: BigInt, - filledPodAmount: BigInt, - filledBeanAmount: BigInt, - timestamp: BigInt -): void { - // Need to account for v2 bean amounts - - let market = loadPodMarketplace(marketAddress); - let marketHourly = loadPodMarketplaceHourlySnapshot(marketAddress, market.season, timestamp); - let marketDaily = loadPodMarketplaceDailySnapshot(marketAddress, timestamp); - - if (newPodAmount > ZERO_BI) { - market.orders.push(orderID); - } - if (cancelledPodAmount > ZERO_BI) { - let orderIndex = market.orders.indexOf(orderID); - market.listingIndexes.splice(orderIndex, 1); - } - market.orderedPods = market.orderedPods.plus(newPodAmount); - market.filledOrderedPods = market.filledOrderedPods.plus(filledPodAmount); - market.podVolume = market.podVolume.plus(filledPodAmount); - market.beanVolume = market.beanVolume.plus(filledBeanAmount); - market.cancelledOrderedPods = market.cancelledOrderedPods.plus(cancelledPodAmount); - market.save(); - - marketHourly.deltaOrderedPods = marketHourly.deltaOrderedPods.plus(newPodAmount); - marketHourly.orderedPods = market.orderedPods; - marketHourly.deltaFilledOrderedPods = marketHourly.deltaFilledOrderedPods.plus(filledPodAmount); - marketHourly.filledOrderedPods = market.filledOrderedPods; - marketHourly.deltaPodVolume = marketHourly.deltaPodVolume.plus(filledPodAmount); - marketHourly.podVolume = market.podVolume; - marketHourly.deltaBeanVolume = marketHourly.deltaBeanVolume.plus(filledBeanAmount); - marketHourly.beanVolume = market.beanVolume; - marketHourly.deltaCancelledOrderedPods = marketHourly.deltaCancelledOrderedPods.plus(cancelledPodAmount); - marketHourly.cancelledOrderedPods = market.cancelledOrderedPods; - marketHourly.updatedAt = timestamp; - marketHourly.save(); - - marketDaily.deltaOrderedPods = marketDaily.deltaOrderedPods.plus(newPodAmount); - marketDaily.orderedPods = market.orderedPods; - marketDaily.deltaFilledOrderedPods = marketDaily.deltaFilledOrderedPods.plus(filledPodAmount); - marketDaily.filledOrderedPods = market.filledOrderedPods; - marketDaily.deltaPodVolume = marketDaily.deltaPodVolume.plus(filledPodAmount); - marketDaily.podVolume = market.podVolume; - marketDaily.deltaBeanVolume = marketDaily.deltaBeanVolume.plus(filledBeanAmount); - marketDaily.beanVolume = market.beanVolume; - marketDaily.deltaCancelledOrderedPods = marketDaily.deltaCancelledOrderedPods.plus(cancelledPodAmount); - marketDaily.cancelledOrderedPods = market.cancelledOrderedPods; - marketDaily.updatedAt = timestamp; - marketDaily.save(); + // Update source/cost per pod of the sold plot + fillPlot.beansPerPod = costInBeans.times(BI_10.pow(6)).div(length); + fillPlot.source = "MARKET"; + fillPlot.sourceHash = event.transaction.hash.toHexString(); + fillPlot.save(); } diff --git a/projects/subgraph-beanstalk/src/SeasonHandler.ts b/projects/subgraph-beanstalk/src/SeasonHandler.ts index 5a0d02aa09..27b5389ba7 100644 --- a/projects/subgraph-beanstalk/src/SeasonHandler.ts +++ b/projects/subgraph-beanstalk/src/SeasonHandler.ts @@ -9,8 +9,12 @@ import { Reward as RewardEntity, MetapoolOracle as MetapoolOracleEntity, WellOra import { BEANSTALK, BEANSTALK_PRICE, BEAN_ERC20, CURVE_PRICE, GAUGE_BIP45_BLOCK } from "../../subgraph-core/utils/Constants"; import { ONE_BI, toDecimal, ZERO_BD, ZERO_BI } from "../../subgraph-core/utils/Decimals"; import { loadField, loadFieldDaily, loadFieldHourly } from "./utils/Field"; -import { expirePodListing, loadPodListing } from "./utils/PodListing"; -import { loadPodMarketplace, loadPodMarketplaceDailySnapshot, loadPodMarketplaceHourlySnapshot } from "./utils/PodMarketplace"; +import { + loadPodMarketplace, + loadPodMarketplaceDailySnapshot, + loadPodMarketplaceHourlySnapshot, + updateExpiredPlots +} from "./utils/PodMarketplace"; import { loadSeason } from "./utils/Season"; import { addDepositToSiloAsset, updateStalkWithCalls } from "./SiloHandler"; import { updateBeanEMA } from "./YieldHandler"; @@ -67,26 +71,6 @@ export function handleSunrise(event: Sunrise): void { marketHourly.save(); marketDaily.save(); - let remainingListings = market.listingIndexes; - - // Cancel any pod marketplace listings beyond the index - for (let i = 0; i < market.listingIndexes.length; i++) { - if (market.listingIndexes[i] < season.harvestableIndex) { - expirePodListing(event.address, event.block.timestamp, market.listingIndexes[i]); - remainingListings.shift(); - } else { - let listing = loadPodListing(event.address, market.listingIndexes[i]); - if (listing.maxHarvestableIndex < season.harvestableIndex) { - expirePodListing(event.address, event.block.timestamp, market.listingIndexes[i]); - let listingIndex = market.listingIndexes.indexOf(listing.index); - remainingListings.splice(listingIndex, 1); - } - } - } - - market.listingIndexes = remainingListings; - market.save(); - // Create silo entities for the protocol let silo = loadSilo(event.address); loadSiloHourlySnapshot(event.address, currentSeason, event.block.timestamp); @@ -265,5 +249,6 @@ export function handleIncentive(event: Incentivization): void { season.harvestableIndex = beanstalk_contract.harvestableIndex(); season.save(); + updateExpiredPlots(season.harvestableIndex, event.address, event.block.timestamp); updateHarvestablePlots(season.harvestableIndex, event.block.timestamp, event.block.number); } diff --git a/projects/subgraph-beanstalk/src/utils/Beanstalk.ts b/projects/subgraph-beanstalk/src/utils/Beanstalk.ts index 670f388e9e..f291ba5861 100644 --- a/projects/subgraph-beanstalk/src/utils/Beanstalk.ts +++ b/projects/subgraph-beanstalk/src/utils/Beanstalk.ts @@ -8,9 +8,9 @@ export function loadBeanstalk(protocol: Address): Beanstalk { beanstalk = new Beanstalk(protocol.toHexString()); beanstalk.name = "Beanstalk"; beanstalk.slug = "beanstalk"; - beanstalk.schemaVersion = "2.2.2"; - beanstalk.subgraphVersion = "2.2.2"; - beanstalk.methodologyVersion = "2.2.2"; + beanstalk.schemaVersion = "2.3.0"; + beanstalk.subgraphVersion = "2.3.0"; + beanstalk.methodologyVersion = "2.3.0"; beanstalk.lastUpgrade = ZERO_BI; beanstalk.lastSeason = 1; beanstalk.activeFarmers = []; diff --git a/projects/subgraph-beanstalk/src/utils/Plot.ts b/projects/subgraph-beanstalk/src/utils/Plot.ts index b6bcb2b4b1..8e97468e9c 100644 --- a/projects/subgraph-beanstalk/src/utils/Plot.ts +++ b/projects/subgraph-beanstalk/src/utils/Plot.ts @@ -10,16 +10,16 @@ export function loadPlot(diamondAddress: Address, index: BigInt): Plot { plot = new Plot(index.toString()); plot.field = diamondAddress.toHexString(); plot.farmer = ADDRESS_ZERO.toHexString(); - plot.source = "SOW"; // Assume new plots come from sowing + plot.source = "SOW"; // Should be overwritten in case of a transfer creating a new plot + plot.sourceHash = ""; plot.season = 0; plot.creationHash = ""; plot.createdAt = ZERO_BI; plot.updatedAt = ZERO_BI; + plot.updatedAtBlock = ZERO_BI; plot.index = index; - plot.beans = ZERO_BI; plot.pods = ZERO_BI; - plot.sownPods = ZERO_BI; - plot.temperature = 0; + plot.beansPerPod = ZERO_BI; plot.harvestablePods = ZERO_BI; plot.harvestedPods = ZERO_BI; plot.fullyHarvested = false; diff --git a/projects/subgraph-beanstalk/src/utils/PodFill.ts b/projects/subgraph-beanstalk/src/utils/PodFill.ts index 56cd9f4c71..6f1f3bcad6 100644 --- a/projects/subgraph-beanstalk/src/utils/PodFill.ts +++ b/projects/subgraph-beanstalk/src/utils/PodFill.ts @@ -11,9 +11,11 @@ export function loadPodFill(diamondAddress: Address, index: BigInt, hash: String fill.createdAt = ZERO_BI; fill.from = ""; fill.to = ""; + fill.placeInLine = ZERO_BI; fill.amount = ZERO_BI; fill.index = ZERO_BI; fill.start = ZERO_BI; + fill.costInBeans = ZERO_BI; fill.save(); } return fill; diff --git a/projects/subgraph-beanstalk/src/utils/PodListing.ts b/projects/subgraph-beanstalk/src/utils/PodListing.ts index 22f5d37233..ee94cec930 100644 --- a/projects/subgraph-beanstalk/src/utils/PodListing.ts +++ b/projects/subgraph-beanstalk/src/utils/PodListing.ts @@ -1,8 +1,7 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Address, BigInt, log } from "@graphprotocol/graph-ts"; import { PodListing } from "../../generated/schema"; import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; -import { loadPlot } from "./Plot"; import { loadPodMarketplace, loadPodMarketplaceDailySnapshot, loadPodMarketplaceHourlySnapshot } from "./PodMarketplace"; export function loadPodListing(account: Address, index: BigInt): PodListing { @@ -32,7 +31,6 @@ export function loadPodListing(account: Address, index: BigInt): PodListing { listing.amount = ZERO_BI; listing.remainingAmount = ZERO_BI; listing.filledAmount = ZERO_BI; - listing.cancelledAmount = ZERO_BI; listing.status = "ACTIVE"; listing.createdAt = ZERO_BI; @@ -45,16 +43,42 @@ export function loadPodListing(account: Address, index: BigInt): PodListing { return listing; } -export function expirePodListing(diamondAddress: Address, timestamp: BigInt, listingIndex: BigInt): void { +export function expirePodListingIfExists( + diamondAddress: Address, + farmer: string, + listedPlotIndex: BigInt, + timestamp: BigInt, + activeListingIndex: i32 = -1 // If provided, avoids having to lookup the index +): void { + let listing = PodListing.load(farmer + "-" + listedPlotIndex.toString()); + if (listing == null || listing.status != "ACTIVE") { + return; + } + listing.status = "EXPIRED"; + listing.save(); + let market = loadPodMarketplace(diamondAddress); + + if (activeListingIndex == -1) { + // There should always be a matching entry in this list because it is verified that the listing is ACTIVE + for (let i = 0; i < market.activeListings.length; i++) { + const destructured = market.activeListings[i].split("-"); + // Unnecessary to check if the account matches. + if (destructured[1] == listedPlotIndex.toString()) { + activeListingIndex = i; + break; + } + } + } + let marketHourly = loadPodMarketplaceHourlySnapshot(diamondAddress, market.season, timestamp); let marketDaily = loadPodMarketplaceDailySnapshot(diamondAddress, timestamp); - //farmer info - let plot = loadPlot(diamondAddress, listingIndex); - let listing = loadPodListing(Address.fromString(plot.farmer), listingIndex); market.expiredListedPods = market.expiredListedPods.plus(listing.remainingAmount); market.availableListedPods = market.availableListedPods.minus(listing.remainingAmount); + let activeListings = market.activeListings; + activeListings.splice(activeListingIndex, 1); + market.activeListings = activeListings; market.save(); marketHourly.season = market.season; @@ -70,10 +94,6 @@ export function expirePodListing(diamondAddress: Address, timestamp: BigInt, lis marketDaily.deltaAvailableListedPods = marketDaily.deltaAvailableListedPods.minus(listing.remainingAmount); marketDaily.availableListedPods = market.availableListedPods; marketDaily.save(); - - listing.status = "EXPIRED"; - listing.remainingAmount = ZERO_BI; - listing.save(); } export function createHistoricalPodListing(listing: PodListing): void { @@ -105,7 +125,6 @@ export function createHistoricalPodListing(listing: PodListing): void { newListing.amount = listing.amount; newListing.remainingAmount = listing.remainingAmount; newListing.filledAmount = listing.filledAmount; - newListing.cancelledAmount = listing.cancelledAmount; newListing.fill = listing.fill; diff --git a/projects/subgraph-beanstalk/src/utils/PodMarketplace.ts b/projects/subgraph-beanstalk/src/utils/PodMarketplace.ts index 6f0d8e748a..9489441d47 100644 --- a/projects/subgraph-beanstalk/src/utils/PodMarketplace.ts +++ b/projects/subgraph-beanstalk/src/utils/PodMarketplace.ts @@ -1,8 +1,17 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { Address, BigInt, log } from "@graphprotocol/graph-ts"; import { PodMarketplace, PodMarketplaceHourlySnapshot, PodMarketplaceDailySnapshot } from "../../generated/schema"; -import { dayFromTimestamp, hourFromTimestamp } from "./Dates"; +import { dayFromTimestamp } from "./Dates"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; import { loadField } from "./Field"; +import { expirePodListingIfExists, loadPodListing } from "./PodListing"; + +export enum MarketplaceAction { + CREATED, + FILLED_PARTIAL, + FILLED_FULL, + CANCELLED, + EXPIRED +} export function loadPodMarketplace(diamondAddress: Address): PodMarketplace { let marketplace = PodMarketplace.load(diamondAddress.toHexString()); @@ -10,16 +19,18 @@ export function loadPodMarketplace(diamondAddress: Address): PodMarketplace { let field = loadField(diamondAddress); marketplace = new PodMarketplace(diamondAddress.toHexString()); marketplace.season = field.season; - marketplace.listingIndexes = []; - marketplace.orders = []; + marketplace.activeListings = []; + marketplace.activeOrders = []; marketplace.listedPods = ZERO_BI; + marketplace.availableListedPods = ZERO_BI; marketplace.filledListedPods = ZERO_BI; marketplace.expiredListedPods = ZERO_BI; marketplace.cancelledListedPods = ZERO_BI; - marketplace.availableListedPods = ZERO_BI; - marketplace.orderedPods = ZERO_BI; + marketplace.orderBeans = ZERO_BI; + marketplace.availableOrderBeans = ZERO_BI; marketplace.filledOrderedPods = ZERO_BI; - marketplace.cancelledOrderedPods = ZERO_BI; + marketplace.filledOrderBeans = ZERO_BI; + marketplace.cancelledOrderBeans = ZERO_BI; marketplace.podVolume = ZERO_BI; marketplace.beanVolume = ZERO_BI; marketplace.save(); @@ -39,20 +50,24 @@ export function loadPodMarketplaceHourlySnapshot(diamondAddress: Address, season snapshot.podMarketplace = diamondAddress.toHexString(); snapshot.deltaListedPods = ZERO_BI; snapshot.listedPods = marketplace.listedPods; + snapshot.deltaAvailableListedPods = ZERO_BI; + snapshot.availableListedPods = marketplace.availableListedPods; snapshot.deltaFilledListedPods = ZERO_BI; snapshot.filledListedPods = marketplace.filledListedPods; snapshot.deltaExpiredListedPods = ZERO_BI; snapshot.expiredListedPods = marketplace.expiredListedPods; snapshot.deltaCancelledListedPods = ZERO_BI; snapshot.cancelledListedPods = marketplace.cancelledListedPods; - snapshot.deltaAvailableListedPods = ZERO_BI; - snapshot.availableListedPods = marketplace.availableListedPods; - snapshot.deltaOrderedPods = ZERO_BI; - snapshot.orderedPods = marketplace.orderedPods; + snapshot.deltaOrderBeans = ZERO_BI; + snapshot.orderBeans = marketplace.orderBeans; + snapshot.deltaAvailableOrderBeans = ZERO_BI; + snapshot.availableOrderBeans = marketplace.availableOrderBeans; snapshot.deltaFilledOrderedPods = ZERO_BI; snapshot.filledOrderedPods = marketplace.filledOrderedPods; - snapshot.deltaCancelledOrderedPods = ZERO_BI; - snapshot.cancelledOrderedPods = marketplace.cancelledOrderedPods; + snapshot.deltaFilledOrderBeans = ZERO_BI; + snapshot.filledOrderBeans = marketplace.filledOrderBeans; + snapshot.deltaCancelledOrderBeans = ZERO_BI; + snapshot.cancelledOrderBeans = marketplace.cancelledOrderBeans; snapshot.deltaPodVolume = ZERO_BI; snapshot.podVolume = marketplace.podVolume; snapshot.deltaBeanVolume = ZERO_BI; @@ -75,20 +90,24 @@ export function loadPodMarketplaceDailySnapshot(diamondAddress: Address, timesta snapshot.podMarketplace = diamondAddress.toHexString(); snapshot.deltaListedPods = ZERO_BI; snapshot.listedPods = marketplace.listedPods; + snapshot.deltaAvailableListedPods = ZERO_BI; + snapshot.availableListedPods = marketplace.availableListedPods; snapshot.deltaFilledListedPods = ZERO_BI; snapshot.filledListedPods = marketplace.filledListedPods; snapshot.deltaExpiredListedPods = ZERO_BI; snapshot.expiredListedPods = marketplace.expiredListedPods; snapshot.deltaCancelledListedPods = ZERO_BI; snapshot.cancelledListedPods = marketplace.cancelledListedPods; - snapshot.deltaAvailableListedPods = ZERO_BI; - snapshot.availableListedPods = marketplace.availableListedPods; - snapshot.deltaOrderedPods = ZERO_BI; - snapshot.orderedPods = marketplace.orderedPods; + snapshot.deltaOrderBeans = ZERO_BI; + snapshot.orderBeans = marketplace.orderBeans; + snapshot.deltaAvailableOrderBeans = ZERO_BI; + snapshot.availableOrderBeans = marketplace.availableOrderBeans; snapshot.deltaFilledOrderedPods = ZERO_BI; snapshot.filledOrderedPods = marketplace.filledOrderedPods; - snapshot.deltaCancelledOrderedPods = ZERO_BI; - snapshot.cancelledOrderedPods = marketplace.cancelledOrderedPods; + snapshot.deltaFilledOrderBeans = ZERO_BI; + snapshot.filledOrderBeans = marketplace.filledOrderBeans; + snapshot.deltaCancelledOrderBeans = ZERO_BI; + snapshot.cancelledOrderBeans = marketplace.cancelledOrderBeans; snapshot.deltaPodVolume = ZERO_BI; snapshot.podVolume = marketplace.podVolume; snapshot.deltaBeanVolume = ZERO_BI; @@ -99,3 +118,193 @@ export function loadPodMarketplaceDailySnapshot(diamondAddress: Address, timesta } return snapshot; } + +export function updateMarketListingBalances( + marketAddress: Address, + newPodAmount: BigInt, + cancelledPodAmount: BigInt, + filledPodAmount: BigInt, + filledBeanAmount: BigInt, + timestamp: BigInt +): void { + let market = loadPodMarketplace(marketAddress); + let marketHourly = loadPodMarketplaceHourlySnapshot(marketAddress, market.season, timestamp); + let marketDaily = loadPodMarketplaceDailySnapshot(marketAddress, timestamp); + + const netListingChange = newPodAmount.minus(cancelledPodAmount).minus(filledPodAmount); + + market.listedPods = market.listedPods.plus(newPodAmount); + market.availableListedPods = market.availableListedPods.plus(netListingChange); + market.cancelledListedPods = market.cancelledListedPods.plus(cancelledPodAmount); + market.filledListedPods = market.filledListedPods.plus(filledPodAmount); + market.podVolume = market.podVolume.plus(filledPodAmount); + market.beanVolume = market.beanVolume.plus(filledBeanAmount); + market.save(); + + marketHourly.season = market.season; + marketHourly.deltaListedPods = marketHourly.deltaListedPods.plus(newPodAmount); + marketHourly.listedPods = market.listedPods; + marketHourly.deltaAvailableListedPods = marketHourly.deltaAvailableListedPods.plus(netListingChange); + marketHourly.availableListedPods = market.availableListedPods; + marketHourly.deltaCancelledListedPods = marketHourly.deltaCancelledListedPods.plus(cancelledPodAmount); + marketHourly.cancelledListedPods = market.cancelledListedPods; + marketHourly.deltaFilledListedPods = marketHourly.deltaFilledListedPods.plus(filledPodAmount); + marketHourly.filledListedPods = market.filledListedPods; + marketHourly.deltaPodVolume = marketHourly.deltaPodVolume.plus(filledPodAmount); + marketHourly.podVolume = market.podVolume; + marketHourly.deltaBeanVolume = marketHourly.deltaBeanVolume.plus(filledBeanAmount); + marketHourly.beanVolume = market.beanVolume; + marketHourly.updatedAt = timestamp; + marketHourly.save(); + + marketDaily.season = market.season; + marketDaily.deltaListedPods = marketDaily.deltaListedPods.plus(newPodAmount); + marketDaily.listedPods = market.listedPods; + marketDaily.deltaAvailableListedPods = marketDaily.deltaAvailableListedPods.plus(netListingChange); + marketDaily.availableListedPods = market.availableListedPods; + marketDaily.deltaCancelledListedPods = marketDaily.deltaCancelledListedPods.plus(cancelledPodAmount); + marketDaily.cancelledListedPods = market.cancelledListedPods; + marketDaily.deltaFilledListedPods = marketDaily.deltaFilledListedPods.plus(filledPodAmount); + marketDaily.filledListedPods = market.filledListedPods; + marketDaily.deltaPodVolume = marketDaily.deltaPodVolume.plus(filledPodAmount); + marketDaily.podVolume = market.podVolume; + marketDaily.deltaBeanVolume = marketDaily.deltaBeanVolume.plus(filledBeanAmount); + marketDaily.beanVolume = market.beanVolume; + marketDaily.updatedAt = timestamp; + marketDaily.save(); +} + +export function updateMarketOrderBalances( + marketAddress: Address, + newBeanAmount: BigInt, + cancelledBeanAmount: BigInt, + filledPodAmount: BigInt, + filledBeanAmount: BigInt, + timestamp: BigInt +): void { + let market = loadPodMarketplace(marketAddress); + let marketHourly = loadPodMarketplaceHourlySnapshot(marketAddress, market.season, timestamp); + let marketDaily = loadPodMarketplaceDailySnapshot(marketAddress, timestamp); + + const netOrderChange = newBeanAmount.minus(cancelledBeanAmount).minus(filledBeanAmount); + + market.orderBeans = market.orderBeans.plus(newBeanAmount); + market.availableOrderBeans = market.availableOrderBeans.plus(netOrderChange); + market.filledOrderedPods = market.filledOrderedPods.plus(filledPodAmount); + market.filledOrderBeans = market.filledOrderBeans.plus(filledBeanAmount); + market.podVolume = market.podVolume.plus(filledPodAmount); + market.beanVolume = market.beanVolume.plus(filledBeanAmount); + market.cancelledOrderBeans = market.cancelledOrderBeans.plus(cancelledBeanAmount); + market.save(); + + marketHourly.deltaOrderBeans = marketHourly.deltaOrderBeans.plus(newBeanAmount); + marketHourly.orderBeans = market.orderBeans; + marketHourly.deltaAvailableOrderBeans = marketHourly.deltaAvailableOrderBeans.plus(netOrderChange); + marketHourly.availableOrderBeans = market.availableOrderBeans; + marketHourly.deltaFilledOrderedPods = marketHourly.deltaFilledOrderedPods.plus(filledPodAmount); + marketHourly.filledOrderedPods = market.filledOrderedPods; + marketHourly.deltaFilledOrderBeans = marketHourly.deltaFilledOrderBeans.plus(filledBeanAmount); + marketHourly.filledOrderBeans = market.filledOrderBeans; + marketHourly.deltaPodVolume = marketHourly.deltaPodVolume.plus(filledPodAmount); + marketHourly.podVolume = market.podVolume; + marketHourly.deltaBeanVolume = marketHourly.deltaBeanVolume.plus(filledBeanAmount); + marketHourly.beanVolume = market.beanVolume; + marketHourly.deltaCancelledOrderBeans = marketHourly.deltaCancelledOrderBeans.plus(cancelledBeanAmount); + marketHourly.cancelledOrderBeans = market.cancelledOrderBeans; + marketHourly.updatedAt = timestamp; + marketHourly.save(); + + marketDaily.deltaOrderBeans = marketDaily.deltaOrderBeans.plus(newBeanAmount); + marketDaily.orderBeans = market.orderBeans; + marketDaily.deltaAvailableOrderBeans = marketHourly.deltaAvailableOrderBeans.plus(netOrderChange); + marketDaily.availableOrderBeans = market.availableOrderBeans; + marketDaily.deltaFilledOrderedPods = marketDaily.deltaFilledOrderedPods.plus(filledPodAmount); + marketDaily.filledOrderedPods = market.filledOrderedPods; + marketDaily.deltaFilledOrderBeans = marketHourly.deltaFilledOrderBeans.plus(filledBeanAmount); + marketDaily.filledOrderBeans = market.filledOrderBeans; + marketDaily.deltaPodVolume = marketDaily.deltaPodVolume.plus(filledPodAmount); + marketDaily.podVolume = market.podVolume; + marketDaily.deltaBeanVolume = marketDaily.deltaBeanVolume.plus(filledBeanAmount); + marketDaily.beanVolume = market.beanVolume; + marketDaily.deltaCancelledOrderBeans = marketDaily.deltaCancelledOrderBeans.plus(cancelledBeanAmount); + marketDaily.cancelledOrderBeans = market.cancelledOrderBeans; + marketDaily.updatedAt = timestamp; + marketDaily.save(); +} + +export function updateExpiredPlots(harvestableIndex: BigInt, diamondAddress: Address, timestamp: BigInt): void { + let market = loadPodMarketplace(diamondAddress); + let remainingListings = market.activeListings; + + // Cancel any pod marketplace listings beyond the index + for (let i = 0; i < remainingListings.length; i++) { + const destructured = remainingListings[i].split("-"); + const maxHarvestableIndex = BigInt.fromString(destructured[2]); + if (harvestableIndex > maxHarvestableIndex) { + // This method updates the marketplace entity, so it will perform the splice. + expirePodListingIfExists(diamondAddress, destructured[0], BigInt.fromString(destructured[1]), timestamp, i); + // A similar splice is done here also to track the updated index on the underlying array. + remainingListings.splice(i--, 1); + } + } +} + +export function updateActiveListings( + diamondAddress: Address, + action: MarketplaceAction, + farmer: string, + plotIndex: BigInt, + expiryIndex: BigInt +): void { + let market = loadPodMarketplace(diamondAddress); + let listings = market.activeListings; + + if (action == MarketplaceAction.CREATED) { + listings.push(farmer + "-" + plotIndex.toString() + "-" + expiryIndex.toString()); + } + if ( + [MarketplaceAction.CANCELLED, MarketplaceAction.FILLED_PARTIAL, MarketplaceAction.FILLED_FULL, MarketplaceAction.EXPIRED].includes( + action + ) + ) { + listings.splice(Marketplace_findIndex_listing(listings, plotIndex), 1); + } + + market.activeListings = listings; + market.save(); +} + +export function updateActiveOrders(diamondAddress: Address, action: MarketplaceAction, orderId: string, maxPlaceInLine: BigInt): void { + let market = loadPodMarketplace(diamondAddress); + let orders = market.activeOrders; + + if (action == MarketplaceAction.CREATED) { + orders.push(orderId + "-" + maxPlaceInLine.toString()); + } + if ([MarketplaceAction.CANCELLED, MarketplaceAction.FILLED_FULL, MarketplaceAction.EXPIRED].includes(action)) { + orders.splice(Marketplace_findIndex_order(orders, orderId), 1); + } + + market.activeOrders = orders; + market.save(); +} + +export function Marketplace_findIndex_listing(listings: string[], plotIndex: BigInt): i32 { + for (let i = 0; i < listings.length; i++) { + const values = listings[i].split("-"); + if (BigInt.fromString(values[1]) == plotIndex) { + return i; + } + } + return -1; +} + +export function Marketplace_findIndex_order(orders: string[], orderId: string): i32 { + for (let i = 0; i < orders.length; i++) { + const values = orders[i].split("-"); + if (values[0] == orderId) { + return i; + } + } + return -1; +} diff --git a/projects/subgraph-beanstalk/src/utils/PodOrder.ts b/projects/subgraph-beanstalk/src/utils/PodOrder.ts index a284760e78..3f8cee0fe2 100644 --- a/projects/subgraph-beanstalk/src/utils/PodOrder.ts +++ b/projects/subgraph-beanstalk/src/utils/PodOrder.ts @@ -1,4 +1,4 @@ -import { Bytes } from "@graphprotocol/graph-ts"; +import { Bytes, BigInt, Address } from "@graphprotocol/graph-ts"; import { PodOrder } from "../../generated/schema"; import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; @@ -13,7 +13,6 @@ export function loadPodOrder(orderID: Bytes): PodOrder { order.createdAt = ZERO_BI; order.updatedAt = ZERO_BI; order.status = ""; - order.podAmount = ZERO_BI; order.beanAmount = ZERO_BI; order.podAmountFilled = ZERO_BI; order.beanAmountFilled = ZERO_BI; @@ -41,7 +40,6 @@ export function createHistoricalPodOrder(order: PodOrder): void { newOrder.createdAt = order.createdAt; newOrder.updatedAt = order.updatedAt; newOrder.status = order.status; - newOrder.podAmount = order.podAmount; newOrder.beanAmount = order.beanAmount; newOrder.podAmountFilled = order.podAmountFilled; newOrder.beanAmountFilled = order.beanAmountFilled; @@ -55,3 +53,36 @@ export function createHistoricalPodOrder(order: PodOrder): void { } } } + +// Currently there is no concept of an expired pod order, but there may be in the future +// export function expirePodOrder(diamondAddress: Address, orderId: string, timestamp: BigInt, activeOrderIndex: i32): void { +// let order = loadPodOrder(Bytes.fromHexString(orderId)); +// order.status = "EXPIRED"; +// order.save(); +// +// let market = loadPodMarketplace(diamondAddress); +// let marketHourly = loadPodMarketplaceHourlySnapshot(diamondAddress, market.season, timestamp); +// let marketDaily = loadPodMarketplaceDailySnapshot(diamondAddress, timestamp); +// +// const expiredBeans = order.beanAmount.minus(order.beanAmountFilled); +// market.expiredOrderBeans = market.expiredOrderBeans.plus(expiredBeans); +// market.availableOrderBeans = market.availableOrderBeans.minus(expiredBeans); +// let activeOrders = market.activeOrders; +// activeOrders.splice(activeOrderIndex, 1); +// market.activeOrders = activeOrders; +// market.save(); +// +// marketHourly.season = market.season; +// marketHourly.deltaExpiredOrderBeans = marketHourly.deltaExpiredOrderBeans.plus(expiredBeans); +// marketHourly.expiredOrderBeans = market.expiredListedPods; +// marketHourly.deltaAvailableOrderBeans = marketHourly.deltaAvailableOrderBeans.minus(expiredBeans); +// marketHourly.availableOrderBeans = market.availableOrderBeans; +// marketHourly.save(); +// +// marketDaily.season = market.season; +// marketDaily.deltaExpiredOrderBeans = marketDaily.deltaExpiredOrderBeans.plus(expiredBeans); +// marketDaily.expiredOrderBeans = market.expiredListedPods; +// marketDaily.deltaAvailableOrderBeans = marketDaily.deltaAvailableOrderBeans.minus(expiredBeans); +// marketDaily.availableOrderBeans = market.availableOrderBeans; +// marketDaily.save(); +// } diff --git a/projects/subgraph-beanstalk/src/utils/Season.ts b/projects/subgraph-beanstalk/src/utils/Season.ts index 1fcb8edb2d..3b0a7d5940 100644 --- a/projects/subgraph-beanstalk/src/utils/Season.ts +++ b/projects/subgraph-beanstalk/src/utils/Season.ts @@ -39,3 +39,9 @@ export function getCurrentSeason(beanstalk: Address): i32 { let beanstalkEntity = loadBeanstalk(beanstalk); return beanstalkEntity.lastSeason; } + +export function getHarvestableIndex(beanstalk: Address): BigInt { + let bs = loadBeanstalk(beanstalk); + let season = loadSeason(beanstalk, BigInt.fromI32(bs.lastSeason)); + return season.harvestableIndex; +} diff --git a/projects/subgraph-beanstalk/tests/Field.test.ts b/projects/subgraph-beanstalk/tests/Field.test.ts new file mode 100644 index 0000000000..a5b4687336 --- /dev/null +++ b/projects/subgraph-beanstalk/tests/Field.test.ts @@ -0,0 +1,30 @@ +import { afterEach, assert, clearStore, describe, test } from "matchstick-as/assembly/index"; +import { BigInt } from "@graphprotocol/graph-ts"; + +import { BEANSTALK } from "../../subgraph-core/utils/Constants"; +import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; +import { beans_BI as beans, podlineMil_BI as mil } from "../../subgraph-core/tests/Values"; +import { assertFarmerHasPlot, assertFieldHas, sow } from "./utils/Field"; + +const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); + +const plotStart = mil(10); +const beansSown = beans(500); +const temperature = 15; +const pods = beansSown.times(BigInt.fromI32(temperature)); + +// Begin tests +describe("Field", () => { + afterEach(() => { + clearStore(); + }); + + test("Sow", () => { + sow(account, plotStart, beansSown, pods); + assertFarmerHasPlot(account, plotStart, pods); + assertFieldHas(BEANSTALK.toHexString(), pods, ZERO_BI); + + assert.fieldEquals("Plot", plotStart.toString(), "source", "SOW"); + assert.fieldEquals("Plot", plotStart.toString(), "beansPerPod", BI_10.pow(6).div(BigInt.fromU32(temperature)).toString()); + }); +}); diff --git a/projects/subgraph-beanstalk/tests/Marketplace.test.ts b/projects/subgraph-beanstalk/tests/Marketplace.test.ts deleted file mode 100644 index d6cb2d5491..0000000000 --- a/projects/subgraph-beanstalk/tests/Marketplace.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { BigInt, Bytes, log } from "@graphprotocol/graph-ts"; -import { afterEach, assert, beforeAll, clearStore, describe, test } from "matchstick-as/assembly/index"; -import { handleSow } from "../src/FieldHandler"; -import { handlePodListingCreated_v2 } from "../src/MarketplaceHandler"; -import { handleAddDeposit, handleRemoveDeposit } from "../src/SiloHandler"; -import { createSowEvent } from "./event-mocking/Field"; -import { createPodListingCreatedEvent_v2 } from "./event-mocking/Marketplace"; -import { createAddDepositEvent, createRemoveDepositEvent } from "./event-mocking/Silo"; - -let account = "0x1234567890abcdef1234567890abcdef12345678".toLowerCase(); -let listingIndex = BigInt.fromString("1000000000000"); -let pricingFunction = Bytes.fromHexString( - "0x0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000c8000000000000000000000000000000000000000000000000000000000000012c000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010101010101010101010101010000" -); - -describe("Mocked Events", () => { - beforeAll(() => { - // Create a plot with the listing index - let event = createSowEvent(account, listingIndex, BigInt.fromString("1000000000000"), BigInt.fromString("2000000000000")); - handleSow(event); - }); - - describe("Marketplace v2", () => { - test("Create a pod listing", () => { - let event = createPodListingCreatedEvent_v2( - account, - listingIndex, - BigInt.fromString("100000000000"), - BigInt.fromString("500000000000"), - BigInt.fromString("250000"), - BigInt.fromString("300000000000000"), - BigInt.fromString("10000000"), - pricingFunction, - BigInt.fromI32(0), - BigInt.fromI32(1) - ); - - handlePodListingCreated_v2(event); - - let listingID = account + "-" + listingIndex.toString(); - - assert.fieldEquals("PodListing", listingID, "plot", listingIndex.toString()); - assert.fieldEquals("PodListing", listingID, "farmer", account); - assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); - assert.fieldEquals("PodListing", listingID, "originalIndex", listingIndex.toString()); - assert.fieldEquals("PodListing", listingID, "index", listingIndex.toString()); - assert.fieldEquals("PodListing", listingID, "start", "100000000000"); - assert.fieldEquals("PodListing", listingID, "start", "100000000000"); - assert.fieldEquals("PodListing", listingID, "pricingFunction", pricingFunction.toHexString()); - }); - }); -}); diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts new file mode 100644 index 0000000000..d80d09f8c0 --- /dev/null +++ b/projects/subgraph-beanstalk/tests/MarketplaceV1.test.ts @@ -0,0 +1,667 @@ +import { BigInt, Bytes, log } from "@graphprotocol/graph-ts"; +import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; +import { beans_BI, podlineMil_BI } from "../../subgraph-core/tests/Values"; +import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; +import { BEANSTALK } from "../../subgraph-core/utils/Constants"; +import { + assertMarketListingsState, + assertMarketOrdersState, + cancelListing, + cancelOrder, + createListing_v1, + createListing_v1_1, + createOrder_v1, + fillListing_v1, + fillOrder_v1, + getPodFillId +} from "./utils/Marketplace"; +import { harvest, setHarvestable, sow } from "./utils/Field"; + +const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); +const account2 = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8".toLowerCase(); + +const listingIndex = podlineMil_BI(10); +const listingStart = beans_BI(500); +const currentHarvestable = podlineMil_BI(4); +const listingPricePerPod = BigInt.fromString("250000"); +const maxHarvestableIndex = podlineMil_BI(100); +const sowedBeans = beans_BI(5000); +const sowedPods = sowedBeans.times(BigInt.fromString("3")); + +const orderBeans = beans_BI(80000); +const orderPricePerPod = BigInt.fromString("500000"); // 0.5 beans +const orderId = Bytes.fromHexString("0xabcd"); + +describe("Marketplace", () => { + beforeEach(() => { + setHarvestable(currentHarvestable); + sow(account, listingIndex, sowedBeans, sowedPods); + }); + + afterEach(() => { + clearStore(); + }); + + describe("Marketplace v1", () => { + test("Create a pod listing - full plot", () => { + const event = createListing_v1(account, listingIndex, sowedPods, ZERO_BI, listingPricePerPod, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], + sowedPods, + sowedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + + // Create a second listing to assert the market state again + const listing2Index = listingIndex.times(BI_10); + sow(account, listing2Index, sowedBeans, sowedPods); + const event2 = createListing_v1(account, listing2Index, sowedPods, ZERO_BI, listingPricePerPod, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [ + account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString(), + account + "-" + listing2Index.toString() + "-" + maxHarvestableIndex.toString() + ], + sowedPods.times(BigInt.fromI32(2)), + sowedPods.times(BigInt.fromI32(2)), + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + + test("Create a pod listing - partial plot", () => { + const listedPods = sowedPods.minus(listingStart); + const event = createListing_v1(account, listingIndex, listedPods, listingStart, listingPricePerPod, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods, + listedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + + test("Create a pod listing - partial plot", () => { + const listedPods = sowedPods.minus(listingStart); + const event = createListing_v1(account, listingIndex, listedPods, listingStart, listingPricePerPod, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods, + listedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + + test("Create a pod order", () => { + const event = createOrder_v1(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + assertMarketOrdersState( + BEANSTALK.toHexString(), + [event.params.id.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans, + orderBeans, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + + test("Market events correctly track place in line", () => { + let placeInLine = listingIndex.plus(listingStart).minus(currentHarvestable); + const listedPods = sowedPods.minus(listingStart); + const createEvent = createListing_v1(account, listingIndex, listedPods, listingStart, listingPricePerPod, maxHarvestableIndex); + const createListingId = "podListingCreated-" + createEvent.transaction.hash.toHexString() + "-" + createEvent.logIndex.toString(); + assert.fieldEquals("PodListingCreated", createListingId, "placeInLine", placeInLine.toString()); + + // Line advances 1m before fill + let newHarvestable = currentHarvestable.plus(podlineMil_BI(1)); + setHarvestable(newHarvestable); + placeInLine = placeInLine.minus(podlineMil_BI(1)); + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = beans_BI(2000); + const fillEvent = fillListing_v1(account, account2, listingIndex, listingStart, filledPods, listingPricePerPod); + const fillListingId = "podListingFilled-" + fillEvent.transaction.hash.toHexString() + "-" + fillEvent.logIndex.toString(); + assert.fieldEquals("PodListingFilled", fillListingId, "placeInLine", placeInLine.toString()); + assert.fieldEquals("PodFill", getPodFillId(listingIndex, fillEvent), "placeInLine", placeInLine.toString()); + + placeInLine = placeInLine.plus(filledPods); + const newListingIndex = fillEvent.params.index.plus(listingStart).plus(filledPods); + const cancelListingEvent = cancelListing(account, newListingIndex); + const cancelListingId = + "podListingCancelled-" + cancelListingEvent.transaction.hash.toHexString() + "-" + cancelListingEvent.logIndex.toString(); + assert.fieldEquals("PodListingCancelled", cancelListingId, "placeInLine", placeInLine.toString()); + + // Test order fill + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + sow(account2, orderPlotIndex, sowedBeans, orderedPods); + placeInLine = orderPlotIndex.minus(newHarvestable); + + createOrder_v1(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + const fillOrderEvent = fillOrder_v1(account2, account, orderId, orderPlotIndex, ZERO_BI, orderedPods, orderPricePerPod); + const fillOrderId = "podOrderFilled-" + fillOrderEvent.transaction.hash.toHexString() + "-" + fillOrderEvent.logIndex.toString(); + assert.fieldEquals("PodOrderFilled", fillOrderId, "placeInLine", placeInLine.toString()); + assert.fieldEquals("PodFill", getPodFillId(orderPlotIndex, fillOrderEvent), "placeInLine", placeInLine.toString()); + }); + + describe("Tests requiring Listing", () => { + beforeEach(() => { + createListing_v1(account, listingIndex, sowedPods.minus(beans_BI(500)), beans_BI(500), listingPricePerPod, maxHarvestableIndex); + }); + + test("Fill listing - full", () => { + const listedPods = sowedPods.minus(listingStart); + const filledBeans = listedPods.times(listingPricePerPod).div(BI_10.pow(6)); + const event = fillListing_v1(account, account2, listingIndex, listingStart, listedPods, listingPricePerPod); + + let listingID = event.params.from.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "status", "FILLED"); + assert.fieldEquals("PodListing", listingID, "filledAmount", listedPods.toString()); + assert.fieldEquals("PodListing", listingID, "remainingAmount", "0"); + assert.fieldEquals("PodListing", listingID, "filled", listedPods.toString()); + assert.entityCount("PodListing", 1); + + assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, ZERO_BI, listedPods, listedPods, filledBeans); + }); + + test("Fill listing - partial, then full", () => { + const listedPods = sowedPods.minus(listingStart); + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = filledPods.times(listingPricePerPod).div(BI_10.pow(6)); + const event = fillListing_v1(account, account2, listingIndex, listingStart, filledPods, listingPricePerPod); + + const remaining = listedPods.minus(filledPods); + const listingID = event.params.from.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "status", "FILLED_PARTIAL"); + assert.fieldEquals("PodListing", listingID, "filledAmount", filledPods.toString()); + assert.fieldEquals("PodListing", listingID, "remainingAmount", remaining.toString()); + assert.fieldEquals("PodListing", listingID, "filled", filledPods.toString()); + assert.entityCount("PodListing", 2); + + const newListingIndex = event.params.index.plus(listingStart).plus(filledPods); + const derivedListingID = event.params.from.toHexString() + "-" + newListingIndex.toString(); + assert.fieldEquals("PodListing", derivedListingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", derivedListingID, "filledAmount", "0"); + assert.fieldEquals("PodListing", derivedListingID, "remainingAmount", remaining.toString()); + assert.fieldEquals("PodListing", derivedListingID, "originalIndex", listingIndex.toString()); + assert.fieldEquals("PodListing", derivedListingID, "originalAmount", listedPods.toString()); + assert.fieldEquals("PodListing", derivedListingID, "filled", filledPods.toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + newListingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods, + remaining, + ZERO_BI, + ZERO_BI, + filledPods, + filledPods, + filledBeans + ); + + // Now sell the rest + const newFilledBeans = remaining.times(listingPricePerPod).div(BI_10.pow(6)); + const event2 = fillListing_v1(account, account2, newListingIndex, ZERO_BI, remaining, listingPricePerPod); + + assert.entityCount("PodListing", 2); + assert.fieldEquals("PodListing", derivedListingID, "status", "FILLED"); + assert.fieldEquals("PodListing", derivedListingID, "filledAmount", remaining.toString()); + assert.fieldEquals("PodListing", derivedListingID, "remainingAmount", "0"); + assert.fieldEquals("PodListing", derivedListingID, "filled", listedPods.toString()); + // Original should be unchanged + assert.fieldEquals("PodListing", listingID, "status", "FILLED_PARTIAL"); + assert.fieldEquals("PodListing", listingID, "filled", filledPods.toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [], + listedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + listedPods, + listedPods, + filledBeans.plus(newFilledBeans) + ); + }); + + test("Cancel listing - full", () => { + const event = cancelListing(account, listingIndex); + const cancelledAmount = sowedPods.minus(beans_BI(500)); + const listingID = event.params.account.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "status", "CANCELLED"); + assert.fieldEquals("PodListing", listingID, "remainingAmount", cancelledAmount.toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [], + cancelledAmount, + ZERO_BI, + cancelledAmount, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + + test("Cancel listing - partial", () => { + const listedPods = sowedPods.minus(listingStart); + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = filledPods.times(listingPricePerPod).div(BI_10.pow(6)); + const fillEvent = fillListing_v1(account, account2, listingIndex, listingStart, filledPods, listingPricePerPod); + + const remaining = listedPods.minus(filledPods); + const newListingIndex = fillEvent.params.index.plus(listingStart).plus(filledPods); + + const event = cancelListing(account, newListingIndex); + + const newListingID = event.params.account.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", newListingID, "status", "CANCELLED_PARTIAL"); + assert.fieldEquals("PodListing", newListingID, "remainingAmount", remaining.toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [], + listedPods, + ZERO_BI, + remaining, + ZERO_BI, + filledPods, + filledPods, + filledBeans + ); + }); + + test("Recreate listing", () => { + const listedPods = sowedPods.minus(listingStart); + cancelListing(account, listingIndex); + const listEvent = createListing_v1(account, listingIndex, listedPods, listingStart, listingPricePerPod, maxHarvestableIndex); + + const listingID = listEvent.params.account.toHexString() + "-" + listEvent.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", listingID + "-0", "status", "CANCELLED"); + assert.fieldEquals("PodListing", listingID + "-0", "filled", "0"); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods.times(BigInt.fromU32(2)), + listedPods, + listedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + + // Partial fill, then recreate again + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = filledPods.times(listingPricePerPod).div(BI_10.pow(6)); + const fillEvent = fillListing_v1(account, account2, listingIndex, listingStart, filledPods, listingPricePerPod); + + const remaining = listedPods.minus(filledPods); + const newListingIndex = fillEvent.params.index.plus(listingStart).plus(filledPods); + const newListingAmount = listedPods.minus(filledPods); + cancelListing(account, newListingIndex); + const newListEvent = createListing_v1(account, newListingIndex, remaining, ZERO_BI, listingPricePerPod, maxHarvestableIndex); + + const newListingID = newListEvent.params.account.toHexString() + "-" + newListEvent.params.index.toString(); + assert.notInStore("PodListing", listingID + "-1"); + assert.notInStore("PodListing", newListingID + "-1"); + assert.fieldEquals("PodListing", newListingID + "-0", "status", "CANCELLED_PARTIAL"); + assert.fieldEquals("PodListing", newListingID + "-0", "filled", filledPods.toString()); + assert.fieldEquals("PodListing", newListingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", newListingID, "filled", "0"); + assert.fieldEquals("PodListing", newListingID, "remainingAmount", newListingAmount.toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + newListingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods.times(BigInt.fromU32(2)).plus(newListingAmount), + newListingAmount, + listedPods.plus(newListingAmount), + ZERO_BI, + filledPods, + filledPods, + filledBeans + ); + }); + + test("Listing expires due to moving podline", () => { + const listedPods = sowedPods.minus(listingStart); + const listingID = account + "-" + listingIndex.toString(); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", listingID, "maxHarvestableIndex", maxHarvestableIndex.toString()); + + // Expires due to exceeding max harvestable index + setHarvestable(maxHarvestableIndex); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + setHarvestable(maxHarvestableIndex.plus(ONE_BI)); + assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); + assert.fieldEquals("PodListing", listingID, "remainingAmount", listedPods.toString()); + + assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + + // Test expiration after a partial sale + setHarvestable(maxHarvestableIndex); + createListing_v1(account, listingIndex, listedPods, listingStart, listingPricePerPod, maxHarvestableIndex); + + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = filledPods.times(listingPricePerPod).div(BI_10.pow(6)); + const fillEvent = fillListing_v1(account, account2, listingIndex, listingStart, filledPods, listingPricePerPod); + + const remaining = listedPods.minus(filledPods); + const newListingIndex = fillEvent.params.index.plus(listingStart).plus(filledPods); + const newListingID = account + "-" + newListingIndex.toString(); + + setHarvestable(maxHarvestableIndex.plus(ONE_BI)); + assert.fieldEquals("PodListing", listingID, "status", "FILLED_PARTIAL"); + assert.fieldEquals("PodListing", listingID, "filled", filledPods.toString()); + assert.fieldEquals("PodListing", newListingID, "status", "EXPIRED"); + assert.fieldEquals("PodListing", newListingID, "filled", filledPods.toString()); + assert.fieldEquals("PodListing", newListingID, "remainingAmount", listedPods.minus(filledPods).toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [], + listedPods.times(BigInt.fromU32(2)), + ZERO_BI, + ZERO_BI, + listedPods.plus(remaining), + filledPods, + filledPods, + filledBeans + ); + }); + + test("Listing expires due to plot harvesting", () => { + const listedPods = sowedPods.minus(listingStart); + const listingID = account + "-" + listingIndex.toString(); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + + // Plot is harvestable, but still active + setHarvestable(listingIndex.plus(sowedPods)); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + // Plot harvests, now expired + harvest(account, [listingIndex], sowedPods); + assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); + assert.fieldEquals("PodListing", listingID, "remainingAmount", listedPods.toString()); + + assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + }); + + test("Cancel expired/nonexistent listing", () => { + const listedPods = sowedPods.minus(listingStart); + setHarvestable(maxHarvestableIndex.plus(ONE_BI)); + const listingID = account + "-" + listingIndex.toString(); + assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); + + // Cancelling listing is still possible, nothing should change in market + cancelListing(account, listingIndex); + + assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); + assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + }); + }); + + describe("Tests requiring Order", () => { + beforeEach(() => { + createOrder_v1(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + }); + + test("Fill order - full", () => { + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + sow(account2, orderPlotIndex, sowedBeans, orderedPods); + const event = fillOrder_v1(account2, account, orderId, orderPlotIndex, ZERO_BI, orderedPods, orderPricePerPod); + + assert.fieldEquals("PodOrder", orderId.toHexString(), "status", "FILLED"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmountFilled", orderBeans.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", orderedPods.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, event) + "]"); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [], + orderBeans, + ZERO_BI, + orderBeans, + orderedPods, + ZERO_BI, + orderedPods, + orderBeans + ); + }); + + test("Fill order - partial", () => { + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + const soldToOrder1 = orderedPods.div(BigInt.fromU32(5)); + const orderBeans1 = orderBeans.div(BigInt.fromU32(5)); + sow(account2, orderPlotIndex, sowedBeans, orderedPods.times(BigInt.fromU32(2))); + const event = fillOrder_v1(account2, account, orderId, orderPlotIndex, beans_BI(1000), soldToOrder1, orderPricePerPod); + + assert.fieldEquals("PodOrder", orderId.toHexString(), "status", "ACTIVE"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmountFilled", orderBeans1.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", soldToOrder1.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, event) + "]"); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [event.params.id.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans, + orderBeans.minus(orderBeans1), + orderBeans1, + soldToOrder1, + ZERO_BI, + soldToOrder1, + orderBeans1 + ); + + // Now fill the rest + const newOrderPlotIndex = orderPlotIndex.plus(beans_BI(1000)).plus(soldToOrder1); + const soldToOrder2 = orderedPods.minus(soldToOrder1); + const orderBeans2 = orderBeans.minus(orderBeans1); + const event2 = fillOrder_v1(account2, account, orderId, newOrderPlotIndex, ZERO_BI, soldToOrder2, orderPricePerPod); + + assert.fieldEquals("PodOrder", orderId.toHexString(), "status", "FILLED"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmountFilled", orderBeans.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", orderedPods.toString()); + assert.fieldEquals( + "PodOrder", + orderId.toHexString(), + "fills", + "[" + getPodFillId(orderPlotIndex, event) + ", " + getPodFillId(newOrderPlotIndex, event2) + "]" + ); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [], + orderBeans, + ZERO_BI, + orderBeans, + orderedPods, + ZERO_BI, + orderedPods, + orderBeans + ); + }); + + test("Cancel order - full", () => { + cancelOrder(account, orderId); + + assert.fieldEquals("PodOrder", orderId.toHexString(), "status", "CANCELLED"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmountFilled", "0"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", "0"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[]"); + + assertMarketOrdersState(BEANSTALK.toHexString(), [], orderBeans, ZERO_BI, ZERO_BI, ZERO_BI, orderBeans, ZERO_BI, ZERO_BI); + }); + + test("Cancel order - partial", () => { + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + const soldToOrder1 = orderedPods.div(BigInt.fromU32(5)); + const orderBeans1 = orderBeans.div(BigInt.fromU32(5)); + sow(account2, orderPlotIndex, sowedBeans, orderedPods.times(BigInt.fromU32(2))); + const fillEvent = fillOrder_v1(account2, account, orderId, orderPlotIndex, beans_BI(1000), soldToOrder1, orderPricePerPod); + + cancelOrder(account, orderId); + + assert.fieldEquals("PodOrder", orderId.toHexString(), "status", "CANCELLED_PARTIAL"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmountFilled", orderBeans1.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", soldToOrder1.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, fillEvent) + "]"); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [], + orderBeans, + ZERO_BI, + orderBeans1, + soldToOrder1, + orderBeans.minus(orderBeans1), + soldToOrder1, + orderBeans1 + ); + }); + + test("Recreate order", () => { + cancelOrder(account, orderId); + createOrder_v1(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + + assert.fieldEquals("PodOrder", orderId.toHexString() + "-0", "fills", "[]"); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans.times(BigInt.fromU32(2)), + orderBeans, + ZERO_BI, + ZERO_BI, + orderBeans, + ZERO_BI, + ZERO_BI + ); + + // Recreate after a partial fill + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + const soldToOrder1 = orderedPods.div(BigInt.fromU32(5)); + const orderBeans1 = orderBeans.div(BigInt.fromU32(5)); + sow(account2, orderPlotIndex, sowedBeans, orderedPods.times(BigInt.fromU32(2))); + const fillEvent = fillOrder_v1(account2, account, orderId, orderPlotIndex, beans_BI(1000), soldToOrder1, orderPricePerPod); + + cancelOrder(account, orderId); + createOrder_v1(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + + // The historical order has one fill + assert.fieldEquals("PodOrder", orderId.toHexString() + "-1", "fills", "[" + getPodFillId(orderPlotIndex, fillEvent) + "]"); + // The recreated order has no fills + assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[]"); + + // The same amount of beans were re-ordered, but fewer were cancelled + assertMarketOrdersState( + BEANSTALK.toHexString(), + [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans.times(BigInt.fromU32(3)), + orderBeans, + orderBeans1, + soldToOrder1, + orderBeans.plus(orderBeans.minus(orderBeans1)), + soldToOrder1, + orderBeans1 + ); + }); + + test("Cancel nonexistent order", () => { + const nonexistent = Bytes.fromHexString("0x1234"); + cancelOrder(account, nonexistent); + assert.notInStore("PodOrder", nonexistent.toHexString()); + assertMarketOrdersState( + BEANSTALK.toHexString(), + [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans, + orderBeans, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + }); + }); + + // At replant, but before v2, there was a slight change in the listing event + describe("Marketplace v1_1", () => { + test("Create a pod listing - full plot", () => { + const event = createListing_v1_1(account, listingIndex, sowedPods, ZERO_BI, listingPricePerPod, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], + sowedPods, + sowedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + + // Create a second listing to assert the market state again + const listing2Index = listingIndex.times(BI_10); + sow(account, listing2Index, sowedBeans, sowedPods); + const event2 = createListing_v1_1(account, listing2Index, sowedPods, ZERO_BI, listingPricePerPod, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [ + account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString(), + account + "-" + listing2Index.toString() + "-" + maxHarvestableIndex.toString() + ], + sowedPods.times(BigInt.fromI32(2)), + sowedPods.times(BigInt.fromI32(2)), + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + + test("Create a pod listing - partial plot", () => { + const listedPods = sowedPods.minus(listingStart); + const event = createListing_v1_1(account, listingIndex, listedPods, listingStart, listingPricePerPod, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods, + listedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + }); +}); diff --git a/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts new file mode 100644 index 0000000000..80605ffd0f --- /dev/null +++ b/projects/subgraph-beanstalk/tests/MarketplaceV2.test.ts @@ -0,0 +1,566 @@ +import { BigInt, Bytes, log } from "@graphprotocol/graph-ts"; +import { afterEach, assert, beforeEach, clearStore, describe, test } from "matchstick-as/assembly/index"; +import { beans_BI, podlineMil_BI } from "../../subgraph-core/tests/Values"; +import { BI_10, ONE_BI, ZERO_BI } from "../../subgraph-core/utils/Decimals"; +import { BEANSTALK } from "../../subgraph-core/utils/Constants"; +import { + assertMarketListingsState, + assertMarketOrdersState, + cancelListing, + cancelOrder, + createListing_v2, + createOrder_v2, + fillListing_v2, + fillOrder_v2, + getPodFillId +} from "./utils/Marketplace"; +import { harvest, setHarvestable, sow } from "./utils/Field"; + +const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); +const account2 = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8".toLowerCase(); + +const listingIndex = podlineMil_BI(10); +const listingStart = beans_BI(500); +const currentHarvestable = podlineMil_BI(4); +const maxHarvestableIndex = podlineMil_BI(100); +const sowedBeans = beans_BI(5000); +const temperature = 37; +const sowedPods = sowedBeans.times(BigInt.fromU32(temperature)); + +const orderBeans = beans_BI(80000); +const orderPricePerPod = BigInt.fromString("500000"); // 0.5 beans +const orderId = Bytes.fromHexString("0xabcd"); + +describe("Marketplace", () => { + beforeEach(() => { + setHarvestable(currentHarvestable); + sow(account, listingIndex, sowedBeans, sowedPods); + }); + + afterEach(() => { + clearStore(); + }); + + describe("Marketplace v2", () => { + test("Create a pod listing - full plot", () => { + const event = createListing_v2(account, listingIndex, sowedPods, ZERO_BI, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], + sowedPods, + sowedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + + // Create a second listing to assert the market state again + const listing2Index = listingIndex.times(BI_10); + sow(account, listing2Index, sowedBeans, sowedPods); + const event2 = createListing_v2(account, listing2Index, sowedPods, ZERO_BI, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [ + account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString(), + account + "-" + listing2Index.toString() + "-" + maxHarvestableIndex.toString() + ], + sowedPods.times(BigInt.fromI32(2)), + sowedPods.times(BigInt.fromI32(2)), + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + + test("Create a pod listing - partial plot", () => { + const listedPods = sowedPods.minus(listingStart); + const event = createListing_v2(account, listingIndex, listedPods, listingStart, maxHarvestableIndex); + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods, + listedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + + test("Create a pod order", () => { + const event = createOrder_v2(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + assertMarketOrdersState( + BEANSTALK.toHexString(), + [event.params.id.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans, + orderBeans, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + + test("Market events correctly track place in line", () => { + let placeInLine = listingIndex.plus(listingStart).minus(currentHarvestable); + const listedPods = sowedPods.minus(listingStart); + const createEvent = createListing_v2(account, listingIndex, listedPods, listingStart, maxHarvestableIndex); + const createListingId = "podListingCreated-" + createEvent.transaction.hash.toHexString() + "-" + createEvent.logIndex.toString(); + assert.fieldEquals("PodListingCreated", createListingId, "placeInLine", placeInLine.toString()); + + // Line advances 1m before fill + let newHarvestable = currentHarvestable.plus(podlineMil_BI(1)); + setHarvestable(newHarvestable); + placeInLine = placeInLine.minus(podlineMil_BI(1)); + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = beans_BI(2000); + const fillEvent = fillListing_v2(account, account2, listingIndex, listingStart, filledPods, filledBeans); + const fillListingId = "podListingFilled-" + fillEvent.transaction.hash.toHexString() + "-" + fillEvent.logIndex.toString(); + assert.fieldEquals("PodListingFilled", fillListingId, "placeInLine", placeInLine.toString()); + assert.fieldEquals("PodFill", getPodFillId(listingIndex, fillEvent), "placeInLine", placeInLine.toString()); + + placeInLine = placeInLine.plus(filledPods); + const newListingIndex = fillEvent.params.index.plus(listingStart).plus(filledPods); + const cancelListingEvent = cancelListing(account, newListingIndex); + const cancelListingId = + "podListingCancelled-" + cancelListingEvent.transaction.hash.toHexString() + "-" + cancelListingEvent.logIndex.toString(); + assert.fieldEquals("PodListingCancelled", cancelListingId, "placeInLine", placeInLine.toString()); + + // Test order fill + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + sow(account2, orderPlotIndex, sowedBeans, orderedPods); + placeInLine = orderPlotIndex.minus(newHarvestable); + + createOrder_v2(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + const fillOrderEvent = fillOrder_v2(account2, account, orderId, orderPlotIndex, ZERO_BI, orderedPods, orderBeans); + const fillOrderId = "podOrderFilled-" + fillOrderEvent.transaction.hash.toHexString() + "-" + fillOrderEvent.logIndex.toString(); + assert.fieldEquals("PodOrderFilled", fillOrderId, "placeInLine", placeInLine.toString()); + assert.fieldEquals("PodFill", getPodFillId(orderPlotIndex, fillOrderEvent), "placeInLine", placeInLine.toString()); + }); + + describe("Listing tests", () => { + beforeEach(() => { + createListing_v2(account, listingIndex, sowedPods.minus(beans_BI(500)), beans_BI(500), maxHarvestableIndex); + }); + + test("Fill listing - full", () => { + const listedPods = sowedPods.minus(listingStart); + const filledBeans = beans_BI(7000); + const event = fillListing_v2(account, account2, listingIndex, listingStart, listedPods, filledBeans); + + let listingID = event.params.from.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "status", "FILLED"); + assert.fieldEquals("PodListing", listingID, "filledAmount", listedPods.toString()); + assert.fieldEquals("PodListing", listingID, "remainingAmount", "0"); + assert.fieldEquals("PodListing", listingID, "filled", listedPods.toString()); + assert.entityCount("PodListing", 1); + + assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, ZERO_BI, listedPods, listedPods, filledBeans); + }); + + test("Fill listing - partial, then full", () => { + const listedPods = sowedPods.minus(listingStart); + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = beans_BI(2000); + const event = fillListing_v2(account, account2, listingIndex, listingStart, filledPods, filledBeans); + + const remaining = listedPods.minus(filledPods); + const listingID = event.params.from.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "status", "FILLED_PARTIAL"); + assert.fieldEquals("PodListing", listingID, "filledAmount", filledPods.toString()); + assert.fieldEquals("PodListing", listingID, "remainingAmount", remaining.toString()); + assert.fieldEquals("PodListing", listingID, "filled", filledPods.toString()); + assert.entityCount("PodListing", 2); + + const newListingIndex = event.params.index.plus(listingStart).plus(filledPods); + const derivedListingID = event.params.from.toHexString() + "-" + newListingIndex.toString(); + assert.fieldEquals("PodListing", derivedListingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", derivedListingID, "filledAmount", "0"); + assert.fieldEquals("PodListing", derivedListingID, "remainingAmount", remaining.toString()); + assert.fieldEquals("PodListing", derivedListingID, "originalIndex", listingIndex.toString()); + assert.fieldEquals("PodListing", derivedListingID, "originalAmount", listedPods.toString()); + assert.fieldEquals("PodListing", derivedListingID, "filled", filledPods.toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + newListingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods, + remaining, + ZERO_BI, + ZERO_BI, + filledPods, + filledPods, + filledBeans + ); + + // Now sell the rest + const newFilledBeans = beans_BI(4000); + const event2 = fillListing_v2(account, account2, newListingIndex, ZERO_BI, remaining, newFilledBeans); + + assert.entityCount("PodListing", 2); + assert.fieldEquals("PodListing", derivedListingID, "status", "FILLED"); + assert.fieldEquals("PodListing", derivedListingID, "filledAmount", remaining.toString()); + assert.fieldEquals("PodListing", derivedListingID, "remainingAmount", "0"); + assert.fieldEquals("PodListing", derivedListingID, "filled", listedPods.toString()); + // Original should be unchanged + assert.fieldEquals("PodListing", listingID, "status", "FILLED_PARTIAL"); + assert.fieldEquals("PodListing", listingID, "filled", filledPods.toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [], + listedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + listedPods, + listedPods, + filledBeans.plus(newFilledBeans) + ); + }); + + test("Cancel listing - partial", () => { + const listedPods = sowedPods.minus(listingStart); + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = beans_BI(2000); + const fillEvent = fillListing_v2(account, account2, listingIndex, listingStart, filledPods, filledBeans); + + const remaining = listedPods.minus(filledPods); + const newListingIndex = fillEvent.params.index.plus(listingStart).plus(filledPods); + + const event = cancelListing(account, newListingIndex); + + const newListingID = event.params.account.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", newListingID, "status", "CANCELLED_PARTIAL"); + assert.fieldEquals("PodListing", newListingID, "remainingAmount", remaining.toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [], + listedPods, + ZERO_BI, + remaining, + ZERO_BI, + filledPods, + filledPods, + filledBeans + ); + }); + + test("Recreate listing", () => { + const listedPods = sowedPods.minus(listingStart); + cancelListing(account, listingIndex); + const listEvent = createListing_v2(account, listingIndex, listedPods, listingStart, maxHarvestableIndex); + + const listingID = listEvent.params.account.toHexString() + "-" + listEvent.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", listingID + "-0", "status", "CANCELLED"); + assert.fieldEquals("PodListing", listingID + "-0", "filled", "0"); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + listingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods.times(BigInt.fromU32(2)), + listedPods, + listedPods, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + + // Partial fill, then recreate again + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = beans_BI(2000); + const fillEvent = fillListing_v2(account, account2, listingIndex, listingStart, filledPods, filledBeans); + + const remaining = listedPods.minus(filledPods); + const newListingIndex = fillEvent.params.index.plus(listingStart).plus(filledPods); + const newListingAmount = listedPods.minus(filledPods); + cancelListing(account, newListingIndex); + const newListEvent = createListing_v2(account, newListingIndex, remaining, ZERO_BI, maxHarvestableIndex); + + const newListingID = newListEvent.params.account.toHexString() + "-" + newListEvent.params.index.toString(); + assert.notInStore("PodListing", listingID + "-1"); + assert.notInStore("PodListing", newListingID + "-1"); + assert.fieldEquals("PodListing", newListingID + "-0", "status", "CANCELLED_PARTIAL"); + assert.fieldEquals("PodListing", newListingID + "-0", "filled", filledPods.toString()); + assert.fieldEquals("PodListing", newListingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", newListingID, "filled", "0"); + assert.fieldEquals("PodListing", newListingID, "remainingAmount", newListingAmount.toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [account + "-" + newListingIndex.toString() + "-" + maxHarvestableIndex.toString()], + listedPods.times(BigInt.fromU32(2)).plus(newListingAmount), + newListingAmount, + listedPods.plus(newListingAmount), + ZERO_BI, + filledPods, + filledPods, + filledBeans + ); + }); + + test("Listing expires due to moving podline", () => { + const listedPods = sowedPods.minus(listingStart); + const listingID = account + "-" + listingIndex.toString(); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", listingID, "maxHarvestableIndex", maxHarvestableIndex.toString()); + + // Expires due to exceeding max harvestable index + setHarvestable(maxHarvestableIndex); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + setHarvestable(maxHarvestableIndex.plus(ONE_BI)); + assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); + assert.fieldEquals("PodListing", listingID, "remainingAmount", listedPods.toString()); + + assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + + // Test expiration after a partial sale + setHarvestable(maxHarvestableIndex); + createListing_v2(account, listingIndex, listedPods, listingStart, maxHarvestableIndex); + + const filledPods = listedPods.div(BigInt.fromString("4")); + const filledBeans = beans_BI(2000); + const fillEvent = fillListing_v2(account, account2, listingIndex, listingStart, filledPods, filledBeans); + + const remaining = listedPods.minus(filledPods); + const newListingIndex = fillEvent.params.index.plus(listingStart).plus(filledPods); + const newListingID = account + "-" + newListingIndex.toString(); + + setHarvestable(maxHarvestableIndex.plus(ONE_BI)); + assert.fieldEquals("PodListing", listingID, "status", "FILLED_PARTIAL"); + assert.fieldEquals("PodListing", listingID, "filled", filledPods.toString()); + assert.fieldEquals("PodListing", newListingID, "status", "EXPIRED"); + assert.fieldEquals("PodListing", newListingID, "filled", filledPods.toString()); + assert.fieldEquals("PodListing", newListingID, "remainingAmount", listedPods.minus(filledPods).toString()); + + assertMarketListingsState( + BEANSTALK.toHexString(), + [], + listedPods.times(BigInt.fromU32(2)), + ZERO_BI, + ZERO_BI, + listedPods.plus(remaining), + filledPods, + filledPods, + filledBeans + ); + }); + + test("Listing expires due to plot harvesting", () => { + const listedPods = sowedPods.minus(listingStart); + const listingID = account + "-" + listingIndex.toString(); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + + // Plot is harvestable, but still active + setHarvestable(listingIndex.plus(sowedPods)); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + // Plot harvests, now expired + harvest(account, [listingIndex], sowedPods); + assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); + assert.fieldEquals("PodListing", listingID, "remainingAmount", listedPods.toString()); + + assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + }); + + test("Cancel expired/nonexistent listing", () => { + const listedPods = sowedPods.minus(listingStart); + setHarvestable(maxHarvestableIndex.plus(ONE_BI)); + const listingID = account + "-" + listingIndex.toString(); + assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); + + // Cancelling listing is still possible, nothing should change in market + cancelListing(account, listingIndex); + + assert.fieldEquals("PodListing", listingID, "status", "EXPIRED"); + assertMarketListingsState(BEANSTALK.toHexString(), [], listedPods, ZERO_BI, ZERO_BI, listedPods, ZERO_BI, ZERO_BI, ZERO_BI); + }); + }); + + describe("Order tests", () => { + beforeEach(() => { + createOrder_v2(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + }); + + test("Fill order - full", () => { + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + sow(account2, orderPlotIndex, sowedBeans, orderedPods); + const event = fillOrder_v2(account2, account, orderId, orderPlotIndex, ZERO_BI, orderedPods, orderBeans); + + assert.fieldEquals("PodOrder", orderId.toHexString(), "status", "FILLED"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmountFilled", orderBeans.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", orderedPods.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, event) + "]"); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [], + orderBeans, + ZERO_BI, + orderBeans, + orderedPods, + ZERO_BI, + orderedPods, + orderBeans + ); + }); + + test("Fill order - partial", () => { + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + const soldToOrder1 = orderedPods.div(BigInt.fromU32(5)); + const orderBeans1 = orderBeans.div(BigInt.fromU32(5)); + sow(account2, orderPlotIndex, sowedBeans, orderedPods.times(BigInt.fromU32(2))); + const event = fillOrder_v2(account2, account, orderId, orderPlotIndex, beans_BI(1000), soldToOrder1, orderBeans1); + + assert.fieldEquals("PodOrder", orderId.toHexString(), "status", "ACTIVE"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmountFilled", orderBeans1.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", soldToOrder1.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, event) + "]"); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [event.params.id.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans, + orderBeans.minus(orderBeans1), + orderBeans1, + soldToOrder1, + ZERO_BI, + soldToOrder1, + orderBeans1 + ); + + // Now fill the rest + const newOrderPlotIndex = orderPlotIndex.plus(beans_BI(1000)).plus(soldToOrder1); + const soldToOrder2 = orderedPods.minus(soldToOrder1); + const orderBeans2 = orderBeans.minus(orderBeans1); + const event2 = fillOrder_v2(account2, account, orderId, newOrderPlotIndex, ZERO_BI, soldToOrder2, orderBeans2); + + assert.fieldEquals("PodOrder", orderId.toHexString(), "status", "FILLED"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmountFilled", orderBeans.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", orderedPods.toString()); + assert.fieldEquals( + "PodOrder", + orderId.toHexString(), + "fills", + "[" + getPodFillId(orderPlotIndex, event) + ", " + getPodFillId(newOrderPlotIndex, event2) + "]" + ); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [], + orderBeans, + ZERO_BI, + orderBeans, + orderedPods, + ZERO_BI, + orderedPods, + orderBeans + ); + }); + + test("Cancel order - partial", () => { + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + const soldToOrder1 = orderedPods.div(BigInt.fromU32(5)); + const orderBeans1 = orderBeans.div(BigInt.fromU32(5)); + sow(account2, orderPlotIndex, sowedBeans, orderedPods.times(BigInt.fromU32(2))); + const fillEvent = fillOrder_v2(account2, account, orderId, orderPlotIndex, beans_BI(1000), soldToOrder1, orderBeans1); + + cancelOrder(account, orderId); + + assert.fieldEquals("PodOrder", orderId.toHexString(), "status", "CANCELLED_PARTIAL"); + assert.fieldEquals("PodOrder", orderId.toHexString(), "beanAmountFilled", orderBeans1.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "podAmountFilled", soldToOrder1.toString()); + assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[" + getPodFillId(orderPlotIndex, fillEvent) + "]"); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [], + orderBeans, + ZERO_BI, + orderBeans1, + soldToOrder1, + orderBeans.minus(orderBeans1), + soldToOrder1, + orderBeans1 + ); + }); + + test("Recreate order", () => { + cancelOrder(account, orderId); + createOrder_v2(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + + assert.fieldEquals("PodOrder", orderId.toHexString() + "-0", "fills", "[]"); + + assertMarketOrdersState( + BEANSTALK.toHexString(), + [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans.times(BigInt.fromU32(2)), + orderBeans, + ZERO_BI, + ZERO_BI, + orderBeans, + ZERO_BI, + ZERO_BI + ); + + // Recreate after a partial fill + const orderPlotIndex = podlineMil_BI(15); + const orderedPods = orderBeans.times(BigInt.fromU32(1000000)).div(orderPricePerPod); + const soldToOrder1 = orderedPods.div(BigInt.fromU32(5)); + const orderBeans1 = orderBeans.div(BigInt.fromU32(5)); + sow(account2, orderPlotIndex, sowedBeans, orderedPods.times(BigInt.fromU32(2))); + const fillEvent = fillOrder_v2(account2, account, orderId, orderPlotIndex, beans_BI(1000), soldToOrder1, orderBeans1); + + cancelOrder(account, orderId); + createOrder_v2(account, orderId, orderBeans, orderPricePerPod, maxHarvestableIndex); + + // The historical order has one fill + assert.fieldEquals("PodOrder", orderId.toHexString() + "-1", "fills", "[" + getPodFillId(orderPlotIndex, fillEvent) + "]"); + // The recreated order has no fills + assert.fieldEquals("PodOrder", orderId.toHexString(), "fills", "[]"); + + // The same amount of beans were re-ordered, but fewer were cancelled + assertMarketOrdersState( + BEANSTALK.toHexString(), + [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans.times(BigInt.fromU32(3)), + orderBeans, + orderBeans1, + soldToOrder1, + orderBeans.plus(orderBeans.minus(orderBeans1)), + soldToOrder1, + orderBeans1 + ); + }); + + test("Cancel nonexistent order", () => { + const nonexistent = Bytes.fromHexString("0x1234"); + cancelOrder(account, nonexistent); + assert.notInStore("PodOrder", nonexistent.toHexString()); + assertMarketOrdersState( + BEANSTALK.toHexString(), + [orderId.toHexString() + "-" + maxHarvestableIndex.toString()], + orderBeans, + orderBeans, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI, + ZERO_BI + ); + }); + }); + }); +}); diff --git a/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts b/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts index b500e56636..b87e47bcbb 100644 --- a/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts +++ b/projects/subgraph-beanstalk/tests/PlotTransfer.test.ts @@ -2,32 +2,27 @@ import { beforeEach, afterEach, assert, clearStore, describe, test, createMockedFunction } from "matchstick-as/assembly/index"; import { log } from "matchstick-as/assembly/log"; -import { logStore } from "matchstick-as/assembly/store"; -import { BigInt, ethereum } from "@graphprotocol/graph-ts"; -import { createSowEvent, createPlotTransferEvent } from "./event-mocking/Field"; -import { createIncentivizationEvent } from "./event-mocking/Season"; +import { BigInt, Bytes } from "@graphprotocol/graph-ts"; -import { loadSeason } from "../src/utils/Season"; - -import { handleSow, handlePlotTransfer } from "../src/FieldHandler"; -import { handleIncentive } from "../src/SeasonHandler"; import { BEANSTALK } from "../../subgraph-core/utils/Constants"; -import { ZERO_BI } from "../../subgraph-core/utils/Decimals"; - -const ANVIL_ADDR_1 = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); -const ANVIL_ADDR_2 = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8".toLowerCase(); +import { BI_10, ZERO_BI } from "../../subgraph-core/utils/Decimals"; +import { beans_BI as beans, podlineMil_BI } from "../../subgraph-core/tests/Values"; +import { assertFarmerHasPlot, assertFieldHas, setHarvestable, sow, transferPlot } from "./utils/Field"; +import { createListing_v2, createOrder_v2, fillListing_v2, fillOrder_v2 } from "./utils/Marketplace"; -// These functions may exist elsewhere but I dont know of them -const beans = (b: number): BigInt => BigInt.fromI32(b).times(BigInt.fromI32(10).pow(6)); -const mil = (m: number): BigInt => BigInt.fromI32(m).times(BigInt.fromI32(10).pow(12)); +const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); +const account2 = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8".toLowerCase(); // 2 plots: each sow 500 for 7500 at 10m and 15m in line. -const plot1Start = mil(10); -const plot2Start = mil(15); +const plot1Start = podlineMil_BI(10); +const plot2Start = podlineMil_BI(15); const beansSown = beans(500); const temperature = 15; const pods = beansSown.times(BigInt.fromI32(temperature)); +const maxHarvestableIndex = podlineMil_BI(100); +const orderId = Bytes.fromHexString("0xabcd"); + class Plot { plotStart: BigInt; beansSown: BigInt; @@ -53,86 +48,46 @@ const initialPlots: Plot[] = [ } ]; -const assertFarmerHasPlot = ( - farmer: string, - index: BigInt, - numPods: BigInt, - numHarvestable: BigInt = ZERO_BI, - debug: boolean = false -): void => { - if (debug) { - log.debug("about to assert plot {}", [farmer]); - } - assert.fieldEquals("Plot", index.toString(), "farmer", farmer); - assert.fieldEquals("Plot", index.toString(), "pods", numPods.toString()); - // log.debug("about to assert harvestable {}", [numHarvestable.toString()]); - assert.fieldEquals("Plot", index.toString(), "harvestablePods", numHarvestable.toString()); -}; - -// Field can be either a farmer or beanstalk address -const assertFieldHas = (field: string, unharvestable: BigInt, harvestable: BigInt, debug: boolean = false): void => { - if (debug) { - log.debug("about to assert field {}", [field]); - } - assert.fieldEquals("Field", field, "unharvestablePods", unharvestable.toString()); - assert.fieldEquals("Field", field, "harvestablePods", harvestable.toString()); -}; - -const setHarvestable = (harvestableIndex: BigInt): BigInt => { - createMockedFunction(BEANSTALK, "harvestableIndex", "harvestableIndex():(uint256)") - // @ts-expect-error:2322 - .returns([ethereum.Value.fromUnsignedBigInt(harvestableIndex)]); - - // Incentivization event triggers update of harvestable amount of each plot - handleIncentive(createIncentivizationEvent(ANVIL_ADDR_1, BigInt.fromI32(123456))); - - return harvestableIndex; -}; - // Begin tests describe("Field: Plot Transfer", () => { beforeEach(() => { // Create two equally sized plots next to each other for (let i = 0; i < initialPlots.length; ++i) { - handleSow(createSowEvent(ANVIL_ADDR_1, initialPlots[i].plotStart, initialPlots[i].beansSown, initialPlots[i].pods)); + sow(account, initialPlots[i].plotStart, initialPlots[i].beansSown, initialPlots[i].pods); } // Ensure setup was done correctly - assertFarmerHasPlot(ANVIL_ADDR_1, initialPlots[0].plotStart, initialPlots[0].pods); - assertFieldHas(ANVIL_ADDR_1, initialPlots[0].pods.plus(initialPlots[1].pods), ZERO_BI); - assert.notInStore("Field", ANVIL_ADDR_2); + assertFarmerHasPlot(account, initialPlots[0].plotStart, initialPlots[0].pods); + assertFieldHas(account, initialPlots[0].pods.plus(initialPlots[1].pods), ZERO_BI); + assert.notInStore("Field", account2); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods.plus(initialPlots[1].pods), ZERO_BI); log.info("Initial data populated", []); }); afterEach(() => { - log.debug("clearing the store", []); clearStore(); }); // Transfers entire first plot describe("Full Plot", () => { test("F: Unharvestable", () => { - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, initialPlots[0].plotStart, initialPlots[0].pods)); + transferPlot(account, account2, initialPlots[0].plotStart, initialPlots[0].pods); - assertFarmerHasPlot(ANVIL_ADDR_2, initialPlots[0].plotStart, initialPlots[0].pods); - assertFieldHas(ANVIL_ADDR_1, initialPlots[1].pods, ZERO_BI); - assertFieldHas(ANVIL_ADDR_2, initialPlots[0].pods, ZERO_BI); + assertFarmerHasPlot(account2, initialPlots[0].plotStart, initialPlots[0].pods); + assertFieldHas(account, initialPlots[1].pods, ZERO_BI); + assertFieldHas(account2, initialPlots[0].pods, ZERO_BI); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods.plus(initialPlots[1].pods), ZERO_BI); }); test("F: Harvestable (Full)", () => { // Entire first plot is harvestable setHarvestable(initialPlots[0].plotStart.plus(initialPlots[0].pods)); - // const season = loadSeason(BEANSTALK, BigInt.fromU32(1)); - // season.harvestableIndex = initialPlots[0].plotStart.plus(initialPlots[0].pods); - // season.save(); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, initialPlots[0].plotStart, initialPlots[0].pods)); + transferPlot(account, account2, initialPlots[0].plotStart, initialPlots[0].pods); - assertFarmerHasPlot(ANVIL_ADDR_2, initialPlots[0].plotStart, initialPlots[0].pods, initialPlots[0].pods); - assertFieldHas(ANVIL_ADDR_1, initialPlots[1].pods, ZERO_BI); - assertFieldHas(ANVIL_ADDR_2, ZERO_BI, initialPlots[0].pods); + assertFarmerHasPlot(account2, initialPlots[0].plotStart, initialPlots[0].pods, initialPlots[0].pods); + assertFieldHas(account, initialPlots[1].pods, ZERO_BI); + assertFieldHas(account2, ZERO_BI, initialPlots[0].pods); assertFieldHas(BEANSTALK.toHexString(), initialPlots[1].pods, initialPlots[0].pods); }); @@ -140,17 +95,42 @@ describe("Field: Plot Transfer", () => { // 1/3 of first plot is harvestable const harvestableAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); setHarvestable(initialPlots[0].plotStart.plus(harvestableAmount)); - // const season = loadSeason(BEANSTALK, BigInt.fromU32(1)); - // season.harvestableIndex = initialPlots[0].plotStart.plus(harvestableAmount); - // season.save(); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, initialPlots[0].plotStart, initialPlots[0].pods)); + transferPlot(account, account2, initialPlots[0].plotStart, initialPlots[0].pods); - assertFarmerHasPlot(ANVIL_ADDR_2, initialPlots[0].plotStart, initialPlots[0].pods, harvestableAmount); - assertFieldHas(ANVIL_ADDR_1, initialPlots[1].pods, ZERO_BI); - assertFieldHas(ANVIL_ADDR_2, initialPlots[0].pods.minus(harvestableAmount), harvestableAmount); + assertFarmerHasPlot(account2, initialPlots[0].plotStart, initialPlots[0].pods, harvestableAmount); + assertFieldHas(account, initialPlots[1].pods, ZERO_BI); + assertFieldHas(account2, initialPlots[0].pods.minus(harvestableAmount), harvestableAmount); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods.minus(harvestableAmount).plus(initialPlots[1].pods), harvestableAmount); }); + + test("F: Plot Source", () => { + transferPlot(account, account2, initialPlots[0].plotStart, initialPlots[0].pods); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "TRANSFER"); + }); + + test("F: Marketplace Listing", () => { + const fillBeans = beans(7500); + createListing_v2(account, initialPlots[0].plotStart, initialPlots[0].pods, ZERO_BI, maxHarvestableIndex); + fillListing_v2(account, account2, initialPlots[0].plotStart, ZERO_BI, initialPlots[0].pods, fillBeans); + + const filledBeansPerPod = fillBeans.times(BI_10.pow(6)).div(initialPlots[0].pods).toString(); + assert.entityCount("Plot", 2); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "beansPerPod", filledBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "MARKET"); + }); + + test("F: Marketplace Order", () => { + const fillBeans = beans(8500); + const orderPricePerPod = BigInt.fromString("1234"); + createOrder_v2(account, orderId, beans(10000), orderPricePerPod, maxHarvestableIndex); + fillOrder_v2(account2, account, orderId, initialPlots[0].plotStart, ZERO_BI, initialPlots[0].pods, fillBeans); + + const filledBeansPerPod = fillBeans.times(BI_10.pow(6)).div(initialPlots[0].pods).toString(); + assert.entityCount("Plot", 2); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "beansPerPod", filledBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "MARKET"); + }); }); // Transfers the first third of the plot @@ -158,35 +138,32 @@ describe("Field: Plot Transfer", () => { test("S: Unharvestable", () => { const transferredIndex = initialPlots[0].plotStart; const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, transferredIndex, transferredAmount)); + transferPlot(account, account2, transferredIndex, transferredAmount); - assertFarmerHasPlot(ANVIL_ADDR_1, transferredIndex.plus(transferredAmount), initialPlots[0].pods.minus(transferredAmount)); - assertFarmerHasPlot(ANVIL_ADDR_2, transferredIndex, transferredAmount); - assertFieldHas(ANVIL_ADDR_1, initialPlots[0].pods.minus(transferredAmount).plus(initialPlots[1].pods), ZERO_BI); - assertFieldHas(ANVIL_ADDR_2, transferredAmount, ZERO_BI); + assertFarmerHasPlot(account, transferredIndex.plus(transferredAmount), initialPlots[0].pods.minus(transferredAmount)); + assertFarmerHasPlot(account2, transferredIndex, transferredAmount); + assertFieldHas(account, initialPlots[0].pods.minus(transferredAmount).plus(initialPlots[1].pods), ZERO_BI); + assertFieldHas(account2, transferredAmount, ZERO_BI); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods.plus(initialPlots[1].pods), ZERO_BI); }); test("S: Harvestable (Full)", () => { // Entire first plot is harvestable setHarvestable(initialPlots[0].plotStart.plus(initialPlots[0].pods)); - // const season = loadSeason(BEANSTALK, BigInt.fromU32(1)); - // season.harvestableIndex = initialPlots[0].plotStart.plus(initialPlots[0].pods); - // season.save(); const transferredIndex = initialPlots[0].plotStart; const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, transferredIndex, transferredAmount)); + transferPlot(account, account2, transferredIndex, transferredAmount); assertFarmerHasPlot( - ANVIL_ADDR_1, + account, transferredIndex.plus(transferredAmount), initialPlots[0].pods.minus(transferredAmount), initialPlots[0].pods.minus(transferredAmount) ); - assertFarmerHasPlot(ANVIL_ADDR_2, transferredIndex, transferredAmount, transferredAmount); - assertFieldHas(ANVIL_ADDR_1, initialPlots[1].pods, initialPlots[0].pods.minus(transferredAmount)); - assertFieldHas(ANVIL_ADDR_2, ZERO_BI, transferredAmount); + assertFarmerHasPlot(account2, transferredIndex, transferredAmount, transferredAmount); + assertFieldHas(account, initialPlots[1].pods, initialPlots[0].pods.minus(transferredAmount)); + assertFieldHas(account2, ZERO_BI, transferredAmount); assertFieldHas(BEANSTALK.toHexString(), initialPlots[1].pods, initialPlots[0].pods); }); @@ -194,22 +171,58 @@ describe("Field: Plot Transfer", () => { // 1/4 of first plot is harvestable const harvestableAmount = initialPlots[0].pods.div(BigInt.fromI32(4)); setHarvestable(initialPlots[0].plotStart.plus(harvestableAmount)); - // const season = loadSeason(BEANSTALK, BigInt.fromU32(1)); - // season.harvestableIndex = initialPlots[0].plotStart.plus(harvestableAmount); - // season.save(); // Transfers first third of plot (only some of which is harvestable) const transferredIndex = initialPlots[0].plotStart; const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, transferredIndex, transferredAmount)); + transferPlot(account, account2, transferredIndex, transferredAmount); const transferredUnharvestable = transferredAmount.minus(harvestableAmount); - assertFarmerHasPlot(ANVIL_ADDR_1, transferredIndex.plus(transferredAmount), initialPlots[0].pods.minus(transferredAmount), ZERO_BI); - assertFarmerHasPlot(ANVIL_ADDR_2, transferredIndex, transferredAmount, harvestableAmount); - assertFieldHas(ANVIL_ADDR_1, initialPlots[0].pods.minus(transferredAmount).plus(initialPlots[1].pods), ZERO_BI); - assertFieldHas(ANVIL_ADDR_2, transferredUnharvestable, harvestableAmount); + assertFarmerHasPlot(account, transferredIndex.plus(transferredAmount), initialPlots[0].pods.minus(transferredAmount), ZERO_BI); + assertFarmerHasPlot(account2, transferredIndex, transferredAmount, harvestableAmount); + assertFieldHas(account, initialPlots[0].pods.minus(transferredAmount).plus(initialPlots[1].pods), ZERO_BI); + assertFieldHas(account2, transferredUnharvestable, harvestableAmount); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods.minus(harvestableAmount).plus(initialPlots[1].pods), harvestableAmount); }); + + test("S: Plot Source", () => { + const transferredIndex = initialPlots[0].plotStart; + const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); + transferPlot(account, account2, transferredIndex, transferredAmount); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "TRANSFER"); + assert.fieldEquals("Plot", transferredIndex.plus(transferredAmount).toString(), "source", "SOW"); + }); + + test("S: Marketplace Listing", () => { + const listingAmount = initialPlots[0].pods.div(BigInt.fromI32(4)); + const fillBeans = beans(7500); + createListing_v2(account, initialPlots[0].plotStart, listingAmount, ZERO_BI, maxHarvestableIndex); + fillListing_v2(account, account2, initialPlots[0].plotStart, ZERO_BI, listingAmount, fillBeans); + + const initialBeansPerPod = BI_10.pow(6).div(BigInt.fromU32(temperature)).toString(); + const filledBeansPerPod = fillBeans.times(BI_10.pow(6)).div(listingAmount).toString(); + assert.entityCount("Plot", 3); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "beansPerPod", filledBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "MARKET"); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(listingAmount).toString(), "beansPerPod", initialBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(listingAmount).toString(), "source", "SOW"); + }); + + test("S: Marketplace Order", () => { + const fillAmount = initialPlots[0].pods.div(BigInt.fromI32(4)); + const fillBeans = beans(8500); + const orderPricePerPod = BigInt.fromString("1234"); + createOrder_v2(account, orderId, beans(10000), orderPricePerPod, maxHarvestableIndex); + fillOrder_v2(account2, account, orderId, initialPlots[0].plotStart, ZERO_BI, fillAmount, fillBeans); + + const initialBeansPerPod = BI_10.pow(6).div(BigInt.fromU32(temperature)).toString(); + const filledBeansPerPod = fillBeans.times(BI_10.pow(6)).div(fillAmount).toString(); + assert.entityCount("Plot", 3); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "beansPerPod", filledBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "MARKET"); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(fillAmount).toString(), "beansPerPod", initialBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(fillAmount).toString(), "source", "SOW"); + }); }); // Transfers the final third of the plot @@ -217,35 +230,32 @@ describe("Field: Plot Transfer", () => { test("E: Unharvestable", () => { const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); const transferredIndex = initialPlots[0].plotEnd.minus(transferredAmount); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, transferredIndex, transferredAmount)); + transferPlot(account, account2, transferredIndex, transferredAmount); - assertFarmerHasPlot(ANVIL_ADDR_1, initialPlots[0].plotStart, initialPlots[0].pods.minus(transferredAmount)); - assertFarmerHasPlot(ANVIL_ADDR_2, transferredIndex, transferredAmount); - assertFieldHas(ANVIL_ADDR_1, initialPlots[0].pods.minus(transferredAmount).plus(initialPlots[1].pods), ZERO_BI); - assertFieldHas(ANVIL_ADDR_2, transferredAmount, ZERO_BI); + assertFarmerHasPlot(account, initialPlots[0].plotStart, initialPlots[0].pods.minus(transferredAmount)); + assertFarmerHasPlot(account2, transferredIndex, transferredAmount); + assertFieldHas(account, initialPlots[0].pods.minus(transferredAmount).plus(initialPlots[1].pods), ZERO_BI); + assertFieldHas(account2, transferredAmount, ZERO_BI); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods.plus(initialPlots[1].pods), ZERO_BI); }); test("E: Harvestable (Full)", () => { // Entire first plot is harvestable setHarvestable(initialPlots[0].plotStart.plus(initialPlots[0].pods)); - // const season = loadSeason(BEANSTALK, BigInt.fromU32(1)); - // season.harvestableIndex = initialPlots[0].plotStart.plus(initialPlots[0].pods); - // season.save(); const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); const transferredIndex = initialPlots[0].plotEnd.minus(transferredAmount); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, transferredIndex, transferredAmount)); + transferPlot(account, account2, transferredIndex, transferredAmount); assertFarmerHasPlot( - ANVIL_ADDR_1, + account, initialPlots[0].plotStart, initialPlots[0].pods.minus(transferredAmount), initialPlots[0].pods.minus(transferredAmount) ); - assertFarmerHasPlot(ANVIL_ADDR_2, transferredIndex, transferredAmount, transferredAmount); - assertFieldHas(ANVIL_ADDR_1, initialPlots[1].pods, initialPlots[0].pods.minus(transferredAmount)); - assertFieldHas(ANVIL_ADDR_2, ZERO_BI, transferredAmount); + assertFarmerHasPlot(account2, transferredIndex, transferredAmount, transferredAmount); + assertFieldHas(account, initialPlots[1].pods, initialPlots[0].pods.minus(transferredAmount)); + assertFieldHas(account2, ZERO_BI, transferredAmount); assertFieldHas(BEANSTALK.toHexString(), initialPlots[1].pods, initialPlots[0].pods); }); @@ -253,26 +263,64 @@ describe("Field: Plot Transfer", () => { // 3/4 of first plot is harvestable const harvestableAmount = initialPlots[0].pods.times(BigInt.fromI32(3)).div(BigInt.fromI32(4)); const harvestableIndex = setHarvestable(initialPlots[0].plotStart.plus(harvestableAmount)); - // const season = loadSeason(BEANSTALK, BigInt.fromU32(1)); - // season.harvestableIndex = initialPlots[0].plotStart.plus(harvestableAmount); - // season.save(); const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); const transferredIndex = initialPlots[0].plotEnd.minus(transferredAmount); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, transferredIndex, transferredAmount)); + transferPlot(account, account2, transferredIndex, transferredAmount); const transferredHarvestable = harvestableIndex.minus(transferredIndex); assertFarmerHasPlot( - ANVIL_ADDR_1, + account, initialPlots[0].plotStart, initialPlots[0].pods.minus(transferredAmount), harvestableAmount.minus(transferredHarvestable) ); - assertFarmerHasPlot(ANVIL_ADDR_2, transferredIndex, transferredAmount, transferredHarvestable); - assertFieldHas(ANVIL_ADDR_1, initialPlots[1].pods, harvestableAmount.minus(transferredHarvestable)); - assertFieldHas(ANVIL_ADDR_2, initialPlots[0].pods.minus(harvestableAmount), transferredHarvestable); + assertFarmerHasPlot(account2, transferredIndex, transferredAmount, transferredHarvestable); + assertFieldHas(account, initialPlots[1].pods, harvestableAmount.minus(transferredHarvestable)); + assertFieldHas(account2, initialPlots[0].pods.minus(harvestableAmount), transferredHarvestable); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods.minus(harvestableAmount).plus(initialPlots[1].pods), harvestableAmount); }); + + test("E: Plot Source", () => { + const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); + const transferredIndex = initialPlots[0].plotEnd.minus(transferredAmount); + transferPlot(account, account2, transferredIndex, transferredAmount); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "SOW"); + assert.fieldEquals("Plot", transferredIndex.toString(), "source", "TRANSFER"); + }); + + test("E: Marketplace Listing", () => { + const listingStart = initialPlots[0].pods.div(BigInt.fromI32(3)); + const listingAmount = initialPlots[0].pods.minus(listingStart); + const fillBeans = beans(5500); + createListing_v2(account, initialPlots[0].plotStart, listingAmount, listingStart, maxHarvestableIndex); + fillListing_v2(account, account2, initialPlots[0].plotStart, listingStart, listingAmount, fillBeans); + + const initialBeansPerPod = BI_10.pow(6).div(BigInt.fromU32(temperature)).toString(); + const filledBeansPerPod = fillBeans.times(BI_10.pow(6)).div(listingAmount).toString(); + assert.entityCount("Plot", 3); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "beansPerPod", initialBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "SOW"); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(listingStart).toString(), "beansPerPod", filledBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(listingStart).toString(), "source", "MARKET"); + }); + + test("E: Marketplace Order", () => { + const fillStart = initialPlots[0].pods.div(BigInt.fromI32(3)); + const fillAmount = initialPlots[0].pods.minus(fillStart); + const fillBeans = beans(5500); + const orderPricePerPod = BigInt.fromString("1234"); + createOrder_v2(account, orderId, beans(10000), orderPricePerPod, maxHarvestableIndex); + fillOrder_v2(account2, account, orderId, initialPlots[0].plotStart, fillStart, fillAmount, fillBeans); + + const initialBeansPerPod = BI_10.pow(6).div(BigInt.fromU32(temperature)).toString(); + const filledBeansPerPod = fillBeans.times(BI_10.pow(6)).div(fillAmount).toString(); + assert.entityCount("Plot", 3); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "beansPerPod", initialBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "SOW"); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(fillStart).toString(), "beansPerPod", filledBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(fillStart).toString(), "source", "MARKET"); + }); }); // Transfers the middle third of the plot @@ -280,32 +328,29 @@ describe("Field: Plot Transfer", () => { test("M: Unharvestable", () => { const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); const transferredIndex = initialPlots[0].plotStart.plus(transferredAmount); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, transferredIndex, transferredAmount)); + transferPlot(account, account2, transferredIndex, transferredAmount); - assertFarmerHasPlot(ANVIL_ADDR_1, initialPlots[0].plotStart, transferredAmount); - assertFarmerHasPlot(ANVIL_ADDR_1, initialPlots[0].plotEnd.minus(transferredAmount), transferredAmount); - assertFarmerHasPlot(ANVIL_ADDR_2, transferredIndex, transferredAmount); - assertFieldHas(ANVIL_ADDR_1, initialPlots[0].pods.minus(transferredAmount).plus(initialPlots[1].pods), ZERO_BI); - assertFieldHas(ANVIL_ADDR_2, transferredAmount, ZERO_BI); + assertFarmerHasPlot(account, initialPlots[0].plotStart, transferredAmount); + assertFarmerHasPlot(account, initialPlots[0].plotEnd.minus(transferredAmount), transferredAmount); + assertFarmerHasPlot(account2, transferredIndex, transferredAmount); + assertFieldHas(account, initialPlots[0].pods.minus(transferredAmount).plus(initialPlots[1].pods), ZERO_BI); + assertFieldHas(account2, transferredAmount, ZERO_BI); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods.plus(initialPlots[1].pods), ZERO_BI); }); test("M: Harvestable (Full)", () => { // Entire first plot is harvestable setHarvestable(initialPlots[0].plotStart.plus(initialPlots[0].pods)); - // const season = loadSeason(BEANSTALK, BigInt.fromU32(1)); - // season.harvestableIndex = initialPlots[0].plotStart.plus(initialPlots[0].pods); - // season.save(); const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); const transferredIndex = initialPlots[0].plotStart.plus(transferredAmount); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, transferredIndex, transferredAmount)); + transferPlot(account, account2, transferredIndex, transferredAmount); - assertFarmerHasPlot(ANVIL_ADDR_1, initialPlots[0].plotStart, transferredAmount, transferredAmount); - assertFarmerHasPlot(ANVIL_ADDR_1, initialPlots[0].plotEnd.minus(transferredAmount), transferredAmount, transferredAmount); - assertFarmerHasPlot(ANVIL_ADDR_2, transferredIndex, transferredAmount, transferredAmount); - assertFieldHas(ANVIL_ADDR_1, initialPlots[1].pods, initialPlots[0].pods.minus(transferredAmount)); - assertFieldHas(ANVIL_ADDR_2, ZERO_BI, transferredAmount); + assertFarmerHasPlot(account, initialPlots[0].plotStart, transferredAmount, transferredAmount); + assertFarmerHasPlot(account, initialPlots[0].plotEnd.minus(transferredAmount), transferredAmount, transferredAmount); + assertFarmerHasPlot(account2, transferredIndex, transferredAmount, transferredAmount); + assertFieldHas(account, initialPlots[1].pods, initialPlots[0].pods.minus(transferredAmount)); + assertFieldHas(account2, ZERO_BI, transferredAmount); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods, initialPlots[1].pods); }); @@ -313,37 +358,73 @@ describe("Field: Plot Transfer", () => { // 1/2 of first plot is harvestable const harvestableAmount = initialPlots[0].pods.div(BigInt.fromI32(2)); setHarvestable(initialPlots[0].plotStart.plus(harvestableAmount)); - // const season = loadSeason(BEANSTALK, BigInt.fromU32(1)); - // season.harvestableIndex = initialPlots[0].plotStart.plus(harvestableAmount); - // season.save(); const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); const transferredIndex = initialPlots[0].plotStart.plus(transferredAmount); - handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, transferredIndex, transferredAmount)); + transferPlot(account, account2, transferredIndex, transferredAmount); const transferredHarvestable = harvestableAmount.minus(transferredAmount); - assertFarmerHasPlot(ANVIL_ADDR_1, initialPlots[0].plotStart, transferredAmount, harvestableAmount.minus(transferredHarvestable)); - assertFarmerHasPlot(ANVIL_ADDR_1, initialPlots[0].plotEnd.minus(transferredAmount), transferredAmount, ZERO_BI); - assertFarmerHasPlot(ANVIL_ADDR_2, transferredIndex, transferredAmount, transferredHarvestable); + assertFarmerHasPlot(account, initialPlots[0].plotStart, transferredAmount, harvestableAmount.minus(transferredHarvestable)); + assertFarmerHasPlot(account, initialPlots[0].plotEnd.minus(transferredAmount), transferredAmount, ZERO_BI); + assertFarmerHasPlot(account2, transferredIndex, transferredAmount, transferredHarvestable); assertFieldHas( - ANVIL_ADDR_1, + account, initialPlots[0].pods.minus(harvestableAmount).minus(transferredHarvestable).plus(initialPlots[1].pods), harvestableAmount.minus(transferredHarvestable) ); - assertFieldHas(ANVIL_ADDR_2, transferredHarvestable, transferredHarvestable); + assertFieldHas(account2, transferredHarvestable, transferredHarvestable); assertFieldHas(BEANSTALK.toHexString(), initialPlots[0].pods.plus(initialPlots[1].pods).minus(harvestableAmount), harvestableAmount); }); - }); - // Unclear whether tests like this are actually necessary - // describe("Invalid Transfers", () => { - // test("Too Many", () => { - // // Try to send 1/10^6 more pods. - // handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_1, ANVIL_ADDR_2, initialPlots[0].plotStart, initialPlots[0].pods.plus(BigInt.fromI32(1)))); - // }); - // test("Unowned Plot", () => { - // // Try to send someone else's plot - // handlePlotTransfer(createPlotTransferEvent(ANVIL_ADDR_2, ANVIL_ADDR_1, initialPlots[0].plotStart, initialPlots[0].pods)); - // }); - // }); + test("M: Plot Source", () => { + const transferredAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); + const transferredIndex = initialPlots[0].plotStart.plus(transferredAmount); + transferPlot(account, account2, transferredIndex, transferredAmount); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "SOW"); + assert.fieldEquals("Plot", transferredIndex.toString(), "source", "TRANSFER"); + assert.fieldEquals("Plot", transferredIndex.plus(transferredAmount).toString(), "source", "SOW"); + }); + + test("M: Marketplace Listing", () => { + const listingStart = initialPlots[0].pods.div(BigInt.fromI32(3)); + const listingAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); + const fillBeans = beans(5500); + createListing_v2(account, initialPlots[0].plotStart, listingAmount, listingStart, maxHarvestableIndex); + fillListing_v2(account, account2, initialPlots[0].plotStart, listingStart, listingAmount, fillBeans); + + const initialBeansPerPod = BI_10.pow(6).div(BigInt.fromU32(temperature)).toString(); + const filledBeansPerPod = fillBeans.times(BI_10.pow(6)).div(listingAmount).toString(); + assert.entityCount("Plot", 4); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "beansPerPod", initialBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "SOW"); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(listingStart).toString(), "beansPerPod", filledBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(listingStart).toString(), "source", "MARKET"); + assert.fieldEquals( + "Plot", + initialPlots[0].plotStart.plus(listingStart).plus(listingAmount).toString(), + "beansPerPod", + initialBeansPerPod + ); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(listingStart).plus(listingAmount).toString(), "source", "SOW"); + }); + + test("M: Marketplace Order", () => { + const fillStart = initialPlots[0].pods.div(BigInt.fromI32(3)); + const fillAmount = initialPlots[0].pods.div(BigInt.fromI32(3)); + const fillBeans = beans(5500); + const orderPricePerPod = BigInt.fromString("1234"); + createOrder_v2(account, orderId, beans(10000), orderPricePerPod, maxHarvestableIndex); + fillOrder_v2(account2, account, orderId, initialPlots[0].plotStart, fillStart, fillAmount, fillBeans); + + const initialBeansPerPod = BI_10.pow(6).div(BigInt.fromU32(temperature)).toString(); + const filledBeansPerPod = fillBeans.times(BI_10.pow(6)).div(fillAmount).toString(); + assert.entityCount("Plot", 4); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "beansPerPod", initialBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.toString(), "source", "SOW"); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(fillStart).toString(), "beansPerPod", filledBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(fillStart).toString(), "source", "MARKET"); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(fillStart).plus(fillAmount).toString(), "beansPerPod", initialBeansPerPod); + assert.fieldEquals("Plot", initialPlots[0].plotStart.plus(fillStart).plus(fillAmount).toString(), "source", "SOW"); + }); + }); }); diff --git a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts index 57e3924fe3..efca899cf0 100644 --- a/projects/subgraph-beanstalk/tests/SeedGauge.test.ts +++ b/projects/subgraph-beanstalk/tests/SeedGauge.test.ts @@ -32,7 +32,7 @@ import { simpleMockPrice } from "../../subgraph-core/tests/event-mocking/Prices" import { loadSilo } from "../src/utils/SiloEntities"; import { mockBlock } from "../../subgraph-core/tests/event-mocking/Block"; import { dayFromTimestamp } from "../src/utils/Dates"; -import { setSeason } from "./event-mocking/Season"; +import { setSeason } from "./utils/Season"; const ANVIL_ADDR_1 = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); diff --git a/projects/subgraph-beanstalk/tests/YieldHandler.test.ts b/projects/subgraph-beanstalk/tests/YieldHandler.test.ts index e02e31b89b..35187d83ff 100644 --- a/projects/subgraph-beanstalk/tests/YieldHandler.test.ts +++ b/projects/subgraph-beanstalk/tests/YieldHandler.test.ts @@ -12,7 +12,7 @@ import { UNRIPE_BEAN_3CRV, LUSD_3POOL } from "../../subgraph-core/utils/Constants"; -import { setSeason } from "./event-mocking/Season"; +import { setSeason } from "./utils/Season"; describe("APY Calculations", () => { describe("Pre-Gauge", () => { diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Field.ts b/projects/subgraph-beanstalk/tests/event-mocking/Field.ts index eb1c7ea23b..41091d27fd 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Field.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Field.ts @@ -1,16 +1,7 @@ import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; -import { newMockEvent } from "matchstick-as/assembly/index"; -import { Sow, PlotTransfer } from "../../generated/Field/Beanstalk"; +import { Sow, PlotTransfer, Harvest } from "../../generated/Field/Beanstalk"; import { TemperatureChange } from "../../generated/BIP45-SeedGauge/Beanstalk"; - -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; - -// Default mock to include beanstalk address -const mockBeanstalkEvent = (): ethereum.Event => { - let e = changetype(newMockEvent()); - e.address = BEANSTALK; - return e; -}; +import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; export function createWeatherChangeEvent(season: BigInt, caseID: BigInt, change: i32): void {} @@ -46,7 +37,26 @@ export function createSowEvent(account: string, index: BigInt, beans: BigInt, po return event as Sow; } -export function createHarvestEvent(account: string, plots: BigInt[], beans: BigInt): void {} +export function createHarvestEvent(account: string, plots: BigInt[], beans: BigInt): Harvest { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let plotsArray: ethereum.Value[] = []; + for (let i = 0; i < plots.length; ++i) { + plotsArray.push(ethereum.Value.fromUnsignedBigInt(plots[i])); + } + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); + let param2 = new ethereum.EventParam("plots", ethereum.Value.fromArray(plotsArray)); + let param3 = new ethereum.EventParam("beans", ethereum.Value.fromUnsignedBigInt(beans)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + + return event as Harvest; +} + export function createPlotTransferEvent(from: string, to: string, id: BigInt, pods: BigInt): PlotTransfer { let event = changetype(mockBeanstalkEvent()); event.parameters = new Array(); diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Marketplace.ts b/projects/subgraph-beanstalk/tests/event-mocking/Marketplace.ts index 4c4783db51..030e7c42e6 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Marketplace.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Marketplace.ts @@ -1,5 +1,4 @@ import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; -import { newMockEvent } from "matchstick-as/assembly/index"; import { PodListingCancelled, @@ -16,8 +15,9 @@ import { PodOrderCreated as PodOrderCreated_v2, PodOrderFilled as PodOrderFilled_v2 } from "../../generated/BIP29-PodMarketplace/Beanstalk"; +import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; -/* V1 Marketplace events */ +/** ===== Marketplace V1 Events ===== */ export function createPodListingCreatedEvent( account: string, index: BigInt, @@ -25,13 +25,101 @@ export function createPodListingCreatedEvent( amount: BigInt, pricePerPod: BigInt, maxHarvestableIndex: BigInt, - toWallet: Boolean -): void {} -export function createPodListingCancelledEvent(account: string, index: BigInt): void {} -export function createPodListingFilledEvent(from: string, to: string, index: BigInt, start: BigInt, amount: BigInt): void {} -export function createPodOrderCreatedEvent(account: string, id: Bytes, amount: BigInt, pricePerPod: BigInt, maxPlaceInLine: BigInt): void {} -export function createPodOrderFilledEvent(from: string, to: string, id: Bytes, index: BigInt, start: BigInt, amount: BigInt): void {} -export function createPodOrderCancelledEvent(account: string, id: Bytes): void {} + toWallet: boolean +): PodListingCreated_v1 { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); + let param2 = new ethereum.EventParam("index", ethereum.Value.fromUnsignedBigInt(index)); + let param3 = new ethereum.EventParam("start", ethereum.Value.fromUnsignedBigInt(start)); + let param4 = new ethereum.EventParam("amount", ethereum.Value.fromUnsignedBigInt(amount)); + let param5 = new ethereum.EventParam("pricePerPod", ethereum.Value.fromUnsignedBigInt(pricePerPod)); + let param6 = new ethereum.EventParam("maxHarvestableIndex", ethereum.Value.fromUnsignedBigInt(maxHarvestableIndex)); + let param7 = new ethereum.EventParam("toWallet", ethereum.Value.fromBoolean(toWallet)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + event.parameters.push(param6); + event.parameters.push(param7); + + return event as PodListingCreated_v1; +} + +export function createPodListingFilledEvent(from: string, to: string, index: BigInt, start: BigInt, amount: BigInt): PodListingFilled_v1 { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("from", ethereum.Value.fromAddress(Address.fromString(from))); + let param2 = new ethereum.EventParam("to", ethereum.Value.fromAddress(Address.fromString(to))); + let param3 = new ethereum.EventParam("index", ethereum.Value.fromUnsignedBigInt(index)); + let param4 = new ethereum.EventParam("start", ethereum.Value.fromUnsignedBigInt(start)); + let param5 = new ethereum.EventParam("amount", ethereum.Value.fromUnsignedBigInt(amount)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + + return event as PodListingFilled_v1; +} + +export function createPodOrderCreatedEvent( + account: string, + id: Bytes, + podsOrdered: BigInt, + pricePerPod: BigInt, + maxPlaceInLine: BigInt +): PodOrderCreated_v1 { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); + let param2 = new ethereum.EventParam("id", ethereum.Value.fromBytes(id)); + let param3 = new ethereum.EventParam("amount", ethereum.Value.fromUnsignedBigInt(podsOrdered)); + let param4 = new ethereum.EventParam("pricePerPod", ethereum.Value.fromUnsignedBigInt(pricePerPod)); + let param5 = new ethereum.EventParam("maxPlaceInLine", ethereum.Value.fromUnsignedBigInt(maxPlaceInLine)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + + return event as PodOrderCreated_v1; +} + +export function createPodOrderFilledEvent( + from: string, + to: string, + id: Bytes, + index: BigInt, + start: BigInt, + amount: BigInt +): PodOrderFilled_v1 { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("from", ethereum.Value.fromAddress(Address.fromString(from))); + let param2 = new ethereum.EventParam("to", ethereum.Value.fromAddress(Address.fromString(to))); + let param3 = new ethereum.EventParam("id", ethereum.Value.fromBytes(id)); + let param4 = new ethereum.EventParam("index", ethereum.Value.fromUnsignedBigInt(index)); + let param5 = new ethereum.EventParam("start", ethereum.Value.fromUnsignedBigInt(start)); + let param6 = new ethereum.EventParam("amount", ethereum.Value.fromUnsignedBigInt(amount)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + event.parameters.push(param6); + + return event as PodOrderFilled_v1; +} /* V1_1 Marketplace events (on replant) */ export function createPodListingCreatedEvent_v1_1( @@ -42,7 +130,28 @@ export function createPodListingCreatedEvent_v1_1( pricePerPod: BigInt, maxHarvestableIndex: BigInt, mode: BigInt -): void {} +): PodListingCreated_v1_1 { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); + let param2 = new ethereum.EventParam("index", ethereum.Value.fromUnsignedBigInt(index)); + let param3 = new ethereum.EventParam("start", ethereum.Value.fromUnsignedBigInt(start)); + let param4 = new ethereum.EventParam("amount", ethereum.Value.fromUnsignedBigInt(amount)); + let param5 = new ethereum.EventParam("pricePerPod", ethereum.Value.fromUnsignedBigInt(pricePerPod)); + let param6 = new ethereum.EventParam("maxHarvestableIndex", ethereum.Value.fromUnsignedBigInt(maxHarvestableIndex)); + let param7 = new ethereum.EventParam("mode", ethereum.Value.fromUnsignedBigInt(mode)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + event.parameters.push(param6); + event.parameters.push(param7); + + return event as PodListingCreated_v1_1; +} /** ===== Marketplace V2 Events ===== */ export function createPodListingCreatedEvent_v2( @@ -57,7 +166,7 @@ export function createPodListingCreatedEvent_v2( mode: BigInt, pricingType: BigInt ): PodListingCreated_v2 { - let event = changetype(newMockEvent()); + let event = changetype(mockBeanstalkEvent()); event.parameters = new Array(); let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); @@ -92,17 +201,61 @@ export function createPodListingFilledEvent_v2( start: BigInt, amount: BigInt, costInBeans: BigInt -): void {} +): PodListingFilled_v2 { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("from", ethereum.Value.fromAddress(Address.fromString(from))); + let param2 = new ethereum.EventParam("to", ethereum.Value.fromAddress(Address.fromString(to))); + let param3 = new ethereum.EventParam("index", ethereum.Value.fromUnsignedBigInt(index)); + let param4 = new ethereum.EventParam("start", ethereum.Value.fromUnsignedBigInt(start)); + let param5 = new ethereum.EventParam("amount", ethereum.Value.fromUnsignedBigInt(amount)); + let param6 = new ethereum.EventParam("costInBeans", ethereum.Value.fromUnsignedBigInt(costInBeans)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + event.parameters.push(param6); + + return event as PodListingFilled_v2; +} + export function createPodOrderCreatedEvent_v2( account: string, id: Bytes, - amount: BigInt, + beanAmount: BigInt, pricePerPod: BigInt, maxPlaceInLine: BigInt, minFillAmount: BigInt, pricingFunction: Bytes, pricingType: BigInt -): void {} +): PodOrderCreated_v2 { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); + let param2 = new ethereum.EventParam("id", ethereum.Value.fromBytes(id)); + let param3 = new ethereum.EventParam("amount", ethereum.Value.fromUnsignedBigInt(beanAmount)); + let param4 = new ethereum.EventParam("pricePerPod", ethereum.Value.fromUnsignedBigInt(pricePerPod)); + let param5 = new ethereum.EventParam("maxPlaceInLine", ethereum.Value.fromUnsignedBigInt(maxPlaceInLine)); + let param6 = new ethereum.EventParam("minFillAmount", ethereum.Value.fromUnsignedBigInt(minFillAmount)); + let param7 = new ethereum.EventParam("pricingFunction", ethereum.Value.fromBytes(pricingFunction)); + let param8 = new ethereum.EventParam("pricingType", ethereum.Value.fromUnsignedBigInt(pricingType)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + event.parameters.push(param6); + event.parameters.push(param7); + event.parameters.push(param8); + + return event as PodOrderCreated_v2; +} + export function createPodOrderFilledEvent_v2( from: string, to: string, @@ -111,4 +264,52 @@ export function createPodOrderFilledEvent_v2( start: BigInt, amount: BigInt, costInBeans: BigInt -): void {} +): PodOrderFilled_v2 { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("from", ethereum.Value.fromAddress(Address.fromString(from))); + let param2 = new ethereum.EventParam("to", ethereum.Value.fromAddress(Address.fromString(to))); + let param3 = new ethereum.EventParam("id", ethereum.Value.fromBytes(id)); + let param4 = new ethereum.EventParam("index", ethereum.Value.fromUnsignedBigInt(index)); + let param5 = new ethereum.EventParam("start", ethereum.Value.fromUnsignedBigInt(start)); + let param6 = new ethereum.EventParam("amount", ethereum.Value.fromUnsignedBigInt(amount)); + let param7 = new ethereum.EventParam("costInBeans", ethereum.Value.fromUnsignedBigInt(costInBeans)); + + event.parameters.push(param1); + event.parameters.push(param2); + event.parameters.push(param3); + event.parameters.push(param4); + event.parameters.push(param5); + event.parameters.push(param6); + event.parameters.push(param7); + + return event as PodOrderFilled_v2; +} + +/* Cancellation events */ +export function createPodOrderCancelledEvent(account: string, id: Bytes): PodOrderCancelled { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); + let param2 = new ethereum.EventParam("id", ethereum.Value.fromBytes(id)); + + event.parameters.push(param1); + event.parameters.push(param2); + + return event as PodOrderCancelled; +} + +export function createPodListingCancelledEvent(account: string, index: BigInt): PodListingCancelled { + let event = changetype(mockBeanstalkEvent()); + event.parameters = new Array(); + + let param1 = new ethereum.EventParam("account", ethereum.Value.fromAddress(Address.fromString(account))); + let param2 = new ethereum.EventParam("index", ethereum.Value.fromUnsignedBigInt(index)); + + event.parameters.push(param1); + event.parameters.push(param2); + + return event as PodListingCancelled; +} diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Season.ts b/projects/subgraph-beanstalk/tests/event-mocking/Season.ts index 4c409ec282..0b197f8f32 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Season.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Season.ts @@ -1,22 +1,7 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; -import { newMockEvent } from "matchstick-as/assembly/index"; import { Incentivization } from "../../generated/Season-Replanted/Beanstalk"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; -import { loadBeanstalk } from "../../src/utils/Beanstalk"; - -// Default mock to include beanstalk address -const mockBeanstalkEvent = (): ethereum.Event => { - let e = changetype(newMockEvent()); - e.address = BEANSTALK; - return e; -}; - -export function setSeason(season: u32): void { - let beanstalk = loadBeanstalk(BEANSTALK); - beanstalk.lastSeason = season; - beanstalk.save(); -} +import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; export function createSunriseEvent(season: BigInt): void {} export function createSeasonSnapshotEvent( diff --git a/projects/subgraph-beanstalk/tests/event-mocking/SeedGauge.ts b/projects/subgraph-beanstalk/tests/event-mocking/SeedGauge.ts index a73d3c458f..6458a22c71 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/SeedGauge.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/SeedGauge.ts @@ -1,5 +1,4 @@ import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; -import { newMockEvent } from "matchstick-as/assembly/index"; import { BeanToMaxLpGpPerBdvRatioChange, GaugePointChange, @@ -10,15 +9,7 @@ import { TotalGerminatingStalkChanged, TotalStalkChangedFromGermination } from "../../generated/BIP45-SeedGauge/Beanstalk"; - -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; - -// Default mock to include beanstalk address -const mockBeanstalkEvent = (): ethereum.Event => { - let e = changetype(newMockEvent()); - e.address = BEANSTALK; - return e; -}; +import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; export function createBeanToMaxLpGpPerBdvRatioChangeEvent( season: BigInt, diff --git a/projects/subgraph-beanstalk/tests/event-mocking/Whitelist.ts b/projects/subgraph-beanstalk/tests/event-mocking/Whitelist.ts index 668e92f7ed..37d30a5ee6 100644 --- a/projects/subgraph-beanstalk/tests/event-mocking/Whitelist.ts +++ b/projects/subgraph-beanstalk/tests/event-mocking/Whitelist.ts @@ -1,17 +1,10 @@ import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; -import { newMockEvent } from "matchstick-as/assembly/index"; -import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; import { WhitelistToken as WhitelistToken_V2, DewhitelistToken } from "../../generated/Silo-Replanted/Beanstalk"; import { WhitelistToken as WhitelistToken_V3 } from "../../generated/Silo-V3/Beanstalk"; import { WhitelistToken as WhitelistToken_V4 } from "../../generated/BIP45-SeedGauge/Beanstalk"; +import { mockBeanstalkEvent } from "../../../subgraph-core/tests/event-mocking/Util"; -// Default mock to include beanstalk address -const mockBeanstalkEvent = (): ethereum.Event => { - let e = changetype(newMockEvent()); - e.address = BEANSTALK; - return e; -}; export function createWhitelistTokenV2Event(token: string, selector: string, seeds: BigInt, stalk: BigInt): WhitelistToken_V2 { let event = changetype(mockBeanstalkEvent()); diff --git a/projects/subgraph-beanstalk/tests/utils/Field.ts b/projects/subgraph-beanstalk/tests/utils/Field.ts new file mode 100644 index 0000000000..31103182ec --- /dev/null +++ b/projects/subgraph-beanstalk/tests/utils/Field.ts @@ -0,0 +1,58 @@ +import { BigInt, ethereum, log } from "@graphprotocol/graph-ts"; +import { assert, createMockedFunction } from "matchstick-as/assembly/index"; +import { createHarvestEvent, createPlotTransferEvent, createSowEvent } from "../event-mocking/Field"; +import { handleHarvest, handlePlotTransfer, handleSow } from "../../src/FieldHandler"; +import { createIncentivizationEvent } from "../event-mocking/Season"; +import { handleIncentive } from "../../src/SeasonHandler"; +import { ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; + +const account = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".toLowerCase(); + +export function sow(account: string, index: BigInt, beans: BigInt, pods: BigInt): void { + handleSow(createSowEvent(account, index, beans, pods)); +} + +export function harvest(account: string, plotIndexex: BigInt[], beans: BigInt): void { + handleHarvest(createHarvestEvent(account, plotIndexex, beans)); +} + +export function transferPlot(from: string, to: string, id: BigInt, amount: BigInt): void { + handlePlotTransfer(createPlotTransferEvent(from, to, id, amount)); +} + +export function setHarvestable(harvestableIndex: BigInt): BigInt { + createMockedFunction(BEANSTALK, "harvestableIndex", "harvestableIndex():(uint256)").returns([ + ethereum.Value.fromUnsignedBigInt(harvestableIndex) + ]); + + // Incentivization event triggers update of harvestable amount of each plot + handleIncentive(createIncentivizationEvent(account, BigInt.fromI32(123456))); + + return harvestableIndex; +} + +export function assertFarmerHasPlot( + farmer: string, + index: BigInt, + numPods: BigInt, + numHarvestable: BigInt = ZERO_BI, + debug: boolean = false +): void { + if (debug) { + log.debug("about to assert plot {}", [farmer]); + } + assert.fieldEquals("Plot", index.toString(), "farmer", farmer); + assert.fieldEquals("Plot", index.toString(), "pods", numPods.toString()); + // log.debug("about to assert harvestable {}", [numHarvestable.toString()]); + assert.fieldEquals("Plot", index.toString(), "harvestablePods", numHarvestable.toString()); +} + +// Field can be either a farmer or beanstalk address +export function assertFieldHas(field: string, unharvestable: BigInt, harvestable: BigInt, debug: boolean = false): void { + if (debug) { + log.debug("about to assert field {}", [field]); + } + assert.fieldEquals("Field", field, "unharvestablePods", unharvestable.toString()); + assert.fieldEquals("Field", field, "harvestablePods", harvestable.toString()); +} diff --git a/projects/subgraph-beanstalk/tests/utils/Marketplace.ts b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts new file mode 100644 index 0000000000..d6bfb69abe --- /dev/null +++ b/projects/subgraph-beanstalk/tests/utils/Marketplace.ts @@ -0,0 +1,369 @@ +import { BigInt, Bytes, ethereum, log } from "@graphprotocol/graph-ts"; +import { assert } from "matchstick-as/assembly/index"; +import { + handlePodListingCancelled, + handlePodListingCreated, + handlePodListingCreated_v1_1, + handlePodListingCreated_v2, + handlePodListingFilled, + handlePodListingFilled_v2, + handlePodOrderCancelled, + handlePodOrderCreated, + handlePodOrderCreated_v2, + handlePodOrderFilled, + handlePodOrderFilled_v2 +} from "../../src/MarketplaceHandler"; +import { + createPodListingCancelledEvent, + createPodListingCreatedEvent, + createPodListingCreatedEvent_v1_1, + createPodListingCreatedEvent_v2, + createPodListingFilledEvent, + createPodListingFilledEvent_v2, + createPodOrderCancelledEvent, + createPodOrderCreatedEvent, + createPodOrderCreatedEvent_v2, + createPodOrderFilledEvent, + createPodOrderFilledEvent_v2 +} from "../event-mocking/Marketplace"; +import { BI_10, ONE_BI, ZERO_BI } from "../../../subgraph-core/utils/Decimals"; +import { + PodListingCreated as PodListingCreated_v2, + PodListingFilled as PodListingFilled_v2, + PodOrderCreated as PodOrderCreated_v2, + PodOrderFilled as PodOrderFilled_v2 +} from "../../generated/BIP29-PodMarketplace/Beanstalk"; +import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { transferPlot } from "./Field"; +import { + PodOrderCancelled, + PodListingCancelled, + PodListingCreated as PodListingCreated_v1, + PodListingFilled as PodListingFilled_v1, + PodOrderCreated as PodOrderCreated_v1, + PodOrderFilled as PodOrderFilled_v1 +} from "../../generated/Field/Beanstalk"; +import { PodListingCreated as PodListingCreated_v1_1 } from "../../generated/Marketplace-Replanted/Beanstalk"; + +const pricingFunction = Bytes.fromHexString( + "0x0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000c8000000000000000000000000000000000000000000000000000000000000012c000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010101010101010101010101010000" +); + +export function getPodFillId(index: BigInt, event: ethereum.Event): string { + return BEANSTALK.toHexString() + "-" + index.toString() + "-" + event.transaction.hash.toHexString(); +} + +export function fillListing_v1( + from: string, + to: string, + listingIndex: BigInt, + listingStart: BigInt, + podAmount: BigInt, + pricePerPod: BigInt +): PodListingFilled_v1 { + // Perform plot transfer + transferPlot(from, to, listingIndex.plus(listingStart), podAmount); + + const event = createPodListingFilledEvent(from, to, listingIndex, listingStart, podAmount); + handlePodListingFilled(event); + + // Assert PodFill + const podFillId = getPodFillId(event.params.index, event); + assert.fieldEquals("PodFill", podFillId, "listing", event.params.from.toHexString() + "-" + event.params.index.toString()); + assert.fieldEquals("PodFill", podFillId, "from", event.params.from.toHexString()); + assert.fieldEquals("PodFill", podFillId, "to", event.params.to.toHexString()); + assert.fieldEquals("PodFill", podFillId, "amount", event.params.amount.toString()); + assert.fieldEquals("PodFill", podFillId, "index", event.params.index.toString()); + assert.fieldEquals("PodFill", podFillId, "start", event.params.start.toString()); + assert.fieldEquals("PodFill", podFillId, "costInBeans", podAmount.times(pricePerPod).div(BI_10.pow(6)).toString()); + + return event; +} + +export function fillListing_v2( + from: string, + to: string, + listingIndex: BigInt, + listingStart: BigInt, + podAmount: BigInt, + costInBeans: BigInt +): PodListingFilled_v2 { + const event = createPodListingFilledEvent_v2(from, to, listingIndex, listingStart, podAmount, costInBeans); + handlePodListingFilled_v2(event); + + // Perform plot transfer + transferPlot(from, to, listingIndex.plus(listingStart), podAmount); + + // Assert PodFill + const podFillId = getPodFillId(event.params.index, event); + assert.fieldEquals("PodFill", podFillId, "listing", event.params.from.toHexString() + "-" + event.params.index.toString()); + assert.fieldEquals("PodFill", podFillId, "from", event.params.from.toHexString()); + assert.fieldEquals("PodFill", podFillId, "to", event.params.to.toHexString()); + assert.fieldEquals("PodFill", podFillId, "amount", event.params.amount.toString()); + assert.fieldEquals("PodFill", podFillId, "index", event.params.index.toString()); + assert.fieldEquals("PodFill", podFillId, "start", event.params.start.toString()); + assert.fieldEquals("PodFill", podFillId, "costInBeans", event.params.costInBeans.toString()); + + return event; +} + +export function fillOrder_v1( + from: string, + to: string, + orderId: Bytes, + index: BigInt, + start: BigInt, + podAmount: BigInt, + pricePerPod: BigInt +): PodOrderFilled_v1 { + const event = createPodOrderFilledEvent(from, to, orderId, index, start, podAmount); + handlePodOrderFilled(event); + + // Perform plot transfer + transferPlot(from, to, index.plus(start), podAmount); + + // Assert PodFill + const podFillId = getPodFillId(index, event); + assert.fieldEquals("PodFill", podFillId, "order", event.params.id.toHexString()); + assert.fieldEquals("PodFill", podFillId, "from", event.params.from.toHexString()); + assert.fieldEquals("PodFill", podFillId, "to", event.params.to.toHexString()); + assert.fieldEquals("PodFill", podFillId, "amount", event.params.amount.toString()); + assert.fieldEquals("PodFill", podFillId, "index", event.params.index.toString()); + assert.fieldEquals("PodFill", podFillId, "start", event.params.start.toString()); + assert.fieldEquals("PodFill", podFillId, "costInBeans", podAmount.times(pricePerPod).div(BI_10.pow(6)).toString()); + + return event; +} + +export function fillOrder_v2( + from: string, + to: string, + orderId: Bytes, + index: BigInt, + start: BigInt, + podAmount: BigInt, + costInBeans: BigInt +): PodOrderFilled_v2 { + const event = createPodOrderFilledEvent_v2(from, to, orderId, index, start, podAmount, costInBeans); + handlePodOrderFilled_v2(event); + + // Perform plot transfer + transferPlot(from, to, index.plus(start), podAmount); + + // Assert PodFill + const podFillId = getPodFillId(index, event); + assert.fieldEquals("PodFill", podFillId, "order", event.params.id.toHexString()); + assert.fieldEquals("PodFill", podFillId, "from", event.params.from.toHexString()); + assert.fieldEquals("PodFill", podFillId, "to", event.params.to.toHexString()); + assert.fieldEquals("PodFill", podFillId, "amount", event.params.amount.toString()); + assert.fieldEquals("PodFill", podFillId, "index", event.params.index.toString()); + assert.fieldEquals("PodFill", podFillId, "start", event.params.start.toString()); + assert.fieldEquals("PodFill", podFillId, "costInBeans", event.params.costInBeans.toString()); + + return event; +} + +export function cancelListing(account: string, listingIndex: BigInt): PodListingCancelled { + const event = createPodListingCancelledEvent(account, listingIndex); + handlePodListingCancelled(event); + return event; +} + +export function cancelOrder(account: string, orderId: Bytes): PodOrderCancelled { + const event = createPodOrderCancelledEvent(account, orderId); + handlePodOrderCancelled(event); + return event; +} + +function assertListingCreated_v1(event: PodListingCreated_v1): void { + let listingID = event.params.account.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "plot", event.params.index.toString()); + assert.fieldEquals("PodListing", listingID, "farmer", event.params.account.toHexString()); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", listingID, "originalIndex", event.params.index.toString()); + assert.fieldEquals("PodListing", listingID, "originalAmount", event.params.amount.toString()); + assert.fieldEquals("PodListing", listingID, "index", event.params.index.toString()); + assert.fieldEquals("PodListing", listingID, "start", event.params.start.toString()); + assert.fieldEquals("PodListing", listingID, "amount", event.params.amount.toString()); + assert.fieldEquals("PodListing", listingID, "remainingAmount", event.params.amount.toString()); + assert.fieldEquals("PodListing", listingID, "pricePerPod", event.params.pricePerPod.toString()); + assert.fieldEquals("PodListing", listingID, "maxHarvestableIndex", event.params.maxHarvestableIndex.toString()); + assert.fieldEquals("PodListing", listingID, "mode", event.params.toWallet ? "0" : "1"); +} + +function assertListingCreated_v1_1(event: PodListingCreated_v1_1): void { + let listingID = event.params.account.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "plot", event.params.index.toString()); + assert.fieldEquals("PodListing", listingID, "farmer", event.params.account.toHexString()); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", listingID, "originalIndex", event.params.index.toString()); + assert.fieldEquals("PodListing", listingID, "originalAmount", event.params.amount.toString()); + assert.fieldEquals("PodListing", listingID, "index", event.params.index.toString()); + assert.fieldEquals("PodListing", listingID, "start", event.params.start.toString()); + assert.fieldEquals("PodListing", listingID, "amount", event.params.amount.toString()); + assert.fieldEquals("PodListing", listingID, "remainingAmount", event.params.amount.toString()); + assert.fieldEquals("PodListing", listingID, "pricePerPod", event.params.pricePerPod.toString()); + assert.fieldEquals("PodListing", listingID, "maxHarvestableIndex", event.params.maxHarvestableIndex.toString()); + assert.fieldEquals("PodListing", listingID, "mode", event.params.mode.toString()); +} + +function assertListingCreated_v2(event: PodListingCreated_v2): void { + let listingID = event.params.account.toHexString() + "-" + event.params.index.toString(); + assert.fieldEquals("PodListing", listingID, "plot", event.params.index.toString()); + assert.fieldEquals("PodListing", listingID, "farmer", event.params.account.toHexString()); + assert.fieldEquals("PodListing", listingID, "status", "ACTIVE"); + assert.fieldEquals("PodListing", listingID, "originalIndex", event.params.index.toString()); + assert.fieldEquals("PodListing", listingID, "originalAmount", event.params.amount.toString()); + assert.fieldEquals("PodListing", listingID, "index", event.params.index.toString()); + assert.fieldEquals("PodListing", listingID, "start", event.params.start.toString()); + assert.fieldEquals("PodListing", listingID, "amount", event.params.amount.toString()); + assert.fieldEquals("PodListing", listingID, "remainingAmount", event.params.amount.toString()); + assert.fieldEquals("PodListing", listingID, "pricePerPod", event.params.pricePerPod.toString()); + assert.fieldEquals("PodListing", listingID, "maxHarvestableIndex", event.params.maxHarvestableIndex.toString()); + assert.fieldEquals("PodListing", listingID, "minFillAmount", event.params.minFillAmount.toString()); + assert.fieldEquals("PodListing", listingID, "pricingFunction", event.params.pricingFunction.toHexString()); + assert.fieldEquals("PodListing", listingID, "mode", event.params.mode.toString()); + assert.fieldEquals("PodListing", listingID, "pricingType", event.params.pricingType.toString()); +} + +function assertOrderCreated_v1(account: string, event: PodOrderCreated_v1): void { + let orderID = event.params.id.toHexString(); + assert.fieldEquals("PodOrder", orderID, "historyID", orderID + "-" + event.block.timestamp.toString() + "-" + event.logIndex.toString()); + assert.fieldEquals("PodOrder", orderID, "farmer", account); + assert.fieldEquals("PodOrder", orderID, "status", "ACTIVE"); + assert.fieldEquals( + "PodOrder", + orderID, + "beanAmount", + event.params.amount.times(BigInt.fromU32(event.params.pricePerPod)).div(BI_10.pow(6)).toString() + ); + assert.fieldEquals("PodOrder", orderID, "beanAmountFilled", "0"); + assert.fieldEquals("PodOrder", orderID, "maxPlaceInLine", event.params.maxPlaceInLine.toString()); + assert.fieldEquals("PodOrder", orderID, "pricePerPod", event.params.pricePerPod.toString()); +} + +function assertOrderCreated_v2(account: string, event: PodOrderCreated_v2): void { + let orderID = event.params.id.toHexString(); + assert.fieldEquals("PodOrder", orderID, "historyID", orderID + "-" + event.block.timestamp.toString() + "-" + event.logIndex.toString()); + assert.fieldEquals("PodOrder", orderID, "farmer", account); + assert.fieldEquals("PodOrder", orderID, "status", "ACTIVE"); + assert.fieldEquals("PodOrder", orderID, "beanAmount", event.params.amount.toString()); + assert.fieldEquals("PodOrder", orderID, "beanAmountFilled", "0"); + assert.fieldEquals("PodOrder", orderID, "minFillAmount", event.params.minFillAmount.toString()); + assert.fieldEquals("PodOrder", orderID, "maxPlaceInLine", event.params.maxPlaceInLine.toString()); + assert.fieldEquals("PodOrder", orderID, "pricePerPod", event.params.pricePerPod.toString()); + assert.fieldEquals("PodOrder", orderID, "pricingFunction", event.params.pricingFunction.toHexString()); + assert.fieldEquals("PodOrder", orderID, "pricingType", event.params.priceType.toString()); +} + +export function createListing_v1( + account: string, + index: BigInt, + listedPods: BigInt, + start: BigInt, + pricePerPod: BigInt, + maxHarvestableIndex: BigInt +): PodListingCreated_v1 { + const event = createPodListingCreatedEvent(account, index, start, listedPods, pricePerPod, maxHarvestableIndex, true); + handlePodListingCreated(event); + assertListingCreated_v1(event); + return event; +} + +export function createListing_v1_1( + account: string, + index: BigInt, + listedPods: BigInt, + start: BigInt, + pricePerPod: BigInt, + maxHarvestableIndex: BigInt +): PodListingCreated_v1_1 { + const event = createPodListingCreatedEvent_v1_1(account, index, start, listedPods, pricePerPod, maxHarvestableIndex, ZERO_BI); + handlePodListingCreated_v1_1(event); + assertListingCreated_v1_1(event); + return event; +} + +export function createListing_v2( + account: string, + index: BigInt, + listedPods: BigInt, + start: BigInt, + maxHarvestableIndex: BigInt +): PodListingCreated_v2 { + const event = createPodListingCreatedEvent_v2( + account, + index, + start, + listedPods, + BigInt.fromString("250000"), + maxHarvestableIndex, + BigInt.fromString("10000000"), + pricingFunction, + BigInt.fromI32(0), + BigInt.fromI32(1) + ); + handlePodListingCreated_v2(event); + assertListingCreated_v2(event); + return event; +} + +export function createOrder_v1(account: string, id: Bytes, beans: BigInt, pricePerPod: BigInt, maxPlaceInLine: BigInt): PodOrderCreated_v1 { + const event = createPodOrderCreatedEvent(account, id, beans.times(BI_10.pow(6)).div(pricePerPod), pricePerPod, maxPlaceInLine); + handlePodOrderCreated(event); + assertOrderCreated_v1(account, event); + return event; +} + +export function createOrder_v2(account: string, id: Bytes, beans: BigInt, pricePerPod: BigInt, maxPlaceInLine: BigInt): PodOrderCreated_v2 { + const event = createPodOrderCreatedEvent_v2(account, id, beans, pricePerPod, maxPlaceInLine, ONE_BI, pricingFunction, ZERO_BI); + handlePodOrderCreated_v2(event); + assertOrderCreated_v2(account, event); + return event; +} + +export function assertMarketListingsState( + address: string, + listings: string[], + listedPods: BigInt, + availableListedPods: BigInt, + cancelledListedPods: BigInt, + expiredListedPods: BigInt, + filledListedPods: BigInt, + podVolume: BigInt, + beanVolume: BigInt +): void { + assert.fieldEquals("PodMarketplace", address, "activeListings", arrayToString(listings)); + assert.fieldEquals("PodMarketplace", address, "listedPods", listedPods.toString()); + assert.fieldEquals("PodMarketplace", address, "availableListedPods", availableListedPods.toString()); + assert.fieldEquals("PodMarketplace", address, "cancelledListedPods", cancelledListedPods.toString()); + assert.fieldEquals("PodMarketplace", address, "expiredListedPods", expiredListedPods.toString()); + assert.fieldEquals("PodMarketplace", address, "filledListedPods", filledListedPods.toString()); + assert.fieldEquals("PodMarketplace", address, "podVolume", podVolume.toString()); + assert.fieldEquals("PodMarketplace", address, "beanVolume", beanVolume.toString()); +} + +export function assertMarketOrdersState( + address: string, + orders: string[], + orderBeans: BigInt, + availableOrderBeans: BigInt, + filledOrderBeans: BigInt, + filledOrderedPods: BigInt, + cancelledOrderBeans: BigInt, + podVolume: BigInt, + beanVolume: BigInt +): void { + assert.fieldEquals("PodMarketplace", address, "activeOrders", arrayToString(orders)); + assert.fieldEquals("PodMarketplace", address, "orderBeans", orderBeans.toString()); + assert.fieldEquals("PodMarketplace", address, "availableOrderBeans", availableOrderBeans.toString()); + assert.fieldEquals("PodMarketplace", address, "filledOrderBeans", filledOrderBeans.toString()); + assert.fieldEquals("PodMarketplace", address, "filledOrderedPods", filledOrderedPods.toString()); + assert.fieldEquals("PodMarketplace", address, "cancelledOrderBeans", cancelledOrderBeans.toString()); + assert.fieldEquals("PodMarketplace", address, "podVolume", podVolume.toString()); + assert.fieldEquals("PodMarketplace", address, "beanVolume", beanVolume.toString()); +} + +function arrayToString(a: string[]): string { + return "[" + a.join(", ") + "]"; +} diff --git a/projects/subgraph-beanstalk/tests/utils/Season.ts b/projects/subgraph-beanstalk/tests/utils/Season.ts new file mode 100644 index 0000000000..775486c734 --- /dev/null +++ b/projects/subgraph-beanstalk/tests/utils/Season.ts @@ -0,0 +1,8 @@ +import { BEANSTALK } from "../../../subgraph-core/utils/Constants"; +import { loadBeanstalk } from "../../src/utils/Beanstalk"; + +export function setSeason(season: u32): void { + let beanstalk = loadBeanstalk(BEANSTALK); + beanstalk.lastSeason = season; + beanstalk.save(); +} diff --git a/projects/subgraph-core/tests/Values.ts b/projects/subgraph-core/tests/Values.ts new file mode 100644 index 0000000000..6bc58bd935 --- /dev/null +++ b/projects/subgraph-core/tests/Values.ts @@ -0,0 +1,11 @@ +import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; + +/* Shorthand functions for constructing some common value types */ + +export function beans_BI(b: number): BigInt { + return BigInt.fromI32(b).times(BigInt.fromI32(10).pow(6)); +} + +export function podlineMil_BI(m: number): BigInt { + return BigInt.fromI32(m).times(BigInt.fromI32(10).pow(12)); +} diff --git a/projects/ui/codegen-individual.yml b/projects/ui/codegen-individual.yml index 1e655d679e..3901a79bbc 100644 --- a/projects/ui/codegen-individual.yml +++ b/projects/ui/codegen-individual.yml @@ -3,16 +3,16 @@ # A more optimal solution would involve generating a different schema for each entry in src/graph.endpoints.ts. overwrite: true generates: - ./src/graph/schema-beanstalk.graphql: - schema: - - https://graph.node.bean.money/subgraphs/name/beanstalk - plugins: - - "schema-ast" - #./src/graph/schema-bean.graphql: - # schema: - # - https://graph.node.bean.money/subgraphs/name/bean - # plugins: - # - "schema-ast" + # ./src/graph/schema-beanstalk.graphql: + # schema: + # - https://graph.node.bean.money/subgraphs/name/beanstalk-testing + # plugins: + # - "schema-ast" + ./src/graph/schema-bean.graphql: + schema: + - https://graph.node.bean.money/subgraphs/name/bean + plugins: + - "schema-ast" ./src/graph/schema-snapshot1.graphql: schema: - https://hub.snapshot.org/graphql diff --git a/projects/ui/src/components/Common/Form/PlotInputField.tsx b/projects/ui/src/components/Common/Form/PlotInputField.tsx index 7d508e8288..293c0945b0 100644 --- a/projects/ui/src/components/Common/Form/PlotInputField.tsx +++ b/projects/ui/src/components/Common/Form/PlotInputField.tsx @@ -72,6 +72,7 @@ const PlotInputField: FC< const [numPods, numPodsFloat] = useMemo(() => { if (!plot.index) return [ZERO_BN, 0]; const _pods = plots[plot.index]; + if (!_pods) return [ZERO_BN, 0]; return [_pods, _pods.toNumber()]; }, [plots, plot.index]); diff --git a/projects/ui/src/components/Common/ScrollPaginationControl.tsx b/projects/ui/src/components/Common/ScrollPaginationControl.tsx index db4f8b68da..a216abd98a 100644 --- a/projects/ui/src/components/Common/ScrollPaginationControl.tsx +++ b/projects/ui/src/components/Common/ScrollPaginationControl.tsx @@ -12,7 +12,7 @@ type IScrollPaginationControl = { /** * ref of the data grid container element */ - scrollRef: React.MutableRefObject; + scrollref: React.MutableRefObject; /** * async function to fetch more data when scrolled to the bottom of the table */ @@ -33,7 +33,7 @@ type ControllerCache = { const CONTROL_HEIGHT = 52; const ScrollPaginationControl: React.FC = ({ - scrollRef, + scrollref, handleFetchMore, }) => { const apiRef = useGridApiContext(); @@ -56,7 +56,7 @@ const ScrollPaginationControl: React.FC = ({ }, []); // get the Mui Data-Grid-scroll container element in which the scrollbar is rendered - const el = scrollRef?.current?.querySelector('.MuiDataGrid-virtualScroller'); + const el = scrollref?.current?.querySelector('.MuiDataGrid-virtualScroller'); const hasNextPage = useMemo( () => !(page === pageCount - 1 || pageCount === 0), diff --git a/projects/ui/src/components/Common/TxnToast.tsx b/projects/ui/src/components/Common/TxnToast.tsx index 3f4869415d..742f702e91 100644 --- a/projects/ui/src/components/Common/TxnToast.tsx +++ b/projects/ui/src/components/Common/TxnToast.tsx @@ -41,9 +41,11 @@ export function ToastAlert({ display: 'flex', alignItems: 'center', flexDirection: 'row', + maxHeight: 250, + overflow: 'hidden', }} > - + {desc} {hash && ( @@ -70,7 +72,7 @@ export function ToastAlert({
{msg}
)} -
+ {rawError && ( { if (!account) return; + const _pricePerPod = toTokenUnitsBN(podListing.pricePerPod, 0); + const _remaining = toTokenUnitsBN(podListing.remainingAmount, 0); // Maximum BEAN precision is 6 decimals. remainingAmount * pricePerPod may // have more decimals, so we truncate at 6. - const maxBeans = podListing.remainingAmount - .times(podListing.pricePerPod) - .dp(BEAN[1].decimals, BigNumber.ROUND_DOWN); + + let maxBeans = _remaining.times(_pricePerPod).dp(6, BigNumber.ROUND_UP); + const diff = (maxBeans.div(podListing.pricePerPod)).dp(6, BigNumber.ROUND_DOWN).minus(podListing.remainingAmount); + + let loop = 0; + let found = false; + + do { + let adjustedMaxBeans + if (diff.isPositive()) { + adjustedMaxBeans = maxBeans.minus(new BigNumber(loop * 0.0000001)); + } else { + adjustedMaxBeans = maxBeans.plus(new BigNumber(loop * 0.0000001)); + }; + const adjustedPodAmount = adjustedMaxBeans.div(podListing.pricePerPod).dp(6, BigNumber.ROUND_DOWN); + if (adjustedPodAmount.eq(podListing.remainingAmount)) { + maxBeans = adjustedMaxBeans; + found = true; + } else { + loop += 1; + }; + } while (found === false && loop < 50); if (maxBeans.gt(0)) { if (tokenIn === Bean) { diff --git a/projects/ui/src/components/Market/PodsV2/AllPodListings.graphql b/projects/ui/src/components/Market/PodsV2/AllPodListings.graphql index 0c09d770dc..5f5b0662cb 100644 --- a/projects/ui/src/components/Market/PodsV2/AllPodListings.graphql +++ b/projects/ui/src/components/Market/PodsV2/AllPodListings.graphql @@ -2,10 +2,12 @@ query AllPodListings( $first: Int = 1000, $status: MarketStatus = ACTIVE, - $maxHarvestableIndex: BigInt! + $maxHarvestableIndex: BigInt!, + $skip: Int = 0, ) { podListings( first: $first, + skip: $skip, where: { status: $status, maxHarvestableIndex_gt: $maxHarvestableIndex, diff --git a/projects/ui/src/components/Market/PodsV2/AllPodOrders.graphql b/projects/ui/src/components/Market/PodsV2/AllPodOrders.graphql index f101f43383..afc287e71e 100644 --- a/projects/ui/src/components/Market/PodsV2/AllPodOrders.graphql +++ b/projects/ui/src/components/Market/PodsV2/AllPodOrders.graphql @@ -1,10 +1,12 @@ #import "./PodOrder.fragment.graphql" query AllPodOrders( $first: Int = 1000, - $status: MarketStatus = ACTIVE + $status: MarketStatus = ACTIVE, + $skip: Int = 0, ) { podOrders( first: $first, + skip: $skip, orderBy: createdAt, orderDirection: desc, where: { status: $status } diff --git a/projects/ui/src/components/Market/PodsV2/FarmerPodListings.graphql b/projects/ui/src/components/Market/PodsV2/FarmerPodListings.graphql index 5ebfb97931..ade30dbe3b 100644 --- a/projects/ui/src/components/Market/PodsV2/FarmerPodListings.graphql +++ b/projects/ui/src/components/Market/PodsV2/FarmerPodListings.graphql @@ -1,7 +1,7 @@ #import "../../PodListing.fragment.graphql" query FarmerPodListings( - $first: Int = 100, + $first: Int = 1000, $createdAt_gt: BigInt, $account: String! ) { diff --git a/projects/ui/src/components/Market/PodsV2/FarmerPodOrders.graphql b/projects/ui/src/components/Market/PodsV2/FarmerPodOrders.graphql index 54d5c561c3..46041843a4 100644 --- a/projects/ui/src/components/Market/PodsV2/FarmerPodOrders.graphql +++ b/projects/ui/src/components/Market/PodsV2/FarmerPodOrders.graphql @@ -1,7 +1,7 @@ #import "../../PodOrder.fragment.graphql" query FarmerPodOrders( - $first: Int = 100, + $first: Int = 1000, $createdAt_gt: BigInt, $account: String! ) { diff --git a/projects/ui/src/components/Market/PodsV2/HistoricalPodListings.graphql b/projects/ui/src/components/Market/PodsV2/HistoricalPodListings.graphql index a51c0eec1a..26e2dbb251 100644 --- a/projects/ui/src/components/Market/PodsV2/HistoricalPodListings.graphql +++ b/projects/ui/src/components/Market/PodsV2/HistoricalPodListings.graphql @@ -3,7 +3,7 @@ query HistoricalPodListings( ) { podListings(where: { historyID_in: $historyIDs - }, orderBy: updatedAt, orderDirection: desc) { + }, orderBy: updatedAt, orderDirection: desc, first: 1000) { #// Identifiers id status diff --git a/projects/ui/src/components/Market/PodsV2/HistoricalPodOrders.graphql b/projects/ui/src/components/Market/PodsV2/HistoricalPodOrders.graphql index 02c6bb55a0..6444c06811 100644 --- a/projects/ui/src/components/Market/PodsV2/HistoricalPodOrders.graphql +++ b/projects/ui/src/components/Market/PodsV2/HistoricalPodOrders.graphql @@ -3,7 +3,7 @@ query HistoricalPodOrders( ) { podOrders(where: { historyID_in: $historyIDs - }, orderBy: updatedAt, orderDirection: desc) { + }, orderBy: updatedAt, orderDirection: desc, first: 1000) { #// Identifiers id historyID @@ -15,7 +15,9 @@ query HistoricalPodOrders( maxPlaceInLine #// Amounts - podAmount + #podAmount # sk/fix/pod-market removed podAmount and added beanAmount + beanAmount + beanAmountFilled podAmountFilled #// Metadata diff --git a/projects/ui/src/components/Market/PodsV2/MarketEvents.graphql b/projects/ui/src/components/Market/PodsV2/MarketEvents.graphql index a86e0b24e3..9740e60f30 100644 --- a/projects/ui/src/components/Market/PodsV2/MarketEvents.graphql +++ b/projects/ui/src/components/Market/PodsV2/MarketEvents.graphql @@ -20,6 +20,7 @@ query MarketEvents( index # of the Listing that was cancelled account historyID + placeInLine # => amount # => pricePerPod } @@ -30,6 +31,7 @@ query MarketEvents( maxHarvestableIndex pricePerPod historyID + placeInLine } ... on PodListingFilled { id @@ -37,6 +39,7 @@ query MarketEvents( to amount index # of Listing that sold + placeInLine start historyID # => pricePerPod @@ -66,6 +69,7 @@ query MarketEvents( to historyID amount + placeInLine index # index of plot was sold to the Order start # # => maxPlaceInLine diff --git a/projects/ui/src/components/Market/PodsV2/Modules/MarketGraph.tsx b/projects/ui/src/components/Market/PodsV2/Modules/MarketGraph.tsx index 8805900f7c..98d1e54367 100644 --- a/projects/ui/src/components/Market/PodsV2/Modules/MarketGraph.tsx +++ b/projects/ui/src/components/Market/PodsV2/Modules/MarketGraph.tsx @@ -366,10 +366,10 @@ const Graph: FC = ({ !cursorPoint?.type ? 1 : cursorPoint.type === _type - ? cursorPoint.index === _i - ? 1 - : HOVER_PEER_OPACITY - : HOVER_PEER_OPACITY, + ? cursorPoint.index === _i + ? 1 + : HOVER_PEER_OPACITY + : HOVER_PEER_OPACITY, [cursorPoint] ); @@ -565,7 +565,8 @@ const Graph: FC = ({ setSelectedPoint(hoveredPoint); if (hoveredPoint.type === 'listing') { // handleClickFill(PodOrderAction.BUY, PodOrderType.FILL); - navigate(`/market/buy/${listings[hoveredPoint.index].id}`); + const idNumber = listings[hoveredPoint.index].id.slice(43); + navigate(`/market/buy/${idNumber}`); } else if (hoveredPoint.type === 'order') { // handleClickFill(PodOrderAction.SELL, PodOrderType.FILL); navigate(`/market/sell/${orders[hoveredPoint.index].id}`); @@ -581,14 +582,17 @@ const Graph: FC = ({ hideTooltip(); } } else if (params.listingID) { - const index = listings.findIndex((l) => l.id === params.listingID); + // Extract index from listing id "0xaddr-index" + const index = listings.findIndex( + (l) => l.id.slice(43) === params.listingID + ); if (index === -1) { if (selectedPoint) { setSelectedPoint(undefined); hideTooltip(); } - return - }; + return; + } const newSelectdPoint: SelectedPoint = { type: 'listing', index, @@ -608,8 +612,8 @@ const Graph: FC = ({ setSelectedPoint(undefined); hideTooltip(); } - return - }; + return; + } if (!selectedPoint || selectedPoint.index !== index) { setSelectedPoint({ type: 'order', @@ -775,10 +779,10 @@ const Graph: FC = ({ cursor: selectedPoint ? 'default' // when selected, freeze cursor : hoveredPoint // hovering over a point but haven't clicked it yet - ? 'pointer' - : zoom.isDragging - ? 'grabbing' // if dragging, show grab - : 'default', + ? 'pointer' + : zoom.isDragging + ? 'grabbing' // if dragging, show grab + : 'default', touchAction: 'none', }} /> @@ -850,7 +854,7 @@ const Graph: FC = ({ > Viewing: {selectedPoint.type}{' '} {selectedPoint.type === 'listing' - ? selectedPoint.coordinate.id + ? selectedPoint.coordinate.id.slice(43) : selectedPoint.coordinate.id.substring(0, 8)} = () => { const { data: eventsData, harvestableIndex, - fetchMoreData, } = useMarketActivityData(); // "MARKET ACTIVITY" // FUNCTIONS @@ -127,7 +124,6 @@ const MarketTables: React.FC<{}> = () => { {openState !== 0 && tab === 3 && ( )} diff --git a/projects/ui/src/components/Market/PodsV2/PodOrder.fragment.graphql b/projects/ui/src/components/Market/PodsV2/PodOrder.fragment.graphql index a623b1c62d..2c8c4818cf 100644 --- a/projects/ui/src/components/Market/PodsV2/PodOrder.fragment.graphql +++ b/projects/ui/src/components/Market/PodsV2/PodOrder.fragment.graphql @@ -14,7 +14,7 @@ fragment PodOrder on PodOrder { minFillAmount #// Amounts - podAmount # Market V1: Original amount of the ordered pods + #podAmount # Market V1: Original amount of the ordered pods. sk/fix/pod-market removed podAmount beanAmount # Market V2: Original amount of beans used to ordered beans podAmountFilled # current filled amount beanAmountFilled # bean amount filled diff --git a/projects/ui/src/components/Market/PodsV2/Tables/AllActiveListings.tsx b/projects/ui/src/components/Market/PodsV2/Tables/AllActiveListings.tsx index 1435ef1c56..489e789074 100644 --- a/projects/ui/src/components/Market/PodsV2/Tables/AllActiveListings.tsx +++ b/projects/ui/src/components/Market/PodsV2/Tables/AllActiveListings.tsx @@ -38,7 +38,7 @@ const AllActiveListings: React.FC<{ loading={data.loading} getRowId={(row: PodListing) => `${row.account}-${row.id}`} onRowClick={({ row }) => { - navigate(`/market/buy/${row.id.toString()}`); + navigate(`/market/buy/${row.id.toString().slice(43)}`); }} /> ); diff --git a/projects/ui/src/components/Market/PodsV2/Tables/BaseTable.tsx b/projects/ui/src/components/Market/PodsV2/Tables/BaseTable.tsx index 533b8a3f20..df18b21486 100644 --- a/projects/ui/src/components/Market/PodsV2/Tables/BaseTable.tsx +++ b/projects/ui/src/components/Market/PodsV2/Tables/BaseTable.tsx @@ -57,10 +57,10 @@ const BaseTable: FC = ({ sortModel, ...props }) => { - const scrollRef = useRef(null); + const scrollref = useRef(null); return ( = ({ }} componentsProps={{ footer: { - scrollRef, + scrollref, // handleFetchMore: fetchMore, }, noRowsOverlay: { diff --git a/projects/ui/src/components/Market/PodsV2/Tables/FarmerOrders.tsx b/projects/ui/src/components/Market/PodsV2/Tables/FarmerOrders.tsx index 03f89a4aa4..02c6ed6ed6 100644 --- a/projects/ui/src/components/Market/PodsV2/Tables/FarmerOrders.tsx +++ b/projects/ui/src/components/Market/PodsV2/Tables/FarmerOrders.tsx @@ -10,10 +10,10 @@ const columns = [ MarketColumns.HistoryItem.amountPods(1, 'left'), MarketColumns.Shared.placeInLine(undefined, 1, 'left'), MarketColumns.Shared.pricePerPod(0.8), - MarketColumns.HistoryItem.amountBeans(1.3), + MarketColumns.HistoryItem.amountBeans(1), MarketColumns.HistoryItem.fillPct(0.6), - MarketColumns.Shared.expiry(0.5), - MarketColumns.HistoryItem.status(0.6, 'right'), + MarketColumns.Shared.expiry(0.7), + MarketColumns.HistoryItem.status(0.9, 'right'), ]; /** * Displays a table of a Farmer's outstanding Listings and Orders. diff --git a/projects/ui/src/components/Market/PodsV2/Tables/MarketActivity.tsx b/projects/ui/src/components/Market/PodsV2/Tables/MarketActivity.tsx index fb6fc338c1..a4b2d4a0ad 100644 --- a/projects/ui/src/components/Market/PodsV2/Tables/MarketActivity.tsx +++ b/projects/ui/src/components/Market/PodsV2/Tables/MarketActivity.tsx @@ -22,8 +22,7 @@ const columns = [ const MarketActivity: React.FC<{ data: MarketEvent[] | undefined; initializing: boolean; - fetchMoreData: () => Promise; -}> = ({ data, initializing, fetchMoreData }) => { +}> = ({ data, initializing }) => { const rows = useMemo(() => (!data || !data.length ? [] : data), [data]); return ( @@ -31,7 +30,6 @@ const MarketActivity: React.FC<{ rows={rows} columns={columns} loading={initializing} - fetchMore={fetchMoreData} getRowId={(row: MarketEvent) => row.eventId} /> ); diff --git a/projects/ui/src/components/Market/PodsV2/Tables/columns/market-columns.tsx b/projects/ui/src/components/Market/PodsV2/Tables/columns/market-columns.tsx index 84e1156d99..9fb0d4d45c 100644 --- a/projects/ui/src/components/Market/PodsV2/Tables/columns/market-columns.tsx +++ b/projects/ui/src/components/Market/PodsV2/Tables/columns/market-columns.tsx @@ -140,7 +140,7 @@ export const MarketColumns = { valueFormatter: (params: GridValueFormatterParams) => formatDate(params.value), renderCell: (params: GridRenderCellParams) => ( - + <> {params.row[hashKey] ? ( @@ -160,9 +161,11 @@ export const MarketColumns = { ) : ( - params.formattedValue + + {params.formattedValue} + )} - + ), } as GridColumns[number]), /** */ @@ -461,7 +464,7 @@ export const MarketColumns = { return ( - {params.value.toString().toUpperCase()} + {key === 'cancelled_partial' ? `CANCELLED (PARTIAL)` : params.value.toString().toUpperCase()} ); }, diff --git a/projects/ui/src/graph/endpoints.ts b/projects/ui/src/graph/endpoints.ts index df4c74fc17..008c55e97a 100644 --- a/projects/ui/src/graph/endpoints.ts +++ b/projects/ui/src/graph/endpoints.ts @@ -47,7 +47,8 @@ export const SUBGRAPH_ENVIRONMENTS: Record = { [SGEnvironments.BF_2_0_3]: { name: 'Beanstalk Farms / v2.0.3', subgraphs: { - beanstalk: 'https://graph.node.bean.money/subgraphs/name/beanstalk-2-0-3', + beanstalk: + 'https://api.studio.thegraph.com/query/69878/beanstalkdev/v2.2.1.1', bean: 'https://graph.node.bean.money/subgraphs/name/bean', // fixme beanft: 'https://graph.node.bean.money/subgraphs/name/beanft-dev', }, diff --git a/projects/ui/src/graph/graphql.schema.json b/projects/ui/src/graph/graphql.schema.json index 4da34416c2..c59b56150f 100644 --- a/projects/ui/src/graph/graphql.schema.json +++ b/projects/ui/src/graph/graphql.schema.json @@ -48329,8 +48329,8 @@ "description": null, "fields": [ { - "name": "beans", - "description": "Beans used to sow, if any", + "name": "beansPerPod", + "description": "Number of beans spent for each pod, whether through sowing or on the marketplace", "args": [], "type": { "kind": "NON_NULL", @@ -48362,7 +48362,7 @@ }, { "name": "creationHash", - "description": "Creation transaction hash", + "description": "Transaction hash of when this plot entity was created", "args": [], "type": { "kind": "NON_NULL", @@ -48534,7 +48534,7 @@ }, { "name": "source", - "description": "Transaction source for this plot", + "description": "Transaction source for this plot. Not the same as creationHash which can include plots splitting from transfer or harvest without the owner changing", "args": [], "type": { "kind": "NON_NULL", @@ -48549,15 +48549,15 @@ "deprecationReason": null }, { - "name": "sownPods", - "description": "Total pods that were sown, if any", + "name": "sourceHash", + "description": "Transaction hash corresponding to source", "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "SCALAR", - "name": "BigInt", + "name": "String", "ofType": null } }, @@ -48565,15 +48565,15 @@ "deprecationReason": null }, { - "name": "temperature", - "description": "Temperature when the plot was sown", + "name": "updatedAt", + "description": "Timestamp when updated", "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "SCALAR", - "name": "Int", + "name": "BigInt", "ofType": null } }, @@ -48581,8 +48581,8 @@ "deprecationReason": null }, { - "name": "updatedAt", - "description": "Timestamp when updated", + "name": "updatedAtBlock", + "description": "Block when updated", "args": [], "type": { "kind": "NON_NULL", @@ -48611,7 +48611,7 @@ "interfaces": null, "enumValues": [ { - "name": "HARVEST", + "name": "MARKET", "description": null, "isDeprecated": false, "deprecationReason": null @@ -48666,7 +48666,7 @@ "deprecationReason": null }, { - "name": "beans", + "name": "beansPerPod", "description": null, "type": { "kind": "SCALAR", @@ -48678,7 +48678,7 @@ "deprecationReason": null }, { - "name": "beans_gt", + "name": "beansPerPod_gt", "description": null, "type": { "kind": "SCALAR", @@ -48690,7 +48690,7 @@ "deprecationReason": null }, { - "name": "beans_gte", + "name": "beansPerPod_gte", "description": null, "type": { "kind": "SCALAR", @@ -48702,7 +48702,7 @@ "deprecationReason": null }, { - "name": "beans_in", + "name": "beansPerPod_in", "description": null, "type": { "kind": "LIST", @@ -48722,7 +48722,7 @@ "deprecationReason": null }, { - "name": "beans_lt", + "name": "beansPerPod_lt", "description": null, "type": { "kind": "SCALAR", @@ -48734,7 +48734,7 @@ "deprecationReason": null }, { - "name": "beans_lte", + "name": "beansPerPod_lte", "description": null, "type": { "kind": "SCALAR", @@ -48746,7 +48746,7 @@ "deprecationReason": null }, { - "name": "beans_not", + "name": "beansPerPod_not", "description": null, "type": { "kind": "SCALAR", @@ -48758,7 +48758,7 @@ "deprecationReason": null }, { - "name": "beans_not_in", + "name": "beansPerPod_not_in", "description": null, "type": { "kind": "LIST", @@ -50714,31 +50714,23 @@ "deprecationReason": null }, { - "name": "source_in", + "name": "sourceHash", "description": null, "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PlotSource", - "ofType": null - } - } + "kind": "SCALAR", + "name": "String", + "ofType": null }, "defaultValue": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "source_not", + "name": "sourceHash_contains", "description": null, "type": { - "kind": "ENUM", - "name": "PlotSource", + "kind": "SCALAR", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50746,31 +50738,23 @@ "deprecationReason": null }, { - "name": "source_not_in", + "name": "sourceHash_contains_nocase", "description": null, "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "PlotSource", - "ofType": null - } - } + "kind": "SCALAR", + "name": "String", + "ofType": null }, "defaultValue": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "sownPods", + "name": "sourceHash_ends_with", "description": null, "type": { "kind": "SCALAR", - "name": "BigInt", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50778,11 +50762,11 @@ "deprecationReason": null }, { - "name": "sownPods_gt", + "name": "sourceHash_ends_with_nocase", "description": null, "type": { "kind": "SCALAR", - "name": "BigInt", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50790,11 +50774,11 @@ "deprecationReason": null }, { - "name": "sownPods_gte", + "name": "sourceHash_gt", "description": null, "type": { "kind": "SCALAR", - "name": "BigInt", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50802,7 +50786,19 @@ "deprecationReason": null }, { - "name": "sownPods_in", + "name": "sourceHash_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "sourceHash_in", "description": null, "type": { "kind": "LIST", @@ -50812,7 +50808,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "BigInt", + "name": "String", "ofType": null } } @@ -50822,11 +50818,11 @@ "deprecationReason": null }, { - "name": "sownPods_lt", + "name": "sourceHash_lt", "description": null, "type": { "kind": "SCALAR", - "name": "BigInt", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50834,11 +50830,11 @@ "deprecationReason": null }, { - "name": "sownPods_lte", + "name": "sourceHash_lte", "description": null, "type": { "kind": "SCALAR", - "name": "BigInt", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50846,11 +50842,59 @@ "deprecationReason": null }, { - "name": "sownPods_not", + "name": "sourceHash_not", "description": null, "type": { "kind": "SCALAR", - "name": "BigInt", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "sourceHash_not_contains", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "sourceHash_not_contains_nocase", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "sourceHash_not_ends_with", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "sourceHash_not_ends_with_nocase", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50858,7 +50902,7 @@ "deprecationReason": null }, { - "name": "sownPods_not_in", + "name": "sourceHash_not_in", "description": null, "type": { "kind": "LIST", @@ -50868,7 +50912,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "BigInt", + "name": "String", "ofType": null } } @@ -50878,11 +50922,11 @@ "deprecationReason": null }, { - "name": "temperature", + "name": "sourceHash_not_starts_with", "description": null, "type": { "kind": "SCALAR", - "name": "Int", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50890,11 +50934,11 @@ "deprecationReason": null }, { - "name": "temperature_gt", + "name": "sourceHash_not_starts_with_nocase", "description": null, "type": { "kind": "SCALAR", - "name": "Int", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50902,11 +50946,11 @@ "deprecationReason": null }, { - "name": "temperature_gte", + "name": "sourceHash_starts_with", "description": null, "type": { "kind": "SCALAR", - "name": "Int", + "name": "String", "ofType": null }, "defaultValue": null, @@ -50914,7 +50958,19 @@ "deprecationReason": null }, { - "name": "temperature_in", + "name": "sourceHash_starts_with_nocase", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "source_in", "description": null, "type": { "kind": "LIST", @@ -50923,8 +50979,8 @@ "kind": "NON_NULL", "name": null, "ofType": { - "kind": "SCALAR", - "name": "Int", + "kind": "ENUM", + "name": "PlotSource", "ofType": null } } @@ -50934,11 +50990,43 @@ "deprecationReason": null }, { - "name": "temperature_lt", + "name": "source_not", + "description": null, + "type": { + "kind": "ENUM", + "name": "PlotSource", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "source_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "ENUM", + "name": "PlotSource", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "updatedAt", "description": null, "type": { "kind": "SCALAR", - "name": "Int", + "name": "BigInt", "ofType": null }, "defaultValue": null, @@ -50946,11 +51034,11 @@ "deprecationReason": null }, { - "name": "temperature_lte", + "name": "updatedAtBlock", "description": null, "type": { "kind": "SCALAR", - "name": "Int", + "name": "BigInt", "ofType": null }, "defaultValue": null, @@ -50958,11 +51046,11 @@ "deprecationReason": null }, { - "name": "temperature_not", + "name": "updatedAtBlock_gt", "description": null, "type": { "kind": "SCALAR", - "name": "Int", + "name": "BigInt", "ofType": null }, "defaultValue": null, @@ -50970,7 +51058,19 @@ "deprecationReason": null }, { - "name": "temperature_not_in", + "name": "updatedAtBlock_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "updatedAtBlock_in", "description": null, "type": { "kind": "LIST", @@ -50980,7 +51080,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "Int", + "name": "BigInt", "ofType": null } } @@ -50990,7 +51090,31 @@ "deprecationReason": null }, { - "name": "updatedAt", + "name": "updatedAtBlock_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "updatedAtBlock_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "updatedAtBlock_not", "description": null, "type": { "kind": "SCALAR", @@ -51001,6 +51125,26 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "updatedAtBlock_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "updatedAt_gt", "description": null, @@ -51115,7 +51259,7 @@ "interfaces": null, "enumValues": [ { - "name": "beans", + "name": "beansPerPod", "description": null, "isDeprecated": false, "deprecationReason": null @@ -51270,12 +51414,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "listing__cancelledAmount", - "description": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "listing__createdAt", "description": null, @@ -51409,19 +51547,19 @@ "deprecationReason": null }, { - "name": "sownPods", + "name": "sourceHash", "description": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "temperature", + "name": "updatedAt", "description": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "updatedAt", + "name": "updatedAtBlock", "description": null, "isDeprecated": false, "deprecationReason": null @@ -51455,9 +51593,13 @@ "description": "Total beans used to fill listing/order", "args": [], "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } }, "isDeprecated": false, "deprecationReason": null @@ -51480,7 +51622,7 @@ }, { "name": "from", - "description": "Account fulfilling the order", + "description": "Account that is sending pods", "args": [], "type": { "kind": "NON_NULL", @@ -51550,6 +51692,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": "Where these pods were in line when filled", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace", "description": "Marketplace associated with this fill", @@ -51584,7 +51742,7 @@ }, { "name": "to", - "description": "Account filling the order", + "description": "Account that is receiving pods", "args": [], "type": { "kind": "NON_NULL", @@ -53006,6 +53164,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace", "description": null, @@ -53715,12 +53985,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "listing__cancelledAmount", - "description": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "listing__createdAt", "description": null, @@ -53889,12 +54153,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "order__podAmount", - "description": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "order__podAmountFilled", "description": null, @@ -53931,6 +54189,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace", "description": null, @@ -53943,6 +54207,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "podMarketplace__availableOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace__beanVolume", "description": null, @@ -53956,7 +54226,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__cancelledOrderedPods", + "name": "podMarketplace__cancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -53973,6 +54243,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "podMarketplace__filledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace__filledOrderedPods", "description": null, @@ -53992,7 +54268,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__orderedPods", + "name": "podMarketplace__orderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -54051,22 +54327,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "cancelledAmount", - "description": "The number of Pods that were remaining in *this* PodListing when it was Cancelled.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "createdAt", "description": "Timestamp of PodListing creation.", @@ -54562,6 +54822,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": "Where these pods were in line when cancelled", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "protocol", "description": " The protocol this transaction belongs to ", @@ -55968,6 +56244,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "protocol", "description": null, @@ -56297,6 +56685,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "protocol", "description": null, @@ -56551,6 +56945,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": "Where these pods were in line when listed", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "pricePerPod", "description": "Price per pod", @@ -58461,6 +58871,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "pricePerPod", "description": null, @@ -59286,6 +59808,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "pricePerPod", "description": null, @@ -59528,6 +60056,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": "Where these pods were in line when filled", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "protocol", "description": " The protocol this transaction belongs to ", @@ -61190,6 +61734,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "protocol", "description": null, @@ -61899,6 +62555,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "protocol", "description": null, @@ -62114,118 +62776,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "cancelledAmount", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cancelledAmount_gt", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cancelledAmount_gte", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cancelledAmount_in", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cancelledAmount_lt", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cancelledAmount_lte", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cancelledAmount_not", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cancelledAmount_not_in", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "createdAt", "description": null, @@ -65725,12 +66275,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "cancelledAmount", - "description": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "createdAt", "description": null, @@ -65797,6 +66341,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "fill__placeInLine", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "fill__start", "description": null, @@ -65870,7 +66420,7 @@ "deprecationReason": null }, { - "name": "plot__beans", + "name": "plot__beansPerPod", "description": null, "isDeprecated": false, "deprecationReason": null @@ -65936,19 +66486,19 @@ "deprecationReason": null }, { - "name": "plot__sownPods", + "name": "plot__sourceHash", "description": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "plot__temperature", + "name": "plot__updatedAt", "description": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "plot__updatedAt", + "name": "plot__updatedAtBlock", "description": null, "isDeprecated": false, "deprecationReason": null @@ -65965,6 +66515,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "podMarketplace__availableOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace__beanVolume", "description": null, @@ -65978,7 +66534,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__cancelledOrderedPods", + "name": "podMarketplace__cancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -65995,6 +66551,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "podMarketplace__filledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace__filledOrderedPods", "description": null, @@ -66014,7 +66576,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__orderedPods", + "name": "podMarketplace__orderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -66081,6 +66643,54 @@ "name": "PodMarketplace", "description": null, "fields": [ + { + "name": "activeListings", + "description": "Information about the active pod listings. Each entry of the form 'account-index-expiry'", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeOrders", + "description": "Information about the active pod orders. Each entry of the form 'orderId-maxPlaceInLine'", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "allListings", "description": "All historical listings", @@ -66267,6 +66877,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "availableOrderBeans", + "description": "Current amount of total beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "beanVolume", "description": "Cumulative bean volume between listings and orders", @@ -66300,8 +66926,8 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods", - "description": "Current cumulative pod orders cancelled", + "name": "cancelledOrderBeans", + "description": "Current cumulative beans in pod orders cancelled", "args": [], "type": { "kind": "NON_NULL", @@ -66432,6 +67058,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "filledOrderBeans", + "description": "Current cumulative filled beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "filledOrderedPods", "description": "Current cumulative pod orders filled", @@ -66651,32 +67293,8 @@ "deprecationReason": null }, { - "name": "listingIndexes", - "description": "Indexes of actively listed plots", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orderedPods", - "description": "Current cumulative pod orders created", + "name": "orderBeans", + "description": "Current cumulative beans in pod orders created", "args": [], "type": { "kind": "NON_NULL", @@ -66690,91 +67308,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "orders", - "description": "Active pod order IDs", - "args": [ - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "100", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orderBy", - "description": null, - "type": { - "kind": "ENUM", - "name": "PodOrder_orderBy", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orderDirection", - "description": null, - "type": { - "kind": "ENUM", - "name": "OrderDirection", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "skip", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": "0", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "where", - "description": null, - "type": { - "kind": "INPUT_OBJECT", - "name": "PodOrder_filter", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PodOrder", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "podVolume", "description": "Cumulative pod volume between listings and orders", @@ -66834,6 +67367,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "availableOrderBeans", + "description": "Current amount of total beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "beanVolume", "description": "Point in time current cumulative bean volume between listings and orders", @@ -66867,8 +67416,8 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods", - "description": "Point in time current cumulative pod orders cancelled", + "name": "cancelledOrderBeans", + "description": "Current cumulative beans in pod orders cancelled", "args": [], "type": { "kind": "NON_NULL", @@ -66914,6 +67463,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaAvailableOrderBeans", + "description": "Point in time current delta available ordered beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaBeanVolume", "description": "Point in time current delta bean volume between listings and orders", @@ -66947,8 +67512,8 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods", - "description": "Point in time current delta pod orders cancelled", + "name": "deltaCancelledOrderBeans", + "description": "Point in time current delta cancelled ordered beans in pod orders", "args": [], "type": { "kind": "NON_NULL", @@ -66994,6 +67559,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaFilledOrderBeans", + "description": "Point in time current delta filled ordered beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaFilledOrderedPods", "description": "Point in time current delta pod orders filled", @@ -67027,8 +67608,8 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods", - "description": "Point in time current delta pod orders created", + "name": "deltaOrderBeans", + "description": "Point in time current delta ordered beans in pod orders created", "args": [], "type": { "kind": "NON_NULL", @@ -67090,9 +67671,25 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "filledOrderBeans", + "description": "Current cumulative filled beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "filledOrderedPods", - "description": "Point in time current cumulative pod orders filled", + "description": "Current cumulative pod orders filled", "args": [], "type": { "kind": "NON_NULL", @@ -67139,8 +67736,8 @@ "deprecationReason": null }, { - "name": "orderedPods", - "description": "Point in time current cumulative pod orders created", + "name": "orderBeans", + "description": "Current cumulative beans in pod orders created", "args": [], "type": { "kind": "NON_NULL", @@ -67371,7 +67968,7 @@ "deprecationReason": null }, { - "name": "beanVolume", + "name": "availableOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -67383,7 +67980,7 @@ "deprecationReason": null }, { - "name": "beanVolume_gt", + "name": "availableOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -67395,7 +67992,7 @@ "deprecationReason": null }, { - "name": "beanVolume_gte", + "name": "availableOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -67407,7 +68004,7 @@ "deprecationReason": null }, { - "name": "beanVolume_in", + "name": "availableOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -67427,7 +68024,7 @@ "deprecationReason": null }, { - "name": "beanVolume_lt", + "name": "availableOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -67439,7 +68036,7 @@ "deprecationReason": null }, { - "name": "beanVolume_lte", + "name": "availableOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -67451,7 +68048,7 @@ "deprecationReason": null }, { - "name": "beanVolume_not", + "name": "availableOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -67463,7 +68060,7 @@ "deprecationReason": null }, { - "name": "beanVolume_not_in", + "name": "availableOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -67483,7 +68080,7 @@ "deprecationReason": null }, { - "name": "cancelledListedPods", + "name": "beanVolume", "description": null, "type": { "kind": "SCALAR", @@ -67495,7 +68092,7 @@ "deprecationReason": null }, { - "name": "cancelledListedPods_gt", + "name": "beanVolume_gt", "description": null, "type": { "kind": "SCALAR", @@ -67507,7 +68104,7 @@ "deprecationReason": null }, { - "name": "cancelledListedPods_gte", + "name": "beanVolume_gte", "description": null, "type": { "kind": "SCALAR", @@ -67519,7 +68116,7 @@ "deprecationReason": null }, { - "name": "cancelledListedPods_in", + "name": "beanVolume_in", "description": null, "type": { "kind": "LIST", @@ -67539,7 +68136,7 @@ "deprecationReason": null }, { - "name": "cancelledListedPods_lt", + "name": "beanVolume_lt", "description": null, "type": { "kind": "SCALAR", @@ -67551,7 +68148,7 @@ "deprecationReason": null }, { - "name": "cancelledListedPods_lte", + "name": "beanVolume_lte", "description": null, "type": { "kind": "SCALAR", @@ -67563,7 +68160,7 @@ "deprecationReason": null }, { - "name": "cancelledListedPods_not", + "name": "beanVolume_not", "description": null, "type": { "kind": "SCALAR", @@ -67575,7 +68172,7 @@ "deprecationReason": null }, { - "name": "cancelledListedPods_not_in", + "name": "beanVolume_not_in", "description": null, "type": { "kind": "LIST", @@ -67595,7 +68192,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods", + "name": "cancelledListedPods", "description": null, "type": { "kind": "SCALAR", @@ -67607,7 +68204,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_gt", + "name": "cancelledListedPods_gt", "description": null, "type": { "kind": "SCALAR", @@ -67619,7 +68216,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_gte", + "name": "cancelledListedPods_gte", "description": null, "type": { "kind": "SCALAR", @@ -67631,7 +68228,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_in", + "name": "cancelledListedPods_in", "description": null, "type": { "kind": "LIST", @@ -67651,7 +68248,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_lt", + "name": "cancelledListedPods_lt", "description": null, "type": { "kind": "SCALAR", @@ -67663,7 +68260,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_lte", + "name": "cancelledListedPods_lte", "description": null, "type": { "kind": "SCALAR", @@ -67675,7 +68272,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_not", + "name": "cancelledListedPods_not", "description": null, "type": { "kind": "SCALAR", @@ -67687,7 +68284,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_not_in", + "name": "cancelledListedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -67707,7 +68304,7 @@ "deprecationReason": null }, { - "name": "createdAt", + "name": "cancelledOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -67719,7 +68316,7 @@ "deprecationReason": null }, { - "name": "createdAt_gt", + "name": "cancelledOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -67731,7 +68328,7 @@ "deprecationReason": null }, { - "name": "createdAt_gte", + "name": "cancelledOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -67743,7 +68340,7 @@ "deprecationReason": null }, { - "name": "createdAt_in", + "name": "cancelledOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -67763,7 +68360,7 @@ "deprecationReason": null }, { - "name": "createdAt_lt", + "name": "cancelledOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -67775,7 +68372,7 @@ "deprecationReason": null }, { - "name": "createdAt_lte", + "name": "cancelledOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -67787,7 +68384,7 @@ "deprecationReason": null }, { - "name": "createdAt_not", + "name": "cancelledOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -67799,7 +68396,7 @@ "deprecationReason": null }, { - "name": "createdAt_not_in", + "name": "cancelledOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -67819,7 +68416,7 @@ "deprecationReason": null }, { - "name": "deltaAvailableListedPods", + "name": "createdAt", "description": null, "type": { "kind": "SCALAR", @@ -67831,7 +68428,7 @@ "deprecationReason": null }, { - "name": "deltaAvailableListedPods_gt", + "name": "createdAt_gt", "description": null, "type": { "kind": "SCALAR", @@ -67843,7 +68440,7 @@ "deprecationReason": null }, { - "name": "deltaAvailableListedPods_gte", + "name": "createdAt_gte", "description": null, "type": { "kind": "SCALAR", @@ -67855,7 +68452,7 @@ "deprecationReason": null }, { - "name": "deltaAvailableListedPods_in", + "name": "createdAt_in", "description": null, "type": { "kind": "LIST", @@ -67875,7 +68472,7 @@ "deprecationReason": null }, { - "name": "deltaAvailableListedPods_lt", + "name": "createdAt_lt", "description": null, "type": { "kind": "SCALAR", @@ -67887,7 +68484,7 @@ "deprecationReason": null }, { - "name": "deltaAvailableListedPods_lte", + "name": "createdAt_lte", "description": null, "type": { "kind": "SCALAR", @@ -67899,7 +68496,7 @@ "deprecationReason": null }, { - "name": "deltaAvailableListedPods_not", + "name": "createdAt_not", "description": null, "type": { "kind": "SCALAR", @@ -67911,7 +68508,7 @@ "deprecationReason": null }, { - "name": "deltaAvailableListedPods_not_in", + "name": "createdAt_not_in", "description": null, "type": { "kind": "LIST", @@ -67931,7 +68528,7 @@ "deprecationReason": null }, { - "name": "deltaBeanVolume", + "name": "deltaAvailableListedPods", "description": null, "type": { "kind": "SCALAR", @@ -67943,7 +68540,7 @@ "deprecationReason": null }, { - "name": "deltaBeanVolume_gt", + "name": "deltaAvailableListedPods_gt", "description": null, "type": { "kind": "SCALAR", @@ -67955,7 +68552,7 @@ "deprecationReason": null }, { - "name": "deltaBeanVolume_gte", + "name": "deltaAvailableListedPods_gte", "description": null, "type": { "kind": "SCALAR", @@ -67967,7 +68564,7 @@ "deprecationReason": null }, { - "name": "deltaBeanVolume_in", + "name": "deltaAvailableListedPods_in", "description": null, "type": { "kind": "LIST", @@ -67987,7 +68584,7 @@ "deprecationReason": null }, { - "name": "deltaBeanVolume_lt", + "name": "deltaAvailableListedPods_lt", "description": null, "type": { "kind": "SCALAR", @@ -67999,7 +68596,7 @@ "deprecationReason": null }, { - "name": "deltaBeanVolume_lte", + "name": "deltaAvailableListedPods_lte", "description": null, "type": { "kind": "SCALAR", @@ -68011,7 +68608,7 @@ "deprecationReason": null }, { - "name": "deltaBeanVolume_not", + "name": "deltaAvailableListedPods_not", "description": null, "type": { "kind": "SCALAR", @@ -68023,7 +68620,7 @@ "deprecationReason": null }, { - "name": "deltaBeanVolume_not_in", + "name": "deltaAvailableListedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -68043,7 +68640,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledListedPods", + "name": "deltaAvailableOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -68055,7 +68652,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledListedPods_gt", + "name": "deltaAvailableOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -68067,7 +68664,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledListedPods_gte", + "name": "deltaAvailableOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -68079,7 +68676,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledListedPods_in", + "name": "deltaAvailableOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -68099,7 +68696,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledListedPods_lt", + "name": "deltaAvailableOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -68111,7 +68708,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledListedPods_lte", + "name": "deltaAvailableOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -68123,7 +68720,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledListedPods_not", + "name": "deltaAvailableOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -68135,7 +68732,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledListedPods_not_in", + "name": "deltaAvailableOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -68155,7 +68752,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods", + "name": "deltaBeanVolume", "description": null, "type": { "kind": "SCALAR", @@ -68167,7 +68764,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_gt", + "name": "deltaBeanVolume_gt", "description": null, "type": { "kind": "SCALAR", @@ -68179,7 +68776,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_gte", + "name": "deltaBeanVolume_gte", "description": null, "type": { "kind": "SCALAR", @@ -68191,7 +68788,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_in", + "name": "deltaBeanVolume_in", "description": null, "type": { "kind": "LIST", @@ -68211,7 +68808,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_lt", + "name": "deltaBeanVolume_lt", "description": null, "type": { "kind": "SCALAR", @@ -68223,7 +68820,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_lte", + "name": "deltaBeanVolume_lte", "description": null, "type": { "kind": "SCALAR", @@ -68235,7 +68832,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_not", + "name": "deltaBeanVolume_not", "description": null, "type": { "kind": "SCALAR", @@ -68247,7 +68844,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_not_in", + "name": "deltaBeanVolume_not_in", "description": null, "type": { "kind": "LIST", @@ -68267,7 +68864,7 @@ "deprecationReason": null }, { - "name": "deltaExpiredListedPods", + "name": "deltaCancelledListedPods", "description": null, "type": { "kind": "SCALAR", @@ -68279,7 +68876,7 @@ "deprecationReason": null }, { - "name": "deltaExpiredListedPods_gt", + "name": "deltaCancelledListedPods_gt", "description": null, "type": { "kind": "SCALAR", @@ -68291,7 +68888,7 @@ "deprecationReason": null }, { - "name": "deltaExpiredListedPods_gte", + "name": "deltaCancelledListedPods_gte", "description": null, "type": { "kind": "SCALAR", @@ -68303,7 +68900,7 @@ "deprecationReason": null }, { - "name": "deltaExpiredListedPods_in", + "name": "deltaCancelledListedPods_in", "description": null, "type": { "kind": "LIST", @@ -68323,7 +68920,7 @@ "deprecationReason": null }, { - "name": "deltaExpiredListedPods_lt", + "name": "deltaCancelledListedPods_lt", "description": null, "type": { "kind": "SCALAR", @@ -68335,7 +68932,7 @@ "deprecationReason": null }, { - "name": "deltaExpiredListedPods_lte", + "name": "deltaCancelledListedPods_lte", "description": null, "type": { "kind": "SCALAR", @@ -68347,7 +68944,7 @@ "deprecationReason": null }, { - "name": "deltaExpiredListedPods_not", + "name": "deltaCancelledListedPods_not", "description": null, "type": { "kind": "SCALAR", @@ -68359,7 +68956,7 @@ "deprecationReason": null }, { - "name": "deltaExpiredListedPods_not_in", + "name": "deltaCancelledListedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -68379,7 +68976,7 @@ "deprecationReason": null }, { - "name": "deltaFilledListedPods", + "name": "deltaCancelledOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -68391,7 +68988,7 @@ "deprecationReason": null }, { - "name": "deltaFilledListedPods_gt", + "name": "deltaCancelledOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -68403,7 +69000,7 @@ "deprecationReason": null }, { - "name": "deltaFilledListedPods_gte", + "name": "deltaCancelledOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -68415,7 +69012,7 @@ "deprecationReason": null }, { - "name": "deltaFilledListedPods_in", + "name": "deltaCancelledOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -68435,7 +69032,7 @@ "deprecationReason": null }, { - "name": "deltaFilledListedPods_lt", + "name": "deltaCancelledOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -68447,7 +69044,7 @@ "deprecationReason": null }, { - "name": "deltaFilledListedPods_lte", + "name": "deltaCancelledOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -68459,7 +69056,7 @@ "deprecationReason": null }, { - "name": "deltaFilledListedPods_not", + "name": "deltaCancelledOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -68471,7 +69068,7 @@ "deprecationReason": null }, { - "name": "deltaFilledListedPods_not_in", + "name": "deltaCancelledOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -68491,7 +69088,7 @@ "deprecationReason": null }, { - "name": "deltaFilledOrderedPods", + "name": "deltaExpiredListedPods", "description": null, "type": { "kind": "SCALAR", @@ -68503,7 +69100,7 @@ "deprecationReason": null }, { - "name": "deltaFilledOrderedPods_gt", + "name": "deltaExpiredListedPods_gt", "description": null, "type": { "kind": "SCALAR", @@ -68515,7 +69112,7 @@ "deprecationReason": null }, { - "name": "deltaFilledOrderedPods_gte", + "name": "deltaExpiredListedPods_gte", "description": null, "type": { "kind": "SCALAR", @@ -68527,7 +69124,7 @@ "deprecationReason": null }, { - "name": "deltaFilledOrderedPods_in", + "name": "deltaExpiredListedPods_in", "description": null, "type": { "kind": "LIST", @@ -68547,7 +69144,7 @@ "deprecationReason": null }, { - "name": "deltaFilledOrderedPods_lt", + "name": "deltaExpiredListedPods_lt", "description": null, "type": { "kind": "SCALAR", @@ -68559,7 +69156,7 @@ "deprecationReason": null }, { - "name": "deltaFilledOrderedPods_lte", + "name": "deltaExpiredListedPods_lte", "description": null, "type": { "kind": "SCALAR", @@ -68571,7 +69168,7 @@ "deprecationReason": null }, { - "name": "deltaFilledOrderedPods_not", + "name": "deltaExpiredListedPods_not", "description": null, "type": { "kind": "SCALAR", @@ -68583,7 +69180,7 @@ "deprecationReason": null }, { - "name": "deltaFilledOrderedPods_not_in", + "name": "deltaExpiredListedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -68603,7 +69200,7 @@ "deprecationReason": null }, { - "name": "deltaListedPods", + "name": "deltaFilledListedPods", "description": null, "type": { "kind": "SCALAR", @@ -68615,7 +69212,7 @@ "deprecationReason": null }, { - "name": "deltaListedPods_gt", + "name": "deltaFilledListedPods_gt", "description": null, "type": { "kind": "SCALAR", @@ -68627,7 +69224,7 @@ "deprecationReason": null }, { - "name": "deltaListedPods_gte", + "name": "deltaFilledListedPods_gte", "description": null, "type": { "kind": "SCALAR", @@ -68639,7 +69236,7 @@ "deprecationReason": null }, { - "name": "deltaListedPods_in", + "name": "deltaFilledListedPods_in", "description": null, "type": { "kind": "LIST", @@ -68659,7 +69256,7 @@ "deprecationReason": null }, { - "name": "deltaListedPods_lt", + "name": "deltaFilledListedPods_lt", "description": null, "type": { "kind": "SCALAR", @@ -68671,7 +69268,7 @@ "deprecationReason": null }, { - "name": "deltaListedPods_lte", + "name": "deltaFilledListedPods_lte", "description": null, "type": { "kind": "SCALAR", @@ -68683,7 +69280,7 @@ "deprecationReason": null }, { - "name": "deltaListedPods_not", + "name": "deltaFilledListedPods_not", "description": null, "type": { "kind": "SCALAR", @@ -68695,7 +69292,7 @@ "deprecationReason": null }, { - "name": "deltaListedPods_not_in", + "name": "deltaFilledListedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -68715,7 +69312,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods", + "name": "deltaFilledOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -68727,7 +69324,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_gt", + "name": "deltaFilledOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -68739,7 +69336,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_gte", + "name": "deltaFilledOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -68751,7 +69348,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_in", + "name": "deltaFilledOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -68771,7 +69368,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_lt", + "name": "deltaFilledOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -68783,7 +69380,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_lte", + "name": "deltaFilledOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -68795,7 +69392,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_not", + "name": "deltaFilledOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -68807,7 +69404,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_not_in", + "name": "deltaFilledOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -68827,7 +69424,7 @@ "deprecationReason": null }, { - "name": "deltaPodVolume", + "name": "deltaFilledOrderedPods", "description": null, "type": { "kind": "SCALAR", @@ -68839,7 +69436,7 @@ "deprecationReason": null }, { - "name": "deltaPodVolume_gt", + "name": "deltaFilledOrderedPods_gt", "description": null, "type": { "kind": "SCALAR", @@ -68851,7 +69448,7 @@ "deprecationReason": null }, { - "name": "deltaPodVolume_gte", + "name": "deltaFilledOrderedPods_gte", "description": null, "type": { "kind": "SCALAR", @@ -68863,7 +69460,7 @@ "deprecationReason": null }, { - "name": "deltaPodVolume_in", + "name": "deltaFilledOrderedPods_in", "description": null, "type": { "kind": "LIST", @@ -68883,7 +69480,7 @@ "deprecationReason": null }, { - "name": "deltaPodVolume_lt", + "name": "deltaFilledOrderedPods_lt", "description": null, "type": { "kind": "SCALAR", @@ -68895,7 +69492,7 @@ "deprecationReason": null }, { - "name": "deltaPodVolume_lte", + "name": "deltaFilledOrderedPods_lte", "description": null, "type": { "kind": "SCALAR", @@ -68907,7 +69504,7 @@ "deprecationReason": null }, { - "name": "deltaPodVolume_not", + "name": "deltaFilledOrderedPods_not", "description": null, "type": { "kind": "SCALAR", @@ -68919,7 +69516,7 @@ "deprecationReason": null }, { - "name": "deltaPodVolume_not_in", + "name": "deltaFilledOrderedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -68939,7 +69536,7 @@ "deprecationReason": null }, { - "name": "expiredListedPods", + "name": "deltaListedPods", "description": null, "type": { "kind": "SCALAR", @@ -68951,7 +69548,7 @@ "deprecationReason": null }, { - "name": "expiredListedPods_gt", + "name": "deltaListedPods_gt", "description": null, "type": { "kind": "SCALAR", @@ -68963,7 +69560,7 @@ "deprecationReason": null }, { - "name": "expiredListedPods_gte", + "name": "deltaListedPods_gte", "description": null, "type": { "kind": "SCALAR", @@ -68975,7 +69572,7 @@ "deprecationReason": null }, { - "name": "expiredListedPods_in", + "name": "deltaListedPods_in", "description": null, "type": { "kind": "LIST", @@ -68995,7 +69592,7 @@ "deprecationReason": null }, { - "name": "expiredListedPods_lt", + "name": "deltaListedPods_lt", "description": null, "type": { "kind": "SCALAR", @@ -69007,7 +69604,7 @@ "deprecationReason": null }, { - "name": "expiredListedPods_lte", + "name": "deltaListedPods_lte", "description": null, "type": { "kind": "SCALAR", @@ -69019,7 +69616,7 @@ "deprecationReason": null }, { - "name": "expiredListedPods_not", + "name": "deltaListedPods_not", "description": null, "type": { "kind": "SCALAR", @@ -69031,7 +69628,7 @@ "deprecationReason": null }, { - "name": "expiredListedPods_not_in", + "name": "deltaListedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -69051,7 +69648,7 @@ "deprecationReason": null }, { - "name": "filledListedPods", + "name": "deltaOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -69063,7 +69660,7 @@ "deprecationReason": null }, { - "name": "filledListedPods_gt", + "name": "deltaOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -69075,7 +69672,7 @@ "deprecationReason": null }, { - "name": "filledListedPods_gte", + "name": "deltaOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -69087,7 +69684,7 @@ "deprecationReason": null }, { - "name": "filledListedPods_in", + "name": "deltaOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -69107,7 +69704,7 @@ "deprecationReason": null }, { - "name": "filledListedPods_lt", + "name": "deltaOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -69119,7 +69716,7 @@ "deprecationReason": null }, { - "name": "filledListedPods_lte", + "name": "deltaOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -69131,7 +69728,7 @@ "deprecationReason": null }, { - "name": "filledListedPods_not", + "name": "deltaOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -69143,7 +69740,7 @@ "deprecationReason": null }, { - "name": "filledListedPods_not_in", + "name": "deltaOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -69163,7 +69760,7 @@ "deprecationReason": null }, { - "name": "filledOrderedPods", + "name": "deltaPodVolume", "description": null, "type": { "kind": "SCALAR", @@ -69175,7 +69772,7 @@ "deprecationReason": null }, { - "name": "filledOrderedPods_gt", + "name": "deltaPodVolume_gt", "description": null, "type": { "kind": "SCALAR", @@ -69187,7 +69784,7 @@ "deprecationReason": null }, { - "name": "filledOrderedPods_gte", + "name": "deltaPodVolume_gte", "description": null, "type": { "kind": "SCALAR", @@ -69199,7 +69796,7 @@ "deprecationReason": null }, { - "name": "filledOrderedPods_in", + "name": "deltaPodVolume_in", "description": null, "type": { "kind": "LIST", @@ -69219,7 +69816,7 @@ "deprecationReason": null }, { - "name": "filledOrderedPods_lt", + "name": "deltaPodVolume_lt", "description": null, "type": { "kind": "SCALAR", @@ -69231,7 +69828,7 @@ "deprecationReason": null }, { - "name": "filledOrderedPods_lte", + "name": "deltaPodVolume_lte", "description": null, "type": { "kind": "SCALAR", @@ -69243,7 +69840,7 @@ "deprecationReason": null }, { - "name": "filledOrderedPods_not", + "name": "deltaPodVolume_not", "description": null, "type": { "kind": "SCALAR", @@ -69255,7 +69852,7 @@ "deprecationReason": null }, { - "name": "filledOrderedPods_not_in", + "name": "deltaPodVolume_not_in", "description": null, "type": { "kind": "LIST", @@ -69275,11 +69872,11 @@ "deprecationReason": null }, { - "name": "id", + "name": "expiredListedPods", "description": null, "type": { "kind": "SCALAR", - "name": "ID", + "name": "BigInt", "ofType": null }, "defaultValue": null, @@ -69287,11 +69884,11 @@ "deprecationReason": null }, { - "name": "id_gt", + "name": "expiredListedPods_gt", "description": null, "type": { "kind": "SCALAR", - "name": "ID", + "name": "BigInt", "ofType": null }, "defaultValue": null, @@ -69299,11 +69896,11 @@ "deprecationReason": null }, { - "name": "id_gte", + "name": "expiredListedPods_gte", "description": null, "type": { "kind": "SCALAR", - "name": "ID", + "name": "BigInt", "ofType": null }, "defaultValue": null, @@ -69311,7 +69908,7 @@ "deprecationReason": null }, { - "name": "id_in", + "name": "expiredListedPods_in", "description": null, "type": { "kind": "LIST", @@ -69321,7 +69918,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "ID", + "name": "BigInt", "ofType": null } } @@ -69331,11 +69928,11 @@ "deprecationReason": null }, { - "name": "id_lt", + "name": "expiredListedPods_lt", "description": null, "type": { "kind": "SCALAR", - "name": "ID", + "name": "BigInt", "ofType": null }, "defaultValue": null, @@ -69343,11 +69940,11 @@ "deprecationReason": null }, { - "name": "id_lte", + "name": "expiredListedPods_lte", "description": null, "type": { "kind": "SCALAR", - "name": "ID", + "name": "BigInt", "ofType": null }, "defaultValue": null, @@ -69355,11 +69952,11 @@ "deprecationReason": null }, { - "name": "id_not", + "name": "expiredListedPods_not", "description": null, "type": { "kind": "SCALAR", - "name": "ID", + "name": "BigInt", "ofType": null }, "defaultValue": null, @@ -69367,7 +69964,7 @@ "deprecationReason": null }, { - "name": "id_not_in", + "name": "expiredListedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -69377,7 +69974,7 @@ "name": null, "ofType": { "kind": "SCALAR", - "name": "ID", + "name": "BigInt", "ofType": null } } @@ -69387,7 +69984,7 @@ "deprecationReason": null }, { - "name": "listedPods", + "name": "filledListedPods", "description": null, "type": { "kind": "SCALAR", @@ -69399,7 +69996,7 @@ "deprecationReason": null }, { - "name": "listedPods_gt", + "name": "filledListedPods_gt", "description": null, "type": { "kind": "SCALAR", @@ -69411,7 +70008,7 @@ "deprecationReason": null }, { - "name": "listedPods_gte", + "name": "filledListedPods_gte", "description": null, "type": { "kind": "SCALAR", @@ -69423,7 +70020,7 @@ "deprecationReason": null }, { - "name": "listedPods_in", + "name": "filledListedPods_in", "description": null, "type": { "kind": "LIST", @@ -69443,7 +70040,7 @@ "deprecationReason": null }, { - "name": "listedPods_lt", + "name": "filledListedPods_lt", "description": null, "type": { "kind": "SCALAR", @@ -69455,7 +70052,7 @@ "deprecationReason": null }, { - "name": "listedPods_lte", + "name": "filledListedPods_lte", "description": null, "type": { "kind": "SCALAR", @@ -69467,7 +70064,7 @@ "deprecationReason": null }, { - "name": "listedPods_not", + "name": "filledListedPods_not", "description": null, "type": { "kind": "SCALAR", @@ -69479,7 +70076,7 @@ "deprecationReason": null }, { - "name": "listedPods_not_in", + "name": "filledListedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -69499,23 +70096,19 @@ "deprecationReason": null }, { - "name": "or", + "name": "filledOrderBeans", "description": null, "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "PodMarketplaceDailySnapshot_filter", - "ofType": null - } + "kind": "SCALAR", + "name": "BigInt", + "ofType": null }, "defaultValue": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "orderedPods", + "name": "filledOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -69527,7 +70120,7 @@ "deprecationReason": null }, { - "name": "orderedPods_gt", + "name": "filledOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -69539,7 +70132,387 @@ "deprecationReason": null }, { - "name": "orderedPods_gte", + "name": "filledOrderBeans_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderedPods", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderedPods_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderedPods_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderedPods_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderedPods_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderedPods_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderedPods_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderedPods_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id", + "description": null, + "type": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "id_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "listedPods", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "listedPods_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "listedPods_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "listedPods_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "listedPods_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "listedPods_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "listedPods_not", "description": null, "type": { "kind": "SCALAR", @@ -69551,7 +70524,7 @@ "deprecationReason": null }, { - "name": "orderedPods_in", + "name": "listedPods_not_in", "description": null, "type": { "kind": "LIST", @@ -69571,7 +70544,23 @@ "deprecationReason": null }, { - "name": "orderedPods_lt", + "name": "or", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "PodMarketplaceDailySnapshot_filter", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "orderBeans", "description": null, "type": { "kind": "SCALAR", @@ -69583,7 +70572,7 @@ "deprecationReason": null }, { - "name": "orderedPods_lte", + "name": "orderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -69595,7 +70584,7 @@ "deprecationReason": null }, { - "name": "orderedPods_not", + "name": "orderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -69607,7 +70596,63 @@ "deprecationReason": null }, { - "name": "orderedPods_not_in", + "name": "orderBeans_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "orderBeans_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "orderBeans_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "orderBeans_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "orderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -70249,6 +71294,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "availableOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "beanVolume", "description": null, @@ -70262,7 +71313,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods", + "name": "cancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -70279,6 +71330,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaAvailableOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaBeanVolume", "description": null, @@ -70292,7 +71349,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods", + "name": "deltaCancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -70309,6 +71366,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaFilledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaFilledOrderedPods", "description": null, @@ -70322,7 +71385,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods", + "name": "deltaOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -70345,6 +71408,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "filledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "filledOrderedPods", "description": null, @@ -70364,7 +71433,7 @@ "deprecationReason": null }, { - "name": "orderedPods", + "name": "orderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -70381,6 +71450,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "podMarketplace__availableOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace__beanVolume", "description": null, @@ -70394,7 +71469,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__cancelledOrderedPods", + "name": "podMarketplace__cancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -70411,6 +71486,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "podMarketplace__filledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace__filledOrderedPods", "description": null, @@ -70430,7 +71511,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__orderedPods", + "name": "podMarketplace__orderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -70489,6 +71570,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "availableOrderBeans", + "description": "Current amount of total beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "beanVolume", "description": "Point in time current cumulative bean volume between listings and orders", @@ -70522,8 +71619,8 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods", - "description": "Point in time current cumulative pod orders cancelled", + "name": "cancelledOrderBeans", + "description": "Current cumulative beans in pod orders cancelled", "args": [], "type": { "kind": "NON_NULL", @@ -70569,6 +71666,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaAvailableOrderBeans", + "description": "Point in time current delta available ordered beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaBeanVolume", "description": "Point in time current delta bean volume between listings and orders", @@ -70602,8 +71715,8 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods", - "description": "Point in time current delta pod orders cancelled", + "name": "deltaCancelledOrderBeans", + "description": "Point in time current delta cancelled ordered beans in pod orders", "args": [], "type": { "kind": "NON_NULL", @@ -70649,6 +71762,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaFilledOrderBeans", + "description": "Point in time current delta filled ordered beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaFilledOrderedPods", "description": "Point in time current delta pod orders filled", @@ -70682,8 +71811,8 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods", - "description": "Point in time current delta pod orders created", + "name": "deltaOrderBeans", + "description": "Point in time current delta ordered beans in pod orders created", "args": [], "type": { "kind": "NON_NULL", @@ -70745,9 +71874,25 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "filledOrderBeans", + "description": "Current cumulative filled beans in pod orders", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "filledOrderedPods", - "description": "Point in time current cumulative pod orders filled", + "description": "Current cumulative pod orders filled", "args": [], "type": { "kind": "NON_NULL", @@ -70794,8 +71939,8 @@ "deprecationReason": null }, { - "name": "orderedPods", - "description": "Point in time current cumulative pod orders created", + "name": "orderBeans", + "description": "Current cumulative beans in pod orders created", "args": [], "type": { "kind": "NON_NULL", @@ -71025,6 +72170,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "availableOrderBeans", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "beanVolume", "description": null, @@ -71250,7 +72507,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods", + "name": "cancelledOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -71262,7 +72519,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_gt", + "name": "cancelledOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -71274,7 +72531,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_gte", + "name": "cancelledOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -71286,7 +72543,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_in", + "name": "cancelledOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -71306,7 +72563,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_lt", + "name": "cancelledOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -71318,7 +72575,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_lte", + "name": "cancelledOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -71330,7 +72587,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_not", + "name": "cancelledOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -71342,7 +72599,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_not_in", + "name": "cancelledOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -71585,6 +72842,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaAvailableOrderBeans", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaAvailableOrderBeans_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaAvailableOrderBeans_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaAvailableOrderBeans_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaAvailableOrderBeans_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaAvailableOrderBeans_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaAvailableOrderBeans_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaAvailableOrderBeans_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaBeanVolume", "description": null, @@ -71810,7 +73179,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods", + "name": "deltaCancelledOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -71822,7 +73191,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_gt", + "name": "deltaCancelledOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -71834,7 +73203,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_gte", + "name": "deltaCancelledOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -71846,7 +73215,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_in", + "name": "deltaCancelledOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -71866,7 +73235,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_lt", + "name": "deltaCancelledOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -71878,7 +73247,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_lte", + "name": "deltaCancelledOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -71890,7 +73259,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_not", + "name": "deltaCancelledOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -71902,7 +73271,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods_not_in", + "name": "deltaCancelledOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -72145,6 +73514,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaFilledOrderBeans", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaFilledOrderBeans_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaFilledOrderBeans_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaFilledOrderBeans_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaFilledOrderBeans_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaFilledOrderBeans_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaFilledOrderBeans_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deltaFilledOrderBeans_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaFilledOrderedPods", "description": null, @@ -72370,7 +73851,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods", + "name": "deltaOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -72382,7 +73863,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_gt", + "name": "deltaOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -72394,7 +73875,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_gte", + "name": "deltaOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -72406,7 +73887,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_in", + "name": "deltaOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -72426,7 +73907,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_lt", + "name": "deltaOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -72438,7 +73919,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_lte", + "name": "deltaOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -72450,7 +73931,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_not", + "name": "deltaOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -72462,7 +73943,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods_not_in", + "name": "deltaOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -72817,6 +74298,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "filledOrderBeans", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "filledOrderedPods", "description": null, @@ -73170,7 +74763,7 @@ "deprecationReason": null }, { - "name": "orderedPods", + "name": "orderBeans", "description": null, "type": { "kind": "SCALAR", @@ -73182,7 +74775,7 @@ "deprecationReason": null }, { - "name": "orderedPods_gt", + "name": "orderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -73194,7 +74787,7 @@ "deprecationReason": null }, { - "name": "orderedPods_gte", + "name": "orderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -73206,7 +74799,7 @@ "deprecationReason": null }, { - "name": "orderedPods_in", + "name": "orderBeans_in", "description": null, "type": { "kind": "LIST", @@ -73226,7 +74819,7 @@ "deprecationReason": null }, { - "name": "orderedPods_lt", + "name": "orderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -73238,7 +74831,7 @@ "deprecationReason": null }, { - "name": "orderedPods_lte", + "name": "orderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -73250,7 +74843,7 @@ "deprecationReason": null }, { - "name": "orderedPods_not", + "name": "orderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -73262,7 +74855,7 @@ "deprecationReason": null }, { - "name": "orderedPods_not_in", + "name": "orderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -73904,6 +75497,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "availableOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "beanVolume", "description": null, @@ -73917,7 +75516,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods", + "name": "cancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -73934,6 +75533,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaAvailableOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaBeanVolume", "description": null, @@ -73947,7 +75552,7 @@ "deprecationReason": null }, { - "name": "deltaCancelledOrderedPods", + "name": "deltaCancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -73964,6 +75569,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deltaFilledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "deltaFilledOrderedPods", "description": null, @@ -73977,7 +75588,7 @@ "deprecationReason": null }, { - "name": "deltaOrderedPods", + "name": "deltaOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -74000,6 +75611,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "filledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "filledOrderedPods", "description": null, @@ -74019,7 +75636,7 @@ "deprecationReason": null }, { - "name": "orderedPods", + "name": "orderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -74036,6 +75653,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "podMarketplace__availableOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace__beanVolume", "description": null, @@ -74049,7 +75672,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__cancelledOrderedPods", + "name": "podMarketplace__cancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -74066,6 +75689,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "podMarketplace__filledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace__filledOrderedPods", "description": null, @@ -74085,7 +75714,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__orderedPods", + "name": "podMarketplace__orderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -74141,6 +75770,246 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "activeListings", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeListings_contains", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeListings_contains_nocase", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeListings_not", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeListings_not_contains", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeListings_not_contains_nocase", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeOrders", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeOrders_contains", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeOrders_contains_nocase", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeOrders_not", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeOrders_not_contains", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeOrders_not_contains_nocase", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "allListings_", "description": null, @@ -74293,6 +76162,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "availableOrderBeans", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "availableOrderBeans_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "beanVolume", "description": null, @@ -74518,7 +76499,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods", + "name": "cancelledOrderBeans", "description": null, "type": { "kind": "SCALAR", @@ -74530,7 +76511,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_gt", + "name": "cancelledOrderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -74542,7 +76523,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_gte", + "name": "cancelledOrderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -74554,7 +76535,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_in", + "name": "cancelledOrderBeans_in", "description": null, "type": { "kind": "LIST", @@ -74574,7 +76555,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_lt", + "name": "cancelledOrderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -74586,7 +76567,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_lte", + "name": "cancelledOrderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -74598,7 +76579,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_not", + "name": "cancelledOrderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -74610,7 +76591,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods_not_in", + "name": "cancelledOrderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -74865,6 +76846,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "filledOrderBeans", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "filledOrderBeans_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "filledOrderedPods", "description": null, @@ -75225,126 +77318,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "listingIndexes", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "listingIndexes_contains", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "listingIndexes_contains_nocase", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "listingIndexes_not", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "listingIndexes_not_contains", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "listingIndexes_not_contains_nocase", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "or", "description": null, @@ -75362,7 +77335,7 @@ "deprecationReason": null }, { - "name": "orderedPods", + "name": "orderBeans", "description": null, "type": { "kind": "SCALAR", @@ -75374,7 +77347,7 @@ "deprecationReason": null }, { - "name": "orderedPods_gt", + "name": "orderBeans_gt", "description": null, "type": { "kind": "SCALAR", @@ -75386,7 +77359,7 @@ "deprecationReason": null }, { - "name": "orderedPods_gte", + "name": "orderBeans_gte", "description": null, "type": { "kind": "SCALAR", @@ -75398,7 +77371,7 @@ "deprecationReason": null }, { - "name": "orderedPods_in", + "name": "orderBeans_in", "description": null, "type": { "kind": "LIST", @@ -75418,7 +77391,7 @@ "deprecationReason": null }, { - "name": "orderedPods_lt", + "name": "orderBeans_lt", "description": null, "type": { "kind": "SCALAR", @@ -75430,7 +77403,7 @@ "deprecationReason": null }, { - "name": "orderedPods_lte", + "name": "orderBeans_lte", "description": null, "type": { "kind": "SCALAR", @@ -75442,7 +77415,7 @@ "deprecationReason": null }, { - "name": "orderedPods_not", + "name": "orderBeans_not", "description": null, "type": { "kind": "SCALAR", @@ -75454,7 +77427,7 @@ "deprecationReason": null }, { - "name": "orderedPods_not_in", + "name": "orderBeans_not_in", "description": null, "type": { "kind": "LIST", @@ -75473,138 +77446,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "orders", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orders_", - "description": null, - "type": { - "kind": "INPUT_OBJECT", - "name": "PodOrder_filter", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orders_contains", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orders_contains_nocase", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orders_not", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orders_not_contains", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orders_not_contains_nocase", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "podVolume", "description": null, @@ -75842,6 +77683,18 @@ "inputFields": null, "interfaces": null, "enumValues": [ + { + "name": "activeListings", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "activeOrders", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "allListings", "description": null, @@ -75860,6 +77713,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "availableOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "beanVolume", "description": null, @@ -75873,7 +77732,7 @@ "deprecationReason": null }, { - "name": "cancelledOrderedPods", + "name": "cancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -75896,6 +77755,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "filledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "filledOrderedPods", "description": null, @@ -75927,19 +77792,7 @@ "deprecationReason": null }, { - "name": "listingIndexes", - "description": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orderedPods", - "description": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orders", + "name": "orderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -76193,22 +78046,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "podAmount", - "description": "The original number of Pods requested by this PodOrder.\n\nDoes NOT change as Fills occur.\nNot deterministic for PodOrders with pricingType = DYNAMIC.\n\nIf pricingType = FIXED:\n Set to the number of Pods which can be purchased by the Order.\n If FIXED (V1): `amount` field emitted in PodOrderCreated.\n If FIXED (V2): `amount / pricePerPod` fields emitted in PodOrderCreated.\n\nIf pricingType = DYNAMIC:\n Set to `0`. The number of Pods that will be provided is unknown, since\n the price is calculated based on the place in line of supplied Pods.\n", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "podAmountFilled", "description": "The current number of Pods that have been purchased by this PodOrder.\n\nIncreases during each subsequent Fill.\nIf pricingType = FIXED: `0 <= podAmountFilled <= podAmount`\nIf pricingType = DYNAMIC: No constraint, since `podAmount` is unknown.\n\nUpon PodOrder cancellation, this value is locked.\n", @@ -81304,6 +83141,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": "Where these pods were in line when filled", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "protocol", "description": " The protocol this transaction belongs to ", @@ -82966,6 +84819,118 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_gte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_lte", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not", + "description": null, + "type": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "placeInLine_not_in", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "BigInt", + "ofType": null + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "protocol", "description": null, @@ -83675,6 +85640,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "placeInLine", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "protocol", "description": null, @@ -85378,18 +87349,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "podAmount", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "podAmountFilled", "description": null, @@ -85502,106 +87461,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "podAmount_gt", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "podAmount_gte", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "podAmount_in", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "podAmount_lt", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "podAmount_lte", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "podAmount_not", - "description": null, - "type": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "podAmount_not_in", - "description": null, - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "BigInt", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "podMarketplace", "description": null, @@ -86486,25 +88345,25 @@ "deprecationReason": null }, { - "name": "podAmount", + "name": "podAmountFilled", "description": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "podAmountFilled", + "name": "podMarketplace", "description": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "podMarketplace", + "name": "podMarketplace__availableListedPods", "description": null, "isDeprecated": false, "deprecationReason": null }, { - "name": "podMarketplace__availableListedPods", + "name": "podMarketplace__availableOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -86522,7 +88381,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__cancelledOrderedPods", + "name": "podMarketplace__cancelledOrderBeans", "description": null, "isDeprecated": false, "deprecationReason": null @@ -86539,6 +88398,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "podMarketplace__filledOrderBeans", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "podMarketplace__filledOrderedPods", "description": null, @@ -86558,7 +88423,7 @@ "deprecationReason": null }, { - "name": "podMarketplace__orderedPods", + "name": "podMarketplace__orderBeans", "description": null, "isDeprecated": false, "deprecationReason": null diff --git a/projects/ui/src/graph/schema-beanstalk.graphql b/projects/ui/src/graph/schema-beanstalk.graphql index cdb693f240..7ff74429fc 100644 --- a/projects/ui/src/graph/schema-beanstalk.graphql +++ b/projects/ui/src/graph/schema-beanstalk.graphql @@ -3046,13 +3046,15 @@ enum OrderDirection { } type Plot { - """Beans used to sow, if any""" - beans: BigInt! + """ + Number of beans spent for each pod, whether through sowing or on the marketplace + """ + beansPerPod: BigInt! """Timestamp of creation""" createdAt: BigInt! - """Creation transaction hash""" + """Transaction hash of when this plot entity was created""" creationHash: String! """Farmer who owns this plot""" @@ -3085,21 +3087,23 @@ type Plot { """Season when created""" season: Int! - """Transaction source for this plot""" + """ + Transaction source for this plot. Not the same as creationHash which can include plots splitting from transfer or harvest without the owner changing + """ source: PlotSource! - """Total pods that were sown, if any""" - sownPods: BigInt! - - """Temperature when the plot was sown""" - temperature: Int! + """Transaction hash corresponding to source""" + sourceHash: String! """Timestamp when updated""" updatedAt: BigInt! + + """Block when updated""" + updatedAtBlock: BigInt! } enum PlotSource { - HARVEST + MARKET SOW TRANSFER } @@ -3108,14 +3112,14 @@ input Plot_filter { """Filter for the block changed event.""" _change_block: BlockChangedFilter and: [Plot_filter] - beans: BigInt - beans_gt: BigInt - beans_gte: BigInt - beans_in: [BigInt!] - beans_lt: BigInt - beans_lte: BigInt - beans_not: BigInt - beans_not_in: [BigInt!] + beansPerPod: BigInt + beansPerPod_gt: BigInt + beansPerPod_gte: BigInt + beansPerPod_in: [BigInt!] + beansPerPod_lt: BigInt + beansPerPod_lte: BigInt + beansPerPod_not: BigInt + beansPerPod_not_in: [BigInt!] createdAt: BigInt createdAt_gt: BigInt createdAt_gte: BigInt @@ -3261,26 +3265,38 @@ input Plot_filter { season_not: Int season_not_in: [Int!] source: PlotSource + sourceHash: String + sourceHash_contains: String + sourceHash_contains_nocase: String + sourceHash_ends_with: String + sourceHash_ends_with_nocase: String + sourceHash_gt: String + sourceHash_gte: String + sourceHash_in: [String!] + sourceHash_lt: String + sourceHash_lte: String + sourceHash_not: String + sourceHash_not_contains: String + sourceHash_not_contains_nocase: String + sourceHash_not_ends_with: String + sourceHash_not_ends_with_nocase: String + sourceHash_not_in: [String!] + sourceHash_not_starts_with: String + sourceHash_not_starts_with_nocase: String + sourceHash_starts_with: String + sourceHash_starts_with_nocase: String source_in: [PlotSource!] source_not: PlotSource source_not_in: [PlotSource!] - sownPods: BigInt - sownPods_gt: BigInt - sownPods_gte: BigInt - sownPods_in: [BigInt!] - sownPods_lt: BigInt - sownPods_lte: BigInt - sownPods_not: BigInt - sownPods_not_in: [BigInt!] - temperature: Int - temperature_gt: Int - temperature_gte: Int - temperature_in: [Int!] - temperature_lt: Int - temperature_lte: Int - temperature_not: Int - temperature_not_in: [Int!] updatedAt: BigInt + updatedAtBlock: BigInt + updatedAtBlock_gt: BigInt + updatedAtBlock_gte: BigInt + updatedAtBlock_in: [BigInt!] + updatedAtBlock_lt: BigInt + updatedAtBlock_lte: BigInt + updatedAtBlock_not: BigInt + updatedAtBlock_not_in: [BigInt!] updatedAt_gt: BigInt updatedAt_gte: BigInt updatedAt_in: [BigInt!] @@ -3291,7 +3307,7 @@ input Plot_filter { } enum Plot_orderBy { - beans + beansPerPod createdAt creationHash farmer @@ -3317,7 +3333,6 @@ enum Plot_orderBy { index listing listing__amount - listing__cancelledAmount listing__createdAt listing__creationHash listing__filled @@ -3340,9 +3355,9 @@ enum Plot_orderBy { pods season source - sownPods - temperature + sourceHash updatedAt + updatedAtBlock } type PodFill { @@ -3350,12 +3365,12 @@ type PodFill { amount: BigInt! """Total beans used to fill listing/order""" - costInBeans: BigInt + costInBeans: BigInt! """Creation timestamp""" createdAt: BigInt! - """Account fulfilling the order""" + """Account that is sending pods""" from: String! """Beanstalk address - Order/Listing index - transaction hash""" @@ -3370,13 +3385,16 @@ type PodFill { """Associated order, if any""" order: PodOrder + """Where these pods were in line when filled""" + placeInLine: BigInt! + """Marketplace associated with this fill""" podMarketplace: PodMarketplace! """Start of plot transferred""" start: BigInt! - """Account filling the order""" + """Account that is receiving pods""" to: Farmer! } @@ -3487,6 +3505,14 @@ input PodFill_filter { order_not_starts_with_nocase: String order_starts_with: String order_starts_with_nocase: String + placeInLine: BigInt + placeInLine_gt: BigInt + placeInLine_gte: BigInt + placeInLine_in: [BigInt!] + placeInLine_lt: BigInt + placeInLine_lte: BigInt + placeInLine_not: BigInt + placeInLine_not_in: [BigInt!] podMarketplace: String podMarketplace_: PodMarketplace_filter podMarketplace_contains: String @@ -3548,7 +3574,6 @@ enum PodFill_orderBy { index listing listing__amount - listing__cancelledAmount listing__createdAt listing__creationHash listing__filled @@ -3577,24 +3602,26 @@ enum PodFill_orderBy { order__id order__maxPlaceInLine order__minFillAmount - order__podAmount order__podAmountFilled order__pricePerPod order__pricingFunction order__pricingType order__status order__updatedAt + placeInLine podMarketplace podMarketplace__availableListedPods + podMarketplace__availableOrderBeans podMarketplace__beanVolume podMarketplace__cancelledListedPods - podMarketplace__cancelledOrderedPods + podMarketplace__cancelledOrderBeans podMarketplace__expiredListedPods podMarketplace__filledListedPods + podMarketplace__filledOrderBeans podMarketplace__filledOrderedPods podMarketplace__id podMarketplace__listedPods - podMarketplace__orderedPods + podMarketplace__orderBeans podMarketplace__podVolume podMarketplace__season start @@ -3606,9 +3633,6 @@ type PodListing { "The maximum amount of Pods remaining to be sold by *this* PodListing.\n\nWhen this PodListing is Filled or Cancelled, `amount` does NOT change.\n" amount: BigInt! - "The number of Pods that were remaining in *this* PodListing when it was Cancelled.\n" - cancelledAmount: BigInt! - """Timestamp of PodListing creation.""" createdAt: BigInt! @@ -3707,6 +3731,9 @@ type PodListingCancelled implements MarketplaceEvent { """ logIndex: Int! + """Where these pods were in line when cancelled""" + placeInLine: BigInt! + """ The protocol this transaction belongs to """ protocol: Beanstalk! } @@ -3816,6 +3843,14 @@ input PodListingCancelled_filter { logIndex_not: Int logIndex_not_in: [Int!] or: [PodListingCancelled_filter] + placeInLine: BigInt + placeInLine_gt: BigInt + placeInLine_gte: BigInt + placeInLine_in: [BigInt!] + placeInLine_lt: BigInt + placeInLine_lte: BigInt + placeInLine_not: BigInt + placeInLine_not_in: [BigInt!] protocol: String protocol_: Beanstalk_filter protocol_contains: String @@ -3848,6 +3883,7 @@ enum PodListingCancelled_orderBy { id index logIndex + placeInLine protocol protocol__id protocol__lastSeason @@ -3897,6 +3933,9 @@ type PodListingCreated implements MarketplaceEvent { """Claim to location""" mode: Int! + """Where these pods were in line when listed""" + placeInLine: BigInt! + """Price per pod""" pricePerPod: Int! @@ -4050,6 +4089,14 @@ input PodListingCreated_filter { mode_not: Int mode_not_in: [Int!] or: [PodListingCreated_filter] + placeInLine: BigInt + placeInLine_gt: BigInt + placeInLine_gte: BigInt + placeInLine_in: [BigInt!] + placeInLine_lt: BigInt + placeInLine_lte: BigInt + placeInLine_not: BigInt + placeInLine_not_in: [BigInt!] pricePerPod: Int pricePerPod_gt: Int pricePerPod_gte: Int @@ -4120,6 +4167,7 @@ enum PodListingCreated_orderBy { maxHarvestableIndex minFillAmount mode + placeInLine pricePerPod pricingFunction pricingType @@ -4167,6 +4215,9 @@ type PodListingFilled implements MarketplaceEvent { """ logIndex: Int! + """Where these pods were in line when filled""" + placeInLine: BigInt! + """ The protocol this transaction belongs to """ protocol: Beanstalk! @@ -4298,6 +4349,14 @@ input PodListingFilled_filter { logIndex_not: Int logIndex_not_in: [Int!] or: [PodListingFilled_filter] + placeInLine: BigInt + placeInLine_gt: BigInt + placeInLine_gte: BigInt + placeInLine_in: [BigInt!] + placeInLine_lt: BigInt + placeInLine_lte: BigInt + placeInLine_not: BigInt + placeInLine_not_in: [BigInt!] protocol: String protocol_: Beanstalk_filter protocol_contains: String @@ -4360,6 +4419,7 @@ enum PodListingFilled_orderBy { id index logIndex + placeInLine protocol protocol__id protocol__lastSeason @@ -4385,14 +4445,6 @@ input PodListing_filter { amount_not: BigInt amount_not_in: [BigInt!] and: [PodListing_filter] - cancelledAmount: BigInt - cancelledAmount_gt: BigInt - cancelledAmount_gte: BigInt - cancelledAmount_in: [BigInt!] - cancelledAmount_lt: BigInt - cancelledAmount_lte: BigInt - cancelledAmount_not: BigInt - cancelledAmount_not_in: [BigInt!] createdAt: BigInt createdAt_gt: BigInt createdAt_gte: BigInt @@ -4656,7 +4708,6 @@ input PodListing_filter { enum PodListing_orderBy { amount - cancelledAmount createdAt creationHash farmer @@ -4668,6 +4719,7 @@ enum PodListing_orderBy { fill__from fill__id fill__index + fill__placeInLine fill__start filled filledAmount @@ -4680,7 +4732,7 @@ enum PodListing_orderBy { originalAmount originalIndex plot - plot__beans + plot__beansPerPod plot__createdAt plot__creationHash plot__fullyHarvested @@ -4691,20 +4743,22 @@ enum PodListing_orderBy { plot__pods plot__season plot__source - plot__sownPods - plot__temperature + plot__sourceHash plot__updatedAt + plot__updatedAtBlock podMarketplace podMarketplace__availableListedPods + podMarketplace__availableOrderBeans podMarketplace__beanVolume podMarketplace__cancelledListedPods - podMarketplace__cancelledOrderedPods + podMarketplace__cancelledOrderBeans podMarketplace__expiredListedPods podMarketplace__filledListedPods + podMarketplace__filledOrderBeans podMarketplace__filledOrderedPods podMarketplace__id podMarketplace__listedPods - podMarketplace__orderedPods + podMarketplace__orderBeans podMarketplace__podVolume podMarketplace__season pricePerPod @@ -4717,6 +4771,16 @@ enum PodListing_orderBy { } type PodMarketplace { + """ + Information about the active pod listings. Each entry of the form 'account-index-expiry' + """ + activeListings: [String!]! + + """ + Information about the active pod orders. Each entry of the form 'orderId-maxPlaceInLine' + """ + activeOrders: [String!]! + """All historical listings""" allListings(first: Int = 100, orderBy: PodListing_orderBy, orderDirection: OrderDirection, skip: Int = 0, where: PodListing_filter): [PodListing!]! @@ -4726,14 +4790,17 @@ type PodMarketplace { """Current amount of total pods listed""" availableListedPods: BigInt! + """Current amount of total beans in pod orders""" + availableOrderBeans: BigInt! + """Cumulative bean volume between listings and orders""" beanVolume: BigInt! """Current cumulative pod listings that were cancelled""" cancelledListedPods: BigInt! - """Current cumulative pod orders cancelled""" - cancelledOrderedPods: BigInt! + """Current cumulative beans in pod orders cancelled""" + cancelledOrderBeans: BigInt! """Link to daily snapshot data""" dailySnapshots(first: Int = 100, orderBy: PodMarketplaceDailySnapshot_orderBy, orderDirection: OrderDirection, skip: Int = 0, where: PodMarketplaceDailySnapshot_filter): [PodMarketplaceDailySnapshot!]! @@ -4744,6 +4811,9 @@ type PodMarketplace { """Current cumulative pod listings filled""" filledListedPods: BigInt! + """Current cumulative filled beans in pod orders""" + filledOrderBeans: BigInt! + """Current cumulative pod orders filled""" filledOrderedPods: BigInt! @@ -4759,14 +4829,8 @@ type PodMarketplace { """Current cumulative pods listed for sale""" listedPods: BigInt! - """Indexes of actively listed plots""" - listingIndexes: [BigInt!]! - - """Current cumulative pod orders created""" - orderedPods: BigInt! - - """Active pod order IDs""" - orders(first: Int = 100, orderBy: PodOrder_orderBy, orderDirection: OrderDirection, skip: Int = 0, where: PodOrder_filter): [PodOrder!]! + """Current cumulative beans in pod orders created""" + orderBeans: BigInt! """Cumulative pod volume between listings and orders""" podVolume: BigInt! @@ -4779,6 +4843,9 @@ type PodMarketplaceDailySnapshot { """Point in time current amount of total pods listed""" availableListedPods: BigInt! + """Current amount of total beans in pod orders""" + availableOrderBeans: BigInt! + """ Point in time current cumulative bean volume between listings and orders """ @@ -4787,8 +4854,8 @@ type PodMarketplaceDailySnapshot { """Point in time current cumulative pod listings that were cancelled""" cancelledListedPods: BigInt! - """Point in time current cumulative pod orders cancelled""" - cancelledOrderedPods: BigInt! + """Current cumulative beans in pod orders cancelled""" + cancelledOrderBeans: BigInt! """Timestamp of initial snapshot creation""" createdAt: BigInt! @@ -4796,14 +4863,17 @@ type PodMarketplaceDailySnapshot { """Point in time current delta of total pods listed""" deltaAvailableListedPods: BigInt! + """Point in time current delta available ordered beans in pod orders""" + deltaAvailableOrderBeans: BigInt! + """Point in time current delta bean volume between listings and orders""" deltaBeanVolume: BigInt! """Point in time current delta pod listings that were cancelled""" deltaCancelledListedPods: BigInt! - """Point in time current delta pod orders cancelled""" - deltaCancelledOrderedPods: BigInt! + """Point in time current delta cancelled ordered beans in pod orders""" + deltaCancelledOrderBeans: BigInt! """Point in time current delta pod listings that expired""" deltaExpiredListedPods: BigInt! @@ -4811,14 +4881,17 @@ type PodMarketplaceDailySnapshot { """Point in time current delta pod listings filled""" deltaFilledListedPods: BigInt! + """Point in time current delta filled ordered beans in pod orders""" + deltaFilledOrderBeans: BigInt! + """Point in time current delta pod orders filled""" deltaFilledOrderedPods: BigInt! """Point in time current delta pods listed for sale""" deltaListedPods: BigInt! - """Point in time current delta pod orders created""" - deltaOrderedPods: BigInt! + """Point in time current delta ordered beans in pod orders created""" + deltaOrderBeans: BigInt! """Point in time current delta pod volume between listings and orders""" deltaPodVolume: BigInt! @@ -4829,7 +4902,10 @@ type PodMarketplaceDailySnapshot { """Point in time current cumulative pod listings filled""" filledListedPods: BigInt! - """Point in time current cumulative pod orders filled""" + """Current cumulative filled beans in pod orders""" + filledOrderBeans: BigInt! + + """Current cumulative pod orders filled""" filledOrderedPods: BigInt! """Marketplace ID - Unix Timestamp""" @@ -4838,8 +4914,8 @@ type PodMarketplaceDailySnapshot { """Point in time current cumulative pods listed for sale""" listedPods: BigInt! - """Point in time current cumulative pod orders created""" - orderedPods: BigInt! + """Current cumulative beans in pod orders created""" + orderBeans: BigInt! """Marketplace associated with snapshot""" podMarketplace: PodMarketplace! @@ -4868,6 +4944,14 @@ input PodMarketplaceDailySnapshot_filter { availableListedPods_lte: BigInt availableListedPods_not: BigInt availableListedPods_not_in: [BigInt!] + availableOrderBeans: BigInt + availableOrderBeans_gt: BigInt + availableOrderBeans_gte: BigInt + availableOrderBeans_in: [BigInt!] + availableOrderBeans_lt: BigInt + availableOrderBeans_lte: BigInt + availableOrderBeans_not: BigInt + availableOrderBeans_not_in: [BigInt!] beanVolume: BigInt beanVolume_gt: BigInt beanVolume_gte: BigInt @@ -4884,14 +4968,14 @@ input PodMarketplaceDailySnapshot_filter { cancelledListedPods_lte: BigInt cancelledListedPods_not: BigInt cancelledListedPods_not_in: [BigInt!] - cancelledOrderedPods: BigInt - cancelledOrderedPods_gt: BigInt - cancelledOrderedPods_gte: BigInt - cancelledOrderedPods_in: [BigInt!] - cancelledOrderedPods_lt: BigInt - cancelledOrderedPods_lte: BigInt - cancelledOrderedPods_not: BigInt - cancelledOrderedPods_not_in: [BigInt!] + cancelledOrderBeans: BigInt + cancelledOrderBeans_gt: BigInt + cancelledOrderBeans_gte: BigInt + cancelledOrderBeans_in: [BigInt!] + cancelledOrderBeans_lt: BigInt + cancelledOrderBeans_lte: BigInt + cancelledOrderBeans_not: BigInt + cancelledOrderBeans_not_in: [BigInt!] createdAt: BigInt createdAt_gt: BigInt createdAt_gte: BigInt @@ -4908,6 +4992,14 @@ input PodMarketplaceDailySnapshot_filter { deltaAvailableListedPods_lte: BigInt deltaAvailableListedPods_not: BigInt deltaAvailableListedPods_not_in: [BigInt!] + deltaAvailableOrderBeans: BigInt + deltaAvailableOrderBeans_gt: BigInt + deltaAvailableOrderBeans_gte: BigInt + deltaAvailableOrderBeans_in: [BigInt!] + deltaAvailableOrderBeans_lt: BigInt + deltaAvailableOrderBeans_lte: BigInt + deltaAvailableOrderBeans_not: BigInt + deltaAvailableOrderBeans_not_in: [BigInt!] deltaBeanVolume: BigInt deltaBeanVolume_gt: BigInt deltaBeanVolume_gte: BigInt @@ -4924,14 +5016,14 @@ input PodMarketplaceDailySnapshot_filter { deltaCancelledListedPods_lte: BigInt deltaCancelledListedPods_not: BigInt deltaCancelledListedPods_not_in: [BigInt!] - deltaCancelledOrderedPods: BigInt - deltaCancelledOrderedPods_gt: BigInt - deltaCancelledOrderedPods_gte: BigInt - deltaCancelledOrderedPods_in: [BigInt!] - deltaCancelledOrderedPods_lt: BigInt - deltaCancelledOrderedPods_lte: BigInt - deltaCancelledOrderedPods_not: BigInt - deltaCancelledOrderedPods_not_in: [BigInt!] + deltaCancelledOrderBeans: BigInt + deltaCancelledOrderBeans_gt: BigInt + deltaCancelledOrderBeans_gte: BigInt + deltaCancelledOrderBeans_in: [BigInt!] + deltaCancelledOrderBeans_lt: BigInt + deltaCancelledOrderBeans_lte: BigInt + deltaCancelledOrderBeans_not: BigInt + deltaCancelledOrderBeans_not_in: [BigInt!] deltaExpiredListedPods: BigInt deltaExpiredListedPods_gt: BigInt deltaExpiredListedPods_gte: BigInt @@ -4948,6 +5040,14 @@ input PodMarketplaceDailySnapshot_filter { deltaFilledListedPods_lte: BigInt deltaFilledListedPods_not: BigInt deltaFilledListedPods_not_in: [BigInt!] + deltaFilledOrderBeans: BigInt + deltaFilledOrderBeans_gt: BigInt + deltaFilledOrderBeans_gte: BigInt + deltaFilledOrderBeans_in: [BigInt!] + deltaFilledOrderBeans_lt: BigInt + deltaFilledOrderBeans_lte: BigInt + deltaFilledOrderBeans_not: BigInt + deltaFilledOrderBeans_not_in: [BigInt!] deltaFilledOrderedPods: BigInt deltaFilledOrderedPods_gt: BigInt deltaFilledOrderedPods_gte: BigInt @@ -4964,14 +5064,14 @@ input PodMarketplaceDailySnapshot_filter { deltaListedPods_lte: BigInt deltaListedPods_not: BigInt deltaListedPods_not_in: [BigInt!] - deltaOrderedPods: BigInt - deltaOrderedPods_gt: BigInt - deltaOrderedPods_gte: BigInt - deltaOrderedPods_in: [BigInt!] - deltaOrderedPods_lt: BigInt - deltaOrderedPods_lte: BigInt - deltaOrderedPods_not: BigInt - deltaOrderedPods_not_in: [BigInt!] + deltaOrderBeans: BigInt + deltaOrderBeans_gt: BigInt + deltaOrderBeans_gte: BigInt + deltaOrderBeans_in: [BigInt!] + deltaOrderBeans_lt: BigInt + deltaOrderBeans_lte: BigInt + deltaOrderBeans_not: BigInt + deltaOrderBeans_not_in: [BigInt!] deltaPodVolume: BigInt deltaPodVolume_gt: BigInt deltaPodVolume_gte: BigInt @@ -4996,6 +5096,14 @@ input PodMarketplaceDailySnapshot_filter { filledListedPods_lte: BigInt filledListedPods_not: BigInt filledListedPods_not_in: [BigInt!] + filledOrderBeans: BigInt + filledOrderBeans_gt: BigInt + filledOrderBeans_gte: BigInt + filledOrderBeans_in: [BigInt!] + filledOrderBeans_lt: BigInt + filledOrderBeans_lte: BigInt + filledOrderBeans_not: BigInt + filledOrderBeans_not_in: [BigInt!] filledOrderedPods: BigInt filledOrderedPods_gt: BigInt filledOrderedPods_gte: BigInt @@ -5021,14 +5129,14 @@ input PodMarketplaceDailySnapshot_filter { listedPods_not: BigInt listedPods_not_in: [BigInt!] or: [PodMarketplaceDailySnapshot_filter] - orderedPods: BigInt - orderedPods_gt: BigInt - orderedPods_gte: BigInt - orderedPods_in: [BigInt!] - orderedPods_lt: BigInt - orderedPods_lte: BigInt - orderedPods_not: BigInt - orderedPods_not_in: [BigInt!] + orderBeans: BigInt + orderBeans_gt: BigInt + orderBeans_gte: BigInt + orderBeans_in: [BigInt!] + orderBeans_lt: BigInt + orderBeans_lte: BigInt + orderBeans_not: BigInt + orderBeans_not_in: [BigInt!] podMarketplace: String podMarketplace_: PodMarketplace_filter podMarketplace_contains: String @@ -5078,37 +5186,43 @@ input PodMarketplaceDailySnapshot_filter { enum PodMarketplaceDailySnapshot_orderBy { availableListedPods + availableOrderBeans beanVolume cancelledListedPods - cancelledOrderedPods + cancelledOrderBeans createdAt deltaAvailableListedPods + deltaAvailableOrderBeans deltaBeanVolume deltaCancelledListedPods - deltaCancelledOrderedPods + deltaCancelledOrderBeans deltaExpiredListedPods deltaFilledListedPods + deltaFilledOrderBeans deltaFilledOrderedPods deltaListedPods - deltaOrderedPods + deltaOrderBeans deltaPodVolume expiredListedPods filledListedPods + filledOrderBeans filledOrderedPods id listedPods - orderedPods + orderBeans podMarketplace podMarketplace__availableListedPods + podMarketplace__availableOrderBeans podMarketplace__beanVolume podMarketplace__cancelledListedPods - podMarketplace__cancelledOrderedPods + podMarketplace__cancelledOrderBeans podMarketplace__expiredListedPods podMarketplace__filledListedPods + podMarketplace__filledOrderBeans podMarketplace__filledOrderedPods podMarketplace__id podMarketplace__listedPods - podMarketplace__orderedPods + podMarketplace__orderBeans podMarketplace__podVolume podMarketplace__season podVolume @@ -5120,6 +5234,9 @@ type PodMarketplaceHourlySnapshot { """Point in time current amount of total pods listed""" availableListedPods: BigInt! + """Current amount of total beans in pod orders""" + availableOrderBeans: BigInt! + """ Point in time current cumulative bean volume between listings and orders """ @@ -5128,8 +5245,8 @@ type PodMarketplaceHourlySnapshot { """Point in time current cumulative pod listings that were cancelled""" cancelledListedPods: BigInt! - """Point in time current cumulative pod orders cancelled""" - cancelledOrderedPods: BigInt! + """Current cumulative beans in pod orders cancelled""" + cancelledOrderBeans: BigInt! """Timestamp of initial snapshot creation""" createdAt: BigInt! @@ -5137,14 +5254,17 @@ type PodMarketplaceHourlySnapshot { """Point in time current delta of total pods listed""" deltaAvailableListedPods: BigInt! + """Point in time current delta available ordered beans in pod orders""" + deltaAvailableOrderBeans: BigInt! + """Point in time current delta bean volume between listings and orders""" deltaBeanVolume: BigInt! """Point in time current delta pod listings that were cancelled""" deltaCancelledListedPods: BigInt! - """Point in time current delta pod orders cancelled""" - deltaCancelledOrderedPods: BigInt! + """Point in time current delta cancelled ordered beans in pod orders""" + deltaCancelledOrderBeans: BigInt! """Point in time current delta pod listings that expired""" deltaExpiredListedPods: BigInt! @@ -5152,14 +5272,17 @@ type PodMarketplaceHourlySnapshot { """Point in time current delta pod listings filled""" deltaFilledListedPods: BigInt! + """Point in time current delta filled ordered beans in pod orders""" + deltaFilledOrderBeans: BigInt! + """Point in time current delta pod orders filled""" deltaFilledOrderedPods: BigInt! """Point in time current delta pods listed for sale""" deltaListedPods: BigInt! - """Point in time current delta pod orders created""" - deltaOrderedPods: BigInt! + """Point in time current delta ordered beans in pod orders created""" + deltaOrderBeans: BigInt! """Point in time current delta pod volume between listings and orders""" deltaPodVolume: BigInt! @@ -5170,7 +5293,10 @@ type PodMarketplaceHourlySnapshot { """Point in time current cumulative pod listings filled""" filledListedPods: BigInt! - """Point in time current cumulative pod orders filled""" + """Current cumulative filled beans in pod orders""" + filledOrderBeans: BigInt! + + """Current cumulative pod orders filled""" filledOrderedPods: BigInt! """Marketplace ID - Unix Timestamp""" @@ -5179,8 +5305,8 @@ type PodMarketplaceHourlySnapshot { """Point in time current cumulative pods listed for sale""" listedPods: BigInt! - """Point in time current cumulative pod orders created""" - orderedPods: BigInt! + """Current cumulative beans in pod orders created""" + orderBeans: BigInt! """Marketplace associated with snapshot""" podMarketplace: PodMarketplace! @@ -5209,6 +5335,14 @@ input PodMarketplaceHourlySnapshot_filter { availableListedPods_lte: BigInt availableListedPods_not: BigInt availableListedPods_not_in: [BigInt!] + availableOrderBeans: BigInt + availableOrderBeans_gt: BigInt + availableOrderBeans_gte: BigInt + availableOrderBeans_in: [BigInt!] + availableOrderBeans_lt: BigInt + availableOrderBeans_lte: BigInt + availableOrderBeans_not: BigInt + availableOrderBeans_not_in: [BigInt!] beanVolume: BigInt beanVolume_gt: BigInt beanVolume_gte: BigInt @@ -5225,14 +5359,14 @@ input PodMarketplaceHourlySnapshot_filter { cancelledListedPods_lte: BigInt cancelledListedPods_not: BigInt cancelledListedPods_not_in: [BigInt!] - cancelledOrderedPods: BigInt - cancelledOrderedPods_gt: BigInt - cancelledOrderedPods_gte: BigInt - cancelledOrderedPods_in: [BigInt!] - cancelledOrderedPods_lt: BigInt - cancelledOrderedPods_lte: BigInt - cancelledOrderedPods_not: BigInt - cancelledOrderedPods_not_in: [BigInt!] + cancelledOrderBeans: BigInt + cancelledOrderBeans_gt: BigInt + cancelledOrderBeans_gte: BigInt + cancelledOrderBeans_in: [BigInt!] + cancelledOrderBeans_lt: BigInt + cancelledOrderBeans_lte: BigInt + cancelledOrderBeans_not: BigInt + cancelledOrderBeans_not_in: [BigInt!] createdAt: BigInt createdAt_gt: BigInt createdAt_gte: BigInt @@ -5249,6 +5383,14 @@ input PodMarketplaceHourlySnapshot_filter { deltaAvailableListedPods_lte: BigInt deltaAvailableListedPods_not: BigInt deltaAvailableListedPods_not_in: [BigInt!] + deltaAvailableOrderBeans: BigInt + deltaAvailableOrderBeans_gt: BigInt + deltaAvailableOrderBeans_gte: BigInt + deltaAvailableOrderBeans_in: [BigInt!] + deltaAvailableOrderBeans_lt: BigInt + deltaAvailableOrderBeans_lte: BigInt + deltaAvailableOrderBeans_not: BigInt + deltaAvailableOrderBeans_not_in: [BigInt!] deltaBeanVolume: BigInt deltaBeanVolume_gt: BigInt deltaBeanVolume_gte: BigInt @@ -5265,14 +5407,14 @@ input PodMarketplaceHourlySnapshot_filter { deltaCancelledListedPods_lte: BigInt deltaCancelledListedPods_not: BigInt deltaCancelledListedPods_not_in: [BigInt!] - deltaCancelledOrderedPods: BigInt - deltaCancelledOrderedPods_gt: BigInt - deltaCancelledOrderedPods_gte: BigInt - deltaCancelledOrderedPods_in: [BigInt!] - deltaCancelledOrderedPods_lt: BigInt - deltaCancelledOrderedPods_lte: BigInt - deltaCancelledOrderedPods_not: BigInt - deltaCancelledOrderedPods_not_in: [BigInt!] + deltaCancelledOrderBeans: BigInt + deltaCancelledOrderBeans_gt: BigInt + deltaCancelledOrderBeans_gte: BigInt + deltaCancelledOrderBeans_in: [BigInt!] + deltaCancelledOrderBeans_lt: BigInt + deltaCancelledOrderBeans_lte: BigInt + deltaCancelledOrderBeans_not: BigInt + deltaCancelledOrderBeans_not_in: [BigInt!] deltaExpiredListedPods: BigInt deltaExpiredListedPods_gt: BigInt deltaExpiredListedPods_gte: BigInt @@ -5289,6 +5431,14 @@ input PodMarketplaceHourlySnapshot_filter { deltaFilledListedPods_lte: BigInt deltaFilledListedPods_not: BigInt deltaFilledListedPods_not_in: [BigInt!] + deltaFilledOrderBeans: BigInt + deltaFilledOrderBeans_gt: BigInt + deltaFilledOrderBeans_gte: BigInt + deltaFilledOrderBeans_in: [BigInt!] + deltaFilledOrderBeans_lt: BigInt + deltaFilledOrderBeans_lte: BigInt + deltaFilledOrderBeans_not: BigInt + deltaFilledOrderBeans_not_in: [BigInt!] deltaFilledOrderedPods: BigInt deltaFilledOrderedPods_gt: BigInt deltaFilledOrderedPods_gte: BigInt @@ -5305,14 +5455,14 @@ input PodMarketplaceHourlySnapshot_filter { deltaListedPods_lte: BigInt deltaListedPods_not: BigInt deltaListedPods_not_in: [BigInt!] - deltaOrderedPods: BigInt - deltaOrderedPods_gt: BigInt - deltaOrderedPods_gte: BigInt - deltaOrderedPods_in: [BigInt!] - deltaOrderedPods_lt: BigInt - deltaOrderedPods_lte: BigInt - deltaOrderedPods_not: BigInt - deltaOrderedPods_not_in: [BigInt!] + deltaOrderBeans: BigInt + deltaOrderBeans_gt: BigInt + deltaOrderBeans_gte: BigInt + deltaOrderBeans_in: [BigInt!] + deltaOrderBeans_lt: BigInt + deltaOrderBeans_lte: BigInt + deltaOrderBeans_not: BigInt + deltaOrderBeans_not_in: [BigInt!] deltaPodVolume: BigInt deltaPodVolume_gt: BigInt deltaPodVolume_gte: BigInt @@ -5337,6 +5487,14 @@ input PodMarketplaceHourlySnapshot_filter { filledListedPods_lte: BigInt filledListedPods_not: BigInt filledListedPods_not_in: [BigInt!] + filledOrderBeans: BigInt + filledOrderBeans_gt: BigInt + filledOrderBeans_gte: BigInt + filledOrderBeans_in: [BigInt!] + filledOrderBeans_lt: BigInt + filledOrderBeans_lte: BigInt + filledOrderBeans_not: BigInt + filledOrderBeans_not_in: [BigInt!] filledOrderedPods: BigInt filledOrderedPods_gt: BigInt filledOrderedPods_gte: BigInt @@ -5362,14 +5520,14 @@ input PodMarketplaceHourlySnapshot_filter { listedPods_not: BigInt listedPods_not_in: [BigInt!] or: [PodMarketplaceHourlySnapshot_filter] - orderedPods: BigInt - orderedPods_gt: BigInt - orderedPods_gte: BigInt - orderedPods_in: [BigInt!] - orderedPods_lt: BigInt - orderedPods_lte: BigInt - orderedPods_not: BigInt - orderedPods_not_in: [BigInt!] + orderBeans: BigInt + orderBeans_gt: BigInt + orderBeans_gte: BigInt + orderBeans_in: [BigInt!] + orderBeans_lt: BigInt + orderBeans_lte: BigInt + orderBeans_not: BigInt + orderBeans_not_in: [BigInt!] podMarketplace: String podMarketplace_: PodMarketplace_filter podMarketplace_contains: String @@ -5419,37 +5577,43 @@ input PodMarketplaceHourlySnapshot_filter { enum PodMarketplaceHourlySnapshot_orderBy { availableListedPods + availableOrderBeans beanVolume cancelledListedPods - cancelledOrderedPods + cancelledOrderBeans createdAt deltaAvailableListedPods + deltaAvailableOrderBeans deltaBeanVolume deltaCancelledListedPods - deltaCancelledOrderedPods + deltaCancelledOrderBeans deltaExpiredListedPods deltaFilledListedPods + deltaFilledOrderBeans deltaFilledOrderedPods deltaListedPods - deltaOrderedPods + deltaOrderBeans deltaPodVolume expiredListedPods filledListedPods + filledOrderBeans filledOrderedPods id listedPods - orderedPods + orderBeans podMarketplace podMarketplace__availableListedPods + podMarketplace__availableOrderBeans podMarketplace__beanVolume podMarketplace__cancelledListedPods - podMarketplace__cancelledOrderedPods + podMarketplace__cancelledOrderBeans podMarketplace__expiredListedPods podMarketplace__filledListedPods + podMarketplace__filledOrderBeans podMarketplace__filledOrderedPods podMarketplace__id podMarketplace__listedPods - podMarketplace__orderedPods + podMarketplace__orderBeans podMarketplace__podVolume podMarketplace__season podVolume @@ -5460,6 +5624,18 @@ enum PodMarketplaceHourlySnapshot_orderBy { input PodMarketplace_filter { """Filter for the block changed event.""" _change_block: BlockChangedFilter + activeListings: [String!] + activeListings_contains: [String!] + activeListings_contains_nocase: [String!] + activeListings_not: [String!] + activeListings_not_contains: [String!] + activeListings_not_contains_nocase: [String!] + activeOrders: [String!] + activeOrders_contains: [String!] + activeOrders_contains_nocase: [String!] + activeOrders_not: [String!] + activeOrders_not_contains: [String!] + activeOrders_not_contains_nocase: [String!] allListings_: PodListing_filter allOrders_: PodOrder_filter and: [PodMarketplace_filter] @@ -5471,6 +5647,14 @@ input PodMarketplace_filter { availableListedPods_lte: BigInt availableListedPods_not: BigInt availableListedPods_not_in: [BigInt!] + availableOrderBeans: BigInt + availableOrderBeans_gt: BigInt + availableOrderBeans_gte: BigInt + availableOrderBeans_in: [BigInt!] + availableOrderBeans_lt: BigInt + availableOrderBeans_lte: BigInt + availableOrderBeans_not: BigInt + availableOrderBeans_not_in: [BigInt!] beanVolume: BigInt beanVolume_gt: BigInt beanVolume_gte: BigInt @@ -5487,14 +5671,14 @@ input PodMarketplace_filter { cancelledListedPods_lte: BigInt cancelledListedPods_not: BigInt cancelledListedPods_not_in: [BigInt!] - cancelledOrderedPods: BigInt - cancelledOrderedPods_gt: BigInt - cancelledOrderedPods_gte: BigInt - cancelledOrderedPods_in: [BigInt!] - cancelledOrderedPods_lt: BigInt - cancelledOrderedPods_lte: BigInt - cancelledOrderedPods_not: BigInt - cancelledOrderedPods_not_in: [BigInt!] + cancelledOrderBeans: BigInt + cancelledOrderBeans_gt: BigInt + cancelledOrderBeans_gte: BigInt + cancelledOrderBeans_in: [BigInt!] + cancelledOrderBeans_lt: BigInt + cancelledOrderBeans_lte: BigInt + cancelledOrderBeans_not: BigInt + cancelledOrderBeans_not_in: [BigInt!] dailySnapshots_: PodMarketplaceDailySnapshot_filter expiredListedPods: BigInt expiredListedPods_gt: BigInt @@ -5512,6 +5696,14 @@ input PodMarketplace_filter { filledListedPods_lte: BigInt filledListedPods_not: BigInt filledListedPods_not_in: [BigInt!] + filledOrderBeans: BigInt + filledOrderBeans_gt: BigInt + filledOrderBeans_gte: BigInt + filledOrderBeans_in: [BigInt!] + filledOrderBeans_lt: BigInt + filledOrderBeans_lte: BigInt + filledOrderBeans_not: BigInt + filledOrderBeans_not_in: [BigInt!] filledOrderedPods: BigInt filledOrderedPods_gt: BigInt filledOrderedPods_gte: BigInt @@ -5538,28 +5730,15 @@ input PodMarketplace_filter { listedPods_lte: BigInt listedPods_not: BigInt listedPods_not_in: [BigInt!] - listingIndexes: [BigInt!] - listingIndexes_contains: [BigInt!] - listingIndexes_contains_nocase: [BigInt!] - listingIndexes_not: [BigInt!] - listingIndexes_not_contains: [BigInt!] - listingIndexes_not_contains_nocase: [BigInt!] or: [PodMarketplace_filter] - orderedPods: BigInt - orderedPods_gt: BigInt - orderedPods_gte: BigInt - orderedPods_in: [BigInt!] - orderedPods_lt: BigInt - orderedPods_lte: BigInt - orderedPods_not: BigInt - orderedPods_not_in: [BigInt!] - orders: [String!] - orders_: PodOrder_filter - orders_contains: [String!] - orders_contains_nocase: [String!] - orders_not: [String!] - orders_not_contains: [String!] - orders_not_contains_nocase: [String!] + orderBeans: BigInt + orderBeans_gt: BigInt + orderBeans_gte: BigInt + orderBeans_in: [BigInt!] + orderBeans_lt: BigInt + orderBeans_lte: BigInt + orderBeans_not: BigInt + orderBeans_not_in: [BigInt!] podVolume: BigInt podVolume_gt: BigInt podVolume_gte: BigInt @@ -5579,23 +5758,25 @@ input PodMarketplace_filter { } enum PodMarketplace_orderBy { + activeListings + activeOrders allListings allOrders availableListedPods + availableOrderBeans beanVolume cancelledListedPods - cancelledOrderedPods + cancelledOrderBeans dailySnapshots expiredListedPods filledListedPods + filledOrderBeans filledOrderedPods fills hourlySnapshots id listedPods - listingIndexes - orderedPods - orders + orderBeans podVolume season } @@ -5631,9 +5812,6 @@ type PodOrder { """Minimum number of Pods required to perform a Fill.""" minFillAmount: BigInt! - "The original number of Pods requested by this PodOrder.\n\nDoes NOT change as Fills occur.\nNot deterministic for PodOrders with pricingType = DYNAMIC.\n\nIf pricingType = FIXED:\n Set to the number of Pods which can be purchased by the Order.\n If FIXED (V1): `amount` field emitted in PodOrderCreated.\n If FIXED (V2): `amount / pricePerPod` fields emitted in PodOrderCreated.\n\nIf pricingType = DYNAMIC:\n Set to `0`. The number of Pods that will be provided is unknown, since\n the price is calculated based on the place in line of supplied Pods.\n" - podAmount: BigInt! - "The current number of Pods that have been purchased by this PodOrder.\n\nIncreases during each subsequent Fill.\nIf pricingType = FIXED: `0 <= podAmountFilled <= podAmount`\nIf pricingType = DYNAMIC: No constraint, since `podAmount` is unknown.\n\nUpon PodOrder cancellation, this value is locked.\n" podAmountFilled: BigInt! @@ -6132,6 +6310,9 @@ type PodOrderFilled implements MarketplaceEvent { """ logIndex: Int! + """Where these pods were in line when filled""" + placeInLine: BigInt! + """ The protocol this transaction belongs to """ protocol: Beanstalk! @@ -6263,6 +6444,14 @@ input PodOrderFilled_filter { logIndex_not: Int logIndex_not_in: [Int!] or: [PodOrderFilled_filter] + placeInLine: BigInt + placeInLine_gt: BigInt + placeInLine_gte: BigInt + placeInLine_in: [BigInt!] + placeInLine_lt: BigInt + placeInLine_lte: BigInt + placeInLine_not: BigInt + placeInLine_not_in: [BigInt!] protocol: String protocol_: Beanstalk_filter protocol_contains: String @@ -6325,6 +6514,7 @@ enum PodOrderFilled_orderBy { id index logIndex + placeInLine protocol protocol__id protocol__lastSeason @@ -6459,7 +6649,6 @@ input PodOrder_filter { minFillAmount_not: BigInt minFillAmount_not_in: [BigInt!] or: [PodOrder_filter] - podAmount: BigInt podAmountFilled: BigInt podAmountFilled_gt: BigInt podAmountFilled_gte: BigInt @@ -6468,13 +6657,6 @@ input PodOrder_filter { podAmountFilled_lte: BigInt podAmountFilled_not: BigInt podAmountFilled_not_in: [BigInt!] - podAmount_gt: BigInt - podAmount_gte: BigInt - podAmount_in: [BigInt!] - podAmount_lt: BigInt - podAmount_lte: BigInt - podAmount_not: BigInt - podAmount_not_in: [BigInt!] podMarketplace: String podMarketplace_: PodMarketplace_filter podMarketplace_contains: String @@ -6548,19 +6730,20 @@ enum PodOrder_orderBy { id maxPlaceInLine minFillAmount - podAmount podAmountFilled podMarketplace podMarketplace__availableListedPods + podMarketplace__availableOrderBeans podMarketplace__beanVolume podMarketplace__cancelledListedPods - podMarketplace__cancelledOrderedPods + podMarketplace__cancelledOrderBeans podMarketplace__expiredListedPods podMarketplace__filledListedPods + podMarketplace__filledOrderBeans podMarketplace__filledOrderedPods podMarketplace__id podMarketplace__listedPods - podMarketplace__orderedPods + podMarketplace__orderBeans podMarketplace__podVolume podMarketplace__season pricePerPod diff --git a/projects/ui/src/hooks/beanstalk/useMarketActivityData.ts b/projects/ui/src/hooks/beanstalk/useMarketActivityData.ts index 0435d17718..027baf0a9a 100644 --- a/projects/ui/src/hooks/beanstalk/useMarketActivityData.ts +++ b/projects/ui/src/hooks/beanstalk/useMarketActivityData.ts @@ -2,6 +2,12 @@ import BigNumber from 'bignumber.js'; import { useCallback, useState, useEffect } from 'react'; import keyBy from 'lodash/keyBy'; import { + HistoricalPodListingsQuery, + HistoricalPodListingsQueryResult, + HistoricalPodOrdersQuery, + HistoricalPodOrdersQueryResult, + MarketEventsQuery, + MarketEventsQueryResult, useHistoricalPodListingsLazyQuery, useHistoricalPodOrdersLazyQuery, useMarketEventsLazyQuery, @@ -27,7 +33,6 @@ export type MarketEvent = { hash: string; }; -export const QUERY_AMOUNT = 500; export const MAX_TIMESTAMP = '9999999999999'; // 166 455 351 3803 /** @@ -43,42 +48,65 @@ const useMarketActivityData = () => { const [page, setPage] = useState(0); const [data, setData] = useState([]); const [loading, setLoading] = useState(true); + const [error, setError] = useState(false); + + const [podOrders, setPodOrders] = useState([]); + const [podListings, setPodListings] = useState([]); + const [markEvents, setMarketEvents] = useState([]); /// Queries - const [getMarketEvents, marketEventsQuery] = useMarketEventsLazyQuery({ + const [getMarketEvents] = useMarketEventsLazyQuery({ fetchPolicy: 'network-only', notifyOnNetworkStatusChange: true, variables: { - events_first: QUERY_AMOUNT, + events_first: 1000, events_timestamp_lt: MAX_TIMESTAMP, }, }); - const [getPodOrders, podOrdersQuery] = useHistoricalPodOrdersLazyQuery({ + + const [getPodOrders] = useHistoricalPodOrdersLazyQuery({ fetchPolicy: 'network-only', }); - const [getPodListings, podListingsQuery] = useHistoricalPodListingsLazyQuery({ + + const [getPodListings] = useHistoricalPodListingsLazyQuery({ fetchPolicy: 'network-only', }); - const error = - marketEventsQuery.error || podOrdersQuery.error || podListingsQuery.error; - // fetch const _fetch = useCallback( - async (first: number, after: string) => { + async () => { setLoading(true); setPage((p) => p + 1); - const result = await getMarketEvents({ - variables: { events_first: first, events_timestamp_lt: after }, - }); - // run join query if we loaded more market events - if (result.data?.marketEvents.length) { + let lastOutputLength = 0; + let lastTimestamp = MAX_TIMESTAMP; + + const podMarketEvents: MarketEventsQuery["marketEvents"] = []; + const podOrdersHistoryIDs: HistoricalPodOrdersQuery["podOrders"] = []; + const podListingsHistoryIDs: HistoricalPodListingsQuery["podListings"] = []; + + try { + do { + const events = await getMarketEvents({ + variables: { events_first: 1000, events_timestamp_lt: lastTimestamp }, + }); + if (events.data?.marketEvents.length) { + podMarketEvents.push(...events.data.marketEvents); + lastOutputLength = events.data.marketEvents.length; + lastTimestamp = events.data.marketEvents[events.data.marketEvents.length - 1].createdAt; + }; + } while ( lastOutputLength === 1000 ); + setError(false); + } catch (e) { + setError(true); + } + + // run join query if we loaded any market events + if (podMarketEvents.length > 0) { + setMarketEvents(podMarketEvents); // find IDs to join against - const [orderIDs, listingIDs] = result.data.marketEvents.reduce< - [string[], string[]] - >( - (prev, curr) => { + const [orderIDs, listingIDs] = podMarketEvents.reduce( + (prev: any, curr: any) => { if ( curr.__typename === 'PodOrderFilled' || curr.__typename === 'PodOrderCancelled' @@ -96,18 +124,60 @@ const useMarketActivityData = () => { ); // lookup all of the orders and listings needed to join to the above query - await Promise.all([ - getPodOrders({ - variables: { - historyIDs: orderIDs, - }, - }), - getPodListings({ - variables: { - historyIDs: listingIDs, - }, - }), - ]); + + const promises: Promise[] = []; + + const podOrdersRequests = Math.ceil(orderIDs.length / 1000); + const podListingsRequests = Math.ceil(listingIDs.length / 1000); + + try { + for (let i = 0; i < podOrdersRequests; i += 1) { + const startPosition = i * 1000; + const amountToSplice = i !== podOrdersRequests - 1 ? 1000 : orderIDs.length % 1000; + const selectedPodOrders = orderIDs.slice(startPosition, startPosition + amountToSplice); + promises.push( + getPodOrders({ + variables: { + historyIDs: selectedPodOrders + } + }).then( + (r) => { + if (r.data && r.data.podOrders.length) { + podOrdersHistoryIDs.push(...r.data.podOrders); + }; + } + ) + ); + }; + + for (let i = 0; i < podListingsRequests; i += 1) { + const startPosition = i * 1000; + const amountToSplice = i !== podListingsRequests - 1 ? 1000 : listingIDs.length % 1000; + const selectedPodListings = listingIDs.slice(startPosition, startPosition + amountToSplice); + promises.push( + getPodListings({ + variables: { + historyIDs: selectedPodListings + } + }) + .then( + (r) => { + if (r.data && r.data.podListings.length) { + podListingsHistoryIDs.push(...r.data.podListings) + }; + } + ) + ); + }; + setError(false); + } catch (e) { + setError(true); + }; + + + await Promise.all(promises); + setPodOrders(podOrdersHistoryIDs); + setPodListings(podListingsHistoryIDs); } setLoading(false); @@ -115,27 +185,14 @@ const useMarketActivityData = () => { [getMarketEvents, getPodListings, getPodOrders] ); - // look up the next set of marketplaceEvents using the last known timestamp - const fetchMoreData = useCallback(async () => { - const first = QUERY_AMOUNT; - const after = marketEventsQuery.data?.marketEvents?.length - ? marketEventsQuery.data?.marketEvents[ - marketEventsQuery.data?.marketEvents.length - 1 - ].createdAt - : MAX_TIMESTAMP; - console.debug('Fetch more: ', first, after); - await _fetch(first, after); - }, [_fetch, marketEventsQuery.data?.marketEvents]); // when all queries finish, process data + useEffect(() => { - const events = marketEventsQuery.data?.marketEvents; + const events = markEvents; if (!loading && events?.length) { - const podOrdersById = keyBy(podOrdersQuery.data?.podOrders, 'historyID'); - const podListingsById = keyBy( - podListingsQuery.data?.podListings, - 'historyID' - ); + const podOrdersById = keyBy(podOrders, 'historyID'); + const podListingsById = keyBy(podListings, 'historyID'); // FIXME: // This duplicates logic from `castPodListing` and `castPodOrder`. @@ -151,9 +208,8 @@ const useMarketActivityData = () => { e.maxPlaceInLine, BEAN[1].decimals ); - // HOTFIX: amountPods is using the legacy bean amount format for these events - const amountPods = amount; - const amountBeans = amount.multipliedBy(pricePerPod); + const amountPods = amount.div(pricePerPod).dp(6); + const amountBeans = amount; return { id: 'unknown', eventId: e.id, @@ -171,19 +227,19 @@ const useMarketActivityData = () => { case 'PodOrderCancelled': { // HOTFIX: Fixes edge case where PodOrderCancelled is emitted for an order that doesn't actually exist. const podOrder = podOrdersById[e.historyID]; - if (!e.historyID || !podOrder) return null; - const podAmount = toTokenUnitsBN( - podOrder.podAmount || 0, + if (!e.historyID || !podOrder) return null; + const beanAmount = toTokenUnitsBN( + podOrder.beanAmount || 0, BEAN[1].decimals ); const pricePerPod = toTokenUnitsBN( new BigNumber(podOrder.pricePerPod || 0), BEAN[1].decimals ); - const totalBeans = - podAmount && pricePerPod - ? podAmount.multipliedBy(pricePerPod) + const podAmount = + beanAmount && pricePerPod + ? beanAmount.dividedBy(pricePerPod).dp(6) : undefined; return { @@ -192,17 +248,14 @@ const useMarketActivityData = () => { hash: e.hash, type: 'order' as const, action: 'cancel' as const, - amountPods: toTokenUnitsBN(podOrder?.podAmount, BEAN[1].decimals), + amountPods: podAmount, placeInLine: toTokenUnitsBN( podOrder?.maxPlaceInLine, BEAN[1].decimals ), - pricePerPod: toTokenUnitsBN( - new BigNumber(podOrder?.pricePerPod || 0), - BEAN[1].decimals - ), - amountBeans: totalBeans, - amountUSD: totalBeans ? getUSD(BEAN[1], totalBeans) : undefined, + pricePerPod: pricePerPod, + amountBeans: beanAmount, + amountUSD: beanAmount ? getUSD(BEAN[1], beanAmount) : undefined, createdAt: e.createdAt, }; } @@ -216,13 +269,10 @@ const useMarketActivityData = () => { BEAN[1].decimals ); const podAmountFilled = toTokenUnitsBN( - podOrder.podAmountFilled, + e.amount, BEAN[1].decimals ); - const totalBeans = getUSD( - BEAN[1], - podAmountFilled.multipliedBy(pricePerPod) - ); + const totalBeans = podAmountFilled.multipliedBy(pricePerPod).dp(6); return { id: podOrder.id, eventId: e.id, @@ -231,9 +281,9 @@ const useMarketActivityData = () => { action: 'fill' as const, amountPods: podAmountFilled, placeInLine: toTokenUnitsBN( - new BigNumber(e.index), + new BigNumber(e.placeInLine), BEAN[1].decimals - ).minus(harvestableIndex), + ), pricePerPod: pricePerPod, amountBeans: totalBeans, amountUSD: getUSD(BEAN[1], totalBeans), @@ -251,8 +301,9 @@ const useMarketActivityData = () => { type: 'listing' as const, action: 'create' as const, amountPods: numPods, - placeInLine: toTokenUnitsBN(e.index, BEAN[1].decimals).minus( - harvestableIndex + placeInLine: toTokenUnitsBN( + new BigNumber(e.placeInLine), + BEAN[1].decimals ), pricePerPod: pricePerPod, amountBeans: totalBeans, @@ -269,8 +320,7 @@ const useMarketActivityData = () => { new BigNumber(podListing.pricePerPod || 0), BEAN[1].decimals ); - const totalBeans = numPods.multipliedBy(pricePerPod); - + const totalBeans = numPods.multipliedBy(pricePerPod).dp(6); return { id: e.historyID.split('-')[1], eventId: e.id, @@ -279,9 +329,9 @@ const useMarketActivityData = () => { action: 'cancel' as const, amountPods: numPods, placeInLine: toTokenUnitsBN( - podListing?.index, + new BigNumber(e.placeInLine), BEAN[1].decimals - ).minus(harvestableIndex), + ), pricePerPod: pricePerPod, amountBeans: totalBeans, amountUSD: getUSD(BEAN[1], totalBeans), @@ -309,9 +359,9 @@ const useMarketActivityData = () => { action: 'fill' as const, amountPods: numPodsFilled, placeInLine: toTokenUnitsBN( - podListing?.index, + new BigNumber(e.placeInLine), BEAN[1].decimals - ).minus(harvestableIndex), + ), pricePerPod: pricePerPod, amountBeans: totalBeans, amountUSD: getUSD(BEAN[1], totalBeans), @@ -325,8 +375,7 @@ const useMarketActivityData = () => { }; const _data: MarketEvent[] = []; - const _max = Math.min(events.length, QUERY_AMOUNT * page); - for (let i = 0; i < _max; i += 1) { + for (let i = 0; i < events.length; i += 1) { const parsed = parseEvent(events[i]); if (parsed) _data.push(parsed); } @@ -337,15 +386,15 @@ const useMarketActivityData = () => { getUSD, harvestableIndex, loading, - marketEventsQuery.data, - podListingsQuery.data, - podOrdersQuery.data, + podOrders, + podListings, + markEvents, page, ]); // kick things off useEffect(() => { - _fetch(QUERY_AMOUNT, MAX_TIMESTAMP); + _fetch(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -354,7 +403,6 @@ const useMarketActivityData = () => { harvestableIndex, loading, error, - fetchMoreData, page, }; }; diff --git a/projects/ui/src/hooks/beanstalk/useMarketData.ts b/projects/ui/src/hooks/beanstalk/useMarketData.ts index 1622f81b7e..19fa03c972 100644 --- a/projects/ui/src/hooks/beanstalk/useMarketData.ts +++ b/projects/ui/src/hooks/beanstalk/useMarketData.ts @@ -1,81 +1,128 @@ import BigNumber from 'bignumber.js'; -import { useCallback, useMemo } from 'react'; -import { MarketStatus, useAllPodOrdersQuery } from '~/generated/graphql'; -import useCastApolloQuery from '~/hooks/app/useCastApolloQuery'; +import { useCallback, useEffect, useState } from 'react'; +import { AllPodListingsQuery, AllPodOrdersQuery, MarketStatus, useAllPodListingsLazyQuery, useAllPodOrdersLazyQuery } from '~/generated/graphql'; import useHarvestableIndex from '~/hooks/beanstalk/useHarvestableIndex'; -import usePodListings from '~/hooks/beanstalk/usePodListings'; import { castPodListing, castPodOrder, PodListing, PodOrder, } from '~/state/farmer/market'; +import useSdk from '../sdk'; const MIN_POD_AMOUNT = 1; const useMarketData = () => { - /// Beanstalk data + const harvestableIndex = useHarvestableIndex(); + const sdk = useSdk(); + + /// status + const [loading, setLoading] = useState(true); + const [error, setError] = useState(false); + + const [listings, setListings] = useState(); + const [orders, setOrders] = useState(); + + const [maxPlaceInLine, setMaxPlaceInLine] = useState(0); + const [maxPlotSize, setMaxPlotSize] = useState(0); /// Queries - const listingsQuery = usePodListings({ - variables: { status: MarketStatus.Active }, - fetchPolicy: 'cache-and-network', - nextFetchPolicy: 'cache-first', - notifyOnNetworkStatusChange: true, - }); - const ordersQuery = useAllPodOrdersQuery({ - variables: { status: MarketStatus.Active }, - fetchPolicy: 'cache-and-network', - nextFetchPolicy: 'cache-first', - notifyOnNetworkStatusChange: true, - }); + const [getListings] = useAllPodListingsLazyQuery(); + const [getOrders] = useAllPodOrdersLazyQuery(); + + const _fetch = useCallback( + async() => { + const _listings: AllPodListingsQuery["podListings"] = []; + const _orders: AllPodOrdersQuery["podOrders"] = []; - /// Query status - const loading = listingsQuery.loading || ordersQuery.loading; - const error = listingsQuery.error || ordersQuery.error; + let listingsOutputLength = 0; + let listingsQueryLoops = 1; + let ordersOutputLength = 0; + let ordersQueryLoops = 1; - /// Cast query data to BigNumber, etc. - const listings = useCastApolloQuery( - listingsQuery, - 'podListings', - useCallback( - (_listing) => castPodListing(_listing, harvestableIndex), - [harvestableIndex] - ), - loading - ); - let orders = useCastApolloQuery( - ordersQuery, - 'podOrders', - castPodOrder, - loading - ); - orders = orders?.filter((order) => - order.beanAmountRemaining.gt(MIN_POD_AMOUNT) - ); + const harvestableIndexFormatted = + harvestableIndex.multipliedBy(new BigNumber(10).pow(sdk.tokens.BEAN.decimals)).toString(); + + try { + setLoading(true); + setError(false); + do { + if (harvestableIndex?.gt(0)) { + const listings = await getListings({ + variables: { + first: 1000, + skip: (listingsQueryLoops * 1000) - 1000, + status: MarketStatus.Active, + maxHarvestableIndex: harvestableIndexFormatted, + }, + fetchPolicy: 'cache-and-network', + nextFetchPolicy: 'cache-first', + notifyOnNetworkStatusChange: true, + }); + if (listings.data) { + _listings.push(...listings.data.podListings); + listingsOutputLength = listings.data.podListings.length; + listingsQueryLoops += 1; + }; + }; + } while ( listingsOutputLength === 1000 ); + do { + const orders = await getOrders({ + variables: { + first: 1000, + skip: (ordersQueryLoops * 1000) - 1000, + status: MarketStatus.Active + }, + fetchPolicy: 'cache-and-network', + nextFetchPolicy: 'cache-first', + notifyOnNetworkStatusChange: true, + }); + if (orders.data) { + _orders.push(...orders.data.podOrders); + ordersOutputLength = orders.data.podOrders.length; + ordersQueryLoops += 1; + }; + } while ( ordersOutputLength === 1000 ); + const _listingsOutput = _listings.map((listing: any) => castPodListing(listing, harvestableIndex)); + setListings(_listingsOutput); + const _ordersOutput = _orders.map(castPodOrder).filter((order: any) => + order.beanAmountRemaining.gt(MIN_POD_AMOUNT) + ); + setOrders(_ordersOutput); + setLoading(false); + } catch (e) { + setError(true); + }; + }, + [harvestableIndex]); + + useEffect(() => { + _fetch(); + }, [harvestableIndex]); /// Calculations - const maxPlaceInLine = useMemo( - () => - listings + useEffect(() => { + if (harvestableIndex) { + const _maxPlaceInLine = listings ? Math.max( ...listings.map((l) => new BigNumber(l.index).minus(harvestableIndex).toNumber() ) ) - : 0, - [harvestableIndex, listings] - ); - const maxPlotSize = useMemo( - () => - listings - ? Math.max( - ...listings.map((l) => new BigNumber(l.remainingAmount).toNumber()) - ) - : 0, - [listings] - ); + : 0; + setMaxPlaceInLine(_maxPlaceInLine); + }; + }, [harvestableIndex, listings]); + + useEffect(() => { + const _maxPlotSize = listings + ? Math.max( + ...listings.map((l) => new BigNumber(l.remainingAmount).toNumber()) + ) + : 0; + setMaxPlotSize(_maxPlotSize); + }, [listings]); return { listings, diff --git a/projects/ui/src/hooks/farmer/market/useFarmerMarket2.ts b/projects/ui/src/hooks/farmer/market/useFarmerMarket2.ts index 98f953328d..c5e1f6ee16 100644 --- a/projects/ui/src/hooks/farmer/market/useFarmerMarket2.ts +++ b/projects/ui/src/hooks/farmer/market/useFarmerMarket2.ts @@ -195,15 +195,30 @@ export default function useFarmerMarket() { // Cast query data to history item form const data = useMemo( - () => + () => { + const filteredOrderItems: FarmerMarketOrder[] = []; + if (orderItems) { + orderItems.forEach((order) => { + if (order.amountBeans.minus(order.amountBeansFilled).lt(new BigNumber(0.00001))) { + const newOrder = { + ...order, + status: MarketStatus.Filled + }; + filteredOrderItems.push(newOrder); + } else { + filteredOrderItems.push(order); + }; + }); + }; // shortcut to check if listings / orders are still loading - [...(listingItems || []), ...(orderItems || [])].sort((a, b) => { + return [...(listingItems || []), ...(filteredOrderItems || [])].sort((a, b) => { // Sort by MARKET_STATUS_TO_ORDER, then by creation date const x = MARKET_STATUS_TO_ORDER[a.status] - MARKET_STATUS_TO_ORDER[b.status]; if (x !== 0) return x; return parseInt(b.createdAt, 10) - parseInt(a.createdAt, 10); - }), + }); + }, [listingItems, orderItems] ); diff --git a/projects/ui/src/hooks/farmer/market/useFarmerMarketItemStats.tsx b/projects/ui/src/hooks/farmer/market/useFarmerMarketItemStats.tsx index 5b2872d54a..4a93bb6b67 100644 --- a/projects/ui/src/hooks/farmer/market/useFarmerMarketItemStats.tsx +++ b/projects/ui/src/hooks/farmer/market/useFarmerMarketItemStats.tsx @@ -40,7 +40,7 @@ export default function useFarmerMarketItemStats( }); items.push({ label: 'PRICE', - info: displayFullBN(item.pricePerPod, 2, 2), + info: displayFullBN(item.pricePerPod, 4, 2), }); if (isListing(item)) { items.push({ diff --git a/projects/ui/src/state/farmer/market/index.ts b/projects/ui/src/state/farmer/market/index.ts index dcbaed06bb..22793a4dfe 100644 --- a/projects/ui/src/state/farmer/market/index.ts +++ b/projects/ui/src/state/farmer/market/index.ts @@ -26,8 +26,9 @@ export const castPodListing = ( listing: PodListingFragment, harvestableIndex: BigNumber ): PodListing => { - const [account, id] = listing.id.split('-'); // Subgraph returns a conjoined ID - const index = toTokenUnitsBN(id, BEAN[1].decimals); + // Subgraph returns id of the form account-index(-relistCount if it got relisted). + const [account, listingIndex] = listing.id.split('-'); + const index = toTokenUnitsBN(listingIndex, BEAN[1].decimals); const maxHarvestableIndex = toTokenUnitsBN( listing.maxHarvestableIndex, BEAN[1].decimals @@ -35,7 +36,7 @@ export const castPodListing = ( return { // Identifiers - id: id, + id: listing.id, account: listing.farmer.id || account, // Configuration @@ -82,7 +83,8 @@ export const castPodListing = ( * @returns Redux form of PodOrder. */ export const castPodOrder = (order: PodOrderFragment): PodOrder => { - const podAmount = toTokenUnitsBN(order.podAmount, BEAN[1].decimals); + const pricePerPod = toTokenUnitsBN(order.pricePerPod, BEAN[1].decimals); + const beanAmount = toTokenUnitsBN(order.beanAmount, BEAN[1].decimals); const podAmountFilled = toTokenUnitsBN( order.podAmountFilled, @@ -93,6 +95,10 @@ export const castPodOrder = (order: PodOrderFragment): PodOrder => { BEAN[1].decimals ); + const beanAmountRemaining = beanAmount.minus(beanAmountFilled).dp(6, BigNumber.ROUND_UP); + const podAmountRemaining = beanAmountRemaining.div(pricePerPod).dp(6, BigNumber.ROUND_UP); + const podAmount = podAmountFilled.plus(podAmountRemaining); + return { // Identifiers id: order.id, @@ -117,8 +123,8 @@ export const castPodOrder = (order: PodOrderFragment): PodOrder => { beanAmountFilled: beanAmountFilled, // Computed - podAmountRemaining: podAmount.minus(podAmountFilled), - beanAmountRemaining: beanAmount.minus(beanAmountFilled), + podAmountRemaining: podAmountRemaining, + beanAmountRemaining: beanAmountRemaining, // Metadata status: order.status as MarketStatus, diff --git a/projects/ui/src/util/Ledger.ts b/projects/ui/src/util/Ledger.ts index 50eda11303..37de6512f9 100644 --- a/projects/ui/src/util/Ledger.ts +++ b/projects/ui/src/util/Ledger.ts @@ -63,8 +63,14 @@ export const parseError = (error: any) => { case 'UNSUPPORTED_OPERATION': case 'CALL_EXCEPTION': if (error.reason) { - errorMessage.message = error.reason.replace('execution reverted: ', ''); - return errorMessage; + if (error.reason.includes('viem')) { + const _message = error.reason.substring(error.reason.indexOf('execution reverted: ')); + errorMessage.message = _message.replace('execution reverted: ', ''); + return errorMessage; + } else { + errorMessage.message = error.reason.replace('execution reverted: ', ''); + return errorMessage; + } } if (error.data && error.data.message) {