Skip to content

Commit

Permalink
Merge pull request #22 from aavegotchi/feat/isBuyNow
Browse files Browse the repository at this point in the history
feat: add isBuyNow
  • Loading branch information
cinnabarhorse authored May 15, 2024
2 parents 5854f90 + fc6bf4f commit 14054b7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type Auction @entity {
category: Int!
buyNowPrice: BigInt!
startBidPrice: BigInt!
startBidFeePercent: BigInt!
isBought: Boolean!
}

type Bid @entity {
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export let BIGINT_ZERO = BigInt.fromI32(0);
export let BIGINT_ONE = BigInt.fromI32(1);

export let BIGINT_CANCELLATION_PERIOD_IN_SECONDS = BigInt.fromI32(3600);
export let BIGINT_STARTING_BID_FEE_PERCENT = BigInt.fromI32(4);

// TODO: Needs to be updated to activated block number
export let BLOCK_NR_BUY_NOW_ACTIVATED = BigInt.fromI32(55931248);
4 changes: 3 additions & 1 deletion src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ethereum,
} from "@graphprotocol/graph-ts";
import { Auction, Bid, Incentive, Statistic, User } from "../generated/schema";
import { BIGINT_ONE, BIGINT_ZERO, BLOCK_NR_BUY_NOW_ACTIVATED } from "./constants";
import {BIGINT_ONE, BIGINT_STARTING_BID_FEE_PERCENT, BIGINT_ZERO, BLOCK_NR_BUY_NOW_ACTIVATED} from "./constants";
import { ContractV1 } from "../generated/Contract/ContractV1";
import { Contract } from "../generated/Contract/Contract";

Expand Down Expand Up @@ -84,6 +84,8 @@ export function getOrCreateAuction(
auction.totalBids = BIGINT_ZERO;
auction.buyNowPrice = BIGINT_ZERO;
auction.startBidPrice = BIGINT_ZERO;
auction.startBidFeePercent = BIGINT_STARTING_BID_FEE_PERCENT;
auction.isBought = false;
}

return auction;
Expand Down
5 changes: 4 additions & 1 deletion src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
import { events, transactions } from "@amxx/graphprotocol-utils";
import {
BIGINT_CANCELLATION_PERIOD_IN_SECONDS,
BIGINT_ONE,
BIGINT_ONE, BIGINT_STARTING_BID_FEE_PERCENT,
BIGINT_ZERO,
} from "./constants";

Expand Down Expand Up @@ -319,6 +319,8 @@ export function handleAuction_Initialized(
auction.cancelled = false;
auction.buyNowPrice = BigInt.fromI32(0);
auction.startBidPrice = BigInt.fromI32(0);
auction.startBidFeePercent = BIGINT_STARTING_BID_FEE_PERCENT;
auction.isBought = false;

// Update Auction
auction = updateAuction(auction, event);
Expand Down Expand Up @@ -598,6 +600,7 @@ export function handleAuction_BoughtNow(
}
auction.claimed = true;
auction.claimAt = event.block.timestamp;
auction.isBought = true;

let bid = getOrCreateBid(
auction.highestBidder,
Expand Down

0 comments on commit 14054b7

Please sign in to comment.