Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get address from hca + remove v2 gauge logic #10

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"solidity-coverage": "^0.7.16"
},
"dependencies": {
"@halodao/halodao-contract-addresses": "1.0.60",
"@openzeppelin/contracts": "^3.4.1",
"@typechain/ethers-v5": "^6.0.4",
"@types/mocha": "^8.2.2",
Expand Down
51 changes: 18 additions & 33 deletions scripts/xsgd-rewards-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import {
import { getSGDRate } from './util/cmc'
import { ExportToCsv } from 'export-to-csv'
import * as fs from 'fs'
import { matic } from '@halodao/halodao-contract-addresses'

const POOL_ADDRESS = '0x726E324c29a1e49309672b244bdC4Ff62A270407'
const GAUGE_ADDRESS = '0x3aC845345fc2d51A3006Ed384055cD5ACde86441'
const GAUGE_ADDRESS_V2 = '0xA7165E1E3dEfe55DAdA5C4289268d57faBA6dAd2'
const POOL_ADDRESS = matic.ammV2.pools.all.LP_XSGD_USDC || ZERO_ADDRESS
const GAUGE_ADDRESS =
matic.ammV2.pools.enabled.find(p => p.address === POOL_ADDRESS)?.gauges
?.child || ZERO_ADDRESS
const ONE_ETH = parseEther('1')

export const snapshotXSGDRewards = async (
Expand All @@ -33,11 +35,7 @@ export const snapshotXSGDRewards = async (
rewardsOnlyGaugeABI,
deployer
)
const GaugeContractV2 = new hre.ethers.Contract(
GAUGE_ADDRESS_V2,
rewardsOnlyGaugeABI, // this works even if ABI doesn't fully match since we only need `balanceOf()`
deployer
)

/**
* STEP 1: Get list of all LPs
*/
Expand All @@ -49,8 +47,7 @@ export const snapshotXSGDRewards = async (

const possibleLPs: string[] = []
const blacklisted = [
GAUGE_ADDRESS, // XSGD-USDC Polygon Gauge (RewardsOnlyGauge)
GAUGE_ADDRESS_V2, // new XSGD-USDC Polygon Gauge (ChildLiquidityGauge)
GAUGE_ADDRESS, // XSGD-USDC Polygon Gauge (ChildLiquidityGauge)
ZERO_ADDRESS // transfer to 0x0 means BPT is burnt
]
events.map(e => {
Expand Down Expand Up @@ -121,7 +118,6 @@ export const snapshotXSGDRewards = async (
for (const block of blocks) {
const getBPTBalancePromises: any[] = []
const getStakedBPTBalancePromises: any[] = []
const getStakedBPTV2BalancePromises: any[] = []

possibleLPs.map(lp => {
getBPTBalancePromises.push(
Expand All @@ -134,26 +130,16 @@ export const snapshotXSGDRewards = async (
blockTag: block
})
)
getStakedBPTV2BalancePromises.push(
GaugeContractV2.balanceOf(lp, {
blockTag: block
})
)
})

const [
blockBPTBalances,
blockStakedBPTBalances,
blockStakedBPTV2Balances,
blockLiquidity
] = await Promise.all([
Promise.all(getBPTBalancePromises),
Promise.all(getStakedBPTBalancePromises),
Promise.all(getStakedBPTV2BalancePromises),
FXPoolContract.liquidity({
blockTag: block
})
])
const [blockBPTBalances, blockStakedBPTBalances, blockLiquidity] =
await Promise.all([
Promise.all(getBPTBalancePromises),
Promise.all(getStakedBPTBalancePromises),
FXPoolContract.liquidity({
blockTag: block
})
])

const xsgdLiquidityIndex = 0

Expand All @@ -178,16 +164,15 @@ export const snapshotXSGDRewards = async (
blockTotalBPT = blockTotalBPT
.add(blockBPTBalances[index])
.add(blockStakedBPTBalances[index])
.add(blockStakedBPTV2Balances[index])
})
console.log('blockTotalBPT:', formatEther(blockTotalBPT))

userRewards[block] = []

possibleLPs.forEach((lp, index) => {
const userBPT = (blockBPTBalances[index] as BigNumber)
.add(blockStakedBPTBalances[index] as BigNumber)
.add(blockStakedBPTV2Balances[index] as BigNumber)
const userBPT = (blockBPTBalances[index] as BigNumber).add(
blockStakedBPTBalances[index] as BigNumber
)

if (userBPT.gt(0)) {
const share = userBPT.mul(ONE_ETH).div(blockTotalBPT)
Expand Down
Loading
Loading