@gooddollar/goodprotocol 2.1.3 → 2.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (318) hide show
  1. package/README.md +0 -2
  2. package/artifacts/abis/IdentityV4.min.json +1 -0
  3. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  4. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  5. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  6. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  7. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  8. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  9. package/artifacts/contracts/IUniswapV3.sol/INonfungiblePositionManager.dbg.json +1 -1
  10. package/artifacts/contracts/IUniswapV3.sol/IUniswapV3Pool.dbg.json +1 -1
  11. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  12. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  13. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  14. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  15. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  16. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  17. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  18. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  19. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +1 -1
  23. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/IQuoterV2.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/ISwapRouter.dbg.json +1 -1
  28. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  29. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  30. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  31. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  32. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  33. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  34. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  35. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  36. package/artifacts/contracts/MentoInterfaces.sol/IBancorExchangeProvider.dbg.json +1 -1
  37. package/artifacts/contracts/MentoInterfaces.sol/IBroker.dbg.json +1 -1
  38. package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExchangeProvider.dbg.json +1 -1
  39. package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExpansionController.dbg.json +1 -1
  40. package/artifacts/contracts/MentoInterfaces.sol/IMentoReserve.dbg.json +1 -1
  41. package/artifacts/contracts/MentoInterfaces.sol/ITradingLimits.dbg.json +1 -1
  42. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
  43. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  44. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
  45. package/artifacts/contracts/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet.dbg.json +1 -1
  46. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  47. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  48. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  49. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
  50. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.json +2 -2
  51. package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +1 -1
  52. package/artifacts/contracts/governance/GoodDollarStaking.sol/IStakingUpgrade.dbg.json +1 -1
  53. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
  54. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  55. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  56. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  57. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  58. package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
  59. package/artifacts/contracts/identity/IdentityV3.sol/IdentityV3.dbg.json +1 -1
  60. package/artifacts/contracts/identity/IdentityV3.sol/IdentityV3.json +2 -2
  61. package/artifacts/contracts/identity/IdentityV4.sol/IdentityV4.dbg.json +4 -0
  62. package/artifacts/contracts/identity/IdentityV4.sol/IdentityV4.json +1162 -0
  63. package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
  64. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  65. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
  66. package/artifacts/contracts/invite/OneTimeReward.sol/OneTimeReward.dbg.json +1 -1
  67. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  68. package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
  69. package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
  70. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTest.dbg.json +1 -1
  71. package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper.dbg.json +1 -1
  72. package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
  73. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  74. package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
  75. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  76. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
  77. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.json +2 -2
  78. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
  79. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
  80. package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
  81. package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
  82. package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.dbg.json +1 -1
  83. package/artifacts/contracts/mocks/GenericDistributionHelperTest.sol/GenericDistributionHelperTest.dbg.json +1 -1
  84. package/artifacts/contracts/mocks/GenericDistributionHelperTest.sol/GenericDistributionHelperTestHelper.dbg.json +1 -1
  85. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  86. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
  87. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.json +2 -2
  88. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  89. package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
  90. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  91. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  92. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
  93. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
  94. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.json +2 -2
  95. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
  96. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  97. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  98. package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.dbg.json +1 -1
  99. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  100. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
  101. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.json +2 -2
  102. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  103. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  104. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  105. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  106. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
  107. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
  108. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  109. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  110. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  111. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  112. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  113. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  114. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  115. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  116. package/artifacts/contracts/reserve/CeloDistributionHelper.sol/CeloDistributionHelper.dbg.json +1 -1
  117. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
  118. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  119. package/artifacts/contracts/reserve/GenericDistributionHelper.sol/GenericDistributionHelper.dbg.json +1 -1
  120. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  121. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  122. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  123. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  124. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  125. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  126. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
  127. package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
  128. package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
  129. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  130. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  131. package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
  132. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  133. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  134. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  135. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  136. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  137. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  138. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  139. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
  140. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
  141. package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
  142. package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
  143. package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
  144. package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
  145. package/artifacts/contracts/token/GoodDollar2.sol/GoodDollar2.dbg.json +1 -1
  146. package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +1 -1
  147. package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +1 -1
  148. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
  149. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
  150. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
  151. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
  152. package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +1 -1
  153. package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
  154. package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
  155. package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
  156. package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
  157. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/Proxy.dbg.json +1 -1
  158. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.dbg.json +1 -1
  159. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
  160. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  161. package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
  162. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
  163. package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
  164. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  165. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
  166. package/artifacts/contracts/utils/BulkWhitelist.sol/BulkWhitelist.dbg.json +1 -1
  167. package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
  168. package/artifacts/contracts/utils/BuyFromReserveHelper.sol/BuyFromReserveHelper.dbg.json +1 -1
  169. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
  170. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
  171. package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +1 -1
  172. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  173. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  174. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  175. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  176. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/EternalStorage.dbg.json +1 -1
  177. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/FuseOldBridgeKill.dbg.json +1 -1
  178. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/IUpgradeabilityOwnerStorage.dbg.json +1 -1
  179. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Initializable.dbg.json +1 -1
  180. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Ownable.dbg.json +1 -1
  181. package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Upgradeable.dbg.json +1 -1
  182. package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.dbg.json +1 -1
  183. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
  184. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
  185. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
  186. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
  187. package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.dbg.json +1 -1
  188. package/artifacts/contracts/utils/LastauthReduction.sol/LastauthReduction.dbg.json +1 -1
  189. package/artifacts/contracts/utils/LastauthReduction.sol/LastauthReduction.json +2 -2
  190. package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
  191. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
  192. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  193. package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
  194. package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.dbg.json +1 -1
  195. package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/MentoExchange.dbg.json +1 -1
  196. package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento.dbg.json +1 -1
  197. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  198. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  199. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  200. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
  201. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
  202. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  203. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  204. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  205. package/artifacts/contracts/utils/ReserveRestore.sol/ReserveRestore.dbg.json +1 -1
  206. package/artifacts/contracts/utils/ReserveRestore.sol/ReserveRestore.json +2 -2
  207. package/contracts/identity/IdentityV3.sol +0 -3
  208. package/contracts/identity/IdentityV4.sol +578 -0
  209. package/hardhat.config.ts +3 -4
  210. package/package.json +8 -4
  211. package/test/governance/ClaimersDistribution.test.ts +1 -1
  212. package/test/governance/CompoundVotingMachine.castvote.test.ts +30 -30
  213. package/test/helpers.ts +76 -195
  214. package/test/identity/IdentityV3.test.ts +53 -129
  215. package/test/identity/IdentityV4.test.ts +454 -0
  216. package/test/reserve/GenericDistributionHelper.e2e.test.ts +445 -0
  217. package/test/utils/AdminWallet.test.ts +14 -15
  218. package/types/contracts/identity/IdentityV4.ts +2001 -0
  219. package/types/contracts/identity/index.ts +1 -0
  220. package/types/contracts/utils/UpdateReserveRatio.sol/MentoExchange.ts +81 -0
  221. package/types/contracts/utils/UpdateReserveRatio.sol/UpdateReserveRatio.ts +134 -0
  222. package/types/contracts/utils/UpdateReserveRatio.sol/index.ts +5 -0
  223. package/types/contracts/utils/UpdateReserveRatioAfterXDC.sol/UpdateReserveRatioAfterXDC.ts +7 -2
  224. package/types/contracts/utils/index.ts +2 -2
  225. package/types/factories/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking__factory.ts +1 -1
  226. package/types/factories/contracts/identity/IdentityV3__factory.ts +1 -1
  227. package/types/factories/contracts/identity/IdentityV4__factory.ts +1213 -0
  228. package/types/factories/contracts/identity/index.ts +1 -0
  229. package/types/factories/contracts/mocks/DistributionBridgeMock__factory.ts +1 -1
  230. package/types/factories/contracts/mocks/GoodDollarStakingMock__factory.ts +1 -1
  231. package/types/factories/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock__factory.ts +1 -1
  232. package/types/factories/contracts/mocks/StakingMockFixedAPY__factory.ts +1 -1
  233. package/types/factories/contracts/utils/LastauthReduction__factory.ts +1 -1
  234. package/types/factories/contracts/utils/ReserveRestore__factory.ts +1 -1
  235. package/types/factories/contracts/utils/UpdateReserveRatio.sol/MentoExchange__factory.ts +39 -0
  236. package/types/factories/contracts/utils/UpdateReserveRatio.sol/UpdateReserveRatio__factory.ts +113 -0
  237. package/types/factories/contracts/utils/UpdateReserveRatio.sol/index.ts +5 -0
  238. package/types/factories/contracts/utils/UpdateReserveRatioAfterXDC.sol/UpdateReserveRatioAfterXDC__factory.ts +9 -15
  239. package/types/factories/contracts/utils/index.ts +1 -1
  240. package/types/hardhat.d.ts +13 -4
  241. package/types/index.ts +4 -2
  242. package/scripts/ProxyFactory.json +0 -4425
  243. package/scripts/analytics/activeGDStakers.ts +0 -188
  244. package/scripts/analytics/activeStakers.ts +0 -25
  245. package/scripts/analytics/activeUsersCount.ts +0 -156
  246. package/scripts/analytics/activeWalletsStats.ts +0 -301
  247. package/scripts/analytics/checkActiveWallets.ts +0 -60
  248. package/scripts/analytics/checkBridgeBalances.ts +0 -442
  249. package/scripts/analytics/claimIncidentStats.ts +0 -98
  250. package/scripts/analytics/faucetStats.ts +0 -130
  251. package/scripts/analytics/gdinflow.ts +0 -57
  252. package/scripts/analytics/goodHolders.ts +0 -46
  253. package/scripts/analytics/goodgiveback.ts +0 -64
  254. package/scripts/analytics/p2pTxs.ts +0 -564
  255. package/scripts/analytics/stuckgd.ts +0 -70
  256. package/scripts/analytics/tokenInOutStats.ts +0 -48
  257. package/scripts/analytics/whitelistsyncIssue.ts +0 -87
  258. package/scripts/bulkProof.ts +0 -202
  259. package/scripts/bulkWhitelist.ts +0 -31
  260. package/scripts/deployGnosisSafe.ts +0 -111
  261. package/scripts/fetchOrDeployProxyFactory.ts +0 -46
  262. package/scripts/fv.ts +0 -263
  263. package/scripts/gdx/gdxAirdropCalculation.ts +0 -479
  264. package/scripts/getFounders.ts +0 -32
  265. package/scripts/governance/README.md +0 -70
  266. package/scripts/governance/airdropCalculation.ts +0 -1119
  267. package/scripts/governance/airdropCalculationRecover.ts +0 -416
  268. package/scripts/governance/airdropCalculationSorted.ts +0 -438
  269. package/scripts/governance/goodCheckpointSorted.ts +0 -300
  270. package/scripts/keeper/fishInactive.ts +0 -47
  271. package/scripts/minimize.sh +0 -17
  272. package/scripts/multichain-deploy/0_proxyFactory-deploy.ts +0 -131
  273. package/scripts/multichain-deploy/1_basicdao-deploy.ts +0 -294
  274. package/scripts/multichain-deploy/2_helpers-deploy.ts +0 -152
  275. package/scripts/multichain-deploy/2b_otp-deploy.ts +0 -73
  276. package/scripts/multichain-deploy/3_gdSavings-deploy.ts +0 -190
  277. package/scripts/multichain-deploy/4_ubi-deploy.ts +0 -129
  278. package/scripts/multichain-deploy/5_gov-deploy.ts +0 -179
  279. package/scripts/multichain-deploy/6_testnetFaucet.ts +0 -85
  280. package/scripts/multichain-deploy/7_superfluidfaucet-deploy.ts +0 -123
  281. package/scripts/multichain-deploy/8_disthelper-deploy.ts +0 -152
  282. package/scripts/multichain-deploy/createUniswapTestPools.ts +0 -163
  283. package/scripts/multichain-deploy/flattened/Avatar.sol +0 -913
  284. package/scripts/multichain-deploy/flattened/Controller.sol +0 -1891
  285. package/scripts/multichain-deploy/flattened/FeeFormula.sol +0 -1290
  286. package/scripts/multichain-deploy/fulldeploy.sh +0 -26
  287. package/scripts/multichain-deploy/helpers.ts +0 -647
  288. package/scripts/multichain-deploy/multichainWrapper-deploy.ts +0 -59
  289. package/scripts/multichain-deploy/verifyEtherscan.ts +0 -177
  290. package/scripts/proposals/gip-14_1.ts +0 -251
  291. package/scripts/proposals/gip-15.ts +0 -427
  292. package/scripts/proposals/gip-25-xdc-upgrade-ubi.ts +0 -746
  293. package/scripts/proposals/gips-14_1.md +0 -29
  294. package/scripts/proposals/hack-ubi-recovery.ts +0 -414
  295. package/scripts/proposals/identityAuthPeriod.ts +0 -229
  296. package/scripts/proposals/reserveRestore.ts +0 -474
  297. package/scripts/proposals/updateDistHelper.ts +0 -180
  298. package/scripts/proposals/v4Upgrade.ts +0 -845
  299. package/scripts/releaser.js +0 -24
  300. package/scripts/staking/stakersGdRewardsCalculation.ts +0 -64
  301. package/scripts/upgradeScheme.ts +0 -97
  302. package/scripts/upgradeToV2/upgradeToV2.ts +0 -853
  303. package/scripts/upgradeToV2/upgradeToV2Recover.ts +0 -939
  304. package/scripts/upgradeToV3/v3-fix.ts +0 -120
  305. package/scripts/upgradeToV3/v3-fuse-multichain.ts +0 -117
  306. package/scripts/upgradeToV3/v3-upgrade.ts +0 -219
  307. package/scripts/upgrades/celo-defi-ubi-deploy.ts +0 -184
  308. package/scripts/upgrades/identity-upgrade.ts +0 -126
  309. package/scripts/upgrades/multichain-formula-upgrade.ts +0 -143
  310. package/scripts/upgrades/multichain-temp-fix.ts +0 -129
  311. package/scripts/upgrades/restoreFunds.ts +0 -91
  312. package/scripts/upgrades/superfluid-nft-celo-gas-token.ts +0 -159
  313. package/scripts/upgrades/transferDaoToGuardians.ts +0 -80
  314. package/scripts/upgrades/upgradeAdminWallet.ts +0 -29
  315. package/scripts/upgrades/upgradeFaucet.ts +0 -46
  316. package/scripts/utils.ts +0 -50
  317. package/scripts/verify.ts +0 -67
  318. package/scripts/voltageswaps.ts +0 -46
