@gearbox-protocol/sdk 9.14.1 → 9.15.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.
- package/dist/cjs/abi/package.json +1 -0
- package/dist/cjs/dev/mint/factory.js +1 -1
- package/dist/cjs/permissionless/bindings/address-provider.js +51 -0
- package/dist/cjs/permissionless/bindings/base-contract.js +173 -0
- package/dist/cjs/permissionless/bindings/bytecode-repository.js +526 -0
- package/dist/cjs/permissionless/bindings/compressors/index.js +24 -0
- package/dist/cjs/permissionless/bindings/compressors/token-compressor.js +110 -0
- package/dist/cjs/permissionless/bindings/compressors/withdrawal-compressor.js +60 -0
- package/dist/cjs/permissionless/bindings/cross-chain-multisig.js +355 -0
- package/dist/cjs/permissionless/bindings/factory/abstract-factory.js +52 -0
- package/dist/cjs/permissionless/bindings/factory/credit-factory.js +197 -0
- package/dist/cjs/permissionless/bindings/factory/pool-factory.js +69 -0
- package/dist/cjs/permissionless/bindings/factory/price-oracle-factory.js +47 -0
- package/dist/cjs/permissionless/bindings/governance/batches-chain.js +41 -0
- package/dist/cjs/permissionless/bindings/governance/governor.js +243 -0
- package/dist/cjs/permissionless/bindings/governance/index.js +26 -0
- package/dist/cjs/permissionless/bindings/governance/timelock.js +104 -0
- package/dist/cjs/permissionless/bindings/governance/types.js +16 -0
- package/dist/cjs/permissionless/bindings/index.js +48 -0
- package/dist/cjs/permissionless/bindings/instance-manager.js +244 -0
- package/dist/cjs/permissionless/bindings/market-configurator-factory.js +75 -0
- package/dist/cjs/permissionless/bindings/market-configurator.js +771 -0
- package/dist/cjs/permissionless/bindings/price-feed-store.js +395 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/balancer-stable.js +63 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/balancer-weighted.js +63 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/bounded.js +47 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/composite.js +43 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/constant.js +42 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/curve-crypto.js +67 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/curve-stable.js +67 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/curve-twap.js +70 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/curve-usd.js +50 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/erc4626.js +72 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/external.js +38 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/index.js +63 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/kodiak.js +50 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/mellow-lrt.js +122 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/pendle-pt-twap.js +51 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/pyth.js +65 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/redstone.js +81 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/wsteth.js +63 -0
- package/dist/cjs/permissionless/bindings/pricefeeds/zero.js +33 -0
- package/dist/cjs/permissionless/bindings/router/index.js +22 -0
- package/dist/cjs/permissionless/bindings/router/routing-manager.js +58 -0
- package/dist/cjs/permissionless/bindings/treasury-splitter.js +60 -0
- package/dist/cjs/permissionless/bindings/types.js +16 -0
- package/dist/cjs/permissionless/chains/archive-transport.js +274 -0
- package/dist/cjs/permissionless/core/auditor.js +16 -0
- package/dist/cjs/permissionless/core/bytecode.js +16 -0
- package/dist/cjs/permissionless/core/index.js +32 -0
- package/dist/cjs/permissionless/core/pricefeed-builder.js +16 -0
- package/dist/cjs/permissionless/core/pricefeed.js +16 -0
- package/dist/cjs/permissionless/core/proposal.js +16 -0
- package/dist/cjs/permissionless/core/raw-tx.js +38 -0
- package/dist/cjs/permissionless/deployment/addresses.js +35 -0
- package/dist/cjs/permissionless/deployment/mainnet.js +54 -0
- package/dist/cjs/permissionless/index.js +32 -0
- package/dist/cjs/permissionless/package.json +1 -0
- package/dist/cjs/permissionless/plugins/index.js +40 -0
- package/dist/cjs/permissionless/plugins/irm/constructor-params-abi.js +81 -0
- package/dist/cjs/permissionless/plugins/loss-policies/constructor-params-abi.js +79 -0
- package/dist/cjs/permissionless/plugins/rate-keepers/constructor-params-abi.js +89 -0
- package/dist/cjs/permissionless/utils/abi-decoder.js +72 -0
- package/dist/cjs/permissionless/utils/abi-encoder.js +89 -0
- package/dist/cjs/permissionless/utils/block-utils.js +55 -0
- package/dist/cjs/permissionless/utils/create2.js +113 -0
- package/dist/cjs/permissionless/utils/format.js +97 -0
- package/dist/cjs/permissionless/utils/governance/batch.js +114 -0
- package/dist/cjs/permissionless/utils/governance/index.js +26 -0
- package/dist/cjs/permissionless/utils/governance/timelock-txs.js +44 -0
- package/dist/cjs/permissionless/utils/governance/types.js +16 -0
- package/dist/cjs/permissionless/utils/index.js +38 -0
- package/dist/cjs/permissionless/utils/literals.js +46 -0
- package/dist/cjs/permissionless/utils/price-update/get-price-feeds.js +91 -0
- package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +84 -0
- package/dist/cjs/permissionless/utils/price-update/get-prices.js +123 -0
- package/dist/cjs/permissionless/utils/price-update/get-updatable-feeds.js +52 -0
- package/dist/cjs/permissionless/utils/price-update/index.js +28 -0
- package/dist/cjs/permissionless/utils/signature.js +35 -0
- package/dist/cjs/plugins/adapters/AdaptersPlugin.js +1 -1
- package/dist/cjs/plugins/adapters/abi/actionAbi.js +1 -1
- package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +2 -2
- package/dist/cjs/plugins/adapters/abi/utils.js +6 -6
- package/dist/cjs/plugins/adapters/index.js +4 -4
- package/dist/cjs/sdk/sdk-gov-legacy/tokens/curveLP.js +1 -1
- package/dist/cjs/sdk/sdk-legacy/tokens/tokenData.js +1 -1
- package/dist/esm/abi/package.json +1 -0
- package/dist/esm/dev/mint/factory.js +1 -1
- package/dist/esm/permissionless/bindings/address-provider.js +27 -0
- package/dist/esm/permissionless/bindings/base-contract.js +151 -0
- package/dist/esm/permissionless/bindings/bytecode-repository.js +508 -0
- package/dist/esm/permissionless/bindings/compressors/index.js +2 -0
- package/dist/esm/permissionless/bindings/compressors/token-compressor.js +89 -0
- package/dist/esm/permissionless/bindings/compressors/withdrawal-compressor.js +38 -0
- package/dist/esm/permissionless/bindings/cross-chain-multisig.js +336 -0
- package/dist/esm/permissionless/bindings/factory/abstract-factory.js +28 -0
- package/dist/esm/permissionless/bindings/factory/credit-factory.js +177 -0
- package/dist/esm/permissionless/bindings/factory/pool-factory.js +45 -0
- package/dist/esm/permissionless/bindings/factory/price-oracle-factory.js +23 -0
- package/dist/esm/permissionless/bindings/governance/batches-chain.js +17 -0
- package/dist/esm/permissionless/bindings/governance/governor.js +224 -0
- package/dist/esm/permissionless/bindings/governance/index.js +3 -0
- package/dist/esm/permissionless/bindings/governance/timelock.js +80 -0
- package/dist/esm/permissionless/bindings/governance/types.js +0 -0
- package/dist/esm/permissionless/bindings/index.js +14 -0
- package/dist/esm/permissionless/bindings/instance-manager.js +223 -0
- package/dist/esm/permissionless/bindings/market-configurator-factory.js +51 -0
- package/dist/esm/permissionless/bindings/market-configurator.js +765 -0
- package/dist/esm/permissionless/bindings/price-feed-store.js +376 -0
- package/dist/esm/permissionless/bindings/pricefeeds/balancer-stable.js +39 -0
- package/dist/esm/permissionless/bindings/pricefeeds/balancer-weighted.js +39 -0
- package/dist/esm/permissionless/bindings/pricefeeds/bounded.js +23 -0
- package/dist/esm/permissionless/bindings/pricefeeds/composite.js +19 -0
- package/dist/esm/permissionless/bindings/pricefeeds/constant.js +18 -0
- package/dist/esm/permissionless/bindings/pricefeeds/curve-crypto.js +43 -0
- package/dist/esm/permissionless/bindings/pricefeeds/curve-stable.js +43 -0
- package/dist/esm/permissionless/bindings/pricefeeds/curve-twap.js +46 -0
- package/dist/esm/permissionless/bindings/pricefeeds/curve-usd.js +26 -0
- package/dist/esm/permissionless/bindings/pricefeeds/erc4626.js +48 -0
- package/dist/esm/permissionless/bindings/pricefeeds/external.js +14 -0
- package/dist/esm/permissionless/bindings/pricefeeds/index.js +39 -0
- package/dist/esm/permissionless/bindings/pricefeeds/kodiak.js +26 -0
- package/dist/esm/permissionless/bindings/pricefeeds/mellow-lrt.js +98 -0
- package/dist/esm/permissionless/bindings/pricefeeds/pendle-pt-twap.js +27 -0
- package/dist/esm/permissionless/bindings/pricefeeds/pyth.js +41 -0
- package/dist/esm/permissionless/bindings/pricefeeds/redstone.js +57 -0
- package/dist/esm/permissionless/bindings/pricefeeds/wsteth.js +39 -0
- package/dist/esm/permissionless/bindings/pricefeeds/zero.js +9 -0
- package/dist/esm/permissionless/bindings/router/index.js +1 -0
- package/dist/esm/permissionless/bindings/router/routing-manager.js +36 -0
- package/dist/esm/permissionless/bindings/treasury-splitter.js +36 -0
- package/dist/esm/permissionless/bindings/types.js +0 -0
- package/dist/esm/permissionless/chains/archive-transport.js +250 -0
- package/dist/esm/permissionless/core/auditor.js +0 -0
- package/dist/esm/permissionless/core/bytecode.js +0 -0
- package/dist/esm/permissionless/core/index.js +6 -0
- package/dist/esm/permissionless/core/pricefeed-builder.js +0 -0
- package/dist/esm/permissionless/core/pricefeed.js +0 -0
- package/dist/esm/permissionless/core/proposal.js +0 -0
- package/dist/esm/permissionless/core/raw-tx.js +14 -0
- package/dist/esm/permissionless/deployment/addresses.js +11 -0
- package/dist/esm/permissionless/deployment/mainnet.js +27 -0
- package/dist/esm/permissionless/index.js +6 -0
- package/dist/esm/permissionless/package.json +1 -0
- package/dist/esm/permissionless/plugins/index.js +20 -0
- package/dist/esm/permissionless/plugins/irm/constructor-params-abi.js +52 -0
- package/dist/esm/permissionless/plugins/loss-policies/constructor-params-abi.js +50 -0
- package/dist/esm/permissionless/plugins/rate-keepers/constructor-params-abi.js +59 -0
- package/dist/esm/permissionless/utils/abi-decoder.js +50 -0
- package/dist/esm/permissionless/utils/abi-encoder.js +65 -0
- package/dist/esm/permissionless/utils/block-utils.js +31 -0
- package/dist/esm/permissionless/utils/create2.js +85 -0
- package/dist/esm/permissionless/utils/format.js +67 -0
- package/dist/esm/permissionless/utils/governance/batch.js +87 -0
- package/dist/esm/permissionless/utils/governance/index.js +3 -0
- package/dist/esm/permissionless/utils/governance/timelock-txs.js +20 -0
- package/dist/esm/permissionless/utils/governance/types.js +0 -0
- package/dist/esm/permissionless/utils/index.js +9 -0
- package/dist/esm/permissionless/utils/literals.js +16 -0
- package/dist/esm/permissionless/utils/price-update/get-price-feeds.js +65 -0
- package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +67 -0
- package/dist/esm/permissionless/utils/price-update/get-prices.js +99 -0
- package/dist/esm/permissionless/utils/price-update/get-updatable-feeds.js +31 -0
- package/dist/esm/permissionless/utils/price-update/index.js +4 -0
- package/dist/esm/permissionless/utils/signature.js +11 -0
- package/dist/esm/plugins/adapters/AdaptersPlugin.js +1 -1
- package/dist/esm/plugins/adapters/abi/actionAbi.js +1 -1
- package/dist/esm/plugins/adapters/abi/conctructorAbi.js +2 -2
- package/dist/esm/plugins/adapters/abi/utils.js +2 -2
- package/dist/esm/plugins/adapters/index.js +2 -2
- package/dist/esm/sdk/sdk-gov-legacy/tokens/curveLP.js +1 -1
- package/dist/esm/sdk/sdk-legacy/tokens/tokenData.js +1 -1
- package/dist/types/dev/mint/factory.d.ts +2 -2
- package/dist/types/permissionless/bindings/address-provider.d.ts +259 -0
- package/dist/types/permissionless/bindings/base-contract.d.ts +23 -0
- package/dist/types/permissionless/bindings/bytecode-repository.d.ts +1352 -0
- package/dist/types/permissionless/bindings/compressors/index.d.ts +2 -0
- package/dist/types/permissionless/bindings/compressors/token-compressor.d.ts +118 -0
- package/dist/types/permissionless/bindings/compressors/withdrawal-compressor.d.ts +331 -0
- package/dist/types/permissionless/bindings/cross-chain-multisig.d.ts +835 -0
- package/dist/types/permissionless/bindings/factory/abstract-factory.d.ts +17 -0
- package/dist/types/permissionless/bindings/factory/credit-factory.d.ts +224 -0
- package/dist/types/permissionless/bindings/factory/pool-factory.d.ts +86 -0
- package/dist/types/permissionless/bindings/factory/price-oracle-factory.d.ts +38 -0
- package/dist/types/permissionless/bindings/governance/batches-chain.d.ts +39 -0
- package/dist/types/permissionless/bindings/governance/governor.d.ts +615 -0
- package/dist/types/permissionless/bindings/governance/index.d.ts +3 -0
- package/dist/types/permissionless/bindings/governance/timelock.d.ts +10 -0
- package/dist/types/permissionless/bindings/governance/types.d.ts +42 -0
- package/dist/types/permissionless/bindings/index.d.ts +14 -0
- package/dist/types/permissionless/bindings/instance-manager.d.ts +361 -0
- package/dist/types/permissionless/bindings/market-configurator-factory.d.ts +244 -0
- package/dist/types/permissionless/bindings/market-configurator.d.ts +1656 -0
- package/dist/types/permissionless/bindings/price-feed-store.d.ts +605 -0
- package/dist/types/permissionless/bindings/pricefeeds/balancer-stable.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/balancer-weighted.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/bounded.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/composite.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/constant.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/curve-crypto.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/curve-stable.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/curve-twap.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/curve-usd.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/erc4626.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/external.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/index.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/kodiak.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/mellow-lrt.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/pendle-pt-twap.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/pyth.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/redstone.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/wsteth.d.ts +2 -0
- package/dist/types/permissionless/bindings/pricefeeds/zero.d.ts +2 -0
- package/dist/types/permissionless/bindings/router/index.d.ts +1 -0
- package/dist/types/permissionless/bindings/router/routing-manager.d.ts +502 -0
- package/dist/types/permissionless/bindings/treasury-splitter.d.ts +21 -0
- package/dist/types/permissionless/bindings/types.d.ts +65 -0
- package/dist/types/permissionless/chains/archive-transport.d.ts +49 -0
- package/dist/types/permissionless/core/auditor.d.ts +7 -0
- package/dist/types/permissionless/core/bytecode.d.ts +46 -0
- package/dist/types/permissionless/core/index.d.ts +6 -0
- package/dist/types/permissionless/core/pricefeed-builder.d.ts +59 -0
- package/dist/types/permissionless/core/pricefeed.d.ts +10 -0
- package/dist/types/permissionless/core/proposal.d.ts +33 -0
- package/dist/types/permissionless/core/raw-tx.d.ts +4 -0
- package/dist/types/permissionless/deployment/addresses.d.ts +7 -0
- package/dist/types/permissionless/deployment/mainnet.d.ts +10 -0
- package/dist/types/permissionless/index.d.ts +6 -0
- package/dist/types/permissionless/plugins/index.d.ts +3 -0
- package/dist/types/permissionless/plugins/irm/constructor-params-abi.d.ts +63 -0
- package/dist/types/permissionless/plugins/loss-policies/constructor-params-abi.d.ts +48 -0
- package/dist/types/permissionless/plugins/rate-keepers/constructor-params-abi.d.ts +55 -0
- package/dist/types/permissionless/utils/abi-decoder.d.ts +13 -0
- package/dist/types/permissionless/utils/abi-encoder.d.ts +7 -0
- package/dist/types/permissionless/utils/block-utils.d.ts +8 -0
- package/dist/types/permissionless/utils/create2.d.ts +17 -0
- package/dist/types/permissionless/utils/format.d.ts +7 -0
- package/dist/types/permissionless/utils/governance/batch.d.ts +17 -0
- package/dist/types/permissionless/utils/governance/index.d.ts +3 -0
- package/dist/types/permissionless/utils/governance/timelock-txs.d.ts +2 -0
- package/dist/types/permissionless/utils/governance/types.d.ts +16 -0
- package/dist/types/permissionless/utils/index.d.ts +9 -0
- package/dist/types/permissionless/utils/literals.d.ts +7 -0
- package/dist/types/permissionless/utils/price-update/get-price-feeds.d.ts +8 -0
- package/dist/types/permissionless/utils/price-update/get-price-update-tx.d.ts +9 -0
- package/dist/types/permissionless/utils/price-update/get-prices.d.ts +6 -0
- package/dist/types/permissionless/utils/price-update/get-updatable-feeds.d.ts +8 -0
- package/dist/types/permissionless/utils/price-update/index.d.ts +4 -0
- package/dist/types/permissionless/utils/signature.d.ts +2 -0
- package/dist/types/plugins/adapters/abi/actionAbi.d.ts +1 -1
- package/dist/types/plugins/adapters/abi/conctructorAbi.d.ts +1 -1
- package/dist/types/plugins/adapters/abi/utils.d.ts +1 -1
- package/dist/types/plugins/adapters/index.d.ts +2 -2
- package/dist/types/plugins/zappers/extraZappers.d.ts +2 -2
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +1 -2
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +1 -2
- package/dist/types/sdk/market/oracle/PriceOracleV300Contract.d.ts +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
erc20Abi,
|
|
3
|
+
parseAbi
|
|
4
|
+
} from "viem";
|
|
5
|
+
import { tokenCompressorAbi } from "../../../abi/compressors/tokenCompressor.js";
|
|
6
|
+
import { BaseContract } from "../base-contract.js";
|
|
7
|
+
const abi = tokenCompressorAbi;
|
|
8
|
+
class TokenCompressorContract extends BaseContract {
|
|
9
|
+
constructor(address, client) {
|
|
10
|
+
super(abi, address, client, "TokenCompressor");
|
|
11
|
+
}
|
|
12
|
+
async getTokenInfo(token) {
|
|
13
|
+
const result = await this.contract.read.getTokenInfo([token]);
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
// @dev workaround for mellow withdrawal phantom token symbol
|
|
17
|
+
async getMellowWithdrawalPhantomTokenInfo(tokens) {
|
|
18
|
+
const abi2 = parseAbi([
|
|
19
|
+
"function multiVault() public view returns (address)"
|
|
20
|
+
]);
|
|
21
|
+
const contracts = tokens.map((token) => ({
|
|
22
|
+
address: token,
|
|
23
|
+
abi: abi2,
|
|
24
|
+
functionName: "multiVault",
|
|
25
|
+
args: []
|
|
26
|
+
}));
|
|
27
|
+
const results = await this.client.multicall({
|
|
28
|
+
contracts
|
|
29
|
+
});
|
|
30
|
+
const multivaultToToken = /* @__PURE__ */ new Map();
|
|
31
|
+
const multivaults = [];
|
|
32
|
+
for (let i = 0; i < results.length; i++) {
|
|
33
|
+
if (results[i].status === "success") {
|
|
34
|
+
const token = tokens[i];
|
|
35
|
+
const multivault = results[i].result;
|
|
36
|
+
multivaultToToken.set(multivault, token);
|
|
37
|
+
multivaults.push(multivault);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const resultsSymbols = await this.client.multicall({
|
|
41
|
+
contracts: multivaults.map((multiVault) => ({
|
|
42
|
+
address: multiVault,
|
|
43
|
+
abi: erc20Abi,
|
|
44
|
+
functionName: "symbol",
|
|
45
|
+
args: []
|
|
46
|
+
})),
|
|
47
|
+
allowFailure: true
|
|
48
|
+
});
|
|
49
|
+
const tokenToSymbol = /* @__PURE__ */ new Map();
|
|
50
|
+
for (let i = 0; i < resultsSymbols.length; i++) {
|
|
51
|
+
if (resultsSymbols[i].status === "success") {
|
|
52
|
+
const multivault = multivaults[i];
|
|
53
|
+
const token = multivaultToToken.get(multivault);
|
|
54
|
+
if (token) {
|
|
55
|
+
tokenToSymbol.set(token, resultsSymbols[i].result);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return Object.fromEntries(tokenToSymbol);
|
|
60
|
+
}
|
|
61
|
+
async getTokensInfo(tokens) {
|
|
62
|
+
const mellowPTInfo = await this.getMellowWithdrawalPhantomTokenInfo(tokens);
|
|
63
|
+
const results = await this.client.multicall({
|
|
64
|
+
contracts: tokens.map((token) => ({
|
|
65
|
+
address: this.address,
|
|
66
|
+
abi,
|
|
67
|
+
functionName: "getTokenInfo",
|
|
68
|
+
args: [token]
|
|
69
|
+
}))
|
|
70
|
+
});
|
|
71
|
+
const tokenInfos = results.map((result, index) => {
|
|
72
|
+
if (result.status === "failure") {
|
|
73
|
+
throw new Error(`Failed to get token info: ${result.error}`);
|
|
74
|
+
}
|
|
75
|
+
const token = tokens[index];
|
|
76
|
+
const multivaultSymbol = mellowPTInfo[token];
|
|
77
|
+
const tokenInfo = result.result;
|
|
78
|
+
const postfix = multivaultSymbol ? `[${multivaultSymbol}]` : "";
|
|
79
|
+
return {
|
|
80
|
+
...tokenInfo,
|
|
81
|
+
symbol: `${tokenInfo.symbol} ${postfix}`
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
return tokenInfos;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
TokenCompressorContract
|
|
89
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hexToString
|
|
3
|
+
} from "viem";
|
|
4
|
+
import { withdrawalCompressorAbi } from "../../../abi/compressors/withdrawalCompressor.js";
|
|
5
|
+
import { BaseContract } from "../base-contract.js";
|
|
6
|
+
const abi = withdrawalCompressorAbi;
|
|
7
|
+
class WithdrawalCompressorContract extends BaseContract {
|
|
8
|
+
constructor(address, client) {
|
|
9
|
+
super(abi, address, client, "RoutingManager");
|
|
10
|
+
}
|
|
11
|
+
parseFunctionParams(params) {
|
|
12
|
+
const { functionName, args } = params;
|
|
13
|
+
switch (functionName) {
|
|
14
|
+
case "setWithdrawableTypeToCompressorType": {
|
|
15
|
+
const [withdrawableType, compressorType] = args;
|
|
16
|
+
return {
|
|
17
|
+
chainId: 0,
|
|
18
|
+
target: this.address,
|
|
19
|
+
label: this.name,
|
|
20
|
+
functionName,
|
|
21
|
+
args: {
|
|
22
|
+
withdrawableType: hexToString(withdrawableType, {
|
|
23
|
+
size: 32
|
|
24
|
+
}),
|
|
25
|
+
compressorType: hexToString(compressorType, {
|
|
26
|
+
size: 32
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
default:
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
WithdrawalCompressorContract
|
|
38
|
+
};
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseAbi,
|
|
3
|
+
parseEventLogs,
|
|
4
|
+
recoverTypedDataAddress,
|
|
5
|
+
zeroAddress
|
|
6
|
+
} from "viem";
|
|
7
|
+
import { crossChainMultisigAbi } from "../../abi/310/crossChainMultisig.js";
|
|
8
|
+
import { json_stringify } from "../../sdk/utils/index.js";
|
|
9
|
+
import { Addresses } from "../deployment/addresses.js";
|
|
10
|
+
import { normalizeSignature } from "../utils/index.js";
|
|
11
|
+
import { CROSS_CHAIN_MULTISIG } from "../utils/literals.js";
|
|
12
|
+
import { BaseContract } from "./base-contract.js";
|
|
13
|
+
import { InstanceManagerContract } from "./instance-manager.js";
|
|
14
|
+
import { MarketConfiguratorFactoryContract } from "./market-configurator-factory.js";
|
|
15
|
+
const abi = crossChainMultisigAbi;
|
|
16
|
+
class CrossChainMultisigContract extends BaseContract {
|
|
17
|
+
constructor(address, client) {
|
|
18
|
+
super(abi, address, client, "CrossChainMultisig");
|
|
19
|
+
}
|
|
20
|
+
async getExecutedBatches(fromBlock, toBlock) {
|
|
21
|
+
const events = await this.getEvents("ExecuteBatch", fromBlock, toBlock);
|
|
22
|
+
const batches = await Promise.all(
|
|
23
|
+
events.map(async (event) => {
|
|
24
|
+
return this.getBatchData({
|
|
25
|
+
proposalHash: event.args.batchHash,
|
|
26
|
+
blockNumber: Number(event.blockNumber),
|
|
27
|
+
transactionHash: event.transactionHash
|
|
28
|
+
});
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
return batches;
|
|
32
|
+
}
|
|
33
|
+
async getCurrentBatches() {
|
|
34
|
+
const hashes = await this.contract.read.getCurrentBatchHashes();
|
|
35
|
+
return await Promise.all(
|
|
36
|
+
hashes.map(async (hash) => this.getBatchData({ proposalHash: hash }))
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
async getBatchData(args) {
|
|
40
|
+
const { proposalHash, blockNumber, transactionHash, timestamp } = args;
|
|
41
|
+
const proposal = await this.contract.read.getBatch([args.proposalHash]);
|
|
42
|
+
const signatures = [];
|
|
43
|
+
for (const sig of proposal.signatures) {
|
|
44
|
+
const recoveredSigner = await recoverTypedDataAddress({
|
|
45
|
+
...this.computeEIP712digest(
|
|
46
|
+
proposal.name,
|
|
47
|
+
proposalHash,
|
|
48
|
+
proposal.prevHash
|
|
49
|
+
),
|
|
50
|
+
signature: sig
|
|
51
|
+
});
|
|
52
|
+
signatures.push({
|
|
53
|
+
signer: recoveredSigner,
|
|
54
|
+
signature: sig
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const calls = proposal.calls.map((c) => ({
|
|
58
|
+
chainId: Number(c.chainId),
|
|
59
|
+
target: c.target,
|
|
60
|
+
callData: c.callData
|
|
61
|
+
}));
|
|
62
|
+
return {
|
|
63
|
+
...proposal,
|
|
64
|
+
calls,
|
|
65
|
+
timestamp,
|
|
66
|
+
transactionHash,
|
|
67
|
+
blockNumber,
|
|
68
|
+
hash: proposalHash,
|
|
69
|
+
parsedCalls: calls.map((c) => BaseContract.parseCall(c)),
|
|
70
|
+
signatures
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
computeEIP712digest(name, batchHash, prevHash) {
|
|
74
|
+
return {
|
|
75
|
+
domain: {
|
|
76
|
+
name: CROSS_CHAIN_MULTISIG,
|
|
77
|
+
version: "310",
|
|
78
|
+
chainId: 1,
|
|
79
|
+
verifyingContract: this.address
|
|
80
|
+
},
|
|
81
|
+
types: {
|
|
82
|
+
CompactBatch: [
|
|
83
|
+
{ name: "name", type: "string" },
|
|
84
|
+
{ name: "batchHash", type: "bytes32" },
|
|
85
|
+
{ name: "prevHash", type: "bytes32" }
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
primaryType: "CompactBatch",
|
|
89
|
+
message: {
|
|
90
|
+
name,
|
|
91
|
+
batchHash,
|
|
92
|
+
prevHash
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
computeRecoveryDigest(chainId, startingBatchHash) {
|
|
97
|
+
return {
|
|
98
|
+
domain: {
|
|
99
|
+
name: CROSS_CHAIN_MULTISIG,
|
|
100
|
+
version: "310",
|
|
101
|
+
chainId: 1,
|
|
102
|
+
verifyingContract: this.address
|
|
103
|
+
},
|
|
104
|
+
types: {
|
|
105
|
+
RecoveryMode: [
|
|
106
|
+
{ name: "chainId", type: "uint256" },
|
|
107
|
+
{ name: "startingBatchHash", type: "bytes32" }
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
primaryType: "RecoveryMode",
|
|
111
|
+
message: {
|
|
112
|
+
chainId: BigInt(chainId),
|
|
113
|
+
startingBatchHash
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
// signCompactBatchTypeData(name: string, batchHash: Hex, prevHash: Hex) {
|
|
118
|
+
// const typedData = this.computeEIP712digest(name, batchHash, prevHash);
|
|
119
|
+
// return {
|
|
120
|
+
// domain: typedData.domain,
|
|
121
|
+
// types: typedData.types,
|
|
122
|
+
// primaryType: typedData.primaryType,
|
|
123
|
+
// message: typedData.message,
|
|
124
|
+
// };
|
|
125
|
+
// }
|
|
126
|
+
async signBatch(batchHash, signature, sponsor) {
|
|
127
|
+
const normalizedSignature = normalizeSignature(signature);
|
|
128
|
+
const hash = await this.contract.write.signBatch(
|
|
129
|
+
[batchHash, normalizedSignature],
|
|
130
|
+
{
|
|
131
|
+
account: sponsor.account,
|
|
132
|
+
chain: sponsor.chain
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
return hash;
|
|
136
|
+
}
|
|
137
|
+
async enableRecovery(recovery, sponsor) {
|
|
138
|
+
const signatures = recovery.signatures.map(
|
|
139
|
+
(s) => normalizeSignature(s.signature)
|
|
140
|
+
);
|
|
141
|
+
return await this.contract.write.enableRecoveryMode(
|
|
142
|
+
[
|
|
143
|
+
{
|
|
144
|
+
chainId: BigInt(recovery.chainId),
|
|
145
|
+
startingBatchHash: recovery.startingBatchHash,
|
|
146
|
+
signatures
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
{
|
|
150
|
+
account: sponsor.account,
|
|
151
|
+
chain: sponsor.chain
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
async getConfirmationThreshold() {
|
|
156
|
+
return await this.contract.read.confirmationThreshold();
|
|
157
|
+
}
|
|
158
|
+
async getSigners() {
|
|
159
|
+
return [...await this.contract.read.getSigners()];
|
|
160
|
+
}
|
|
161
|
+
decodeFunctionData(target, calldata) {
|
|
162
|
+
switch (target.toLowerCase()) {
|
|
163
|
+
case this.address.toLowerCase(): {
|
|
164
|
+
return this.parseFunctionData(calldata);
|
|
165
|
+
}
|
|
166
|
+
case Addresses.INSTANCE_MANAGER.toLowerCase(): {
|
|
167
|
+
const instanceManager = new InstanceManagerContract(
|
|
168
|
+
target,
|
|
169
|
+
this.client
|
|
170
|
+
);
|
|
171
|
+
return instanceManager.parseFunctionData(calldata);
|
|
172
|
+
}
|
|
173
|
+
default: {
|
|
174
|
+
try {
|
|
175
|
+
let parsedData;
|
|
176
|
+
const marketConfiguratorFactory = new MarketConfiguratorFactoryContract(target, this.client);
|
|
177
|
+
parsedData = marketConfiguratorFactory.parseFunctionData(calldata);
|
|
178
|
+
if (!parsedData.functionName.startsWith("Unknown function")) {
|
|
179
|
+
return parsedData;
|
|
180
|
+
}
|
|
181
|
+
} catch {
|
|
182
|
+
return void 0;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
parseFunctionParams(params) {
|
|
188
|
+
switch (params.functionName) {
|
|
189
|
+
case "addSigner": {
|
|
190
|
+
const [signer] = params.args;
|
|
191
|
+
return this.wrapParseCall(params, {
|
|
192
|
+
signer
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
case "removeSigner": {
|
|
196
|
+
const [signer] = params.args;
|
|
197
|
+
return this.wrapParseCall(params, {
|
|
198
|
+
signer
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
case "setConfirmationThreshold": {
|
|
202
|
+
const [threshold] = params.args;
|
|
203
|
+
return this.wrapParseCall(params, {
|
|
204
|
+
threshold: threshold.toString()
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
case "submitBatch": {
|
|
208
|
+
const [name, calls, prevHash] = params.args;
|
|
209
|
+
return this.wrapParseCall(params, {
|
|
210
|
+
name,
|
|
211
|
+
calls: json_stringify(
|
|
212
|
+
calls.map(({ chainId, target, callData }) => ({
|
|
213
|
+
...this.decodeFunctionData(target, callData),
|
|
214
|
+
chainId: Number(chainId),
|
|
215
|
+
target
|
|
216
|
+
}))
|
|
217
|
+
),
|
|
218
|
+
prevHash
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
default:
|
|
222
|
+
return void 0;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async validateProposalSignature(proposalHash, signature) {
|
|
226
|
+
const normalizedSignature = normalizeSignature(signature);
|
|
227
|
+
const proposal = await this.getBatchData({ proposalHash });
|
|
228
|
+
const currentPrevHash = await this.contract.read.lastBatchHash();
|
|
229
|
+
if (proposal.prevHash !== currentPrevHash) {
|
|
230
|
+
return { success: false, error: "Proposal is not the latest" };
|
|
231
|
+
}
|
|
232
|
+
const signer = await this.getSignerFromSignature(
|
|
233
|
+
proposal.name,
|
|
234
|
+
proposalHash,
|
|
235
|
+
proposal.prevHash,
|
|
236
|
+
normalizedSignature
|
|
237
|
+
);
|
|
238
|
+
console.log("signer", signer);
|
|
239
|
+
const signers = await this.getSigners();
|
|
240
|
+
if (!signers.map((s) => s.toLowerCase()).includes(signer.toLowerCase())) {
|
|
241
|
+
return { success: false, error: "Signer is not a valid signer" };
|
|
242
|
+
}
|
|
243
|
+
const threshold = await this.getConfirmationThreshold();
|
|
244
|
+
if (proposal.signatures.length >= threshold) {
|
|
245
|
+
return { success: false, error: "Proposal has enough signatures" };
|
|
246
|
+
}
|
|
247
|
+
return { success: true };
|
|
248
|
+
}
|
|
249
|
+
async getSignerFromSignature(proposalName, proposalHash, prevHash, signature) {
|
|
250
|
+
return await recoverTypedDataAddress({
|
|
251
|
+
...this.computeEIP712digest(proposalName, proposalHash, prevHash),
|
|
252
|
+
signature
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
async executeProposal(signedProposal, sponsor) {
|
|
256
|
+
return await this.contract.write.executeBatch([signedProposal], {
|
|
257
|
+
account: sponsor.account,
|
|
258
|
+
chain: sponsor.chain
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
wrapSubmitBatch(args) {
|
|
262
|
+
const { proposal, prevHash } = args;
|
|
263
|
+
return this.createRawTx({
|
|
264
|
+
functionName: "submitBatch",
|
|
265
|
+
args: [proposal.name, proposal.calls, prevHash],
|
|
266
|
+
description: `CrossChainMultisig.submitBatch(${proposal.name})`
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
executeProposalTx(signedProposal) {
|
|
270
|
+
return this.createRawTx({
|
|
271
|
+
functionName: "executeBatch",
|
|
272
|
+
args: [signedProposal]
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
async submitBatch(proposal, sponsor) {
|
|
276
|
+
const prevHash = await this.getLastBatchHash();
|
|
277
|
+
return await this.contract.write.submitBatch(
|
|
278
|
+
[proposal.name, proposal.calls, prevHash],
|
|
279
|
+
{
|
|
280
|
+
account: sponsor.account,
|
|
281
|
+
chain: sponsor.chain
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
async getLastBatchHash() {
|
|
286
|
+
return await this.contract.read.lastBatchHash();
|
|
287
|
+
}
|
|
288
|
+
async computeBatchHash(args) {
|
|
289
|
+
const { proposal, prevHash } = args;
|
|
290
|
+
return await this.contract.read.computeBatchHash([
|
|
291
|
+
proposal.name,
|
|
292
|
+
proposal.calls,
|
|
293
|
+
prevHash
|
|
294
|
+
]);
|
|
295
|
+
}
|
|
296
|
+
async getConstructorParams() {
|
|
297
|
+
const latestBlock = await this.client.getBlockNumber();
|
|
298
|
+
const result = await this.getEvents(
|
|
299
|
+
"SetConfirmationThreshold",
|
|
300
|
+
0n,
|
|
301
|
+
latestBlock
|
|
302
|
+
);
|
|
303
|
+
const event = result[0];
|
|
304
|
+
const threshold = event.args.newConfirmationThreshold;
|
|
305
|
+
const receipt = await this.client.getTransactionReceipt({
|
|
306
|
+
hash: event.transactionHash
|
|
307
|
+
});
|
|
308
|
+
const signers = [];
|
|
309
|
+
let dao = zeroAddress;
|
|
310
|
+
parseEventLogs({
|
|
311
|
+
abi: parseAbi([
|
|
312
|
+
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
|
|
313
|
+
"event AddSigner(address indexed signer)"
|
|
314
|
+
]),
|
|
315
|
+
logs: receipt.logs
|
|
316
|
+
}).forEach((p) => {
|
|
317
|
+
if (p.eventName === "AddSigner") {
|
|
318
|
+
signers.push(p.args.signer);
|
|
319
|
+
}
|
|
320
|
+
if (p.eventName === "OwnershipTransferred") {
|
|
321
|
+
dao = p.args.newOwner;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
console.log("signers", signers);
|
|
325
|
+
console.log("threshold", threshold);
|
|
326
|
+
console.log("dao", dao);
|
|
327
|
+
return {
|
|
328
|
+
signers,
|
|
329
|
+
threshold,
|
|
330
|
+
dao
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
export {
|
|
335
|
+
CrossChainMultisigContract
|
|
336
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createCallData } from "../../core/raw-tx.js";
|
|
2
|
+
import { decodeFunctionWithNamedArgs } from "../../utils/abi-decoder.js";
|
|
3
|
+
class AbstractFactory {
|
|
4
|
+
abi;
|
|
5
|
+
constructor(abi) {
|
|
6
|
+
this.abi = abi;
|
|
7
|
+
}
|
|
8
|
+
createCallData(parameters) {
|
|
9
|
+
const callData = createCallData(this.abi, parameters);
|
|
10
|
+
return callData;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Decodes configuration calldata using the ABI
|
|
14
|
+
* @param calldata - The encoded function call data
|
|
15
|
+
* @returns Decoded function name and arguments, or null if decoding fails
|
|
16
|
+
*/
|
|
17
|
+
decodeConfig(calldata) {
|
|
18
|
+
const decoded = decodeFunctionWithNamedArgs(this.abi, calldata);
|
|
19
|
+
if (!decoded) return null;
|
|
20
|
+
return {
|
|
21
|
+
functionName: decoded.functionName,
|
|
22
|
+
args: decoded.args
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
AbstractFactory
|
|
28
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { decodeFunctionData, hexToString } from "viem";
|
|
2
|
+
import { iCreditConfigureActionsAbi } from "../../../abi/310/configure/iCreditConfigureActions.js";
|
|
3
|
+
import {
|
|
4
|
+
adapterConstructorAbi,
|
|
5
|
+
parseAdapterAction,
|
|
6
|
+
parseAdapterDeployParams
|
|
7
|
+
} from "../../../plugins/adapters/index.js";
|
|
8
|
+
import { AbstractFactory } from "./abstract-factory.js";
|
|
9
|
+
const abi = iCreditConfigureActionsAbi;
|
|
10
|
+
class CreditFactory extends AbstractFactory {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(abi);
|
|
13
|
+
}
|
|
14
|
+
pause() {
|
|
15
|
+
return this.createCallData({
|
|
16
|
+
functionName: "pause"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
unpause() {
|
|
20
|
+
return this.createCallData({
|
|
21
|
+
functionName: "unpause"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
addCollateralToken(args) {
|
|
25
|
+
return this.createCallData({
|
|
26
|
+
functionName: "addCollateralToken",
|
|
27
|
+
args: [args.token, args.liquidationThreshold]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
allowAdapter(deployParams) {
|
|
31
|
+
return this.createCallData({
|
|
32
|
+
functionName: "allowAdapter",
|
|
33
|
+
args: [deployParams]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
allowToken(token) {
|
|
37
|
+
return this.createCallData({
|
|
38
|
+
functionName: "allowToken",
|
|
39
|
+
args: [token]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
forbidToken(token) {
|
|
43
|
+
return this.createCallData({
|
|
44
|
+
functionName: "forbidToken",
|
|
45
|
+
args: [token]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
configureAdapterFor(targetContract, data) {
|
|
49
|
+
return this.createCallData({
|
|
50
|
+
functionName: "configureAdapterFor",
|
|
51
|
+
args: [targetContract, data]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
forbidAdapter(adapter) {
|
|
55
|
+
return this.createCallData({
|
|
56
|
+
functionName: "forbidAdapter",
|
|
57
|
+
args: [adapter]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
rampLiquidationThreshold(args) {
|
|
61
|
+
return this.createCallData({
|
|
62
|
+
functionName: "rampLiquidationThreshold",
|
|
63
|
+
args: [
|
|
64
|
+
args.token,
|
|
65
|
+
args.liquidationThresholdFinal,
|
|
66
|
+
args.rampStart,
|
|
67
|
+
args.rampDuration
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
setExpirationDate(params) {
|
|
72
|
+
return this.createCallData({
|
|
73
|
+
functionName: "setExpirationDate",
|
|
74
|
+
args: [params.expirationDate]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
setFees(params) {
|
|
78
|
+
return this.createCallData({
|
|
79
|
+
functionName: "setFees",
|
|
80
|
+
args: [
|
|
81
|
+
params.params.feeLiquidation,
|
|
82
|
+
params.params.feeLiquidationPremium,
|
|
83
|
+
params.params.feeLiquidationExpired,
|
|
84
|
+
params.params.feeLiquidationPremiumExpired
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
setMaxDebtPerBlockMultiplier(newMaxDebtLimitPerBlockMultiplier) {
|
|
89
|
+
return this.createCallData({
|
|
90
|
+
functionName: "setMaxDebtPerBlockMultiplier",
|
|
91
|
+
args: [newMaxDebtLimitPerBlockMultiplier]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
upgradeCreditConfigurator() {
|
|
95
|
+
return this.createCallData({
|
|
96
|
+
functionName: "upgradeCreditConfigurator"
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
upgradeCreditFacade(params) {
|
|
100
|
+
return this.createCallData({
|
|
101
|
+
functionName: "upgradeCreditFacade",
|
|
102
|
+
args: [params]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
decodeConfig(calldata) {
|
|
106
|
+
function getMaxVerBelowN(adapterPostfix, n) {
|
|
107
|
+
const keys = Object.keys(
|
|
108
|
+
adapterConstructorAbi[adapterPostfix]
|
|
109
|
+
).map(Number).filter((k) => k < n);
|
|
110
|
+
if (keys.length === 0) return void 0;
|
|
111
|
+
return Math.max(...keys);
|
|
112
|
+
}
|
|
113
|
+
function parseAdapterParams(adapterPostfix, version, data) {
|
|
114
|
+
if (version < 310) return null;
|
|
115
|
+
try {
|
|
116
|
+
return parseAdapterDeployParams(adapterPostfix, version, data);
|
|
117
|
+
} catch {
|
|
118
|
+
const v = getMaxVerBelowN(adapterPostfix, version);
|
|
119
|
+
if (v) return parseAdapterParams(adapterPostfix, v, data);
|
|
120
|
+
else return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const decoded = decodeFunctionData({
|
|
125
|
+
abi: this.abi,
|
|
126
|
+
data: calldata
|
|
127
|
+
});
|
|
128
|
+
if (decoded.functionName === "allowAdapter") {
|
|
129
|
+
const deployParams = decoded.args[0];
|
|
130
|
+
const adapterType = hexToString(deployParams.postfix, {
|
|
131
|
+
size: 32
|
|
132
|
+
});
|
|
133
|
+
const latest = Math.max(
|
|
134
|
+
...Object.keys(adapterConstructorAbi[adapterType]).map(
|
|
135
|
+
Number
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
const constructorArgs = parseAdapterParams(
|
|
139
|
+
adapterType,
|
|
140
|
+
latest,
|
|
141
|
+
deployParams.constructorParams
|
|
142
|
+
);
|
|
143
|
+
if (!constructorArgs) {
|
|
144
|
+
return super.decodeConfig(calldata);
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
functionName: "allowAdapter",
|
|
148
|
+
args: {
|
|
149
|
+
adapterType,
|
|
150
|
+
salt: deployParams.salt,
|
|
151
|
+
constructorArgs: JSON.stringify(constructorArgs)
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (decoded.functionName === "configureAdapterFor") {
|
|
156
|
+
const [targetContract, data] = decoded.args;
|
|
157
|
+
const adapterAction = parseAdapterAction(data);
|
|
158
|
+
if (!adapterAction) {
|
|
159
|
+
return super.decodeConfig(calldata);
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
functionName: "configureAdapterFor",
|
|
163
|
+
args: {
|
|
164
|
+
targetContract,
|
|
165
|
+
adapterAction: JSON.stringify(adapterAction)
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return super.decodeConfig(calldata);
|
|
170
|
+
} catch {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
export {
|
|
176
|
+
CreditFactory
|
|
177
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { iPoolConfigureActionsAbi } from "../../../abi/310/configure/iPoolConfigureActions.js";
|
|
2
|
+
import { AbstractFactory } from "./abstract-factory.js";
|
|
3
|
+
const abi = iPoolConfigureActionsAbi;
|
|
4
|
+
class PoolFactory extends AbstractFactory {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(abi);
|
|
7
|
+
}
|
|
8
|
+
pause() {
|
|
9
|
+
return this.createCallData({
|
|
10
|
+
functionName: "pause"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
unpause() {
|
|
14
|
+
return this.createCallData({
|
|
15
|
+
functionName: "unpause"
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
setCreditManagerDebtLimit(args) {
|
|
19
|
+
return this.createCallData({
|
|
20
|
+
functionName: "setCreditManagerDebtLimit",
|
|
21
|
+
args: [args.creditManager, args.limit]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
setTokenLimit(args) {
|
|
25
|
+
return this.createCallData({
|
|
26
|
+
functionName: "setTokenLimit",
|
|
27
|
+
args: [args.token, args.limit]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
setTokenQuotaIncreaseFee(params) {
|
|
31
|
+
return this.createCallData({
|
|
32
|
+
functionName: "setTokenQuotaIncreaseFee",
|
|
33
|
+
args: [params.token, params.fee]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
setTotalDebtLimit(args) {
|
|
37
|
+
return this.createCallData({
|
|
38
|
+
functionName: "setTotalDebtLimit",
|
|
39
|
+
args: [args.limit]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
PoolFactory
|
|
45
|
+
};
|