diff --git a/configs/optimism.json b/configs/optimism.json index f7ac8e6..e6f5152 100644 --- a/configs/optimism.json +++ b/configs/optimism.json @@ -520,5 +520,10 @@ }, "network": "optimism", "version": "git+ssh://git@github.com:perpetual-protocol/perp-curie-periphery-contract.git#a8fb8b9d6ee5836b0e652e6789c3c2469155fb2f" + }, + "graft": { + "base": "QmVyf7ovnBMjNJioxg2Z8h22JHSgrEZd58wCwqLhV9AdG8", + "baseForSatsuma": "QmVyf7ovnBMjNJioxg2Z8h22JHSgrEZd58wCwqLhV9AdG8", + "block": 113120599 } } \ No newline at end of file diff --git a/schema.graphql b/schema.graphql index 9420eda..a725c1b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -22,9 +22,9 @@ type Protocol @entity { "total repaid" totalRepaid: BigDecimal "threshold amount for Insurance Fund to distribute surplus" - insuranceFundFeeDistributionThreshold: BigDecimal! + insuranceFundFeeDistributionThreshold: BigDecimal "total amount of surplus Insurance Fund has distributed" - insuranceFundFeeDistributionTotalAmount: BigDecimal! + insuranceFundFeeDistributionTotalAmount: BigDecimal "last updated block number" blockNumber: BigInt! "last updated block timestamp" diff --git a/scripts/updateConfigs.ts b/scripts/updateConfigs.ts index 0c50cc8..2ae6dd8 100644 --- a/scripts/updateConfigs.ts +++ b/scripts/updateConfigs.ts @@ -48,12 +48,12 @@ async function main(): Promise { // For Satsuma-based subgraph, log in to https://app.satsuma.xyz/ // -> choose target subgraph // -> find "Deployment ID" - // graft: { - // base: "QmW6xjaqSA37ZxsQ9WLp5fqReHpgXrridcWrk4DcpMqGa2", - // baseForSatsuma: "QmW6xjaqSA37ZxsQ9WLp5fqReHpgXrridcWrk4DcpMqGa2", - // // The block number to restore and start re-syncing from. - // block: 53189383, - // }, + graft: { + base: "QmVyf7ovnBMjNJioxg2Z8h22JHSgrEZd58wCwqLhV9AdG8", + baseForSatsuma: "QmVyf7ovnBMjNJioxg2Z8h22JHSgrEZd58wCwqLhV9AdG8", + // The block number to restore and start re-syncing from. + block: 113120599, + }, }, ] diff --git a/src/mappings/insuranceFund.ts b/src/mappings/insuranceFund.ts index 23e275c..bc084c6 100644 --- a/src/mappings/insuranceFund.ts +++ b/src/mappings/insuranceFund.ts @@ -24,7 +24,12 @@ export function handleFeeDistributed(event: FeeDistributedEvent): void { // update protocol const protocol = getOrCreateProtocol() - protocol.insuranceFundFeeDistributionTotalAmount = protocol.insuranceFundFeeDistributionTotalAmount.plus(surplus) + // protocol.insuranceFundFeeDistributionTotalAmount could be null due to backward compatibility + if (protocol.insuranceFundFeeDistributionTotalAmount !== null) { + protocol.insuranceFundFeeDistributionTotalAmount = protocol.insuranceFundFeeDistributionTotalAmount!.plus(surplus) + } else { + protocol.insuranceFundFeeDistributionTotalAmount = surplus + } // commit changes feeDistributed.save()