@@ -0,0 +1,445 @@
1
+ import { ethers, network, upgrades } from "hardhat";
2
+ import { expect } from "chai";
3
+ import {
4
+ GenericDistributionHelper,
5
+ IGoodDollar,
6
+ IERC20,
7
+ IStaticOracle,
8
+ ISwapRouter,
9
+ IUniswapV3Pool
10
+ } from "../../types";
11
+ import * as networkHelpers from "@nomicfoundation/hardhat-network-helpers";
12
+ import dao from "../../releases/deployment.json";
13
+ import ProtocolSettings from "../../releases/deploy-settings.json";
14
+
15
+ const BN = ethers.BigNumber;
16
+ const XDC_RPC_URL = "https://rpc.ankr.com/xdc";
17
+ const XDC_CHAIN_ID = 50;
18
+
19
+ /**
20
+ * E2E test for GenericDistributionHelper on XDC network using XSWAP pools
21
+ *
22
+ * To run this test:
23
+ * 1. Set up fork environment variable: FORK_CHAIN_ID=50
24
+ * 2. Set up XDC RPC URL in hardhat config or use: FORK_URL=https://rpc.ankr.com/xdc/...
25
+ * 3. Run: npx hardhat test test/reserve/GenericDistributionHelper.e2e.test.ts --network hardhat
26
+ *
27
+ * Note: This test requires forking XDC mainnet, so it may take longer to run
28
+ */
29
+ describe("GenericDistributionHelper - XDC XSWAP E2E Test", function () {
30
+ // Use longer timeout for fork tests
31
+ this.timeout(600000);
32
+
33
+ let distHelper: GenericDistributionHelper;
34
+ let goodDollar: IGoodDollar;
35
+ let reserveToken: IERC20; // CUSD
36
+ let gasToken: IERC20; // WXDC
37
+ let staticOracle: IStaticOracle;
38
+ let swapRouter: ISwapRouter;
39
+ let deployer: any;
40
+ let testAccount: any;
41
+
42
+ // XDC development network addresses
43
+ const XDC_ADDRESSES = {
44
+ WXDC: "0x951857744785e80e2de051c32ee7b25f9c458c42",
45
+ StaticOracle: "0x725244458f011551Dde1104c9728746EEBEA19f9",
46
+ UniswapV3Router: "0x3b9edecc4286ba33ea6e27119c2a4db99829839d",
47
+ ...dao["development-xdc"]
48
+ };
49
+
50
+ after(async function () {
51
+ await networkHelpers.reset();
52
+ });
53
+ before(async function () {
54
+ await networkHelpers.reset(XDC_RPC_URL);
55
+
56
+ [deployer, testAccount] = await ethers.getSigners();
57
+
58
+ // Impersonate the Avatar account to have permissions
59
+ const avatarSigner = await ethers.getImpersonatedSigner(XDC_ADDRESSES.Avatar);
60
+ await deployer.sendTransaction({
61
+ to: XDC_ADDRESSES.Avatar,
62
+ value: ethers.utils.parseEther("10")
63
+ });
64
+
65
+ // Get contract instances
66
+ goodDollar = (await ethers.getContractAt("IGoodDollar", XDC_ADDRESSES.GoodDollar)) as IGoodDollar;
67
+ reserveToken = (await ethers.getContractAt("IERC20", XDC_ADDRESSES.CUSD)) as IERC20;
68
+ gasToken = (await ethers.getContractAt("IERC20", XDC_ADDRESSES.WXDC)) as IERC20;
69
+ staticOracle = (await ethers.getContractAt("IStaticOracle", XDC_ADDRESSES.StaticOracle)) as IStaticOracle;
70
+ swapRouter = (await ethers.getContractAt("ISwapRouter", XDC_ADDRESSES.UniswapV3Router)) as ISwapRouter;
71
+
72
+ // Check if GenericDistributionHelper is already deployed
73
+ const existingDistHelper = dao["development-xdc"] && (dao["development-xdc"] as any).DistributionHelper;
74
+
75
+ if (existingDistHelper && existingDistHelper !== ethers.constants.AddressZero) {
76
+ distHelper = (await ethers.getContractAt(
77
+ "GenericDistributionHelper",
78
+ existingDistHelper
79
+ )) as GenericDistributionHelper;
80
+ console.log("Using existing GenericDistributionHelper at:", existingDistHelper);
81
+ } else {
82
+ // Deploy new GenericDistributionHelper
83
+ console.log("Deploying new GenericDistributionHelper...");
84
+ const GenericDistributionHelperFactory = await ethers.getContractFactory("GenericDistributionHelper");
85
+
86
+ // Get NameService instance
87
+ const nameService = await ethers.getContractAt("NameService", XDC_ADDRESSES.NameService);
88
+
89
+ const feeSettings = {
90
+ maxFee: ethers.utils.parseEther("100"),
91
+ minBalanceForFees: ethers.utils.parseEther("1"),
92
+ percentageToSellForFee: 5, // 5%
93
+ maxSlippage: 5 // 5%
94
+ };
95
+
96
+ distHelper = (await upgrades.deployProxy(
97
+ GenericDistributionHelperFactory,
98
+ [
99
+ nameService.address,
100
+ staticOracle.address,
101
+ gasToken.address,
102
+ reserveToken.address,
103
+ swapRouter.address,
104
+ feeSettings
105
+ ],
106
+ { kind: "uups" }
107
+ )) as GenericDistributionHelper;
108
+
109
+ await distHelper.deployed();
110
+ console.log("Deployed GenericDistributionHelper at:", distHelper.address);
111
+ }
112
+ });
113
+
114
+ it("should successfully swap G$ to WXDC via XSWAP pools", async function () {
115
+ // // Get initial balances
116
+ // const initialWXDCBalance = await gasToken.balanceOf(distHelper.address);
117
+ // const initialxdcBalance = await ethers.provider.getBalance(distHelper.address);
118
+
119
+ // Mint some G$ to the distribution helper for testing
120
+ const amountToSwap = ethers.utils.parseEther("1000"); // 1000 G$
121
+
122
+ // Try to mint G$ to the helper (if we have minter role)
123
+ try {
124
+ // Impersonate a minter if needed
125
+ const minterAddress = XDC_ADDRESSES.Avatar; // Avatar typically has minter role
126
+ const minterSigner = await ethers.getImpersonatedSigner(minterAddress);
127
+ await deployer.sendTransaction({
128
+ to: minterAddress,
129
+ value: ethers.utils.parseEther("1")
130
+ });
131
+
132
+ // Try to mint via the minter
133
+ const goodDollarWithMinter = goodDollar.connect(minterSigner);
134
+ await goodDollarWithMinter.mint(distHelper.address, amountToSwap);
135
+ } catch (error) {
136
+ console.log("Could not mint G$ directly, trying alterxdc approach:", error.message);
137
+ // Alterxdc: transfer from an account that has G$
138
+ // For fork tests, we might need to find an account with G$ balance
139
+ const accountsWithGD = [
140
+ XDC_ADDRESSES.AdminWallet, // AdminWallet
141
+ XDC_ADDRESSES.Avatar
142
+ ];
143
+
144
+ let transferred = false;
145
+ for (const account of accountsWithGD) {
146
+ const balance = await goodDollar.balanceOf(account);
147
+ if (balance.gte(amountToSwap)) {
148
+ const accountSigner = await ethers.getImpersonatedSigner(account);
149
+ await deployer.sendTransaction({
150
+ to: account,
151
+ value: ethers.utils.parseEther("1")
152
+ });
153
+ await goodDollar.connect(accountSigner).transfer(distHelper.address, amountToSwap);
154
+ transferred = true;
155
+ break;
156
+ }
157
+ }
158
+
159
+ if (!transferred) {
160
+ console.log("Skipping swap test - insufficient G$ balance available");
161
+ this.skip();
162
+ }
163
+ }
164
+
165
+ // Get pools for the swap path
166
+ const gdPools = await staticOracle.getAllPoolsForPair(reserveToken.address, goodDollar.address);
167
+ const gasPools = await staticOracle.getAllPoolsForPair(reserveToken.address, gasToken.address);
168
+
169
+ expect(gdPools.length).to.be.gt(0, "No G$/CUSD pools found");
170
+ expect(gasPools.length).to.be.gt(0, "No CUSD/WXDC pools found");
171
+
172
+ console.log("Found pools:", {
173
+ gdPools: gdPools.length,
174
+ gasPools: gasPools.length
175
+ });
176
+
177
+ // Get pool fees
178
+ const gdPool = (await ethers.getContractAt("IUniswapV3Pool", gdPools[0])) as IUniswapV3Pool;
179
+ const gasPool = (await ethers.getContractAt("IUniswapV3Pool", gasPools[0])) as IUniswapV3Pool;
180
+
181
+ const gdFee = await gdPool.fee();
182
+ const gasFee = await gasPool.fee();
183
+
184
+ console.log("Pool fees:", {
185
+ gdFee: gdFee.toString(),
186
+ gasFee: gasFee.toString()
187
+ });
188
+
189
+ // Calculate expected output using oracle
190
+ const amountToSell = amountToSwap.div(20); // 5% for fees (50 G$)
191
+ const [quoteAmount] = await staticOracle.quoteAllAvailablePoolsWithTimePeriod(
192
+ amountToSell,
193
+ goodDollar.address,
194
+ reserveToken.address,
195
+ 60
196
+ );
197
+
198
+ const [quoteGasAmount] = await staticOracle.quoteAllAvailablePoolsWithTimePeriod(
199
+ quoteAmount,
200
+ reserveToken.address,
201
+ gasToken.address,
202
+ 60
203
+ );
204
+
205
+ console.log("Expected swap amounts:", {
206
+ gdIn: ethers.utils.formatEther(amountToSell),
207
+ cusdOut: ethers.utils.formatUnits(quoteAmount, 6), // CUSD has 6 decimals
208
+ wxdcOut: ethers.utils.formatEther(quoteGasAmount)
209
+ });
210
+
211
+ // Set fee settings to trigger swap
212
+ const feeSettings = {
213
+ maxFee: ethers.utils.parseEther("100"),
214
+ minBalanceForFees: ethers.utils.parseEther("1"),
215
+ percentageToSellForFee: 5,
216
+ maxSlippage: 5
217
+ };
218
+
219
+ await deployer.sendTransaction({
220
+ to: XDC_ADDRESSES.Avatar,
221
+ value: ethers.utils.parseEther("1")
222
+ });
223
+
224
+ // Impersonate guardian to set fee settings
225
+ const avatarSigner = await ethers.getImpersonatedSigner(XDC_ADDRESSES.Avatar);
226
+ await distHelper.connect(avatarSigner).setFeeSettings(feeSettings);
227
+
228
+ // Ensure distHelper has low xdc balance to trigger swap
229
+ const currentxdcBalance = await ethers.provider.getBalance(distHelper.address);
230
+ console.log("Current xdc balance:", ethers.utils.formatEther(currentxdcBalance));
231
+ console.log("Min balance for fees:", ethers.utils.formatEther(feeSettings.minBalanceForFees));
232
+ if (currentxdcBalance.gte(feeSettings.minBalanceForFees)) {
233
+ // Send xdc token away to trigger swap
234
+ const tempAccount = ethers.Wallet.createRandom().connect(ethers.provider);
235
+ await deployer.sendTransaction({
236
+ to: tempAccount.address,
237
+ value: ethers.utils.parseEther("0.01")
238
+ });
239
+
240
+ // Transfer xdc balance from distHelper
241
+ const distHelperSigner = await ethers.getImpersonatedSigner(distHelper.address);
242
+
243
+ await distHelperSigner.sendTransaction({
244
+ to: tempAccount.address,
245
+ value: currentxdcBalance.sub(ethers.utils.parseEther("0.05"))
246
+ });
247
+ }
248
+
249
+ // Trigger distribution which should perform the swap
250
+ const xdcBalanceBefore = await ethers.provider.getBalance(distHelper.address);
251
+ const goodDollarBalanceBefore = await goodDollar.balanceOf(distHelper.address);
252
+
253
+ console.log("Balances before swap:", {
254
+ xdc: ethers.utils.formatEther(xdcBalanceBefore),
255
+ goodDollar: ethers.utils.formatEther(goodDollarBalanceBefore)
256
+ });
257
+
258
+ // Call onDistribution to trigger swap
259
+ await distHelper.onDistribution(0);
260
+
261
+ // Check balances after swap
262
+ const xdcBalanceAfter = await ethers.provider.getBalance(distHelper.address);
263
+ const goodDollarBalanceAfter = await goodDollar.balanceOf(distHelper.address);
264
+ console.log("Balances after swap:", {
265
+ xdc: ethers.utils.formatEther(xdcBalanceAfter),
266
+ goodDollar: ethers.utils.formatEther(goodDollarBalanceAfter)
267
+ });
268
+
269
+ // Verify swap occurred
270
+ // Either WXDC balance increased or xdc balance increased (after unwrapping)
271
+ const xdcIncrease = xdcBalanceAfter.sub(xdcBalanceBefore);
272
+
273
+ expect(xdcIncrease.gt(0), "Swap should have increased either WXDC or xdc balance").to.be.true;
274
+ });
275
+
276
+ it("should correctly calculate swap amounts using XSWAP pools", async function () {
277
+ const amountToSell = ethers.utils.parseEther("100"); // 100 G$
278
+
279
+ // Test quote from G$ to CUSD
280
+ const [quoteCUSD, poolsGDCUSD] = await staticOracle.quoteAllAvailablePoolsWithTimePeriod(
281
+ amountToSell,
282
+ goodDollar.address,
283
+ reserveToken.address,
284
+ 60
285
+ );
286
+
287
+ expect(poolsGDCUSD.length).to.be.gt(0, "Should find G$/CUSD pools");
288
+ expect(quoteCUSD.gt(0)).to.be.true;
289
+
290
+ console.log("G$ -> CUSD quote:", {
291
+ gdIn: ethers.utils.formatEther(amountToSell),
292
+ cusdOut: ethers.utils.formatUnits(quoteCUSD, 6)
293
+ });
294
+
295
+ // Test quote from CUSD to WXDC
296
+ const [quoteWXDC, poolsCUSDWXDC] = await staticOracle.quoteAllAvailablePoolsWithTimePeriod(
297
+ quoteCUSD,
298
+ reserveToken.address,
299
+ gasToken.address,
300
+ 60
301
+ );
302
+
303
+ expect(poolsCUSDWXDC.length).to.be.gt(0, "Should find CUSD/WXDC pools");
304
+ expect(quoteWXDC.gt(0)).to.be.true;
305
+
306
+ console.log("CUSD -> WXDC quote:", {
307
+ cusdIn: ethers.utils.formatUnits(quoteCUSD, 6),
308
+ wxdcOut: ethers.utils.formatEther(quoteWXDC)
309
+ });
310
+
311
+ // Test calcGDToSell function
312
+ const [gdToSell, minReceived] = await distHelper.calcGDToSell(amountToSell);
313
+
314
+ expect(gdToSell.gt(0)).to.be.true;
315
+ expect(minReceived.gt(0)).to.be.true;
316
+
317
+ console.log("calcGDToSell result:", {
318
+ gdToSell: ethers.utils.formatEther(gdToSell),
319
+ minReceived: ethers.utils.formatEther(minReceived)
320
+ });
321
+
322
+ expect(gdToSell).to.be.equal(amountToSell);
323
+ expect(quoteWXDC).to.be.equal(minReceived);
324
+ });
325
+
326
+ it("should revert swap when slippage exceeds maxSlippage", async function () {
327
+ // Set maxSlippage to 0% to ensure swap will fail if there's any slippage
328
+ // This tests the slippage protection mechanism
329
+ const feeSettings = {
330
+ maxFee: ethers.utils.parseEther("100"),
331
+ minBalanceForFees: ethers.utils.parseEther("1"),
332
+ percentageToSellForFee: 5,
333
+ maxSlippage: 0 // 0% - no slippage tolerance, swap should fail
334
+ };
335
+
336
+ await deployer.sendTransaction({
337
+ to: XDC_ADDRESSES.Avatar,
338
+ value: ethers.utils.parseEther("1")
339
+ });
340
+
341
+ const avatarSigner = await ethers.getImpersonatedSigner(XDC_ADDRESSES.Avatar);
342
+ await distHelper.connect(avatarSigner).setFeeSettings(feeSettings);
343
+
344
+ // Mint some G$ to the distribution helper for testing
345
+ const amountToSwap = ethers.utils.parseEther("1000"); // 1000 G$
346
+
347
+ // Try to mint G$ to the helper
348
+ try {
349
+ const minterAddress = XDC_ADDRESSES.Avatar;
350
+ const minterSigner = await ethers.getImpersonatedSigner(minterAddress);
351
+ await deployer.sendTransaction({
352
+ to: minterAddress,
353
+ value: ethers.utils.parseEther("1")
354
+ });
355
+ const goodDollarWithMinter = goodDollar.connect(minterSigner);
356
+ await goodDollarWithMinter.mint(distHelper.address, amountToSwap);
357
+ } catch (error) {
358
+ // Try to transfer from an account that has G$
359
+ const accountsWithGD = [XDC_ADDRESSES.AdminWallet, XDC_ADDRESSES.Avatar];
360
+
361
+ let transferred = false;
362
+ for (const account of accountsWithGD) {
363
+ const balance = await goodDollar.balanceOf(account);
364
+ if (balance.gte(amountToSwap)) {
365
+ const accountSigner = await ethers.getImpersonatedSigner(account);
366
+ await deployer.sendTransaction({
367
+ to: account,
368
+ value: ethers.utils.parseEther("1")
369
+ });
370
+ await goodDollar.connect(accountSigner).transfer(distHelper.address, amountToSwap);
371
+ transferred = true;
372
+ break;
373
+ }
374
+ }
375
+
376
+ if (!transferred) {
377
+ console.log("Skipping slippage test - insufficient G$ balance available");
378
+ this.skip();
379
+ return;
380
+ }
381
+ }
382
+
383
+ // Calculate expected output using oracle
384
+ const amountToSell = amountToSwap.div(20); // 5% for fees (50 G$)
385
+ const [calculatedGDToSell, calculatedMinReceived] = await distHelper.calcGDToSell(amountToSell);
386
+
387
+ // With maxSlippage = 0%, amountOutMinimum should equal minReceived exactly
388
+ // amountOutMinimum = minReceived * (100 - 0) / 100 = minReceived
389
+ const expectedMinAmountOut = calculatedMinReceived; // 100% of minReceived (0% slippage)
390
+
391
+ // Ensure distHelper has low xdc balance to trigger swap
392
+ const currentxdcBalance = await ethers.provider.getBalance(distHelper.address);
393
+ if (currentxdcBalance.gte(feeSettings.minBalanceForFees)) {
394
+ const tempAccount = ethers.Wallet.createRandom().connect(ethers.provider);
395
+ await deployer.sendTransaction({
396
+ to: tempAccount.address,
397
+ value: ethers.utils.parseEther("0.01")
398
+ });
399
+
400
+ const distHelperSigner = await ethers.getImpersonatedSigner(distHelper.address);
401
+ await deployer.sendTransaction({
402
+ to: distHelper.address,
403
+ value: ethers.utils.parseEther("0.01")
404
+ });
405
+
406
+ await distHelperSigner.sendTransaction({
407
+ to: tempAccount.address,
408
+ value: currentxdcBalance.sub(ethers.utils.parseEther("0.05"))
409
+ });
410
+ }
411
+
412
+ // Get balances before swap attempt
413
+ const xdcBalanceBefore = await ethers.provider.getBalance(distHelper.address);
414
+ const goodDollarBalanceBefore = await goodDollar.balanceOf(distHelper.address);
415
+
416
+ // Trigger distribution which should attempt the swap
417
+ // With 0% maxSlippage, the swap should fail because real swaps always have some slippage
418
+ const tx = await distHelper.onDistribution(0);
419
+ const receipt = await tx.wait();
420
+
421
+ // Check for BuyNativeFailed event
422
+ const buyNativeFailedEvents = receipt.events?.filter((e: any) => e.event === "BuyNativeFailed");
423
+
424
+ const xdcBalanceAfter = await ethers.provider.getBalance(distHelper.address);
425
+ const xdcIncrease = xdcBalanceAfter.sub(xdcBalanceBefore);
426
+
427
+ // With 0% slippage tolerance, the swap should fail
428
+ // Verify that BuyNativeFailed event was emitted
429
+ const swapFailed = buyNativeFailedEvents && buyNativeFailedEvents.length > 0;
430
+
431
+ expect(swapFailed, "Swap should have failed with BuyNativeFailed event when maxSlippage is 0%").to.be.true;
432
+
433
+ // Verify the event details
434
+ const failedEvent = buyNativeFailedEvents[0];
435
+ const eventAmountOutMinimum = failedEvent.args?.amountOutMinimum || BN.from(0);
436
+
437
+ console.log("BuyNativeFailed event details:", {
438
+ reason: failedEvent.args?.reason,
439
+ amountToSell: ethers.utils.formatEther(failedEvent.args?.amountToSell || 0),
440
+ amountOutMinimum: ethers.utils.formatEther(eventAmountOutMinimum)
441
+ });
442
+
443
+ console.log("Slippage protection test passed: swap correctly reverted when slippage exceeded maxSlippage");
444
+ });
445
+ });
@@ -153,10 +153,10 @@ describe("AdminWallet", () => {
153
153
 
154
154
  await adminWallet
155
155
  .connect(admin2)
156
- ["whitelist(address,string)"](
157
- toWhitelist.address,
158
- "did:test" + Math.random()
159
- );
156
+ ["whitelist(address,string)"](
157
+ toWhitelist.address,
158
+ "did:test" + Math.random()
159
+ );
160
160
  const newBalance = await ethers.provider.getBalance(admin2.address);
161
161
  expect(newBalance).to.be.gte(expectedTopping);
162
162
  });
