@gearbox-protocol/sdk 18.5.0-next.5 → 18.5.0-next.7
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/dev/providers.js +0 -6
- package/dist/cjs/onchain/chain/chains.js +0 -13
- package/dist/cjs/onchain/constants/networks.js +0 -1
- package/dist/cjs/permissionless/bindings/market-configurator.js +55 -28
- package/dist/cjs/permissionless/curator/configurator-actions/addAdminActionData.js +3 -3
- package/dist/cjs/permissionless/curator/configurator-actions/configuratorActionDefinitions.js +4 -0
- package/dist/cjs/permissionless/curator/configurator-actions/configuratorActionHelpers.js +35 -16
- package/dist/cjs/permissionless/curator/configurator-actions/grantRoleActionData.js +31 -0
- package/dist/cjs/permissionless/curator/configurator-actions/index.js +4 -0
- package/dist/cjs/permissionless/curator/configurator-actions/removeAdminActionData.js +3 -3
- package/dist/cjs/permissionless/curator/configurator-actions/revokeRoleActionData.js +38 -0
- package/dist/cjs/permissionless/curator/index.js +4 -0
- package/dist/cjs/permissionless/curator/state/configurator/compareConfiguratorStates.js +9 -0
- package/dist/cjs/permissionless/curator/state/configurator/getConfiguratorState.js +2 -1
- package/dist/cjs/permissionless/curator/state/configurator/types.js +27 -1
- package/dist/cjs/permissionless/curator/utils/objectUtils.js +5 -0
- package/dist/cjs/permissionless/index.js +4 -0
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/index.js +1 -1
- package/dist/esm/dev/providers.js +0 -6
- package/dist/esm/onchain/chain/chains.js +1 -14
- package/dist/esm/onchain/constants/networks.js +0 -1
- package/dist/esm/permissionless/bindings/market-configurator.js +55 -28
- package/dist/esm/permissionless/curator/configurator-actions/addAdminActionData.js +4 -4
- package/dist/esm/permissionless/curator/configurator-actions/configuratorActionDefinitions.js +4 -0
- package/dist/esm/permissionless/curator/configurator-actions/configuratorActionHelpers.js +31 -14
- package/dist/esm/permissionless/curator/configurator-actions/grantRoleActionData.js +30 -0
- package/dist/esm/permissionless/curator/configurator-actions/index.js +3 -1
- package/dist/esm/permissionless/curator/configurator-actions/removeAdminActionData.js +4 -4
- package/dist/esm/permissionless/curator/configurator-actions/revokeRoleActionData.js +37 -0
- package/dist/esm/permissionless/curator/index.js +3 -1
- package/dist/esm/permissionless/curator/state/configurator/compareConfiguratorStates.js +10 -1
- package/dist/esm/permissionless/curator/state/configurator/getConfiguratorState.js +2 -1
- package/dist/esm/permissionless/curator/state/configurator/types.js +24 -1
- package/dist/esm/permissionless/curator/utils/objectUtils.js +5 -1
- package/dist/esm/permissionless/index.js +3 -1
- package/dist/types/dev/providers.d.ts +0 -2
- package/dist/types/onchain/accounts/liquidations/types.d.ts +3 -3
- package/dist/types/onchain/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +2 -2
- package/dist/types/onchain/chain/chains.d.ts +1 -2
- package/dist/types/permissionless/api/configurators/types.d.ts +2 -0
- package/dist/types/permissionless/bindings/market-configurator.d.ts +10 -0
- package/dist/types/permissionless/curator/configurator-actions/configuratorActionDefinitions.d.ts +3 -1
- package/dist/types/permissionless/curator/configurator-actions/configuratorActionHelpers.d.ts +16 -6
- package/dist/types/permissionless/curator/configurator-actions/grantRoleActionData.d.ts +15 -0
- package/dist/types/permissionless/curator/configurator-actions/index.d.ts +3 -1
- package/dist/types/permissionless/curator/configurator-actions/revokeRoleActionData.d.ts +15 -0
- package/dist/types/permissionless/curator/index.d.ts +3 -1
- package/dist/types/permissionless/curator/state/configurator/compareConfiguratorStates.d.ts +2 -0
- package/dist/types/permissionless/curator/state/configurator/types.d.ts +29 -1
- package/dist/types/permissionless/curator/utils/objectUtils.d.ts +2 -0
- package/dist/types/permissionless/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -36,7 +36,6 @@ const DRPC_NETS = {
|
|
|
36
36
|
Avalanche: "avalanche",
|
|
37
37
|
Monad: "monad-mainnet",
|
|
38
38
|
Hemi: "hemi",
|
|
39
|
-
Lisk: "lisk",
|
|
40
39
|
MegaETH: "megaeth",
|
|
41
40
|
Etherlink: null,
|
|
42
41
|
Plasma: "plasma",
|
|
@@ -56,7 +55,6 @@ const ALCHEMY_DOMAINS = {
|
|
|
56
55
|
MegaETH: "megaeth-mainnet",
|
|
57
56
|
Etherlink: null,
|
|
58
57
|
Hemi: null,
|
|
59
|
-
Lisk: null,
|
|
60
58
|
Plasma: "plasma-mainnet",
|
|
61
59
|
Somnia: null
|
|
62
60
|
};
|
|
@@ -73,7 +71,6 @@ const ANKR_DOMAINS = {
|
|
|
73
71
|
BNB: "bsc",
|
|
74
72
|
Etherlink: "etherlink_mainnet",
|
|
75
73
|
Hemi: null,
|
|
76
|
-
Lisk: null,
|
|
77
74
|
Mainnet: "eth",
|
|
78
75
|
MegaETH: null,
|
|
79
76
|
Monad: "monad_mainnet",
|
|
@@ -96,7 +93,6 @@ const THIRDWEB_DOMAINS = {
|
|
|
96
93
|
BNB: chains.BNB.id.toString(),
|
|
97
94
|
Etherlink: chains.Etherlink.id.toString(),
|
|
98
95
|
Hemi: chains.Hemi.id.toString(),
|
|
99
|
-
Lisk: chains.Lisk.id.toString(),
|
|
100
96
|
Mainnet: chains.Mainnet.id.toString(),
|
|
101
97
|
MegaETH: chains.MegaETH.id.toString(),
|
|
102
98
|
Monad: chains.Monad.id.toString(),
|
|
@@ -133,7 +129,6 @@ Non-existent event:
|
|
|
133
129
|
│ WorldChain │ ∞ │ 10M │ 1K │ ✗ │
|
|
134
130
|
│ Etherlink │ ✗ │ ✗ │ ✗ │ ✗ │
|
|
135
131
|
│ Hemi │ ✗ │ ∞ │ 1K │ ✗ │
|
|
136
|
-
│ Lisk │ ✗ │ 5M │ 1K │ ✗ │
|
|
137
132
|
│ Plasma │ 10K │ 100K │ 1K │ ✗ │
|
|
138
133
|
│ Somnia │ ✗ │ ✗ │ 1K │ 10K │
|
|
139
134
|
└────────────┴─────────┴──────┴──────────┴──────┘
|
|
@@ -156,7 +151,6 @@ Rare event (InstanceManager.OwnershipTransferred):
|
|
|
156
151
|
│ WorldChain │ ∞ │ 1M │ 1K │ ✗ │
|
|
157
152
|
│ Etherlink │ ✗ │ ✗ │ ✗ │ ✗ │
|
|
158
153
|
│ Hemi │ ✗ │ ∞ │ 1K │ ✗ │
|
|
159
|
-
│ Lisk │ ✗ │ 10M │ 1K │ ✗ │
|
|
160
154
|
│ Plasma │ 10K │ 100K │ 1K │ ✗ │
|
|
161
155
|
│ Somnia │ ✗ │ ✗ │ 1K │ 10K │
|
|
162
156
|
└────────────┴─────────┴──────┴──────────┴──────┘
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
2
2
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
3
|
import { defineChain } from "viem";
|
|
4
|
-
import { arbitrum, avalanche, base, berachain, bsc, etherlink, hemi,
|
|
4
|
+
import { arbitrum, avalanche, base, berachain, bsc, etherlink, hemi, mainnet, megaeth, monad, optimism, plasma, somnia, sonic, worldchain } from "viem/chains";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
// src/onchain/chain/chains.ts
|
|
7
7
|
/**
|
|
@@ -21,7 +21,6 @@ const SUPPORTED_NETWORKS = [
|
|
|
21
21
|
"WorldChain",
|
|
22
22
|
"Etherlink",
|
|
23
23
|
"Hemi",
|
|
24
|
-
"Lisk",
|
|
25
24
|
"Plasma",
|
|
26
25
|
"Somnia"
|
|
27
26
|
];
|
|
@@ -352,18 +351,6 @@ const chains = {
|
|
|
352
351
|
} },
|
|
353
352
|
gasLimit: 550000000n
|
|
354
353
|
}),
|
|
355
|
-
Lisk: defineChain({
|
|
356
|
-
...lisk,
|
|
357
|
-
network: "Lisk",
|
|
358
|
-
defaultMarketConfigurators: AddressMap.fromRecord({ "0x25778dbf0e56b7feb8358c4aa2f6f9e19a1c145a": "Re7" }),
|
|
359
|
-
rwaFactories: [],
|
|
360
|
-
isPublic: true,
|
|
361
|
-
wellKnownToken: {
|
|
362
|
-
address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
|
|
363
|
-
symbol: "USDC.e"
|
|
364
|
-
},
|
|
365
|
-
gasLimit: 550000000n
|
|
366
|
-
}),
|
|
367
354
|
Plasma: defineChain({
|
|
368
355
|
...plasma,
|
|
369
356
|
network: "Plasma",
|
|
@@ -22,6 +22,19 @@ import { RateKeeperFactory } from "./factory/rate-keeper-factory.js";
|
|
|
22
22
|
import { decodeAbiParameters, encodeAbiParameters, encodeFunctionData, erc20Abi, erc4626Abi, hexToString, isAddressEqual, keccak256, parseAbi, stringToHex, toBytes } from "viem";
|
|
23
23
|
// src/permissionless/bindings/market-configurator.ts
|
|
24
24
|
const PERIPHERY_DOMAINS = ["ZAPPER", "DEGEN_NFT"];
|
|
25
|
+
/** The ACL roles `admins()` reports in fields of their own. **/
|
|
26
|
+
const ADMIN_ROLE_IDS = new Set([
|
|
27
|
+
"PAUSABLE_ADMIN",
|
|
28
|
+
"UNPAUSABLE_ADMIN",
|
|
29
|
+
"LOSS_LIQUIDATOR",
|
|
30
|
+
"EMERGENCY_LIQUIDATOR"
|
|
31
|
+
].map((role) => stringToHex(role, { size: 32 })));
|
|
32
|
+
function aclRoleKey(role) {
|
|
33
|
+
const name = hexToString(role, { size: 32 });
|
|
34
|
+
const id = role.toLowerCase();
|
|
35
|
+
return stringToHex(name).padEnd(id.length, "0") === id ? name : id;
|
|
36
|
+
}
|
|
37
|
+
const aclRolesAbi = parseAbi(["function getRoles() view returns (bytes32[])", "function getRoleHolders(bytes32) view returns (address[])"]);
|
|
25
38
|
const abi = iMarketConfiguratorV310Abi;
|
|
26
39
|
var MarketConfiguratorContract = class extends BaseContract {
|
|
27
40
|
creditFactory;
|
|
@@ -324,6 +337,10 @@ var MarketConfiguratorContract = class extends BaseContract {
|
|
|
324
337
|
async treasury() {
|
|
325
338
|
return await this.contract.read.treasury();
|
|
326
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Who holds each role of the configurator's ACL: the four admin roles in
|
|
342
|
+
* their own fields, every other role in `otherRoles`, by role name.
|
|
343
|
+
**/
|
|
327
344
|
async admins() {
|
|
328
345
|
const [admin, emergencyAdmin, treasury, acl] = await Promise.all([
|
|
329
346
|
this.contract.read.admin(),
|
|
@@ -331,44 +348,43 @@ var MarketConfiguratorContract = class extends BaseContract {
|
|
|
331
348
|
this.contract.read.treasury(),
|
|
332
349
|
this.contract.read.acl()
|
|
333
350
|
]);
|
|
334
|
-
const
|
|
351
|
+
const holders = (role) => ({
|
|
352
|
+
address: acl,
|
|
353
|
+
abi: aclRolesAbi,
|
|
354
|
+
functionName: "getRoleHolders",
|
|
355
|
+
args: [role]
|
|
356
|
+
});
|
|
357
|
+
const roleHex = (role) => stringToHex(role, { size: 32 });
|
|
358
|
+
const [roles, pausableAdmins, unpausableAdmins, lossLiquidators, emergencyLiquidators] = await this.client.multicall({
|
|
335
359
|
allowFailure: false,
|
|
336
360
|
contracts: [
|
|
337
361
|
{
|
|
338
362
|
address: acl,
|
|
339
|
-
abi:
|
|
340
|
-
functionName: "
|
|
341
|
-
args: [stringToHex("PAUSABLE_ADMIN", { size: 32 })]
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
address: acl,
|
|
345
|
-
abi: parseAbi(["function getRoleHolders(bytes32) view returns (address[])"]),
|
|
346
|
-
functionName: "getRoleHolders",
|
|
347
|
-
args: [stringToHex("UNPAUSABLE_ADMIN", { size: 32 })]
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
address: acl,
|
|
351
|
-
abi: parseAbi(["function getRoleHolders(bytes32) view returns (address[])"]),
|
|
352
|
-
functionName: "getRoleHolders",
|
|
353
|
-
args: [stringToHex("LOSS_LIQUIDATOR", { size: 32 })]
|
|
363
|
+
abi: aclRolesAbi,
|
|
364
|
+
functionName: "getRoles"
|
|
354
365
|
},
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
args: [stringToHex("EMERGENCY_LIQUIDATOR", { size: 32 })]
|
|
360
|
-
}
|
|
366
|
+
holders(roleHex("PAUSABLE_ADMIN")),
|
|
367
|
+
holders(roleHex("UNPAUSABLE_ADMIN")),
|
|
368
|
+
holders(roleHex("LOSS_LIQUIDATOR")),
|
|
369
|
+
holders(roleHex("EMERGENCY_LIQUIDATOR"))
|
|
361
370
|
],
|
|
362
371
|
batchSize: 0
|
|
363
372
|
});
|
|
373
|
+
const otherRoles = roles.filter((role) => !ADMIN_ROLE_IDS.has(role.toLowerCase()));
|
|
374
|
+
const otherHolders = otherRoles.length === 0 ? [] : await this.client.multicall({
|
|
375
|
+
allowFailure: false,
|
|
376
|
+
contracts: otherRoles.map(holders),
|
|
377
|
+
batchSize: 0
|
|
378
|
+
});
|
|
364
379
|
return {
|
|
365
380
|
admin,
|
|
366
381
|
emergencyAdmin,
|
|
367
382
|
treasury,
|
|
368
|
-
pausableAdmins: [...
|
|
369
|
-
unpausableAdmins: [...
|
|
370
|
-
lossLiquidators: [...
|
|
371
|
-
emergencyLiquidators: [...
|
|
383
|
+
pausableAdmins: [...pausableAdmins],
|
|
384
|
+
unpausableAdmins: [...unpausableAdmins],
|
|
385
|
+
lossLiquidators: [...lossLiquidators],
|
|
386
|
+
emergencyLiquidators: [...emergencyLiquidators],
|
|
387
|
+
otherRoles: Object.fromEntries(otherRoles.map((role, i) => [aclRoleKey(role), [...otherHolders[i]]]))
|
|
372
388
|
};
|
|
373
389
|
}
|
|
374
390
|
async multipause() {
|
|
@@ -685,11 +701,12 @@ var MarketConfiguratorContract = class extends BaseContract {
|
|
|
685
701
|
};
|
|
686
702
|
}
|
|
687
703
|
case "revokeRole":
|
|
688
|
-
case "grantRole":
|
|
704
|
+
case "grantRole":
|
|
705
|
+
case "emergencyRevokeRole": {
|
|
689
706
|
const [role, address] = args;
|
|
690
707
|
return {
|
|
691
708
|
address,
|
|
692
|
-
role:
|
|
709
|
+
role: aclRoleKey(role)
|
|
693
710
|
};
|
|
694
711
|
}
|
|
695
712
|
case "emergencyConfigurePool":
|
|
@@ -739,6 +756,16 @@ var MarketConfiguratorContract = class extends BaseContract {
|
|
|
739
756
|
return null;
|
|
740
757
|
}
|
|
741
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* Revokes `role` from `account` at once, without the timelock that
|
|
761
|
+
* `revokeRole` goes through
|
|
762
|
+
*/
|
|
763
|
+
emergencyRevokeRole(role, account) {
|
|
764
|
+
return this.createRawTx({
|
|
765
|
+
functionName: "emergencyRevokeRole",
|
|
766
|
+
args: [stringToHex(role, { size: 32 }), account]
|
|
767
|
+
});
|
|
768
|
+
}
|
|
742
769
|
emergencyConfigurePool(pool, calldata) {
|
|
743
770
|
return this.createRawTx({
|
|
744
771
|
functionName: "emergencyConfigurePool",
|
|
@@ -2,19 +2,19 @@ import { noOp } from "../actions/utils/checkHelpers.js";
|
|
|
2
2
|
import { adminRoleSchema } from "../state/configurator/types.js";
|
|
3
3
|
import { lowerAddress } from "../utils/addressUtils.js";
|
|
4
4
|
import { addressSchema } from "../validationSchemas.js";
|
|
5
|
-
import {
|
|
5
|
+
import { byRoleAndAdmin, holdsRole, roleLabel, updateRoleHolders } from "./configuratorActionHelpers.js";
|
|
6
6
|
import { defineConfiguratorAction } from "./defineConfiguratorAction.js";
|
|
7
7
|
import { z } from "zod/v4";
|
|
8
8
|
// src/permissionless/curator/configurator-actions/addAdminActionData.ts
|
|
9
9
|
const addAdminActionData = defineConfiguratorAction({
|
|
10
10
|
type: "CONFIGURATOR::addAdmin",
|
|
11
|
-
description: `Add a
|
|
11
|
+
description: `Add a pausable admin, unpausable admin, loss liquidator or emergency liquidator for all markets. CONFIGURATOR::grantRole takes any role.`,
|
|
12
12
|
schema: z.object({
|
|
13
13
|
role: adminRoleSchema,
|
|
14
14
|
admin: addressSchema
|
|
15
15
|
}),
|
|
16
|
-
check: ({ state, params }) =>
|
|
17
|
-
apply: ({ state, params }) =>
|
|
16
|
+
check: ({ state, params }) => holdsRole(state, params.role, params.admin) ? [noOp(`${params.admin} is already one of the ${roleLabel(params.role)}`, ["params", "admin"])] : [],
|
|
17
|
+
apply: ({ state, params }) => updateRoleHolders(state, params.role, (holders) => [...holders, lowerAddress(params.admin)]),
|
|
18
18
|
encode: ({ ctx, params }) => ctx.marketConfigurator.grantRole(params.role, params.admin),
|
|
19
19
|
key: byRoleAndAdmin
|
|
20
20
|
});
|
package/dist/esm/permissionless/curator/configurator-actions/configuratorActionDefinitions.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { addAdminActionData } from "./addAdminActionData.js";
|
|
2
2
|
import { cancelConfigureActionData } from "./cancelConfigureActionData.js";
|
|
3
3
|
import { distributeActionData } from "./distributeActionData.js";
|
|
4
|
+
import { grantRoleActionData } from "./grantRoleActionData.js";
|
|
4
5
|
import { removeAdminActionData } from "./removeAdminActionData.js";
|
|
6
|
+
import { revokeRoleActionData } from "./revokeRoleActionData.js";
|
|
5
7
|
import { setDefaultSplitActionData } from "./setDefaultSplitActionData.js";
|
|
6
8
|
import { setEmergencyAdminActionData } from "./setEmergencyAdminActionData.js";
|
|
7
9
|
// src/permissionless/curator/configurator-actions/configuratorActionDefinitions.ts
|
|
@@ -9,6 +11,8 @@ import { setEmergencyAdminActionData } from "./setEmergencyAdminActionData.js";
|
|
|
9
11
|
const configuratorActionDefinitions = [
|
|
10
12
|
addAdminActionData,
|
|
11
13
|
removeAdminActionData,
|
|
14
|
+
grantRoleActionData,
|
|
15
|
+
revokeRoleActionData,
|
|
12
16
|
setEmergencyAdminActionData,
|
|
13
17
|
setDefaultSplitActionData,
|
|
14
18
|
cancelConfigureActionData,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TreasurySplitterContract } from "../../bindings/treasury-splitter.js";
|
|
2
2
|
import { isSameAddress } from "../utils/addressUtils.js";
|
|
3
|
+
import { ownEntry } from "../utils/objectUtils.js";
|
|
3
4
|
// src/permissionless/curator/configurator-actions/configuratorActionHelpers.ts
|
|
4
5
|
async function resolveTreasurySplitter(args) {
|
|
5
6
|
const { treasury } = await args.ctx.marketConfigurator.admins();
|
|
@@ -27,26 +28,42 @@ const ADMIN_ROLE_LISTS = {
|
|
|
27
28
|
label: "emergency liquidators"
|
|
28
29
|
}
|
|
29
30
|
};
|
|
31
|
+
/** The list field of `role` if it has one, `undefined` for any other role. **/
|
|
30
32
|
function adminRoleList(role) {
|
|
31
|
-
|
|
32
|
-
if (!list) throw new Error(`Unknown admin role: ${role}`);
|
|
33
|
-
return list;
|
|
33
|
+
return Object.hasOwn(ADMIN_ROLE_LISTS, role) ? ADMIN_ROLE_LISTS[role] : void 0;
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Who holds `role`: its own list for the four admin roles, `otherRoles` for
|
|
37
|
+
* any other.
|
|
38
|
+
**/
|
|
39
|
+
function roleHolders(state, role) {
|
|
40
|
+
const list = adminRoleList(role);
|
|
41
|
+
return list ? state[list.field] : ownEntry(state.otherRoles, role) ?? [];
|
|
38
42
|
}
|
|
39
|
-
/**
|
|
40
|
-
function
|
|
41
|
-
return
|
|
43
|
+
/** Whether `account` holds `role`. **/
|
|
44
|
+
function holdsRole(state, role, account) {
|
|
45
|
+
return roleHolders(state, role).some((holder) => isSameAddress(holder, account));
|
|
42
46
|
}
|
|
43
|
-
/**
|
|
44
|
-
function
|
|
45
|
-
|
|
47
|
+
/** How diagnostics name the holders of `role`. **/
|
|
48
|
+
function roleLabel(role) {
|
|
49
|
+
return adminRoleList(role)?.label ?? `${role} holders`;
|
|
50
|
+
}
|
|
51
|
+
/** Rewrites the holders of `role`: `update` maps the holders to the new ones. **/
|
|
52
|
+
function updateRoleHolders(state, role, update) {
|
|
53
|
+
const list = adminRoleList(role);
|
|
54
|
+
if (list) return {
|
|
55
|
+
...state,
|
|
56
|
+
[list.field]: update(state[list.field])
|
|
57
|
+
};
|
|
46
58
|
return {
|
|
47
59
|
...state,
|
|
48
|
-
|
|
60
|
+
otherRoles: {
|
|
61
|
+
...state.otherRoles,
|
|
62
|
+
[role]: update([...ownEntry(state.otherRoles, role) ?? []])
|
|
63
|
+
}
|
|
49
64
|
};
|
|
50
65
|
}
|
|
51
66
|
const byRoleAndAdmin = (params) => `${params.role}:${params.admin.toLowerCase()}`;
|
|
52
|
-
|
|
67
|
+
/** Merges `CONFIGURATOR::grantRole` and `revokeRole` per role and account. **/
|
|
68
|
+
const byRoleAndAccount = (params) => `${params.role}:${params.account.toLowerCase()}`;
|
|
69
|
+
export { byRoleAndAccount, byRoleAndAdmin, holdsRole, resolveTreasurySplitter, roleHolders, roleLabel, treasurySplitter, updateRoleHolders };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { actionWarning } from "../actions/actionDiagnostics.js";
|
|
2
|
+
import { noOp } from "../actions/utils/checkHelpers.js";
|
|
3
|
+
import { knownRoleLabelMap, roleNameSchema } from "../state/configurator/types.js";
|
|
4
|
+
import { lowerAddress } from "../utils/addressUtils.js";
|
|
5
|
+
import { addressSchema } from "../validationSchemas.js";
|
|
6
|
+
import { byRoleAndAccount, holdsRole, roleLabel, updateRoleHolders } from "./configuratorActionHelpers.js";
|
|
7
|
+
import { defineConfiguratorAction } from "./defineConfiguratorAction.js";
|
|
8
|
+
import { z } from "zod/v4";
|
|
9
|
+
// src/permissionless/curator/configurator-actions/grantRoleActionData.ts
|
|
10
|
+
/**
|
|
11
|
+
* Grants any role in the configurator's ACL. Covers what
|
|
12
|
+
* `CONFIGURATOR::addAdmin` does and the roles it does not take, such as
|
|
13
|
+
* `OPENING_SIGNER`.
|
|
14
|
+
**/
|
|
15
|
+
const grantRoleActionData = defineConfiguratorAction({
|
|
16
|
+
type: "CONFIGURATOR::grantRole",
|
|
17
|
+
description: `Grant a role in the market configurator's ACL to an account, for all markets.`,
|
|
18
|
+
schema: z.object({
|
|
19
|
+
role: roleNameSchema,
|
|
20
|
+
account: addressSchema
|
|
21
|
+
}),
|
|
22
|
+
check: ({ state, params }) => {
|
|
23
|
+
if (holdsRole(state, params.role, params.account)) return [noOp(`${params.account} is already one of the ${roleLabel(params.role)}`, ["params", "account"])];
|
|
24
|
+
return Object.hasOwn(knownRoleLabelMap, params.role) ? [] : [actionWarning("UNKNOWN_ROLE", `No Gearbox contract checks role ${params.role}; known roles: ${Object.keys(knownRoleLabelMap).join(", ")}`, ["params", "role"])];
|
|
25
|
+
},
|
|
26
|
+
apply: ({ state, params }) => updateRoleHolders(state, params.role, (holders) => [...holders, lowerAddress(params.account)]),
|
|
27
|
+
encode: ({ ctx, params }) => ctx.marketConfigurator.grantRole(params.role, params.account),
|
|
28
|
+
key: byRoleAndAccount
|
|
29
|
+
});
|
|
30
|
+
export { grantRoleActionData };
|
|
@@ -2,7 +2,9 @@ import { addAdminActionData } from "./addAdminActionData.js";
|
|
|
2
2
|
import { cancelConfigureActionData } from "./cancelConfigureActionData.js";
|
|
3
3
|
import { defineConfiguratorAction } from "./defineConfiguratorAction.js";
|
|
4
4
|
import { distributeActionData } from "./distributeActionData.js";
|
|
5
|
+
import { grantRoleActionData } from "./grantRoleActionData.js";
|
|
5
6
|
import { removeAdminActionData } from "./removeAdminActionData.js";
|
|
7
|
+
import { revokeRoleActionData } from "./revokeRoleActionData.js";
|
|
6
8
|
import { setDefaultSplitActionData } from "./setDefaultSplitActionData.js";
|
|
7
9
|
import { setEmergencyAdminActionData } from "./setEmergencyAdminActionData.js";
|
|
8
|
-
export { addAdminActionData, cancelConfigureActionData, defineConfiguratorAction, distributeActionData, removeAdminActionData, setDefaultSplitActionData, setEmergencyAdminActionData };
|
|
10
|
+
export { addAdminActionData, cancelConfigureActionData, defineConfiguratorAction, distributeActionData, grantRoleActionData, removeAdminActionData, revokeRoleActionData, setDefaultSplitActionData, setEmergencyAdminActionData };
|
|
@@ -2,19 +2,19 @@ import { actionError } from "../actions/actionDiagnostics.js";
|
|
|
2
2
|
import { adminRoleSchema } from "../state/configurator/types.js";
|
|
3
3
|
import { isSameAddress } from "../utils/addressUtils.js";
|
|
4
4
|
import { addressSchema } from "../validationSchemas.js";
|
|
5
|
-
import {
|
|
5
|
+
import { byRoleAndAdmin, holdsRole, roleLabel, updateRoleHolders } from "./configuratorActionHelpers.js";
|
|
6
6
|
import { defineConfiguratorAction } from "./defineConfiguratorAction.js";
|
|
7
7
|
import { z } from "zod/v4";
|
|
8
8
|
// src/permissionless/curator/configurator-actions/removeAdminActionData.ts
|
|
9
9
|
const removeAdminActionData = defineConfiguratorAction({
|
|
10
10
|
type: "CONFIGURATOR::removeAdmin",
|
|
11
|
-
description: `Remove a pausable
|
|
11
|
+
description: `Remove a pausable admin, unpausable admin, loss liquidator or emergency liquidator from all markets. CONFIGURATOR::revokeRole takes any role.`,
|
|
12
12
|
schema: z.object({
|
|
13
13
|
role: adminRoleSchema,
|
|
14
14
|
admin: addressSchema
|
|
15
15
|
}),
|
|
16
|
-
check: ({ state, params }) =>
|
|
17
|
-
apply: ({ state, params }) =>
|
|
16
|
+
check: ({ state, params }) => holdsRole(state, params.role, params.admin) ? [] : [actionError("ADMIN_NOT_FOUND", `${params.admin} is not one of the ${roleLabel(params.role)}`, ["params", "admin"])],
|
|
17
|
+
apply: ({ state, params }) => updateRoleHolders(state, params.role, (holders) => holders.filter((holder) => !isSameAddress(holder, params.admin))),
|
|
18
18
|
encode: ({ ctx, params }) => ctx.marketConfigurator.revokeRole(params.role, params.admin),
|
|
19
19
|
key: byRoleAndAdmin
|
|
20
20
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { actionError } from "../actions/actionDiagnostics.js";
|
|
2
|
+
import { roleNameSchema } from "../state/configurator/types.js";
|
|
3
|
+
import { isSameAddress } from "../utils/addressUtils.js";
|
|
4
|
+
import { addressSchema } from "../validationSchemas.js";
|
|
5
|
+
import { byRoleAndAccount, holdsRole, roleLabel, updateRoleHolders } from "./configuratorActionHelpers.js";
|
|
6
|
+
import { defineConfiguratorAction } from "./defineConfiguratorAction.js";
|
|
7
|
+
import { z } from "zod/v4";
|
|
8
|
+
// src/permissionless/curator/configurator-actions/revokeRoleActionData.ts
|
|
9
|
+
/**
|
|
10
|
+
* Roles the market configurator grants itself on deployment: it pauses and
|
|
11
|
+
* unpauses market contracts as itself, through `configure*` and
|
|
12
|
+
* `emergencyConfigure*` alike.
|
|
13
|
+
**/
|
|
14
|
+
const CONFIGURATOR_OWN_ROLES = ["PAUSABLE_ADMIN", "UNPAUSABLE_ADMIN"];
|
|
15
|
+
/**
|
|
16
|
+
* Revokes any role in the configurator's ACL. Covers what
|
|
17
|
+
* `CONFIGURATOR::removeAdmin` does and the roles it does not take, such as
|
|
18
|
+
* `OPENING_SIGNER`.
|
|
19
|
+
**/
|
|
20
|
+
const revokeRoleActionData = defineConfiguratorAction({
|
|
21
|
+
type: "CONFIGURATOR::revokeRole",
|
|
22
|
+
description: `Revoke a role in the market configurator's ACL from an account, for all markets.`,
|
|
23
|
+
schema: z.object({
|
|
24
|
+
role: roleNameSchema,
|
|
25
|
+
account: addressSchema
|
|
26
|
+
}),
|
|
27
|
+
check: ({ state, params }) => {
|
|
28
|
+
const diagnostics = [];
|
|
29
|
+
if (!holdsRole(state, params.role, params.account)) diagnostics.push(actionError("ROLE_NOT_GRANTED", `${params.account} is not one of the ${roleLabel(params.role)}`, ["params", "account"]));
|
|
30
|
+
else if (isSameAddress(params.account, state.address) && CONFIGURATOR_OWN_ROLES.includes(params.role)) diagnostics.push(actionError("CONFIGURATOR_ROLE_REQUIRED", `The market configurator needs ${params.role} to pause and unpause its markets`, ["params", "account"]));
|
|
31
|
+
return diagnostics;
|
|
32
|
+
},
|
|
33
|
+
apply: ({ state, params }) => updateRoleHolders(state, params.role, (holders) => holders.filter((holder) => !isSameAddress(holder, params.account))),
|
|
34
|
+
encode: ({ ctx, params }) => ctx.marketConfigurator.revokeRole(params.role, params.account),
|
|
35
|
+
key: byRoleAndAccount
|
|
36
|
+
});
|
|
37
|
+
export { revokeRoleActionData };
|
|
@@ -49,7 +49,9 @@ import { defineConfiguratorAction } from "./configurator-actions/defineConfigura
|
|
|
49
49
|
import { addAdminActionData } from "./configurator-actions/addAdminActionData.js";
|
|
50
50
|
import { cancelConfigureActionData } from "./configurator-actions/cancelConfigureActionData.js";
|
|
51
51
|
import { distributeActionData } from "./configurator-actions/distributeActionData.js";
|
|
52
|
+
import { grantRoleActionData } from "./configurator-actions/grantRoleActionData.js";
|
|
52
53
|
import { removeAdminActionData } from "./configurator-actions/removeAdminActionData.js";
|
|
54
|
+
import { revokeRoleActionData } from "./configurator-actions/revokeRoleActionData.js";
|
|
53
55
|
import { getConfiguratorState } from "./state/configurator/getConfiguratorState.js";
|
|
54
56
|
import { setDefaultSplitActionData } from "./configurator-actions/setDefaultSplitActionData.js";
|
|
55
57
|
import { setEmergencyAdminActionData } from "./configurator-actions/setEmergencyAdminActionData.js";
|
|
@@ -101,4 +103,4 @@ import "./state/index.js";
|
|
|
101
103
|
import { previewCreditSuiteAddress } from "./transactions/previewCreditSuiteAddress.js";
|
|
102
104
|
import "./transactions/index.js";
|
|
103
105
|
import "./utils/index.js";
|
|
104
|
-
export { ABSTRACT_ADAPTER_TYPES, AccountFactoryTypes, BUNDLE_TARGET, ConfigurationExecutor, ConfiguratorBuilder, CuratorSession, DEFAULT_INTEREST_RATE_MODEL_PARAMS, DEFAULT_LOSS_POLICY_PARAMS, DEFAULT_RATE_KEEPER_PARAMS, DEFAULT_RWA_UNDERLYING_TYPE, GipActionError, GipBuilderError, GipRegistry, GipScopeError, GipSimulationError, GipTargetResolutionError, MarketBuilder, MarketExecutor, MergedGip, NO_LIMIT, ON_DEMAND_RWA_UNDERLYING_TYPE, RWA_UNDERLYING_TYPE_PREFIX, RWA_ZAPPER_CONTRACT_TYPE, RWA_ZAPPER_VERSION, ResolveCache, SECURITIZE_RWA_FACTORY_TYPE, actionEnv, actionError, actionWarning, adapterPluginKit, adapterPlugins, addAdminActionData, addAssetActionData, addCollateralTokenActionData, addConfiguratorAction, addConfiguratorActions, addMarketAction, addMarketActions, addPeripheryContractActionData, adminRoleLabelMap, adminRoleSchema, aliasDeployParamsSchema, aliasPlugin, allowAdapterActionData, allowTokenActionData, applyBundle, applyChanges, assertNotBlocked, batchMarketTransactions, bindBundleTarget, buildMarketStateSchema, builtinAdapterPlugins, bundleActions, bundleSuiteId, cancelConfigureActionData, canonicalize, compareConfiguratorStates, compareGipForkState, completeRwaPeripheryActions, contractReaderFromClient, convertTokenAmount, copyCmActions, copyCmActionsForMarket, createAction, createCreditSuite, createCreditSuiteActionData, createCreditSuiteSchema, createMarketActionData, creditManagerFeesSchema, creditManagerTargetSchema, creditSuiteId, creditSuiteRef, creditSuiteRefSchema, customizeBundle, defineConfiguratorAction, defineMarketAction, deployContractActionData, deserializeGipPlan, diffMarketStates, diffStates, distributeActionData, findIncompleteRwaPeripherySetups, forbidAdapterActionData, forbidTokenActionData, formatMarketStateDiff, formatStateDiff, gaugeDeployParamsSchema, gaugeMarketActionsData, gaugePlugin, getAbstractAdapterPlugin, getActionScope, getConfiguratorState, getGipDiagnostics, getGovernorContract, getInitialMarketState, getMarketState, getRawTxHash, getRwaZapperDeployAction, getRwaZapperDeployParams, getTimelockTransactions, getTimelockTransactionsForExecution, hasErrors, insertRwaZapperDeployment, irmDeployParamsSchema, irmPlugins, isAliasedLossPolicy, isContractDeploymentQueued, isCreditSuiteRef, isPeripheryContractAdded, isRwaZapperRegistration, isSameTarget, isZeroFeed, linearInterestRateModelDeployParamsSchema, linearPlugin, locateDiagnostics, lossPolicyDeployParamsSchema, lossPolicyMarketActionsData, lossPolicyPlugins, marketIdentity, marketStateSchema, midasAliasDeployParamsSchema, midasAliasPlugin, normalizeBundleTarget, numberToDecimalString, parseConfiguratorScopedAction, parseContractType, parseMarketScopedAction, pauseCreditManagerActionData, pausePoolActionData, peripheryContractDomains, peripheryDomainOf, peripheryStatus, planRwaPeripheryActions, previewCreditSuiteAddress, rampLiquidationThresholdActionData, rateKeeperDeployParamsSchema, rateKeeperMarketActionsData, rateKeeperPlugins, readContractType, reconcileRwaPeripheryActions, removeAdapterActions, removeAdminActionData, replaceCmActions, resolveSecuritizeRwaSetup, retargetCreditManager, revertTo, sameTree, selectMarketDegenNfts, serializeGipPlan, setCreditManagerDebtLimitActionData, setDefaultSplitActionData, setEmergencyAdminActionData, setExpirationDateActionData, setFeesActionData, setMaxDebtPerBlockMultiplierActionData, setPriceFeedActionData, setReservePriceFeedActionData, setTokenLimitActionData, setTokenQuotaIncreaseFeeActionData, setTotalDebtLimitActionData, simulateGipOnFork, simulateGipPayloadOnFork, simulateOnAnvil, stateSchema, targetKey, targetOf, tumblerDeployParamsSchema, tumblerDiagnostics, tumblerMarketActionsData, tumblerPlugin, unpauseCreditManagerActionData, unpausePoolActionData, updateInterestRateModelActionData, updateLossPolicyActionData, updateRateKeeperActionData, upgradeCreditFacadeActionData, usesBundleTarget, validateForkExecutionCalls };
|
|
106
|
+
export { ABSTRACT_ADAPTER_TYPES, AccountFactoryTypes, BUNDLE_TARGET, ConfigurationExecutor, ConfiguratorBuilder, CuratorSession, DEFAULT_INTEREST_RATE_MODEL_PARAMS, DEFAULT_LOSS_POLICY_PARAMS, DEFAULT_RATE_KEEPER_PARAMS, DEFAULT_RWA_UNDERLYING_TYPE, GipActionError, GipBuilderError, GipRegistry, GipScopeError, GipSimulationError, GipTargetResolutionError, MarketBuilder, MarketExecutor, MergedGip, NO_LIMIT, ON_DEMAND_RWA_UNDERLYING_TYPE, RWA_UNDERLYING_TYPE_PREFIX, RWA_ZAPPER_CONTRACT_TYPE, RWA_ZAPPER_VERSION, ResolveCache, SECURITIZE_RWA_FACTORY_TYPE, actionEnv, actionError, actionWarning, adapterPluginKit, adapterPlugins, addAdminActionData, addAssetActionData, addCollateralTokenActionData, addConfiguratorAction, addConfiguratorActions, addMarketAction, addMarketActions, addPeripheryContractActionData, adminRoleLabelMap, adminRoleSchema, aliasDeployParamsSchema, aliasPlugin, allowAdapterActionData, allowTokenActionData, applyBundle, applyChanges, assertNotBlocked, batchMarketTransactions, bindBundleTarget, buildMarketStateSchema, builtinAdapterPlugins, bundleActions, bundleSuiteId, cancelConfigureActionData, canonicalize, compareConfiguratorStates, compareGipForkState, completeRwaPeripheryActions, contractReaderFromClient, convertTokenAmount, copyCmActions, copyCmActionsForMarket, createAction, createCreditSuite, createCreditSuiteActionData, createCreditSuiteSchema, createMarketActionData, creditManagerFeesSchema, creditManagerTargetSchema, creditSuiteId, creditSuiteRef, creditSuiteRefSchema, customizeBundle, defineConfiguratorAction, defineMarketAction, deployContractActionData, deserializeGipPlan, diffMarketStates, diffStates, distributeActionData, findIncompleteRwaPeripherySetups, forbidAdapterActionData, forbidTokenActionData, formatMarketStateDiff, formatStateDiff, gaugeDeployParamsSchema, gaugeMarketActionsData, gaugePlugin, getAbstractAdapterPlugin, getActionScope, getConfiguratorState, getGipDiagnostics, getGovernorContract, getInitialMarketState, getMarketState, getRawTxHash, getRwaZapperDeployAction, getRwaZapperDeployParams, getTimelockTransactions, getTimelockTransactionsForExecution, grantRoleActionData, hasErrors, insertRwaZapperDeployment, irmDeployParamsSchema, irmPlugins, isAliasedLossPolicy, isContractDeploymentQueued, isCreditSuiteRef, isPeripheryContractAdded, isRwaZapperRegistration, isSameTarget, isZeroFeed, linearInterestRateModelDeployParamsSchema, linearPlugin, locateDiagnostics, lossPolicyDeployParamsSchema, lossPolicyMarketActionsData, lossPolicyPlugins, marketIdentity, marketStateSchema, midasAliasDeployParamsSchema, midasAliasPlugin, normalizeBundleTarget, numberToDecimalString, parseConfiguratorScopedAction, parseContractType, parseMarketScopedAction, pauseCreditManagerActionData, pausePoolActionData, peripheryContractDomains, peripheryDomainOf, peripheryStatus, planRwaPeripheryActions, previewCreditSuiteAddress, rampLiquidationThresholdActionData, rateKeeperDeployParamsSchema, rateKeeperMarketActionsData, rateKeeperPlugins, readContractType, reconcileRwaPeripheryActions, removeAdapterActions, removeAdminActionData, replaceCmActions, resolveSecuritizeRwaSetup, retargetCreditManager, revertTo, revokeRoleActionData, sameTree, selectMarketDegenNfts, serializeGipPlan, setCreditManagerDebtLimitActionData, setDefaultSplitActionData, setEmergencyAdminActionData, setExpirationDateActionData, setFeesActionData, setMaxDebtPerBlockMultiplierActionData, setPriceFeedActionData, setReservePriceFeedActionData, setTokenLimitActionData, setTokenQuotaIncreaseFeeActionData, setTotalDebtLimitActionData, simulateGipOnFork, simulateGipPayloadOnFork, simulateOnAnvil, stateSchema, targetKey, targetOf, tumblerDeployParamsSchema, tumblerDiagnostics, tumblerMarketActionsData, tumblerPlugin, unpauseCreditManagerActionData, unpausePoolActionData, updateInterestRateModelActionData, updateLossPolicyActionData, updateRateKeeperActionData, upgradeCreditFacadeActionData, usesBundleTarget, validateForkExecutionCalls };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { lowerAddress } from "../../utils/addressUtils.js";
|
|
2
|
-
import { compact } from "../../utils/objectUtils.js";
|
|
2
|
+
import { compact, ownEntry } from "../../utils/objectUtils.js";
|
|
3
3
|
// src/permissionless/curator/state/configurator/compareConfiguratorStates.ts
|
|
4
4
|
/** `{ old, new }` when the values differ, `undefined` when they are equal. **/
|
|
5
5
|
function changed(oldValue, newValue) {
|
|
@@ -39,6 +39,14 @@ function areProportionsEqual(old, new_) {
|
|
|
39
39
|
if (old.length !== new_.length) return false;
|
|
40
40
|
return old.every((val, idx) => Math.abs(val - new_[idx]) < 1e-10);
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Holder changes per role of `otherRoles`; a role missing on one side has no
|
|
44
|
+
* holders there. `undefined` when no role's holders changed.
|
|
45
|
+
**/
|
|
46
|
+
function compareOtherRoles(before = {}, after = {}) {
|
|
47
|
+
const roles = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)]);
|
|
48
|
+
return nonEmpty(Object.fromEntries([...roles].map((role) => [role, compareAddressArrays(ownEntry(before, role) ?? [], ownEntry(after, role) ?? [])])));
|
|
49
|
+
}
|
|
42
50
|
/** The fields of `differences` that are set, or `undefined` when none is. **/
|
|
43
51
|
function nonEmpty(differences) {
|
|
44
52
|
const set = compact(differences);
|
|
@@ -146,6 +154,7 @@ function compareConfiguratorStates(before, after) {
|
|
|
146
154
|
unpausableAdmins: compareAddressArrays(before.unpausableAdmins, after.unpausableAdmins),
|
|
147
155
|
lossLiquidators: compareAddressArrays(before.lossLiquidators, after.lossLiquidators),
|
|
148
156
|
emergencyLiquidators: compareAddressArrays(before.emergencyLiquidators, after.emergencyLiquidators),
|
|
157
|
+
otherRoles: compareOtherRoles(before.otherRoles, after.otherRoles),
|
|
149
158
|
governor: compareGovernorStates(before.governor, after.governor),
|
|
150
159
|
treasury: compareTreasuryStates(before.treasury, after.treasury)
|
|
151
160
|
});
|
|
@@ -182,7 +182,7 @@ async function getConfiguratorState(client, marketConfiguratorAddress) {
|
|
|
182
182
|
abi: mc.abi,
|
|
183
183
|
functionName: "version"
|
|
184
184
|
}));
|
|
185
|
-
const { admin, emergencyAdmin, treasury, pausableAdmins, unpausableAdmins, lossLiquidators, emergencyLiquidators } = await mc.admins();
|
|
185
|
+
const { admin, emergencyAdmin, treasury, pausableAdmins, unpausableAdmins, lossLiquidators, emergencyLiquidators, otherRoles } = await mc.admins();
|
|
186
186
|
return {
|
|
187
187
|
address: lowerAddress(marketConfiguratorAddress),
|
|
188
188
|
version,
|
|
@@ -192,6 +192,7 @@ async function getConfiguratorState(client, marketConfiguratorAddress) {
|
|
|
192
192
|
unpausableAdmins,
|
|
193
193
|
lossLiquidators,
|
|
194
194
|
emergencyLiquidators,
|
|
195
|
+
otherRoles,
|
|
195
196
|
governor: await getGovernorState(admin, client),
|
|
196
197
|
treasury: {
|
|
197
198
|
...await getTreasurySplitterState(treasury, client),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { size, stringToBytes } from "viem";
|
|
1
2
|
import { z } from "zod/v4";
|
|
2
3
|
// src/permissionless/curator/state/configurator/types.ts
|
|
3
4
|
/**
|
|
@@ -15,4 +16,26 @@ const adminRoleLabelMap = {
|
|
|
15
16
|
LOSS_LIQUIDATOR: "Loss Liquidator",
|
|
16
17
|
EMERGENCY_LIQUIDATOR: "Emergency Liquidator"
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Every role a Gearbox contract checks in the configurator's ACL, by name:
|
|
21
|
+
* - `PAUSABLE_ADMIN`, `UNPAUSABLE_ADMIN`: pause and unpause market contracts
|
|
22
|
+
* (core-v3 `ACLTrait`);
|
|
23
|
+
* - `EMERGENCY_LIQUIDATOR`: liquidates while a credit facade is paused
|
|
24
|
+
* (`CreditFacadeV3`);
|
|
25
|
+
* - `LOSS_LIQUIDATOR`: liquidates with loss under a permissioned aliased loss
|
|
26
|
+
* policy (`AliasedLossPolicyV3`);
|
|
27
|
+
* - `OPENING_SIGNER`: signs credit account openings for a signature degen NFT
|
|
28
|
+
* (`SignatureDegenNFT`).
|
|
29
|
+
**/
|
|
30
|
+
const knownRoleLabelMap = {
|
|
31
|
+
...adminRoleLabelMap,
|
|
32
|
+
OPENING_SIGNER: "Opening Signer"
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Schema for a role name, as `CONFIGURATOR::grantRole` and `revokeRole` take
|
|
36
|
+
* it: the configurator passes any `bytes32` role to its ACL, so any name
|
|
37
|
+
* fits. It must fit in 32 bytes and consist of printable ASCII without spaces,
|
|
38
|
+
* so that it reads back from the chain as it was written.
|
|
39
|
+
**/
|
|
40
|
+
const roleNameSchema = z.string().regex(/^[\x21-\x7e]+$/, "Role must be printable ASCII without spaces").refine((role) => size(stringToBytes(role)) <= 32, { message: "Role must fit in 32 bytes" });
|
|
41
|
+
export { adminRoleLabelMap, adminRoleSchema, knownRoleLabelMap, roleNameSchema };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// src/permissionless/curator/utils/objectUtils.ts
|
|
2
|
+
/** Looks up an entry without treating inherited object properties as entries. **/
|
|
3
|
+
function ownEntry(record, key) {
|
|
4
|
+
return record && Object.hasOwn(record, key) ? record[key] : void 0;
|
|
5
|
+
}
|
|
2
6
|
/** Drops `undefined` values, keeping the remaining keys in their order. **/
|
|
3
7
|
function compact(value) {
|
|
4
8
|
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
@@ -15,4 +19,4 @@ function stableStringify(value) {
|
|
|
15
19
|
return Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
|
-
export { compact, stableStringify };
|
|
22
|
+
export { compact, ownEntry, stableStringify };
|
|
@@ -64,7 +64,9 @@ import { defineConfiguratorAction } from "./curator/configurator-actions/defineC
|
|
|
64
64
|
import { addAdminActionData } from "./curator/configurator-actions/addAdminActionData.js";
|
|
65
65
|
import { cancelConfigureActionData } from "./curator/configurator-actions/cancelConfigureActionData.js";
|
|
66
66
|
import { distributeActionData } from "./curator/configurator-actions/distributeActionData.js";
|
|
67
|
+
import { grantRoleActionData } from "./curator/configurator-actions/grantRoleActionData.js";
|
|
67
68
|
import { removeAdminActionData } from "./curator/configurator-actions/removeAdminActionData.js";
|
|
69
|
+
import { revokeRoleActionData } from "./curator/configurator-actions/revokeRoleActionData.js";
|
|
68
70
|
import { calculateChecksum, convertRawTxToSafeMultisigTx, getSafeBatch, getSafeBatches } from "./utils/governance/batch.js";
|
|
69
71
|
import { convertQueueBatchToExecuteTx, createExecuteBatchRawTx } from "./utils/governance/timelock-txs.js";
|
|
70
72
|
import { GovernorContract } from "./bindings/governance/governor.js";
|
|
@@ -142,4 +144,4 @@ import { MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLO
|
|
|
142
144
|
import { getBlockNumberByTimestamp } from "./utils/block-utils.js";
|
|
143
145
|
import { getPriceUpdateTx } from "./utils/price-update/get-price-update-tx.js";
|
|
144
146
|
import "./utils/index.js";
|
|
145
|
-
export { ABSTRACT_ADAPTER_TYPES, AccessMode, AccountFactoryTypes, AddressProviderContract, Addresses, ArchiveTransport, BUNDLE_TARGET, BYTECODE_REPOSITORY, BytecodeRepositoryContract, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainsNamespace, ConfigurationExecutor, ConfiguratorBuilder, CrossChainMultisigContract, CuratorSession, DEFAULT_DEPLOY_SALT, DEFAULT_INTEREST_RATE_MODEL_PARAMS, DEFAULT_LOSS_POLICY_PARAMS, DEFAULT_RATE_KEEPER_PARAMS, DEFAULT_RWA_UNDERLYING_TYPE, DEFAULT_SCENARIOS, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GipActionError, GipBuilderError, GipRegistry, GipScopeError, GipSimulationError, GipTargetResolutionError, GovernorContract, INSTANCE_MANAGER, InstanceManagerContract, InstanceOwnerTransactions, KILL_SWITCH_PROXY, KILL_SWITCH_PROXY_MINOR_VERSION, KillSwitchProxyContract, KillSwitchProxyNotAllowedError, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, MarketBuilder, MarketConfiguratorContract, MarketConfiguratorFactoryContract, MarketExecutor, MergedGip, NO_LIMIT, ON_DEMAND_RWA_UNDERLYING_TYPE, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PermissionlessAnalytics, PermissionlessChainUnreachableError, PermissionlessConfigurators, PermissionlessCurator, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, PriceFeedStoreContract, RATE_FEED_TYPE, RWA_UNDERLYING_TYPE_PREFIX, RWA_ZAPPER_CONTRACT_TYPE, RWA_ZAPPER_VERSION, ResolveCache, RoutingManagerContract, SCORE_MULTIPLIER, SECURITIZE_RWA_FACTORY_TYPE, TIMELOCK_EVENTS_CHUNK_SIZE, TOKEN_COMPRESSOR, TimeLockContract, TokenCompressorContract, TreasurySplitterContract, UNBOUNDED_DOWN, UNBOUNDED_UP, WithdrawalCompressorContract, actionEnv, actionError, actionWarning, adapterPluginKit, adapterPlugins, addAdminActionData, addAssetActionData, addCollateralTokenActionData, addConfiguratorAction, addConfiguratorActions, addMarketAction, addMarketActions, addPeripheryContractActionData, adminRoleLabelMap, adminRoleSchema, aliasDeployParamsSchema, aliasPlugin, allowAdapterActionData, allowTokenActionData, applyBundle, applyChanges, assertNotBlocked, batchMarketTransactions, bindBundleTarget, buildMarketStateSchema, builtinAdapterPlugins, bundleActions, bundleSuiteId, calculateChecksum, cancelConfigureActionData, canonicalize, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, classifySources, compareConfiguratorStates, compareGipForkState, completeRwaPeripheryActions, contractReaderFromClient, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, convertTokenAmount, copyCmActions, copyCmActionsForMarket, createAction, createCallData, createCreate2DeployRawTx, createCreditSuite, createCreditSuiteActionData, createCreditSuiteSchema, createExecuteBatchRawTx, createMarketActionData, creditManagerFeesSchema, creditManagerTargetSchema, creditSuiteId, creditSuiteRef, creditSuiteRefSchema, customizeBundle, deepJsonParse, defineConfiguratorAction, defineMarketAction, deployContractActionData, deployUsingPublicCreate2, deriveEffectiveStalenessPeriod, deserializeGipPlan, diffMarketStates, diffStates, distributeActionData, encodeFunctionParams, factorOf, finalPrice, findIncompleteRwaPeripherySetups, forbidAdapterActionData, forbidTokenActionData, formatBytecodeSize, formatBytecodeVersion, formatMarketStateDiff, formatStateDiff, gaugeDeployParamsSchema, gaugeMarketActionsData, gaugePlugin, getAbstractAdapterPlugin, getActionScope, getBlockNumberByTimestamp, getConfiguratorState, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getFeedDecimals, getGipDiagnostics, getGovernorContract, getInitialMarketState, getLatestPrices, getMarketState, getPriceUpdateTx, getPrices, getRawTxHash, getRwaZapperDeployAction, getRwaZapperDeployParams, getSafeBatch, getSafeBatches, getTimelockTransactions, getTimelockTransactionsForExecution, getUpdatablePriceFeeds, groupOverride, handleSalt, hasErrors, insertRwaZapperDeployment, irmDeployParamsSchema, irmPlugins, isAliasedLossPolicy, isContractDeploymentQueued, isCreditSuiteRef, isPeripheryContractAdded, isRwaZapperRegistration, isSameTarget, isZeroFeed, killSwitchProxySalt, linearInterestRateModelDeployParamsSchema, linearPlugin, locateDiagnostics, lossPolicyDeployParamsSchema, lossPolicyMarketActionsData, lossPolicyPlugins, marketIdentity, marketStateSchema, midasAliasDeployParamsSchema, midasAliasPlugin, normalizeBundleTarget, normalizeSignature, numberToDecimalString, parseConfiguratorScopedAction, parseContractType, parseMarketScopedAction, pauseCreditManagerActionData, pausePoolActionData, peripheryContractDomains, peripheryDomainOf, peripheryStatus, perturb, planRwaPeripheryActions, previewCreditSuiteAddress, priceFeedSalt, priceFeedSetupParams, rampLiquidationThresholdActionData, rateKeeperDeployParamsSchema, rateKeeperMarketActionsData, rateKeeperPlugins, rateStub, readContractType, readFeedTrees, readForest, readRateTargets, readUnder, reconcileRwaPeripheryActions, removeAdapterActions, removeAdminActionData, replaceCmActions, resolveSecuritizeRwaSetup, retargetCreditManager, revertTo, roundDataStub, runAssetScores, runFeedPairScore, runStressTest, sameTree, scoreGroup, scoreOfFactor, selectMarketDegenNfts, serializeGipPlan, setCreditManagerDebtLimitActionData, setDefaultSplitActionData, setEmergencyAdminActionData, setExpirationDateActionData, setFeesActionData, setMaxDebtPerBlockMultiplierActionData, setPriceFeedActionData, setReservePriceFeedActionData, setTokenLimitActionData, setTokenQuotaIncreaseFeeActionData, setTotalDebtLimitActionData, shortenHash, significantTrunc, simulateGipOnFork, simulateGipPayloadOnFork, simulateOnAnvil, slotHarm, sourcesByFeed, stateSchema, targetKey, targetOf, tumblerDeployParamsSchema, tumblerDiagnostics, tumblerMarketActionsData, tumblerPlugin, unpauseCreditManagerActionData, unpausePoolActionData, updateInterestRateModelActionData, updateLossPolicyActionData, updateRateKeeperActionData, upgradeCreditFacadeActionData, usesBundleTarget, validateForkExecutionCalls, verdictOf, worstOf };
|
|
147
|
+
export { ABSTRACT_ADAPTER_TYPES, AccessMode, AccountFactoryTypes, AddressProviderContract, Addresses, ArchiveTransport, BUNDLE_TARGET, BYTECODE_REPOSITORY, BytecodeRepositoryContract, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainsNamespace, ConfigurationExecutor, ConfiguratorBuilder, CrossChainMultisigContract, CuratorSession, DEFAULT_DEPLOY_SALT, DEFAULT_INTEREST_RATE_MODEL_PARAMS, DEFAULT_LOSS_POLICY_PARAMS, DEFAULT_RATE_KEEPER_PARAMS, DEFAULT_RWA_UNDERLYING_TYPE, DEFAULT_SCENARIOS, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GipActionError, GipBuilderError, GipRegistry, GipScopeError, GipSimulationError, GipTargetResolutionError, GovernorContract, INSTANCE_MANAGER, InstanceManagerContract, InstanceOwnerTransactions, KILL_SWITCH_PROXY, KILL_SWITCH_PROXY_MINOR_VERSION, KillSwitchProxyContract, KillSwitchProxyNotAllowedError, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, MarketBuilder, MarketConfiguratorContract, MarketConfiguratorFactoryContract, MarketExecutor, MergedGip, NO_LIMIT, ON_DEMAND_RWA_UNDERLYING_TYPE, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PermissionlessAnalytics, PermissionlessChainUnreachableError, PermissionlessConfigurators, PermissionlessCurator, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, PriceFeedStoreContract, RATE_FEED_TYPE, RWA_UNDERLYING_TYPE_PREFIX, RWA_ZAPPER_CONTRACT_TYPE, RWA_ZAPPER_VERSION, ResolveCache, RoutingManagerContract, SCORE_MULTIPLIER, SECURITIZE_RWA_FACTORY_TYPE, TIMELOCK_EVENTS_CHUNK_SIZE, TOKEN_COMPRESSOR, TimeLockContract, TokenCompressorContract, TreasurySplitterContract, UNBOUNDED_DOWN, UNBOUNDED_UP, WithdrawalCompressorContract, actionEnv, actionError, actionWarning, adapterPluginKit, adapterPlugins, addAdminActionData, addAssetActionData, addCollateralTokenActionData, addConfiguratorAction, addConfiguratorActions, addMarketAction, addMarketActions, addPeripheryContractActionData, adminRoleLabelMap, adminRoleSchema, aliasDeployParamsSchema, aliasPlugin, allowAdapterActionData, allowTokenActionData, applyBundle, applyChanges, assertNotBlocked, batchMarketTransactions, bindBundleTarget, buildMarketStateSchema, builtinAdapterPlugins, bundleActions, bundleSuiteId, calculateChecksum, cancelConfigureActionData, canonicalize, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, classifySources, compareConfiguratorStates, compareGipForkState, completeRwaPeripheryActions, contractReaderFromClient, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, convertTokenAmount, copyCmActions, copyCmActionsForMarket, createAction, createCallData, createCreate2DeployRawTx, createCreditSuite, createCreditSuiteActionData, createCreditSuiteSchema, createExecuteBatchRawTx, createMarketActionData, creditManagerFeesSchema, creditManagerTargetSchema, creditSuiteId, creditSuiteRef, creditSuiteRefSchema, customizeBundle, deepJsonParse, defineConfiguratorAction, defineMarketAction, deployContractActionData, deployUsingPublicCreate2, deriveEffectiveStalenessPeriod, deserializeGipPlan, diffMarketStates, diffStates, distributeActionData, encodeFunctionParams, factorOf, finalPrice, findIncompleteRwaPeripherySetups, forbidAdapterActionData, forbidTokenActionData, formatBytecodeSize, formatBytecodeVersion, formatMarketStateDiff, formatStateDiff, gaugeDeployParamsSchema, gaugeMarketActionsData, gaugePlugin, getAbstractAdapterPlugin, getActionScope, getBlockNumberByTimestamp, getConfiguratorState, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getFeedDecimals, getGipDiagnostics, getGovernorContract, getInitialMarketState, getLatestPrices, getMarketState, getPriceUpdateTx, getPrices, getRawTxHash, getRwaZapperDeployAction, getRwaZapperDeployParams, getSafeBatch, getSafeBatches, getTimelockTransactions, getTimelockTransactionsForExecution, getUpdatablePriceFeeds, grantRoleActionData, groupOverride, handleSalt, hasErrors, insertRwaZapperDeployment, irmDeployParamsSchema, irmPlugins, isAliasedLossPolicy, isContractDeploymentQueued, isCreditSuiteRef, isPeripheryContractAdded, isRwaZapperRegistration, isSameTarget, isZeroFeed, killSwitchProxySalt, linearInterestRateModelDeployParamsSchema, linearPlugin, locateDiagnostics, lossPolicyDeployParamsSchema, lossPolicyMarketActionsData, lossPolicyPlugins, marketIdentity, marketStateSchema, midasAliasDeployParamsSchema, midasAliasPlugin, normalizeBundleTarget, normalizeSignature, numberToDecimalString, parseConfiguratorScopedAction, parseContractType, parseMarketScopedAction, pauseCreditManagerActionData, pausePoolActionData, peripheryContractDomains, peripheryDomainOf, peripheryStatus, perturb, planRwaPeripheryActions, previewCreditSuiteAddress, priceFeedSalt, priceFeedSetupParams, rampLiquidationThresholdActionData, rateKeeperDeployParamsSchema, rateKeeperMarketActionsData, rateKeeperPlugins, rateStub, readContractType, readFeedTrees, readForest, readRateTargets, readUnder, reconcileRwaPeripheryActions, removeAdapterActions, removeAdminActionData, replaceCmActions, resolveSecuritizeRwaSetup, retargetCreditManager, revertTo, revokeRoleActionData, roundDataStub, runAssetScores, runFeedPairScore, runStressTest, sameTree, scoreGroup, scoreOfFactor, selectMarketDegenNfts, serializeGipPlan, setCreditManagerDebtLimitActionData, setDefaultSplitActionData, setEmergencyAdminActionData, setExpirationDateActionData, setFeesActionData, setMaxDebtPerBlockMultiplierActionData, setPriceFeedActionData, setReservePriceFeedActionData, setTokenLimitActionData, setTokenQuotaIncreaseFeeActionData, setTotalDebtLimitActionData, shortenHash, significantTrunc, simulateGipOnFork, simulateGipPayloadOnFork, simulateOnAnvil, slotHarm, sourcesByFeed, stateSchema, targetKey, targetOf, tumblerDeployParamsSchema, tumblerDiagnostics, tumblerMarketActionsData, tumblerPlugin, unpauseCreditManagerActionData, unpausePoolActionData, updateInterestRateModelActionData, updateLossPolicyActionData, updateRateKeeperActionData, upgradeCreditFacadeActionData, usesBundleTarget, validateForkExecutionCalls, verdictOf, worstOf };
|
|
@@ -33,7 +33,6 @@ export declare function getErpcKey(network: NetworkType, projectId?: string, url
|
|
|
33
33
|
│ WorldChain │ ∞ │ 10M │ 1K │ ✗ │
|
|
34
34
|
│ Etherlink │ ✗ │ ✗ │ ✗ │ ✗ │
|
|
35
35
|
│ Hemi │ ✗ │ ∞ │ 1K │ ✗ │
|
|
36
|
-
│ Lisk │ ✗ │ 5M │ 1K │ ✗ │
|
|
37
36
|
│ Plasma │ 10K │ 100K │ 1K │ ✗ │
|
|
38
37
|
│ Somnia │ ✗ │ ✗ │ 1K │ 10K │
|
|
39
38
|
└────────────┴─────────┴──────┴──────────┴──────┘
|
|
@@ -56,7 +55,6 @@ Rare event (InstanceManager.OwnershipTransferred):
|
|
|
56
55
|
│ WorldChain │ ∞ │ 1M │ 1K │ ✗ │
|
|
57
56
|
│ Etherlink │ ✗ │ ✗ │ ✗ │ ✗ │
|
|
58
57
|
│ Hemi │ ✗ │ ∞ │ 1K │ ✗ │
|
|
59
|
-
│ Lisk │ ✗ │ 10M │ 1K │ ✗ │
|
|
60
58
|
│ Plasma │ 10K │ 100K │ 1K │ ✗ │
|
|
61
59
|
│ Somnia │ ✗ │ ✗ │ 1K │ 10K │
|
|
62
60
|
└────────────┴─────────┴──────┴──────────┴──────┘
|