From 84d9221c0793f4a744aa34e09730b5235192b85c Mon Sep 17 00:00:00 2001 From: EmberSpirit007 <148816965+EmberSpirit007@users.noreply.github.com> Date: Thu, 6 Feb 2025 21:38:40 +0100 Subject: [PATCH] base deployment --- subgraph/base_sepolia/README.md | 8 ++++++++ subgraph/base_sepolia/deploy.js | 8 ++++++++ subgraph/base_sepolia/src/chains.ts | 8 ++++---- subgraph/base_sepolia/src/stake.ts | 8 ++++---- subgraph/base_sepolia/subgraph.yaml | 12 ++++++------ 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/subgraph/base_sepolia/README.md b/subgraph/base_sepolia/README.md index 35dbfe5..6c3c967 100644 --- a/subgraph/base_sepolia/README.md +++ b/subgraph/base_sepolia/README.md @@ -8,6 +8,13 @@ yarn build yarn deploy ``` +## deployment-script +networks are defined in deploy.js +This solution overwrites the subgraph.yaml with the template and enables the possible to upgrade the same contract on different chains +``` +node deploy.js base +``` + ## queries for stats @@ -29,3 +36,4 @@ for stats } ``` + diff --git a/subgraph/base_sepolia/deploy.js b/subgraph/base_sepolia/deploy.js index ae4a9a4..35939b3 100644 --- a/subgraph/base_sepolia/deploy.js +++ b/subgraph/base_sepolia/deploy.js @@ -18,6 +18,14 @@ const networks = { START_BLOCK: 6746241, SUBGRAPH_NAME: "harb" }, + 'base': { + NETWORK: 'base', + CONTRACT_ADDRESS_HARB: '0x45caa5929f6ee038039984205bdecf968b954820', + CONTRACT_ADDRESS_STAKE: '0xed70707fab05d973ad41eae8d17e2bcd36192cfc', + START_BLOCK: 26038614, + // START_BLOCK: 25895309, + SUBGRAPH_NAME: "kraiken-base" + }, }; // Netzwerk über Kommandozeilenargument auswählen diff --git a/subgraph/base_sepolia/src/chains.ts b/subgraph/base_sepolia/src/chains.ts index accc9a8..b0a6d04 100644 --- a/subgraph/base_sepolia/src/chains.ts +++ b/subgraph/base_sepolia/src/chains.ts @@ -24,13 +24,13 @@ export function getSubgraphConfig(): SubgraphConfig { // subgraph does not support case switch with strings, hence this if else block if (selectedNetwork == BASE_NETWORK_NAME) { return { - harbergAddress: Address.fromString('0x1F98431c8aD98523631AE4a59f267346ea31F984'), - stakeAddress: Address.fromString('0x17c14d2c404d167802b16c450d3c99f88f2c4f4d'), + harbergAddress: Address.fromString('0x45caa5929f6ee038039984205bdecf968b954820'), + stakeAddress: Address.fromString('0xed70707fab05d973ad41eae8d17e2bcd36192cfc'), } } else if (selectedNetwork == BASE_SEPOLIA_NETWORK_NAME) { return { - harbergAddress: Address.fromString('0x54838DC097E7fC4736B801bF1c1FCf1597348265'), - stakeAddress: Address.fromString('0xd7728173F73C748944d29EA77b56f09b8FEc8F33'), + harbergAddress: Address.fromString('0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8'), + stakeAddress: Address.fromString('0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2'), } } else { throw new Error('Unsupported Network') diff --git a/subgraph/base_sepolia/src/stake.ts b/subgraph/base_sepolia/src/stake.ts index 7535c4e..44fcf9d 100644 --- a/subgraph/base_sepolia/src/stake.ts +++ b/subgraph/base_sepolia/src/stake.ts @@ -22,7 +22,7 @@ export function handlePositionCreated(event: PositionCreatedEvent): void { position.creationTime = event.block.timestamp.toI32(); position.lastTaxTime = event.block.timestamp.toI32(); position.taxRate = BigDecimal.fromString(taxRates[event.params.taxRate.toI32()]); - position.harbDeposit = event.params.harbDeposit; + position.harbDeposit = event.params.harbergDeposit; position.status = "Active"; position.snatched = 0; position.payout = BigInt.fromString("0"); @@ -44,7 +44,7 @@ export function handlePositionRemoved(event: PositionRemovedEvent): void { position.status = "Closed"; let harb = Harb.bind(getSubgraphConfig().harbergAddress); position.totalSupplyEnd = harb.totalSupply(); - position.payout = position.payout.plus(event.params.harbPayout); + // position.payout = position.payout.plus(event.params.harbPayout); position.save(); } let stake = Stake.bind(event.address); @@ -59,10 +59,10 @@ export function handlePositionShrunk(event: PositionShrunkEvent): void { let position = Position.load(Bytes.fromI32(event.params.positionId.toI32())); if (position != null) { position.share = event.params.newShares.toBigDecimal().div(totalSupply); - position.harbDeposit = position.harbDeposit.minus(event.params.harbPayout); + position.harbDeposit = position.harbDeposit.minus(event.params.harbergPayout); position.snatched = position.snatched++; - position.payout = position.payout.plus(event.params.harbPayout); + // position.payout = position.payout.plus(event.params.harbPayout); position.save(); } } diff --git a/subgraph/base_sepolia/subgraph.yaml b/subgraph/base_sepolia/subgraph.yaml index 1098cfd..7289e1f 100644 --- a/subgraph/base_sepolia/subgraph.yaml +++ b/subgraph/base_sepolia/subgraph.yaml @@ -6,11 +6,11 @@ schema: dataSources: - kind: ethereum name: Harb - network: base-sepolia + network: base source: - address: "0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8" + address: "0x45caa5929f6ee038039984205bdecf968b954820" abi: Harb - startBlock: 20940337 + startBlock: 26038614 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -29,11 +29,11 @@ dataSources: file: ./src/harb.ts - kind: ethereum name: Stake - network: base-sepolia + network: base source: - address: "0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2" + address: "0xed70707fab05d973ad41eae8d17e2bcd36192cfc" abi: Stake - startBlock: 20940337 + startBlock: 26038614 mapping: kind: ethereum/events apiVersion: 0.0.7