@@ -170,7 +170,7 @@ describe("AdminWallet", () => {
170
170
  expect(await identity.isWhitelisted(whitelisted.address)).to.false;
171
171
  await adminWallet
172
172
  .connect(admin)
173
- ["whitelist(address,string)"](whitelisted.address, "did:test");
173
+ ["whitelist(address,string)"](whitelisted.address, "did:test");
174
174
 
175
175
  expect(await identity.isWhitelisted(whitelisted.address)).to.true;
176
176
  await adminWallet.connect(admin).removeWhitelist(whitelisted.address);
@@ -182,12 +182,12 @@ describe("AdminWallet", () => {
182
182
  await expect(
183
183
  adminWallet
184
184
  .connect(stranger)
185
- ["whitelist(address,string)"](whitelisted.address, "did:test")
185
+ ["whitelist(address,string)"](whitelisted.address, "did:test")
186
186
  ).revertedWith(/Caller is not admin/);
187
187
  expect(await identity.isWhitelisted(whitelisted.address)).to.false;
188
188
  await adminWallet
189
189
  .connect(admin)
190
- ["whitelist(address,string)"](whitelisted.address, "did:test");
190
+ ["whitelist(address,string)"](whitelisted.address, "did:test");
191
191
  expect(await identity.isWhitelisted(whitelisted.address)).to.true;
192
192
  await expect(
193
193
  adminWallet.connect(stranger).removeWhitelist(whitelisted.address)
@@ -273,7 +273,7 @@ describe("AdminWallet", () => {
273
273
  expect(await identity.isWhitelisted(stranger2.address)).to.false;
274
274
  await adminWallet
275
275
  .connect(admin2)
276
- ["whitelist(address,string)"](stranger2.address, "did:test3");
276
+ ["whitelist(address,string)"](stranger2.address, "did:test3");
277
277
  expect(await identity.isWhitelisted(stranger2.address)).to.true;
278
278
  });
279
279
 
@@ -281,7 +281,7 @@ describe("AdminWallet", () => {
281
281
  await expect(
282
282
  adminWallet
283
283
  .connect(admin2)
284
- ["whitelist(address,string)"](stranger.address, "did:test")
284
+ ["whitelist(address,string)"](stranger.address, "did:test")
285
285
  ).revertedWith(/DID already registered/);
286
286
  });
287
287
 
@@ -303,11 +303,10 @@ describe("AdminWallet", () => {
303
303
  await ethers.getContractFactory("AdminWallet"),
304
304
  { kind: "uups" }
305
305
  );
306
- await expect(
307
- upgrades.upgradeProxy(
308
- adminWallet.address,
309
- await ethers.getContractFactory("AdminWallet")
310
- )
311
- ).not.throws;
306
+ const result = await upgrades.upgradeProxy(
307
+ adminWallet.address,
308
+ await ethers.getContractFactory("AdminWallet")
309
+ ).catch(_ => false)
310
+ expect(result).not.false
312
311
  });
313
312
  });