@bgd-labs/toolbox 0.0.1 → 0.0.2
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 +221 -2
- package/dist/index.d.ts +221 -2
- package/dist/index.js +2080 -2
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2067 -1
- package/dist/index.mjs.map +1 -0
- package/package.json +16 -11
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPayloadsControllerCore_ABI, IGovernanceCore_ABI } from '@bgd-labs/aave-address-book/abis';
|
|
2
|
+
import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient } from 'viem';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* In solidity it is a quite common practice to encode bit variables in bitmaps opposed to bool structs.
|
|
@@ -19,6 +20,15 @@ declare function bitmapToIndexes(bitmap: bigint): number[];
|
|
|
19
20
|
* @returns
|
|
20
21
|
*/
|
|
21
22
|
declare function getBits(uint256: bigint, startBit: bigint, _endBit: bigint): bigint;
|
|
23
|
+
/**
|
|
24
|
+
* Sets the bits in a bigint
|
|
25
|
+
* @param input
|
|
26
|
+
* @param startBit inclusive
|
|
27
|
+
* @param endBit inclusive
|
|
28
|
+
* @param value the value to replace
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
declare function setBits(input: bigint, startBit: bigint, endBit: bigint, replaceValue: bigint | number): bigint;
|
|
22
32
|
|
|
23
33
|
/**
|
|
24
34
|
* The userConfiguration on aave is stored as an alteranting bitmap.
|
|
@@ -32,6 +42,160 @@ declare function decodeUserConfiguration(userConfiguration: bigint): {
|
|
|
32
42
|
collateralAssetIds: number[];
|
|
33
43
|
};
|
|
34
44
|
|
|
45
|
+
type ReserveConfiguration = {
|
|
46
|
+
ltv: bigint;
|
|
47
|
+
liquidationThreshold: bigint;
|
|
48
|
+
liquidationBonus: bigint;
|
|
49
|
+
decimals: bigint;
|
|
50
|
+
active: boolean;
|
|
51
|
+
frozen: boolean;
|
|
52
|
+
borrowingEnabled: boolean;
|
|
53
|
+
paused: boolean;
|
|
54
|
+
borrowingInIsolation: boolean;
|
|
55
|
+
siloedBorrowingEnabled: boolean;
|
|
56
|
+
flashloaningEnabled: boolean;
|
|
57
|
+
reserveFactor: bigint;
|
|
58
|
+
borrowCap: bigint;
|
|
59
|
+
supplyCap: bigint;
|
|
60
|
+
liquidationProtocolFee: bigint;
|
|
61
|
+
unbackedMintCap: bigint;
|
|
62
|
+
debtCeiling: bigint;
|
|
63
|
+
virtualAccountingEnabled: boolean;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* ReserveConfiguration is a tightly packed struct that contains the configuration of a reserve
|
|
67
|
+
* @param data
|
|
68
|
+
* @returns the decoded ReserveConfiguration
|
|
69
|
+
*/
|
|
70
|
+
declare function decodeReserveConfiguration(data: bigint): ReserveConfiguration;
|
|
71
|
+
declare function decodeReserveConfigurationV2(data: bigint): {
|
|
72
|
+
ltv: bigint;
|
|
73
|
+
liquidationThreshold: bigint;
|
|
74
|
+
liquidationBonus: bigint;
|
|
75
|
+
decimals: bigint;
|
|
76
|
+
active: boolean;
|
|
77
|
+
frozen: boolean;
|
|
78
|
+
borrowingEnabled: boolean;
|
|
79
|
+
stableBorrowingEnabled: boolean;
|
|
80
|
+
reserveFactor: bigint;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
declare const SECONDS_PER_YEAR = 31536000n;
|
|
84
|
+
declare const LTV_PRECISION = 4n;
|
|
85
|
+
|
|
86
|
+
interface CalculateCompoundedInterestRequest {
|
|
87
|
+
rate: bigint;
|
|
88
|
+
currentTimestamp: number;
|
|
89
|
+
lastUpdateTimestamp: number;
|
|
90
|
+
}
|
|
91
|
+
declare function calculateCompoundedInterest({ rate, currentTimestamp, lastUpdateTimestamp, }: CalculateCompoundedInterestRequest): bigint;
|
|
92
|
+
interface LinearInterestRequest {
|
|
93
|
+
rate: bigint;
|
|
94
|
+
currentTimestamp: number;
|
|
95
|
+
lastUpdateTimestamp: number;
|
|
96
|
+
}
|
|
97
|
+
declare function calculateLinearInterest({ rate, currentTimestamp, lastUpdateTimestamp, }: LinearInterestRequest): bigint;
|
|
98
|
+
interface NormalizedIncomeRequest {
|
|
99
|
+
rate: bigint;
|
|
100
|
+
index: bigint;
|
|
101
|
+
lastUpdateTimestamp: number;
|
|
102
|
+
currentTimestamp: number;
|
|
103
|
+
}
|
|
104
|
+
declare function getNormalizedIncome({ rate, index, lastUpdateTimestamp, currentTimestamp, }: NormalizedIncomeRequest): bigint;
|
|
105
|
+
declare function getNormalizedDebt({ rate, index, currentTimestamp, lastUpdateTimestamp, }: NormalizedIncomeRequest): bigint;
|
|
106
|
+
interface CurrentBalanceRequest {
|
|
107
|
+
scaledBalance: bigint;
|
|
108
|
+
index: bigint;
|
|
109
|
+
rate: bigint;
|
|
110
|
+
lastUpdateTimestamp: number;
|
|
111
|
+
currentTimestamp: number;
|
|
112
|
+
}
|
|
113
|
+
declare function getCurrentLiquidityBalance({ scaledBalance, index, rate, lastUpdateTimestamp, currentTimestamp, }: CurrentBalanceRequest): bigint;
|
|
114
|
+
declare function getCurrentDebtBalance({ index, scaledBalance, rate, lastUpdateTimestamp, currentTimestamp, }: CurrentBalanceRequest): bigint;
|
|
115
|
+
interface HealthFactorFromBalanceRequest {
|
|
116
|
+
collateralBalanceMarketReferenceCurrency: bigint;
|
|
117
|
+
borrowBalanceMarketReferenceCurrency: bigint;
|
|
118
|
+
averageLiquidationThreshold: bigint;
|
|
119
|
+
}
|
|
120
|
+
declare function calculateHealthFactorFromBalances({ borrowBalanceMarketReferenceCurrency, collateralBalanceMarketReferenceCurrency, averageLiquidationThreshold, }: HealthFactorFromBalanceRequest): bigint;
|
|
121
|
+
interface AvailableBorrowsMarketReferenceCurrencyRequest {
|
|
122
|
+
collateralBalanceMarketReferenceCurrency: bigint;
|
|
123
|
+
borrowBalanceMarketReferenceCurrency: bigint;
|
|
124
|
+
currentLtv: bigint;
|
|
125
|
+
}
|
|
126
|
+
declare function calculateAvailableBorrowsMarketReferenceCurrency({ collateralBalanceMarketReferenceCurrency, borrowBalanceMarketReferenceCurrency, currentLtv, }: AvailableBorrowsMarketReferenceCurrencyRequest): bigint;
|
|
127
|
+
interface MarketReferenceCurrencyAndUsdBalanceRequest {
|
|
128
|
+
balance: bigint;
|
|
129
|
+
priceInMarketReferenceCurrency: bigint;
|
|
130
|
+
marketReferenceCurrencyDecimals: number;
|
|
131
|
+
decimals: number;
|
|
132
|
+
marketReferencePriceInUsdNormalized: bigint;
|
|
133
|
+
}
|
|
134
|
+
interface MarketReferenceAndUsdBalanceResponse {
|
|
135
|
+
marketReferenceCurrencyBalance: bigint;
|
|
136
|
+
usdBalance: bigint;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @returns non humanized/normalized values for usd/marketReference
|
|
140
|
+
*/
|
|
141
|
+
declare function getMarketReferenceCurrencyAndUsdBalance({ balance, priceInMarketReferenceCurrency, marketReferenceCurrencyDecimals, decimals, marketReferencePriceInUsdNormalized, }: MarketReferenceCurrencyAndUsdBalanceRequest): MarketReferenceAndUsdBalanceResponse;
|
|
142
|
+
|
|
143
|
+
declare const WAD: bigint;
|
|
144
|
+
declare const HALF_WAD: bigint;
|
|
145
|
+
declare const RAY: bigint;
|
|
146
|
+
declare const HALF_RAY: bigint;
|
|
147
|
+
declare const WAD_RAY_RATIO: bigint;
|
|
148
|
+
declare function rayMul(a: bigint, b: bigint): bigint;
|
|
149
|
+
declare function rayDiv(a: bigint, b: bigint): bigint;
|
|
150
|
+
declare function rayToWad(a: bigint): bigint;
|
|
151
|
+
declare function wadToRay(a: bigint): bigint;
|
|
152
|
+
declare function wadDiv(a: bigint, b: bigint): bigint;
|
|
153
|
+
|
|
154
|
+
declare enum PayloadState {
|
|
155
|
+
None = 0,
|
|
156
|
+
Created = 1,
|
|
157
|
+
Queued = 2,
|
|
158
|
+
Executed = 3,
|
|
159
|
+
Cancelled = 4,
|
|
160
|
+
Expired = 5
|
|
161
|
+
}
|
|
162
|
+
declare const HUMAN_READABLE_PAYLOAD_STATE: {
|
|
163
|
+
0: string;
|
|
164
|
+
1: string;
|
|
165
|
+
2: string;
|
|
166
|
+
3: string;
|
|
167
|
+
4: string;
|
|
168
|
+
5: string;
|
|
169
|
+
};
|
|
170
|
+
type PayloadsControllerContract = GetContractReturnType<typeof IPayloadsControllerCore_ABI, Client>;
|
|
171
|
+
declare function getPayloadsController<T extends Client>(client: T, address: Hex): PayloadsControllerContract;
|
|
172
|
+
declare function makePayloadExecutableOnTestClient(client: TestClient, payloadsController: Address, payloadId: number): Promise<void>;
|
|
173
|
+
declare function getNonFinalizedPayloads<T extends Client>(client: T, payloadsController: Address): Promise<number[]>;
|
|
174
|
+
|
|
175
|
+
declare enum ProposalState {
|
|
176
|
+
Null = 0,// proposal does not exists
|
|
177
|
+
Created = 1,// created, waiting for a cooldown to initiate the balances snapshot
|
|
178
|
+
Active = 2,// balances snapshot set, voting in progress
|
|
179
|
+
Queued = 3,// voting results submitted, but proposal is under grace period when guardian can cancel it
|
|
180
|
+
Executed = 4,// results sent to the execution chain(s)
|
|
181
|
+
Failed = 5,// voting was not successful
|
|
182
|
+
Cancelled = 6,// got cancelled by guardian, or because proposition power of creator dropped below allowed minimum
|
|
183
|
+
Expired = 7
|
|
184
|
+
}
|
|
185
|
+
declare const HUMAN_READABLE_PROPOSAL_STATE: {
|
|
186
|
+
0: string;
|
|
187
|
+
1: string;
|
|
188
|
+
2: string;
|
|
189
|
+
3: string;
|
|
190
|
+
4: string;
|
|
191
|
+
5: string;
|
|
192
|
+
6: string;
|
|
193
|
+
7: string;
|
|
194
|
+
};
|
|
195
|
+
type GovernanceContract = GetContractReturnType<typeof IGovernanceCore_ABI, Client>;
|
|
196
|
+
declare function getGovernance<T extends Client>(client: T, address: Hex): GovernanceContract;
|
|
197
|
+
declare function makeProposalExecutableOnTestClient(client: TestClient, governance: Address, proposalId: bigint): Promise<void>;
|
|
198
|
+
|
|
35
199
|
type ExplorerConfig = {
|
|
36
200
|
api: string;
|
|
37
201
|
explorer: string;
|
|
@@ -81,6 +245,61 @@ declare function parseApiSourceCode(sourceCode: string): {
|
|
|
81
245
|
}>;
|
|
82
246
|
};
|
|
83
247
|
|
|
248
|
+
/**
|
|
249
|
+
* While tenderly is a fenomanal tool for testing, it is not always easy to use as there are minor bugs and small nuances to consider everywhere.
|
|
250
|
+
* This is a simple wrapper around the tenderly APIs.
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
type TenderlyConfig = {
|
|
254
|
+
accountSlug: string;
|
|
255
|
+
projectSlug: string;
|
|
256
|
+
accessToken: string;
|
|
257
|
+
};
|
|
258
|
+
type Tenderly_createVnetParams = {
|
|
259
|
+
slug: string;
|
|
260
|
+
displayName: string;
|
|
261
|
+
baseChainId: number;
|
|
262
|
+
forkChainId: number;
|
|
263
|
+
blockNumber?: Hex;
|
|
264
|
+
};
|
|
265
|
+
type Tenderly_createVnetParamsResponse = {
|
|
266
|
+
id: string;
|
|
267
|
+
slug: string;
|
|
268
|
+
display_name: number;
|
|
269
|
+
fork_config: {
|
|
270
|
+
network_id: number;
|
|
271
|
+
block_number: Hex;
|
|
272
|
+
};
|
|
273
|
+
virtual_network_config: {
|
|
274
|
+
chain_config: {
|
|
275
|
+
chain_id: number;
|
|
276
|
+
};
|
|
277
|
+
accounts: {
|
|
278
|
+
address: string;
|
|
279
|
+
}[];
|
|
280
|
+
};
|
|
281
|
+
rpcs: [
|
|
282
|
+
{
|
|
283
|
+
url: string;
|
|
284
|
+
name: "Admin RPC";
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
url: string;
|
|
288
|
+
name: "Public RPC";
|
|
289
|
+
}
|
|
290
|
+
];
|
|
291
|
+
};
|
|
292
|
+
declare function tenderly_createVnet({ slug, displayName, baseChainId, forkChainId, blockNumber, }: Tenderly_createVnetParams, { accessToken, accountSlug, projectSlug }: TenderlyConfig): Promise<{
|
|
293
|
+
vnet: Tenderly_createVnetParamsResponse;
|
|
294
|
+
testClient: TestClient;
|
|
295
|
+
walletClient: WalletClient;
|
|
296
|
+
simulate: (body: any) => Promise<Response>;
|
|
297
|
+
delete: () => Promise<Response>;
|
|
298
|
+
}>;
|
|
299
|
+
|
|
300
|
+
declare const erc1967_ImplementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
|
|
301
|
+
declare const erc1967_AdminSlot = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
302
|
+
|
|
84
303
|
declare function diffCode(codeBefore: string, codeAfter: string): Promise<Record<string, string>>;
|
|
85
304
|
|
|
86
|
-
export { type ExplorerConfig, bitmapToIndexes, decodeUserConfiguration, diffCode, getBits, getExplorer, getSourceCode, parseApiSourceCode };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPayloadsControllerCore_ABI, IGovernanceCore_ABI } from '@bgd-labs/aave-address-book/abis';
|
|
2
|
+
import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient } from 'viem';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* In solidity it is a quite common practice to encode bit variables in bitmaps opposed to bool structs.
|
|
@@ -19,6 +20,15 @@ declare function bitmapToIndexes(bitmap: bigint): number[];
|
|
|
19
20
|
* @returns
|
|
20
21
|
*/
|
|
21
22
|
declare function getBits(uint256: bigint, startBit: bigint, _endBit: bigint): bigint;
|
|
23
|
+
/**
|
|
24
|
+
* Sets the bits in a bigint
|
|
25
|
+
* @param input
|
|
26
|
+
* @param startBit inclusive
|
|
27
|
+
* @param endBit inclusive
|
|
28
|
+
* @param value the value to replace
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
declare function setBits(input: bigint, startBit: bigint, endBit: bigint, replaceValue: bigint | number): bigint;
|
|
22
32
|
|
|
23
33
|
/**
|
|
24
34
|
* The userConfiguration on aave is stored as an alteranting bitmap.
|
|
@@ -32,6 +42,160 @@ declare function decodeUserConfiguration(userConfiguration: bigint): {
|
|
|
32
42
|
collateralAssetIds: number[];
|
|
33
43
|
};
|
|
34
44
|
|
|
45
|
+
type ReserveConfiguration = {
|
|
46
|
+
ltv: bigint;
|
|
47
|
+
liquidationThreshold: bigint;
|
|
48
|
+
liquidationBonus: bigint;
|
|
49
|
+
decimals: bigint;
|
|
50
|
+
active: boolean;
|
|
51
|
+
frozen: boolean;
|
|
52
|
+
borrowingEnabled: boolean;
|
|
53
|
+
paused: boolean;
|
|
54
|
+
borrowingInIsolation: boolean;
|
|
55
|
+
siloedBorrowingEnabled: boolean;
|
|
56
|
+
flashloaningEnabled: boolean;
|
|
57
|
+
reserveFactor: bigint;
|
|
58
|
+
borrowCap: bigint;
|
|
59
|
+
supplyCap: bigint;
|
|
60
|
+
liquidationProtocolFee: bigint;
|
|
61
|
+
unbackedMintCap: bigint;
|
|
62
|
+
debtCeiling: bigint;
|
|
63
|
+
virtualAccountingEnabled: boolean;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* ReserveConfiguration is a tightly packed struct that contains the configuration of a reserve
|
|
67
|
+
* @param data
|
|
68
|
+
* @returns the decoded ReserveConfiguration
|
|
69
|
+
*/
|
|
70
|
+
declare function decodeReserveConfiguration(data: bigint): ReserveConfiguration;
|
|
71
|
+
declare function decodeReserveConfigurationV2(data: bigint): {
|
|
72
|
+
ltv: bigint;
|
|
73
|
+
liquidationThreshold: bigint;
|
|
74
|
+
liquidationBonus: bigint;
|
|
75
|
+
decimals: bigint;
|
|
76
|
+
active: boolean;
|
|
77
|
+
frozen: boolean;
|
|
78
|
+
borrowingEnabled: boolean;
|
|
79
|
+
stableBorrowingEnabled: boolean;
|
|
80
|
+
reserveFactor: bigint;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
declare const SECONDS_PER_YEAR = 31536000n;
|
|
84
|
+
declare const LTV_PRECISION = 4n;
|
|
85
|
+
|
|
86
|
+
interface CalculateCompoundedInterestRequest {
|
|
87
|
+
rate: bigint;
|
|
88
|
+
currentTimestamp: number;
|
|
89
|
+
lastUpdateTimestamp: number;
|
|
90
|
+
}
|
|
91
|
+
declare function calculateCompoundedInterest({ rate, currentTimestamp, lastUpdateTimestamp, }: CalculateCompoundedInterestRequest): bigint;
|
|
92
|
+
interface LinearInterestRequest {
|
|
93
|
+
rate: bigint;
|
|
94
|
+
currentTimestamp: number;
|
|
95
|
+
lastUpdateTimestamp: number;
|
|
96
|
+
}
|
|
97
|
+
declare function calculateLinearInterest({ rate, currentTimestamp, lastUpdateTimestamp, }: LinearInterestRequest): bigint;
|
|
98
|
+
interface NormalizedIncomeRequest {
|
|
99
|
+
rate: bigint;
|
|
100
|
+
index: bigint;
|
|
101
|
+
lastUpdateTimestamp: number;
|
|
102
|
+
currentTimestamp: number;
|
|
103
|
+
}
|
|
104
|
+
declare function getNormalizedIncome({ rate, index, lastUpdateTimestamp, currentTimestamp, }: NormalizedIncomeRequest): bigint;
|
|
105
|
+
declare function getNormalizedDebt({ rate, index, currentTimestamp, lastUpdateTimestamp, }: NormalizedIncomeRequest): bigint;
|
|
106
|
+
interface CurrentBalanceRequest {
|
|
107
|
+
scaledBalance: bigint;
|
|
108
|
+
index: bigint;
|
|
109
|
+
rate: bigint;
|
|
110
|
+
lastUpdateTimestamp: number;
|
|
111
|
+
currentTimestamp: number;
|
|
112
|
+
}
|
|
113
|
+
declare function getCurrentLiquidityBalance({ scaledBalance, index, rate, lastUpdateTimestamp, currentTimestamp, }: CurrentBalanceRequest): bigint;
|
|
114
|
+
declare function getCurrentDebtBalance({ index, scaledBalance, rate, lastUpdateTimestamp, currentTimestamp, }: CurrentBalanceRequest): bigint;
|
|
115
|
+
interface HealthFactorFromBalanceRequest {
|
|
116
|
+
collateralBalanceMarketReferenceCurrency: bigint;
|
|
117
|
+
borrowBalanceMarketReferenceCurrency: bigint;
|
|
118
|
+
averageLiquidationThreshold: bigint;
|
|
119
|
+
}
|
|
120
|
+
declare function calculateHealthFactorFromBalances({ borrowBalanceMarketReferenceCurrency, collateralBalanceMarketReferenceCurrency, averageLiquidationThreshold, }: HealthFactorFromBalanceRequest): bigint;
|
|
121
|
+
interface AvailableBorrowsMarketReferenceCurrencyRequest {
|
|
122
|
+
collateralBalanceMarketReferenceCurrency: bigint;
|
|
123
|
+
borrowBalanceMarketReferenceCurrency: bigint;
|
|
124
|
+
currentLtv: bigint;
|
|
125
|
+
}
|
|
126
|
+
declare function calculateAvailableBorrowsMarketReferenceCurrency({ collateralBalanceMarketReferenceCurrency, borrowBalanceMarketReferenceCurrency, currentLtv, }: AvailableBorrowsMarketReferenceCurrencyRequest): bigint;
|
|
127
|
+
interface MarketReferenceCurrencyAndUsdBalanceRequest {
|
|
128
|
+
balance: bigint;
|
|
129
|
+
priceInMarketReferenceCurrency: bigint;
|
|
130
|
+
marketReferenceCurrencyDecimals: number;
|
|
131
|
+
decimals: number;
|
|
132
|
+
marketReferencePriceInUsdNormalized: bigint;
|
|
133
|
+
}
|
|
134
|
+
interface MarketReferenceAndUsdBalanceResponse {
|
|
135
|
+
marketReferenceCurrencyBalance: bigint;
|
|
136
|
+
usdBalance: bigint;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @returns non humanized/normalized values for usd/marketReference
|
|
140
|
+
*/
|
|
141
|
+
declare function getMarketReferenceCurrencyAndUsdBalance({ balance, priceInMarketReferenceCurrency, marketReferenceCurrencyDecimals, decimals, marketReferencePriceInUsdNormalized, }: MarketReferenceCurrencyAndUsdBalanceRequest): MarketReferenceAndUsdBalanceResponse;
|
|
142
|
+
|
|
143
|
+
declare const WAD: bigint;
|
|
144
|
+
declare const HALF_WAD: bigint;
|
|
145
|
+
declare const RAY: bigint;
|
|
146
|
+
declare const HALF_RAY: bigint;
|
|
147
|
+
declare const WAD_RAY_RATIO: bigint;
|
|
148
|
+
declare function rayMul(a: bigint, b: bigint): bigint;
|
|
149
|
+
declare function rayDiv(a: bigint, b: bigint): bigint;
|
|
150
|
+
declare function rayToWad(a: bigint): bigint;
|
|
151
|
+
declare function wadToRay(a: bigint): bigint;
|
|
152
|
+
declare function wadDiv(a: bigint, b: bigint): bigint;
|
|
153
|
+
|
|
154
|
+
declare enum PayloadState {
|
|
155
|
+
None = 0,
|
|
156
|
+
Created = 1,
|
|
157
|
+
Queued = 2,
|
|
158
|
+
Executed = 3,
|
|
159
|
+
Cancelled = 4,
|
|
160
|
+
Expired = 5
|
|
161
|
+
}
|
|
162
|
+
declare const HUMAN_READABLE_PAYLOAD_STATE: {
|
|
163
|
+
0: string;
|
|
164
|
+
1: string;
|
|
165
|
+
2: string;
|
|
166
|
+
3: string;
|
|
167
|
+
4: string;
|
|
168
|
+
5: string;
|
|
169
|
+
};
|
|
170
|
+
type PayloadsControllerContract = GetContractReturnType<typeof IPayloadsControllerCore_ABI, Client>;
|
|
171
|
+
declare function getPayloadsController<T extends Client>(client: T, address: Hex): PayloadsControllerContract;
|
|
172
|
+
declare function makePayloadExecutableOnTestClient(client: TestClient, payloadsController: Address, payloadId: number): Promise<void>;
|
|
173
|
+
declare function getNonFinalizedPayloads<T extends Client>(client: T, payloadsController: Address): Promise<number[]>;
|
|
174
|
+
|
|
175
|
+
declare enum ProposalState {
|
|
176
|
+
Null = 0,// proposal does not exists
|
|
177
|
+
Created = 1,// created, waiting for a cooldown to initiate the balances snapshot
|
|
178
|
+
Active = 2,// balances snapshot set, voting in progress
|
|
179
|
+
Queued = 3,// voting results submitted, but proposal is under grace period when guardian can cancel it
|
|
180
|
+
Executed = 4,// results sent to the execution chain(s)
|
|
181
|
+
Failed = 5,// voting was not successful
|
|
182
|
+
Cancelled = 6,// got cancelled by guardian, or because proposition power of creator dropped below allowed minimum
|
|
183
|
+
Expired = 7
|
|
184
|
+
}
|
|
185
|
+
declare const HUMAN_READABLE_PROPOSAL_STATE: {
|
|
186
|
+
0: string;
|
|
187
|
+
1: string;
|
|
188
|
+
2: string;
|
|
189
|
+
3: string;
|
|
190
|
+
4: string;
|
|
191
|
+
5: string;
|
|
192
|
+
6: string;
|
|
193
|
+
7: string;
|
|
194
|
+
};
|
|
195
|
+
type GovernanceContract = GetContractReturnType<typeof IGovernanceCore_ABI, Client>;
|
|
196
|
+
declare function getGovernance<T extends Client>(client: T, address: Hex): GovernanceContract;
|
|
197
|
+
declare function makeProposalExecutableOnTestClient(client: TestClient, governance: Address, proposalId: bigint): Promise<void>;
|
|
198
|
+
|
|
35
199
|
type ExplorerConfig = {
|
|
36
200
|
api: string;
|
|
37
201
|
explorer: string;
|
|
@@ -81,6 +245,61 @@ declare function parseApiSourceCode(sourceCode: string): {
|
|
|
81
245
|
}>;
|
|
82
246
|
};
|
|
83
247
|
|
|
248
|
+
/**
|
|
249
|
+
* While tenderly is a fenomanal tool for testing, it is not always easy to use as there are minor bugs and small nuances to consider everywhere.
|
|
250
|
+
* This is a simple wrapper around the tenderly APIs.
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
type TenderlyConfig = {
|
|
254
|
+
accountSlug: string;
|
|
255
|
+
projectSlug: string;
|
|
256
|
+
accessToken: string;
|
|
257
|
+
};
|
|
258
|
+
type Tenderly_createVnetParams = {
|
|
259
|
+
slug: string;
|
|
260
|
+
displayName: string;
|
|
261
|
+
baseChainId: number;
|
|
262
|
+
forkChainId: number;
|
|
263
|
+
blockNumber?: Hex;
|
|
264
|
+
};
|
|
265
|
+
type Tenderly_createVnetParamsResponse = {
|
|
266
|
+
id: string;
|
|
267
|
+
slug: string;
|
|
268
|
+
display_name: number;
|
|
269
|
+
fork_config: {
|
|
270
|
+
network_id: number;
|
|
271
|
+
block_number: Hex;
|
|
272
|
+
};
|
|
273
|
+
virtual_network_config: {
|
|
274
|
+
chain_config: {
|
|
275
|
+
chain_id: number;
|
|
276
|
+
};
|
|
277
|
+
accounts: {
|
|
278
|
+
address: string;
|
|
279
|
+
}[];
|
|
280
|
+
};
|
|
281
|
+
rpcs: [
|
|
282
|
+
{
|
|
283
|
+
url: string;
|
|
284
|
+
name: "Admin RPC";
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
url: string;
|
|
288
|
+
name: "Public RPC";
|
|
289
|
+
}
|
|
290
|
+
];
|
|
291
|
+
};
|
|
292
|
+
declare function tenderly_createVnet({ slug, displayName, baseChainId, forkChainId, blockNumber, }: Tenderly_createVnetParams, { accessToken, accountSlug, projectSlug }: TenderlyConfig): Promise<{
|
|
293
|
+
vnet: Tenderly_createVnetParamsResponse;
|
|
294
|
+
testClient: TestClient;
|
|
295
|
+
walletClient: WalletClient;
|
|
296
|
+
simulate: (body: any) => Promise<Response>;
|
|
297
|
+
delete: () => Promise<Response>;
|
|
298
|
+
}>;
|
|
299
|
+
|
|
300
|
+
declare const erc1967_ImplementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
|
|
301
|
+
declare const erc1967_AdminSlot = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
302
|
+
|
|
84
303
|
declare function diffCode(codeBefore: string, codeAfter: string): Promise<Record<string, string>>;
|
|
85
304
|
|
|
86
|
-
export { type ExplorerConfig, bitmapToIndexes, decodeUserConfiguration, diffCode, getBits, getExplorer, getSourceCode, parseApiSourceCode };
|
|
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 };
|