Skip to content

Commit

Permalink
Merge pull request #104 from perpetual-protocol/feat/re-enable-graft
Browse files Browse the repository at this point in the history
Feat/re enable graft
  • Loading branch information
lnxrp committed Dec 7, 2023
2 parents c4adefb + b67dd45 commit d945051
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
5 changes: 5 additions & 0 deletions configs/optimism.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
4 changes: 2 additions & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions scripts/updateConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ async function main(): Promise<void> {
// 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,
},
},
]

Expand Down
7 changes: 6 additions & 1 deletion src/mappings/insuranceFund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d945051

Please sign in to comment.