diff --git a/manifest.template.yaml b/manifest.template.yaml index 9ee9b107..3287dedf 100644 --- a/manifest.template.yaml +++ b/manifest.template.yaml @@ -2483,8 +2483,8 @@ templates: # file: ./abis/WeightedPool.json - name: SecondaryIssuePool file: ./abis/SecondaryIssuePool.json - #- name: Orderbook - # file: ./abis/Orderbook.json + - name: Orderbook + file: ./abis/Orderbook.json eventHandlers: - event: Transfer(indexed address,indexed address,uint256) handler: handleTransfer diff --git a/schema.graphql b/schema.graphql index 51835825..f834a1fa 100644 --- a/schema.graphql +++ b/schema.graphql @@ -153,10 +153,11 @@ type Pool @entity { # SecondaryPool and OffchainSecondariesPool only minOrderSize: BigInt - orderBook: Bytes + orderBook: Orderbook + #orderBook: Bytes issueManager: Bytes secondaryTrades: [SecondaryTrades!] @derivedFrom(field: "pool") - # secondaryPreTrades: [SecondaryPreTrades!] @derivedFrom(field: "pool") + #secondaryPreTrades: [SecondaryPreTrades!] @derivedFrom(field: "pool") orders: [SecondaryOrders!]@derivedFrom(field: "pool") # MarginTradingPool only @@ -201,17 +202,16 @@ type SecondaryOrders @entity { priceOffered: BigDecimal! timestamp: BigInt orderReference: Bytes! - orderbook: Orderbook! } type Orderbook @entity { id: ID! - preTrades: [SecondaryPreTrades!]! @derivedFrom(field: "orderbook") + secondaryPreTrades: [SecondaryPreTrades!]! @derivedFrom(field: "orderbook") } type SecondaryPreTrades @entity { id: ID! - pool: Pool! + pool: Pool party: User counterparty: User executionDate: BigInt! diff --git a/src/mappings/helpers/misc.ts b/src/mappings/helpers/misc.ts index 2620197e..a9c62d7f 100644 --- a/src/mappings/helpers/misc.ts +++ b/src/mappings/helpers/misc.ts @@ -233,8 +233,8 @@ export function loadSecondaryTrades(poolId: string, tokenAddress: Address): Seco return SecondaryTrades.load(getPoolTokenId(poolId, tokenAddress)); } -export function loadSecondaryPreTrades(poolId: string, tokenAddress: Address): SecondaryPreTrades | null { - return SecondaryPreTrades.load(getPoolTokenId(poolId, tokenAddress)); +export function loadSecondaryPreTrades(orderBook: string, tokenAddress: Address): SecondaryPreTrades | null { + return SecondaryPreTrades.load(getPoolTokenId(orderBook, tokenAddress)); } export function loadSecondaryOrders(poolId: string, tokenAddress: Address): SecondaryOrders | null { diff --git a/src/mappings/poolController.ts b/src/mappings/poolController.ts index d74abb9d..92456e57 100644 --- a/src/mappings/poolController.ts +++ b/src/mappings/poolController.ts @@ -579,7 +579,7 @@ export function handleSubscription(event: Subscription): void { pool.security = event.params.security; pool.currency = event.params.currency; - pool.orderBook = event.params.orderBook; + pool.orderBook = event.params.orderBook.toHexString(); pool.minOrderSize = event.params.minOrderSize; pool.issueManager = event.params.issueManager; @@ -620,28 +620,28 @@ export function handleOrderBook(event: OrderBook): void { } export function handlePreTrades(event: tradeExecuted): void { - let poolAddress = event.params.pool; + let orderBook = event.address; - let poolContract = SecondaryIssuePool.bind(poolAddress); - let poolIdCall = poolContract.try_getPoolId(); - let poolId = poolIdCall.value; + //let poolContract = SecondaryIssuePool.bind(poolAddress); + //let poolIdCall = poolContract.try_getPoolId(); + //let poolId = poolIdCall.value; - let pretrades = loadSecondaryPreTrades(event.transaction.hash.toHexString(), event.params.pool); + let pretrades = loadSecondaryPreTrades(event.transaction.hash.toHexString(), orderBook); if (pretrades == null) { - let providerId = getPoolTokenId(event.transaction.hash.toHexString(), event.params.pool); + let providerId = getPoolTokenId(event.transaction.hash.toHexString(), orderBook); let pretrades = new SecondaryPreTrades(providerId); - pretrades.pool = poolId.toHexString(); + pretrades.pool = event.params.pool.toHexString(); pretrades.executionDate = event.params.tradeToReportDate; pretrades.party = event.params.party.toHexString(); pretrades.counterparty = event.params.counterparty.toHexString(); pretrades.save(); } - else{ + /*else{ pretrades.executionDate = event.params.tradeToReportDate; pretrades.party = event.params.party.toHexString(); pretrades.counterparty = event.params.counterparty.toHexString(); pretrades.save(); - } + }*/ } export function handleTradeReport(event: TradeReport): void { @@ -683,7 +683,7 @@ export function handleTradeReport(event: TradeReport): void { /************************************ *******OFFCHAIN SECONDARY*********** ************************************/ - +/* export function handleOffchainSecondaryOffer(event: Offer): void { let poolAddress = event.address; @@ -770,7 +770,7 @@ export function handleOffchainTradeReport(event: TradeReport): void { } } - +*/ /************************************ *************MARGIN POOL************ ************************************/ @@ -790,7 +790,7 @@ export function handleOffchainTradeReport(event: TradeReport): void { pool.margin = event.params.margin; pool.collateral = event.params.collateral; pool.cficode = event.params.CfiCode; - pool.orderBook = event.params.orderBook; + pool.orderBook = event.params.orderBook.toHexString(); pool.minOrderSize = event.params.minOrderSize; pool.issueManager = event.params.issueManager; diff --git a/src/mappings/poolFactory.ts b/src/mappings/poolFactory.ts index 7ce51b82..e4102a29 100644 --- a/src/mappings/poolFactory.ts +++ b/src/mappings/poolFactory.ts @@ -406,7 +406,7 @@ export function handleNewSecondaryPool(event: PoolCreated): void { pool.owner = balancerManager; pool.principalToken = security; pool.baseToken = currency; - pool.orderBook = orderBook; + //pool.orderBook = orderBook; let tokens = getPoolTokens(poolId); if (tokens == null) return; @@ -456,7 +456,7 @@ export function handleNewMarginPool(event: PoolCreated): void { pool.margin = margin; pool.collateral = collateral; pool.baseToken = currency; - pool.orderBook = orderBook; + //pool.orderBook = orderBook; let tokens = getPoolTokens(poolId); if (tokens == null) return; @@ -498,7 +498,7 @@ export function handleNewOffchainSecondaryPool(event: PoolCreated): void { pool.owner = balancerManager; pool.principalToken = security; pool.baseToken = currency; - pool.orderBook = orderBook; + //pool.orderBook = orderBook; let tokens = getPoolTokens(poolId); if (tokens == null) return; diff --git a/subgraph.yaml b/subgraph.yaml index 8e680430..5ace4d4f 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -1025,8 +1025,8 @@ templates: # file: ./abis/WeightedPool.json - name: SecondaryIssuePool file: ./abis/SecondaryIssuePool.json - #- name: Orderbook - # file: ./abis/Orderbook.json + - name: Orderbook + file: ./abis/Orderbook.json eventHandlers: - event: Transfer(indexed address,indexed address,uint256) handler: handleTransfer