-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from alpaca-finance/fix/rewarder-deposit-after…
…-harvest [main][fix] Fix wrong reward debt calculation
- Loading branch information
Showing
5 changed files
with
145 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
deploy/exec/xalpaca-v2-rewarder/config/find-pending-tokens.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
import { ethers } from "hardhat"; | ||
import { XALPACAv2Rewarder__factory } from "../../../../typechain"; | ||
import { ConfigEntity } from "../../../entities"; | ||
import { getDeployer } from "../../../../utils/deployer-helper"; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
interface IRewarder { | ||
NAME: string; | ||
AMOUNT: string; | ||
DECIMAL: number; | ||
} | ||
/* | ||
░██╗░░░░░░░██╗░█████╗░██████╗░███╗░░██╗██╗███╗░░██╗░██████╗░ | ||
░██║░░██╗░░██║██╔══██╗██╔══██╗████╗░██║██║████╗░██║██╔════╝░ | ||
░╚██╗████╗██╔╝███████║██████╔╝██╔██╗██║██║██╔██╗██║██║░░██╗░ | ||
░░████╔═████║░██╔══██║██╔══██╗██║╚████║██║██║╚████║██║░░╚██╗ | ||
░░╚██╔╝░╚██╔╝░██║░░██║██║░░██║██║░╚███║██║██║░╚███║╚██████╔╝ | ||
░░░╚═╝░░░╚═╝░░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═╝╚═╝░░╚══╝░╚═════╝░ | ||
Check all variables below before execute the deployment script | ||
*/ | ||
|
||
const config = ConfigEntity.getConfig(); | ||
|
||
const REWARDER_NAME = "PYTH"; | ||
const accounts: string[] = []; | ||
|
||
const rewarder = config.xALPACAv2Rewarders.find((rw) => rw.name === REWARDER_NAME); | ||
if (!rewarder) { | ||
console.log(`>> ${REWARDER_NAME} Rewarder not found`); | ||
return; | ||
} | ||
|
||
const rewarderContract = XALPACAv2Rewarder__factory.connect(rewarder.address, ethers.provider); | ||
|
||
let counter: number = 0; | ||
const badAccounts: string[] = []; | ||
|
||
for (const account of accounts) { | ||
await rewarderContract.pendingToken(account).catch((e) => { | ||
console.log(">> Error:", account); | ||
badAccounts.push(account); | ||
}); | ||
counter++; | ||
} | ||
|
||
if (counter !== accounts.length) { | ||
console.log(`>> Exited before checking all accounts. ${counter} of ${accounts.length} checked.`); | ||
} | ||
|
||
console.log(`>> ${REWARDER_NAME} Rewarder bad accounts: ${badAccounts.length}`); | ||
console.log(badAccounts); | ||
|
||
console.log(`✅ Done`); | ||
}; | ||
|
||
export default func; | ||
func.tags = ["FindPendingTokens"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters