@bgd-labs/toolbox 0.0.2 → 0.0.3

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.
package/dist/index.d.mts CHANGED
@@ -195,6 +195,7 @@ declare const HUMAN_READABLE_PROPOSAL_STATE: {
195
195
  type GovernanceContract = GetContractReturnType<typeof IGovernanceCore_ABI, Client>;
196
196
  declare function getGovernance<T extends Client>(client: T, address: Hex): GovernanceContract;
197
197
  declare function makeProposalExecutableOnTestClient(client: TestClient, governance: Address, proposalId: bigint): Promise<void>;
198
+ declare function getNonFinalizedProposals<T extends Client>(client: T, governanceAddress: Address): Promise<bigint[]>;
198
199
 
199
200
  type ExplorerConfig = {
200
201
  api: string;
@@ -230,7 +231,7 @@ declare function getSourceCode(params: GetSourceCodeParams): Promise<{
230
231
  SimilarMatch: string;
231
232
  SourceCode: string;
232
233
  }>;
233
- declare function parseApiSourceCode(sourceCode: string): {
234
+ declare function parseEtherscanStyleSourceCode(sourceCode: string): {
234
235
  language: string;
235
236
  libraries: any;
236
237
  settings: {
@@ -302,4 +303,4 @@ declare const erc1967_AdminSlot = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8e
302
303
 
303
304
  declare function diffCode(codeBefore: string, codeAfter: string): Promise<Record<string, string>>;
304
305
 
305
- export { type ExplorerConfig, type GovernanceContract, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, LTV_PRECISION, PayloadState, type PayloadsControllerContract, ProposalState, RAY, type ReserveConfiguration, SECONDS_PER_YEAR, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, erc1967_AdminSlot, erc1967_ImplementationSlot, getBits, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNonFinalizedPayloads, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getSourceCode, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseApiSourceCode, rayDiv, rayMul, rayToWad, setBits, tenderly_createVnet, wadDiv, wadToRay };
306
+ export { type ExplorerConfig, type GovernanceContract, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, LTV_PRECISION, PayloadState, type PayloadsControllerContract, ProposalState, RAY, type ReserveConfiguration, SECONDS_PER_YEAR, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, erc1967_AdminSlot, erc1967_ImplementationSlot, getBits, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getSourceCode, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, rayDiv, rayMul, rayToWad, setBits, tenderly_createVnet, wadDiv, wadToRay };
package/dist/index.d.ts CHANGED
@@ -195,6 +195,7 @@ declare const HUMAN_READABLE_PROPOSAL_STATE: {
195
195
  type GovernanceContract = GetContractReturnType<typeof IGovernanceCore_ABI, Client>;
196
196
  declare function getGovernance<T extends Client>(client: T, address: Hex): GovernanceContract;
197
197
  declare function makeProposalExecutableOnTestClient(client: TestClient, governance: Address, proposalId: bigint): Promise<void>;
198
+ declare function getNonFinalizedProposals<T extends Client>(client: T, governanceAddress: Address): Promise<bigint[]>;
198
199
 
199
200
  type ExplorerConfig = {
200
201
  api: string;
@@ -230,7 +231,7 @@ declare function getSourceCode(params: GetSourceCodeParams): Promise<{
230
231
  SimilarMatch: string;
231
232
  SourceCode: string;
232
233
  }>;
233
- declare function parseApiSourceCode(sourceCode: string): {
234
+ declare function parseEtherscanStyleSourceCode(sourceCode: string): {
234
235
  language: string;
235
236
  libraries: any;
236
237
  settings: {
@@ -302,4 +303,4 @@ declare const erc1967_AdminSlot = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8e
302
303
 
303
304
  declare function diffCode(codeBefore: string, codeAfter: string): Promise<Record<string, string>>;
304
305
 
305
- export { type ExplorerConfig, type GovernanceContract, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, LTV_PRECISION, PayloadState, type PayloadsControllerContract, ProposalState, RAY, type ReserveConfiguration, SECONDS_PER_YEAR, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, erc1967_AdminSlot, erc1967_ImplementationSlot, getBits, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNonFinalizedPayloads, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getSourceCode, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseApiSourceCode, rayDiv, rayMul, rayToWad, setBits, tenderly_createVnet, wadDiv, wadToRay };
306
+ export { type ExplorerConfig, type GovernanceContract, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, LTV_PRECISION, PayloadState, type PayloadsControllerContract, ProposalState, RAY, type ReserveConfiguration, SECONDS_PER_YEAR, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, erc1967_AdminSlot, erc1967_ImplementationSlot, getBits, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getSourceCode, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, rayDiv, rayMul, rayToWad, setBits, tenderly_createVnet, wadDiv, wadToRay };
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ __export(index_exports, {
36
36
  HUMAN_READABLE_PROPOSAL_STATE: () => HUMAN_READABLE_PROPOSAL_STATE,
37
37
  LTV_PRECISION: () => LTV_PRECISION,
38
38
  PayloadState: () => PayloadState,
39
+ ProposalState: () => ProposalState,
39
40
  RAY: () => RAY,
40
41
  SECONDS_PER_YEAR: () => SECONDS_PER_YEAR,
41
42
  WAD: () => WAD,
@@ -58,13 +59,14 @@ __export(index_exports, {
58
59
  getGovernance: () => getGovernance,
59
60
  getMarketReferenceCurrencyAndUsdBalance: () => getMarketReferenceCurrencyAndUsdBalance,
60
61
  getNonFinalizedPayloads: () => getNonFinalizedPayloads,
62
+ getNonFinalizedProposals: () => getNonFinalizedProposals,
61
63
  getNormalizedDebt: () => getNormalizedDebt,
62
64
  getNormalizedIncome: () => getNormalizedIncome,
63
65
  getPayloadsController: () => getPayloadsController,
64
66
  getSourceCode: () => getSourceCode,
65
67
  makePayloadExecutableOnTestClient: () => makePayloadExecutableOnTestClient,
66
68
  makeProposalExecutableOnTestClient: () => makeProposalExecutableOnTestClient,
67
- parseApiSourceCode: () => parseApiSourceCode,
69
+ parseEtherscanStyleSourceCode: () => parseEtherscanStyleSourceCode,
68
70
  rayDiv: () => rayDiv,
69
71
  rayMul: () => rayMul,
70
72
  rayToWad: () => rayToWad,
@@ -1958,7 +1960,7 @@ async function getNonFinalizedPayloads(client, payloadsController) {
1958
1960
  const controllerContract = getPayloadsController(client, payloadsController);
1959
1961
  const payloadsCount = await controllerContract.read.getPayloadsCount();
1960
1962
  const nonFinalPayloads = [];
1961
- for (const payloadId of [...Array(Number(payloadsCount)).keys()].reverse()) {
1963
+ for (let payloadId = payloadsCount - 1; payloadId != 0; payloadId--) {
1962
1964
  const maxRange = (35 + 10 + 7) * 24 * 60 * 60;
1963
1965
  const payload = await controllerContract.read.getPayloadById([payloadId]);
1964
1966
  if ([2 /* Queued */, 1 /* Created */].includes(payload.state))
@@ -1971,15 +1973,26 @@ async function getNonFinalizedPayloads(client, payloadsController) {
1971
1973
  // src/aave/governance/governance.ts
1972
1974
  var import_viem3 = require("viem");
1973
1975
  var import_actions2 = require("viem/actions");
1976
+ var ProposalState = /* @__PURE__ */ ((ProposalState2) => {
1977
+ ProposalState2[ProposalState2["Null"] = 0] = "Null";
1978
+ ProposalState2[ProposalState2["Created"] = 1] = "Created";
1979
+ ProposalState2[ProposalState2["Active"] = 2] = "Active";
1980
+ ProposalState2[ProposalState2["Queued"] = 3] = "Queued";
1981
+ ProposalState2[ProposalState2["Executed"] = 4] = "Executed";
1982
+ ProposalState2[ProposalState2["Failed"] = 5] = "Failed";
1983
+ ProposalState2[ProposalState2["Cancelled"] = 6] = "Cancelled";
1984
+ ProposalState2[ProposalState2["Expired"] = 7] = "Expired";
1985
+ return ProposalState2;
1986
+ })(ProposalState || {});
1974
1987
  var HUMAN_READABLE_PROPOSAL_STATE = {
1975
- [ProposalState.Null]: "Null",
1976
- [ProposalState.Created]: "Created",
1977
- [ProposalState.Active]: "Active",
1978
- [ProposalState.Queued]: "Queued",
1979
- [ProposalState.Executed]: "Executed",
1980
- [ProposalState.Failed]: "Failed",
1981
- [ProposalState.Cancelled]: "Cancelled",
1982
- [ProposalState.Expired]: "Expired"
1988
+ [0 /* Null */]: "Null",
1989
+ [1 /* Created */]: "Created",
1990
+ [2 /* Active */]: "Active",
1991
+ [3 /* Queued */]: "Queued",
1992
+ [4 /* Executed */]: "Executed",
1993
+ [5 /* Failed */]: "Failed",
1994
+ [6 /* Cancelled */]: "Cancelled",
1995
+ [7 /* Expired */]: "Expired"
1983
1996
  };
1984
1997
  function getGovernance(client, address) {
1985
1998
  return (0, import_viem3.getContract)({
@@ -2000,7 +2013,7 @@ async function makeProposalExecutableOnTestClient(client, governance, proposalId
2000
2013
  manipulatedStorage,
2001
2014
  0n,
2002
2015
  8n,
2003
- ProposalState.Queued
2016
+ 3 /* Queued */
2004
2017
  );
2005
2018
  manipulatedStorage = setBits(
2006
2019
  manipulatedStorage,
@@ -2016,6 +2029,22 @@ async function makeProposalExecutableOnTestClient(client, governance, proposalId
2016
2029
  value: (0, import_viem3.toHex)(manipulatedStorage, { size: 32 })
2017
2030
  });
2018
2031
  }
2032
+ async function getNonFinalizedProposals(client, governanceAddress) {
2033
+ const goverannceContract = getGovernance(client, governanceAddress);
2034
+ const proposalsCount = await goverannceContract.read.getProposalsCount();
2035
+ const nonFinalProposals = [];
2036
+ for (let proposalId = proposalsCount - 1n; proposalId != 0n; proposalId--) {
2037
+ const proposal = await goverannceContract.read.getProposal([proposalId]);
2038
+ if ([
2039
+ 3 /* Queued */,
2040
+ 1 /* Created */,
2041
+ 2 /* Active */
2042
+ ].includes(proposal.state))
2043
+ nonFinalProposals.push(proposalId);
2044
+ if (proposal.creationTime < Date.now() / 1e3 - 2592e3) break;
2045
+ }
2046
+ return nonFinalProposals;
2047
+ }
2019
2048
 
2020
2049
  // src/ecosystem/generated/etherscanExplorers.ts
2021
2050
  var etherscanExplorers = {
@@ -2910,7 +2939,7 @@ async function getSourceCode(params) {
2910
2939
  }
2911
2940
  return result[0];
2912
2941
  }
2913
- function parseApiSourceCode(sourceCode) {
2942
+ function parseEtherscanStyleSourceCode(sourceCode) {
2914
2943
  if (sourceCode.startsWith("{{") && sourceCode.endsWith("}}")) {
2915
2944
  sourceCode = sourceCode.substring(1, sourceCode.length - 1);
2916
2945
  }
@@ -3016,8 +3045,8 @@ var import_standalone = require("prettier/standalone");
3016
3045
  var import_standalone2 = __toESM(require("prettier-plugin-solidity/standalone"));
3017
3046
  var prettierOptions = { parser: "solidity-parse", plugins: [import_standalone2.default] };
3018
3047
  async function diffCode(codeBefore, codeAfter) {
3019
- const before = parseApiSourceCode(codeBefore);
3020
- const after = parseApiSourceCode(codeAfter);
3048
+ const before = parseEtherscanStyleSourceCode(codeBefore);
3049
+ const after = parseEtherscanStyleSourceCode(codeAfter);
3021
3050
  const changes = {};
3022
3051
  const settingsBefore = JSON.stringify(before.settings, null, 2);
3023
3052
  const settingsAfter = JSON.stringify(after.settings, null, 2);
@@ -3067,6 +3096,7 @@ async function diffCode(codeBefore, codeAfter) {
3067
3096
  HUMAN_READABLE_PROPOSAL_STATE,
3068
3097
  LTV_PRECISION,
3069
3098
  PayloadState,
3099
+ ProposalState,
3070
3100
  RAY,
3071
3101
  SECONDS_PER_YEAR,
3072
3102
  WAD,
@@ -3089,13 +3119,14 @@ async function diffCode(codeBefore, codeAfter) {
3089
3119
  getGovernance,
3090
3120
  getMarketReferenceCurrencyAndUsdBalance,
3091
3121
  getNonFinalizedPayloads,
3122
+ getNonFinalizedProposals,
3092
3123
  getNormalizedDebt,
3093
3124
  getNormalizedIncome,
3094
3125
  getPayloadsController,
3095
3126
  getSourceCode,
3096
3127
  makePayloadExecutableOnTestClient,
3097
3128
  makeProposalExecutableOnTestClient,
3098
- parseApiSourceCode,
3129
+ parseEtherscanStyleSourceCode,
3099
3130
  rayDiv,
3100
3131
  rayMul,
3101
3132
  rayToWad,