@gearbox-protocol/sdk 18.2.0-next.11 → 18.2.0-next.13
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/310/iKillSwitchProxy.js +130 -0
- package/dist/cjs/dev/AccountOpener.js +1 -1
- package/dist/cjs/dev/withdrawalUtils.js +1 -1
- package/dist/cjs/history/trace/extractTransfers.js +1 -1
- package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/cjs/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +2 -1
- package/dist/cjs/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +2 -1
- package/dist/cjs/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +2 -1
- package/dist/cjs/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/cjs/onchain/base/TokensMeta.js +3 -3
- package/dist/cjs/onchain/core/createAddressProvider.js +1 -1
- package/dist/cjs/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/cjs/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/cjs/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/cjs/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/cjs/onchain/market/rwa/createDegenNFT.js +1 -1
- package/dist/cjs/onchain/market/zapper/IETHZapperContract.js +2 -1
- package/dist/cjs/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/cjs/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
- package/dist/cjs/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/cjs/permissionless/api/index.js +7 -3
- package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +11 -11
- package/dist/cjs/permissionless/api/oracles/index.js +7 -3
- package/dist/cjs/permissionless/api/oracles/score/formula.js +44 -82
- package/dist/cjs/permissionless/api/oracles/score/index.js +6 -3
- package/dist/cjs/permissionless/api/oracles/score/run.js +129 -46
- package/dist/cjs/permissionless/api/oracles/stress/index.js +1 -0
- package/dist/cjs/permissionless/api/oracles/stress/run.js +5 -2
- package/dist/cjs/permissionless/bindings/bytecode-repository.js +8 -0
- package/dist/cjs/permissionless/bindings/governance/governor.js +1 -1
- package/dist/cjs/permissionless/bindings/index.js +7 -2
- package/dist/cjs/permissionless/bindings/kill-switch-proxy.js +188 -0
- package/dist/cjs/permissionless/bindings/market-configurator-factory.js +39 -1
- package/dist/cjs/permissionless/bindings/market-configurator.js +142 -0
- package/dist/cjs/permissionless/index.js +15 -5
- package/dist/cjs/permissionless/utils/index.js +1 -0
- package/dist/cjs/permissionless/utils/literals.js +2 -0
- package/dist/esm/abi/310/iKillSwitchProxy.js +129 -0
- package/dist/esm/permissionless/api/index.js +3 -3
- package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +11 -11
- package/dist/esm/permissionless/api/oracles/index.js +3 -3
- package/dist/esm/permissionless/api/oracles/score/formula.js +39 -80
- package/dist/esm/permissionless/api/oracles/score/index.js +2 -2
- package/dist/esm/permissionless/api/oracles/score/run.js +131 -48
- package/dist/esm/permissionless/api/oracles/stress/index.js +2 -2
- package/dist/esm/permissionless/api/oracles/stress/run.js +5 -3
- package/dist/esm/permissionless/bindings/bytecode-repository.js +8 -0
- package/dist/esm/permissionless/bindings/governance/governor.js +1 -1
- package/dist/esm/permissionless/bindings/index.js +4 -3
- package/dist/esm/permissionless/bindings/kill-switch-proxy.js +184 -0
- package/dist/esm/permissionless/bindings/market-configurator-factory.js +37 -0
- package/dist/esm/permissionless/bindings/market-configurator.js +143 -1
- package/dist/esm/permissionless/index.js +7 -6
- package/dist/esm/permissionless/utils/index.js +2 -2
- package/dist/esm/permissionless/utils/literals.js +2 -1
- package/dist/types/abi/310/iKillSwitchProxy.d.ts +114 -0
- package/dist/types/permissionless/api/index.d.ts +4 -4
- package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +11 -11
- package/dist/types/permissionless/api/oracles/index.d.ts +4 -4
- package/dist/types/permissionless/api/oracles/score/formula.d.ts +31 -38
- package/dist/types/permissionless/api/oracles/score/index.d.ts +3 -3
- package/dist/types/permissionless/api/oracles/score/run.d.ts +7 -4
- package/dist/types/permissionless/api/oracles/score/types.d.ts +50 -22
- package/dist/types/permissionless/api/oracles/stress/index.d.ts +2 -2
- package/dist/types/permissionless/api/oracles/stress/run.d.ts +17 -1
- package/dist/types/permissionless/bindings/bytecode-repository.d.ts +10 -1
- package/dist/types/permissionless/bindings/index.d.ts +4 -3
- package/dist/types/permissionless/bindings/kill-switch-proxy.d.ts +205 -0
- package/dist/types/permissionless/bindings/market-configurator-factory.d.ts +30 -0
- package/dist/types/permissionless/bindings/market-configurator.d.ts +30 -1
- package/dist/types/permissionless/bindings/types.d.ts +27 -0
- package/dist/types/permissionless/index.d.ts +8 -7
- package/dist/types/permissionless/utils/index.d.ts +2 -2
- package/dist/types/permissionless/utils/literals.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { iMarketConfiguratorV310Abi } from "../../abi/310/generated.js";
|
|
2
2
|
import { json_stringify } from "../../onchain/utils/json.js";
|
|
3
|
+
import { createRawTx } from "../../onchain/utils/createRawTx.js";
|
|
3
4
|
import { BaseContract } from "../../onchain/base/BaseContract.js";
|
|
4
5
|
import "../../onchain/index.js";
|
|
6
|
+
import { KILL_SWITCH_PROXY } from "../utils/literals.js";
|
|
5
7
|
import { AddressProviderContract } from "./address-provider.js";
|
|
8
|
+
import { iKillSwitchProxyAbi } from "../../abi/310/iKillSwitchProxy.js";
|
|
6
9
|
import { creditFacadeParamsAbi, creditManagerParamsAbi } from "../../abi/310/configure/creditSuiteParams.js";
|
|
7
10
|
import { parseIrmDeployParams } from "../plugins/irm/constructor-params-abi.js";
|
|
8
11
|
import { parseLossPolicyDeployParams } from "../plugins/loss-policies/constructor-params-abi.js";
|
|
@@ -15,7 +18,7 @@ import { LossPolicyFactory } from "./factory/loss-policy-factory.js";
|
|
|
15
18
|
import { PoolFactory } from "./factory/pool-factory.js";
|
|
16
19
|
import { PriceOracleFactory } from "./factory/price-oracle-factory.js";
|
|
17
20
|
import { RateKeeperFactory } from "./factory/rate-keeper-factory.js";
|
|
18
|
-
import { decodeAbiParameters, encodeAbiParameters, encodeFunctionData, erc20Abi, erc4626Abi, hexToString, keccak256, parseAbi, stringToHex, toBytes } from "viem";
|
|
21
|
+
import { decodeAbiParameters, encodeAbiParameters, encodeFunctionData, erc20Abi, erc4626Abi, hexToString, isAddressEqual, keccak256, parseAbi, stringToHex, toBytes } from "viem";
|
|
19
22
|
//#region src/permissionless/bindings/market-configurator.ts
|
|
20
23
|
const PERIPHERY_DOMAINS = ["ZAPPER", "DEGEN_NFT"];
|
|
21
24
|
const abi = iMarketConfiguratorV310Abi;
|
|
@@ -395,6 +398,83 @@ var MarketConfiguratorContract = class extends BaseContract {
|
|
|
395
398
|
return;
|
|
396
399
|
}
|
|
397
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Returns emergency admin of the market configurator.
|
|
403
|
+
* If it is a `KILL_SWITCH_PROXY`, emergency transactions must be sent by proxy's caller via `proxyCall`,
|
|
404
|
+
* otherwise directly by emergency admin itself
|
|
405
|
+
* @param emergencyAdmin - emergency admin address, read from the market configurator if not provided
|
|
406
|
+
*/
|
|
407
|
+
async getEmergencyAdmin(emergencyAdmin) {
|
|
408
|
+
const address = emergencyAdmin ?? await this.contract.read.emergencyAdmin();
|
|
409
|
+
const [contractType, caller, owner, isKilled] = await this.client.multicall({
|
|
410
|
+
allowFailure: true,
|
|
411
|
+
contracts: [
|
|
412
|
+
{
|
|
413
|
+
address,
|
|
414
|
+
abi: iKillSwitchProxyAbi,
|
|
415
|
+
functionName: "contractType"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
address,
|
|
419
|
+
abi: iKillSwitchProxyAbi,
|
|
420
|
+
functionName: "caller"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
address,
|
|
424
|
+
abi: iKillSwitchProxyAbi,
|
|
425
|
+
functionName: "owner"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
address,
|
|
429
|
+
abi: iKillSwitchProxyAbi,
|
|
430
|
+
functionName: "isKilled"
|
|
431
|
+
}
|
|
432
|
+
],
|
|
433
|
+
batchSize: 0
|
|
434
|
+
});
|
|
435
|
+
let isKillSwitch = false;
|
|
436
|
+
if (contractType.status === "success") try {
|
|
437
|
+
isKillSwitch = hexToString(contractType.result, { size: 32 }) === KILL_SWITCH_PROXY;
|
|
438
|
+
} catch {}
|
|
439
|
+
if (!isKillSwitch) return {
|
|
440
|
+
type: "direct",
|
|
441
|
+
address,
|
|
442
|
+
executor: address
|
|
443
|
+
};
|
|
444
|
+
if (caller.status !== "success" || owner.status !== "success" || isKilled.status !== "success") throw new Error(`failed to read state of ${KILL_SWITCH_PROXY} emergency admin ${address}`);
|
|
445
|
+
return {
|
|
446
|
+
type: "killSwitch",
|
|
447
|
+
address,
|
|
448
|
+
caller: caller.result,
|
|
449
|
+
owner: owner.result,
|
|
450
|
+
isKilled: isKilled.result,
|
|
451
|
+
executor: caller.result
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Routes emergency transaction to the market configurator through its emergency admin:
|
|
456
|
+
* returns transaction as is for direct emergency admin, or wraps it into `proxyCall` of kill switch proxy
|
|
457
|
+
* @param tx - emergency transaction to the market configurator, e.g. built by `emergencyConfigurePool`
|
|
458
|
+
* @param emergencyAdmin - result of {@link getEmergencyAdmin}
|
|
459
|
+
* @throws if transaction is not addressed to this market configurator or kill switch proxy is killed
|
|
460
|
+
*/
|
|
461
|
+
wrapEmergencyTx(tx, emergencyAdmin) {
|
|
462
|
+
if (!isAddressEqual(tx.to, this.address)) throw new Error(`emergency tx target ${tx.to} is not market configurator ${this.address}`);
|
|
463
|
+
if (emergencyAdmin.type === "direct") return tx;
|
|
464
|
+
if (emergencyAdmin.isKilled) throw new Error(`${KILL_SWITCH_PROXY} ${emergencyAdmin.address} of market configurator ${this.address} is killed`);
|
|
465
|
+
return createRawTx(emergencyAdmin.address, {
|
|
466
|
+
abi: iKillSwitchProxyAbi,
|
|
467
|
+
functionName: "proxyCall",
|
|
468
|
+
args: [this.address, tx.callData]
|
|
469
|
+
}, tx.description ? `KillSwitchProxy.proxyCall(${tx.description})` : void 0);
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Reads emergency admin and routes emergency transaction through it, see {@link wrapEmergencyTx}
|
|
473
|
+
* @param tx - emergency transaction to the market configurator, e.g. built by `emergencyConfigurePool`
|
|
474
|
+
*/
|
|
475
|
+
async emergencyTx(tx) {
|
|
476
|
+
return this.wrapEmergencyTx(tx, await this.getEmergencyAdmin());
|
|
477
|
+
}
|
|
398
478
|
grantRole(role, address) {
|
|
399
479
|
return this.createRawTx({
|
|
400
480
|
functionName: "grantRole",
|
|
@@ -608,9 +688,53 @@ var MarketConfiguratorContract = class extends BaseContract {
|
|
|
608
688
|
role: hexToString(role, { size: 32 })
|
|
609
689
|
};
|
|
610
690
|
}
|
|
691
|
+
case "emergencyConfigurePool":
|
|
692
|
+
case "emergencyConfigurePriceOracle":
|
|
693
|
+
case "emergencyConfigureLossPolicy":
|
|
694
|
+
case "emergencyConfigureRateKeeper":
|
|
695
|
+
case "emergencyConfigureInterestRateModel": {
|
|
696
|
+
const [pool, calldata] = args;
|
|
697
|
+
const decoded = this.#decodeEmergencyConfig(functionName, calldata);
|
|
698
|
+
return decoded ? {
|
|
699
|
+
pool,
|
|
700
|
+
data: json_stringify(decoded)
|
|
701
|
+
} : {
|
|
702
|
+
pool,
|
|
703
|
+
calldata
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
case "emergencyConfigureCreditSuite": {
|
|
707
|
+
const [creditManager, calldata] = args;
|
|
708
|
+
const decoded = this.#decodeEmergencyConfig(functionName, calldata);
|
|
709
|
+
return decoded ? {
|
|
710
|
+
creditManager,
|
|
711
|
+
data: json_stringify(decoded)
|
|
712
|
+
} : {
|
|
713
|
+
creditManager,
|
|
714
|
+
calldata
|
|
715
|
+
};
|
|
716
|
+
}
|
|
611
717
|
default: return super.parseFunctionParams(params);
|
|
612
718
|
}
|
|
613
719
|
}
|
|
720
|
+
/**
|
|
721
|
+
* Emergency actions share selectors with regular configuration actions only partially
|
|
722
|
+
* (e.g., `pause`, `forbidToken`, `setPriceFeed`), so decoding is best-effort
|
|
723
|
+
*/
|
|
724
|
+
#decodeEmergencyConfig(functionName, calldata) {
|
|
725
|
+
const factory = {
|
|
726
|
+
emergencyConfigurePool: this.poolFactory,
|
|
727
|
+
emergencyConfigureCreditSuite: this.creditFactory,
|
|
728
|
+
emergencyConfigurePriceOracle: this.priceOracleFactory,
|
|
729
|
+
emergencyConfigureLossPolicy: this.lossPolicyFactory,
|
|
730
|
+
emergencyConfigureRateKeeper: this.rateKeeperFactory
|
|
731
|
+
}[functionName];
|
|
732
|
+
try {
|
|
733
|
+
return factory?.decodeConfig(calldata) ?? null;
|
|
734
|
+
} catch {
|
|
735
|
+
return null;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
614
738
|
emergencyConfigurePool(pool, calldata) {
|
|
615
739
|
return this.createRawTx({
|
|
616
740
|
functionName: "emergencyConfigurePool",
|
|
@@ -635,6 +759,24 @@ var MarketConfiguratorContract = class extends BaseContract {
|
|
|
635
759
|
args: [pool, calldata]
|
|
636
760
|
});
|
|
637
761
|
}
|
|
762
|
+
/**
|
|
763
|
+
* Note: current interest rate model factory forbids all emergency configuration calls
|
|
764
|
+
*/
|
|
765
|
+
emergencyConfigureInterestRateModel(pool, calldata) {
|
|
766
|
+
return this.createRawTx({
|
|
767
|
+
functionName: "emergencyConfigureInterestRateModel",
|
|
768
|
+
args: [pool, calldata]
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Note: current rate keeper factory forbids all emergency configuration calls
|
|
773
|
+
*/
|
|
774
|
+
emergencyConfigureRateKeeper(pool, calldata) {
|
|
775
|
+
return this.createRawTx({
|
|
776
|
+
functionName: "emergencyConfigureRateKeeper",
|
|
777
|
+
args: [pool, calldata]
|
|
778
|
+
});
|
|
779
|
+
}
|
|
638
780
|
};
|
|
639
781
|
//#endregion
|
|
640
782
|
export { MarketConfiguratorContract };
|
|
@@ -2,7 +2,7 @@ import { PermissionlessAnalytics } from "./api/analytics/PermissionlessAnalytics
|
|
|
2
2
|
import { PermissionlessChainUnreachableError, PermissionlessNotAttachedError, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError } from "./api/errors.js";
|
|
3
3
|
import { ChainsNamespace } from "./api/chains/ChainsNamespace.js";
|
|
4
4
|
import { deriveEffectiveStalenessPeriod } from "./api/deploy/effective-staleness.js";
|
|
5
|
-
import { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR } from "./utils/literals.js";
|
|
5
|
+
import { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, KILL_SWITCH_PROXY, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR } from "./utils/literals.js";
|
|
6
6
|
import { normalizeSignature } from "./utils/signature.js";
|
|
7
7
|
import { BytecodeRepositoryContract } from "./bindings/bytecode-repository.js";
|
|
8
8
|
import { priceFeedSetupParams } from "./bindings/pricefeeds/index.js";
|
|
@@ -15,8 +15,8 @@ import { getFeedDecimals, getLatestPrices, getPrices } from "./utils/price-updat
|
|
|
15
15
|
import { classifySources, sourcesByFeed } from "./api/oracles/stress/classify.js";
|
|
16
16
|
import { UNBOUNDED_DOWN, UNBOUNDED_UP, groupOverride, perturb, rateStub, roundDataStub } from "./api/oracles/stress/override.js";
|
|
17
17
|
import { scoreGroup, slotHarm, verdictOf } from "./api/oracles/stress/score.js";
|
|
18
|
-
import { DEFAULT_SCENARIOS, RATE_FEED_TYPE, readForest, readRateTargets, runStressTest } from "./api/oracles/stress/run.js";
|
|
19
|
-
import {
|
|
18
|
+
import { DEFAULT_SCENARIOS, RATE_FEED_TYPE, readForest, readRateTargets, readUnder, runStressTest } from "./api/oracles/stress/run.js";
|
|
19
|
+
import { REVERT_SCORE, SCORE_MULTIPLIER, factorOf, finalPrice, scoreOfFactor, worstOf } from "./api/oracles/score/formula.js";
|
|
20
20
|
import { runAssetScores } from "./api/oracles/score/run.js";
|
|
21
21
|
import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./api/oracles/PermissionlessOracles.js";
|
|
22
22
|
import { TokenCompressorContract } from "./bindings/compressors/token-compressor.js";
|
|
@@ -29,13 +29,14 @@ import { getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds
|
|
|
29
29
|
import { InstanceOwnerTransactions } from "./api/transactions/InstanceOwnerTransactions.js";
|
|
30
30
|
import { GearboxPermissionless } from "./api/GearboxPermissionless.js";
|
|
31
31
|
import "./api/index.js";
|
|
32
|
-
import { MarketConfiguratorFactoryContract } from "./bindings/market-configurator-factory.js";
|
|
33
|
-
import { CrossChainMultisigContract } from "./bindings/cross-chain-multisig.js";
|
|
34
32
|
import { PUBLIC_CREATE2_FACTORY, checkCreate2Deployment, checkCreate2DeploymentAddress, createCreate2DeployRawTx, deployUsingPublicCreate2, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, handleSalt } from "./utils/create2.js";
|
|
35
33
|
import { convertPercent, deepJsonParse, formatBytecodeSize, formatBytecodeVersion, shortenHash, significantTrunc } from "./utils/format.js";
|
|
36
34
|
import { createCallData } from "./core/raw-tx.js";
|
|
37
35
|
import { AccessMode } from "./bindings/types.js";
|
|
38
36
|
import { MarketConfiguratorContract } from "./bindings/market-configurator.js";
|
|
37
|
+
import { KILL_SWITCH_PROXY_MINOR_VERSION, KillSwitchProxyContract, KillSwitchProxyNotAllowedError, killSwitchProxySalt } from "./bindings/kill-switch-proxy.js";
|
|
38
|
+
import { MarketConfiguratorFactoryContract } from "./bindings/market-configurator-factory.js";
|
|
39
|
+
import { CrossChainMultisigContract } from "./bindings/cross-chain-multisig.js";
|
|
39
40
|
import { GovernorContract } from "./bindings/governance/governor.js";
|
|
40
41
|
import { TimeLockContract } from "./bindings/governance/timelock.js";
|
|
41
42
|
import "./bindings/index.js";
|
|
@@ -47,4 +48,4 @@ import { getBlockNumberByTimestamp } from "./utils/block-utils.js";
|
|
|
47
48
|
import { convertQueueBatchToExecuteTx } from "./utils/governance/timelock-txs.js";
|
|
48
49
|
import { getPriceUpdateTx } from "./utils/price-update/get-price-update-tx.js";
|
|
49
50
|
import "./utils/index.js";
|
|
50
|
-
export { AccessMode, AddressProviderContract, Addresses, ArchiveTransport,
|
|
51
|
+
export { AccessMode, AddressProviderContract, Addresses, ArchiveTransport, BYTECODE_REPOSITORY, BytecodeRepositoryContract, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainsNamespace, CrossChainMultisigContract, DEFAULT_DEPLOY_SALT, DEFAULT_SCENARIOS, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, 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, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PermissionlessAnalytics, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, PriceFeedStoreContract, RATE_FEED_TYPE, REVERT_SCORE, RoutingManagerContract, SCORE_MULTIPLIER, TOKEN_COMPRESSOR, TimeLockContract, TokenCompressorContract, TreasurySplitterContract, UNBOUNDED_DOWN, UNBOUNDED_UP, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, classifySources, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, deriveEffectiveStalenessPeriod, encodeFunctionParams, factorOf, finalPrice, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getFeedDecimals, getLatestPrices, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, groupOverride, handleSalt, killSwitchProxySalt, normalizeSignature, perturb, priceFeedSalt, priceFeedSetupParams, rateStub, readForest, readRateTargets, readUnder, roundDataStub, runAssetScores, runStressTest, scoreGroup, scoreOfFactor, shortenHash, significantTrunc, slotHarm, sourcesByFeed, verdictOf, worstOf };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR } from "./literals.js";
|
|
1
|
+
import { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, KILL_SWITCH_PROXY, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR } from "./literals.js";
|
|
2
2
|
import { normalizeSignature } from "./signature.js";
|
|
3
3
|
import { encodeFunctionParams } from "./abi-encoder.js";
|
|
4
4
|
import { getFeedDecimals, getLatestPrices, getPrices } from "./price-update/get-prices.js";
|
|
@@ -11,4 +11,4 @@ import { convertQueueBatchToExecuteTx } from "./governance/timelock-txs.js";
|
|
|
11
11
|
import "./governance/index.js";
|
|
12
12
|
import { getPriceUpdateTx } from "./price-update/get-price-update-tx.js";
|
|
13
13
|
import "./price-update/index.js";
|
|
14
|
-
export { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, TOKEN_COMPRESSOR, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getFeedDecimals, getLatestPrices, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, shortenHash, significantTrunc };
|
|
14
|
+
export { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, KILL_SWITCH_PROXY, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, TOKEN_COMPRESSOR, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getFeedDecimals, getLatestPrices, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, shortenHash, significantTrunc };
|
|
@@ -6,5 +6,6 @@ const TOKEN_COMPRESSOR = "GLOBAL::TOKEN_COMPRESSOR";
|
|
|
6
6
|
const CROSS_CHAIN_MULTISIG = "CROSS_CHAIN_MULTISIG";
|
|
7
7
|
const PRICE_FEED_STORE = "PRICE_FEED_STORE";
|
|
8
8
|
const MARKET_CONFIGURATOR_FACTORY = "MARKET_CONFIGURATOR_FACTORY";
|
|
9
|
+
const KILL_SWITCH_PROXY = "KILL_SWITCH_PROXY";
|
|
9
10
|
//#endregion
|
|
10
|
-
export { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR };
|
|
11
|
+
export { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, KILL_SWITCH_PROXY, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
//#region src/abi/310/iKillSwitchProxy.d.ts
|
|
2
|
+
export declare const iKillSwitchProxyAbi: readonly [{
|
|
3
|
+
readonly type: "constructor";
|
|
4
|
+
readonly inputs: readonly [{
|
|
5
|
+
readonly name: "_owner";
|
|
6
|
+
readonly internalType: "address";
|
|
7
|
+
readonly type: "address";
|
|
8
|
+
}, {
|
|
9
|
+
readonly name: "_caller";
|
|
10
|
+
readonly internalType: "address";
|
|
11
|
+
readonly type: "address";
|
|
12
|
+
}];
|
|
13
|
+
readonly stateMutability: "nonpayable";
|
|
14
|
+
}, {
|
|
15
|
+
readonly type: "function";
|
|
16
|
+
readonly inputs: readonly [];
|
|
17
|
+
readonly name: "caller";
|
|
18
|
+
readonly outputs: readonly [{
|
|
19
|
+
readonly name: "";
|
|
20
|
+
readonly internalType: "address";
|
|
21
|
+
readonly type: "address";
|
|
22
|
+
}];
|
|
23
|
+
readonly stateMutability: "view";
|
|
24
|
+
}, {
|
|
25
|
+
readonly type: "function";
|
|
26
|
+
readonly inputs: readonly [];
|
|
27
|
+
readonly name: "contractType";
|
|
28
|
+
readonly outputs: readonly [{
|
|
29
|
+
readonly name: "";
|
|
30
|
+
readonly internalType: "bytes32";
|
|
31
|
+
readonly type: "bytes32";
|
|
32
|
+
}];
|
|
33
|
+
readonly stateMutability: "view";
|
|
34
|
+
}, {
|
|
35
|
+
readonly type: "function";
|
|
36
|
+
readonly inputs: readonly [];
|
|
37
|
+
readonly name: "isKilled";
|
|
38
|
+
readonly outputs: readonly [{
|
|
39
|
+
readonly name: "";
|
|
40
|
+
readonly internalType: "bool";
|
|
41
|
+
readonly type: "bool";
|
|
42
|
+
}];
|
|
43
|
+
readonly stateMutability: "view";
|
|
44
|
+
}, {
|
|
45
|
+
readonly type: "function";
|
|
46
|
+
readonly inputs: readonly [];
|
|
47
|
+
readonly name: "kill";
|
|
48
|
+
readonly outputs: readonly [];
|
|
49
|
+
readonly stateMutability: "nonpayable";
|
|
50
|
+
}, {
|
|
51
|
+
readonly type: "function";
|
|
52
|
+
readonly inputs: readonly [];
|
|
53
|
+
readonly name: "owner";
|
|
54
|
+
readonly outputs: readonly [{
|
|
55
|
+
readonly name: "";
|
|
56
|
+
readonly internalType: "address";
|
|
57
|
+
readonly type: "address";
|
|
58
|
+
}];
|
|
59
|
+
readonly stateMutability: "view";
|
|
60
|
+
}, {
|
|
61
|
+
readonly type: "function";
|
|
62
|
+
readonly inputs: readonly [{
|
|
63
|
+
readonly name: "target";
|
|
64
|
+
readonly internalType: "address";
|
|
65
|
+
readonly type: "address";
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "data";
|
|
68
|
+
readonly internalType: "bytes";
|
|
69
|
+
readonly type: "bytes";
|
|
70
|
+
}];
|
|
71
|
+
readonly name: "proxyCall";
|
|
72
|
+
readonly outputs: readonly [{
|
|
73
|
+
readonly name: "result";
|
|
74
|
+
readonly internalType: "bytes";
|
|
75
|
+
readonly type: "bytes";
|
|
76
|
+
}];
|
|
77
|
+
readonly stateMutability: "nonpayable";
|
|
78
|
+
}, {
|
|
79
|
+
readonly type: "function";
|
|
80
|
+
readonly inputs: readonly [];
|
|
81
|
+
readonly name: "version";
|
|
82
|
+
readonly outputs: readonly [{
|
|
83
|
+
readonly name: "";
|
|
84
|
+
readonly internalType: "uint256";
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
}];
|
|
87
|
+
readonly stateMutability: "view";
|
|
88
|
+
}, {
|
|
89
|
+
readonly type: "event";
|
|
90
|
+
readonly anonymous: false;
|
|
91
|
+
readonly inputs: readonly [];
|
|
92
|
+
readonly name: "Killed";
|
|
93
|
+
}, {
|
|
94
|
+
readonly type: "error";
|
|
95
|
+
readonly inputs: readonly [{
|
|
96
|
+
readonly name: "caller";
|
|
97
|
+
readonly internalType: "address";
|
|
98
|
+
readonly type: "address";
|
|
99
|
+
}];
|
|
100
|
+
readonly name: "CallerIsNotOwnerException";
|
|
101
|
+
}, {
|
|
102
|
+
readonly type: "error";
|
|
103
|
+
readonly inputs: readonly [];
|
|
104
|
+
readonly name: "KilledException";
|
|
105
|
+
}, {
|
|
106
|
+
readonly type: "error";
|
|
107
|
+
readonly inputs: readonly [];
|
|
108
|
+
readonly name: "OnlyCallerException";
|
|
109
|
+
}, {
|
|
110
|
+
readonly type: "error";
|
|
111
|
+
readonly inputs: readonly [];
|
|
112
|
+
readonly name: "OwnerSameAsCallerException";
|
|
113
|
+
}];
|
|
114
|
+
//#endregion
|
|
@@ -5,7 +5,7 @@ import { AttachChainsArgs, ChainScope, ChainSummaryArgs, PermissionlessChain, Pe
|
|
|
5
5
|
import { ChainsNamespace } from "./chains/ChainsNamespace.js";
|
|
6
6
|
import { DeployArgs, DeployContractArgs, DeployPriceFeedArgs, PreparedDeployment, PreparedPriceFeedDeployment } from "./deploy/types.js";
|
|
7
7
|
import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./deploy/PermissionlessDeploy.js";
|
|
8
|
-
import { AssetScore, AssetScoresArgs, MarketScore, ScoredFeed } from "./oracles/score/types.js";
|
|
8
|
+
import { AssetScore, AssetScoresArgs, GroupImpact, MarketScore, ScoredFeed } from "./oracles/score/types.js";
|
|
9
9
|
import { BreakingPoint, FeedOutcome, GroupReport, GroupScenarioOutcome, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs } from "./oracles/stress/types.js";
|
|
10
10
|
import { AssetArgs, AssetCap, AssetsArgs, FeedCap, MarketCap, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetQuota, PermissionlessAssetSummary, PermissionlessIndexedAssetDetails, PermissionlessIndexedAssetSummary, PermissionlessIndexedPriceFeedDetails, PermissionlessIndexedPriceFeedMarket, PermissionlessMarket, PermissionlessMarketSlot, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedStore, PermissionlessQuotaTotals, PriceFeedArgs, PriceFeedDecimals, PriceFeedPrice, PriceFeedRef } from "./oracles/types.js";
|
|
11
11
|
import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./oracles/PermissionlessOracles.js";
|
|
@@ -17,12 +17,12 @@ import "./chains/index.js";
|
|
|
17
17
|
import { deriveEffectiveStalenessPeriod } from "./deploy/effective-staleness.js";
|
|
18
18
|
import "./deploy/index.js";
|
|
19
19
|
import { PermissionlessChainUnreachableError, PermissionlessNotAttachedError, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError } from "./errors.js";
|
|
20
|
-
import {
|
|
20
|
+
import { REVERT_SCORE, SCORE_MULTIPLIER, factorOf, finalPrice, scoreOfFactor, worstOf } from "./oracles/score/formula.js";
|
|
21
21
|
import { runAssetScores } from "./oracles/score/run.js";
|
|
22
22
|
import { TreeNode, classifySources, sourcesByFeed } from "./oracles/stress/classify.js";
|
|
23
23
|
import { UNBOUNDED_DOWN, UNBOUNDED_UP, groupOverride, perturb, rateStub, roundDataStub } from "./oracles/stress/override.js";
|
|
24
|
-
import { DEFAULT_SCENARIOS, RATE_FEED_TYPE, readForest, readRateTargets, runStressTest } from "./oracles/stress/run.js";
|
|
24
|
+
import { DEFAULT_SCENARIOS, RATE_FEED_TYPE, readForest, readRateTargets, readUnder, runStressTest } from "./oracles/stress/run.js";
|
|
25
25
|
import { scoreGroup, slotHarm, verdictOf } from "./oracles/stress/score.js";
|
|
26
26
|
import "./oracles/index.js";
|
|
27
27
|
import "./transactions/index.js";
|
|
28
|
-
export { AddFeedsArgs, AssetArgs, AssetCap, AssetScore, AssetScoresArgs, AssetsArgs, AttachChainsArgs,
|
|
28
|
+
export { AddFeedsArgs, AssetArgs, AssetCap, AssetScore, AssetScoresArgs, AssetsArgs, AttachChainsArgs, BreakingPoint, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, DEFAULT_DEPLOY_SALT, DEFAULT_SCENARIOS, DeployArgs, DeployContractArgs, DeployPriceFeedArgs, FeedCap, FeedOutcome, ForbidFeedsArgs, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions, GroupImpact, GroupReport, GroupScenarioOutcome, InstanceOwnerTransactions, InstanceTxsArgs, MarketCap, MarketScore, PermissionlessAnalytics, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetQuota, PermissionlessAssetSummary, PermissionlessChain, PermissionlessChainSummary, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessIndexedAssetDetails, PermissionlessIndexedAssetSummary, PermissionlessIndexedPriceFeedDetails, PermissionlessIndexedPriceFeedMarket, PermissionlessMarket, PermissionlessMarketSlot, PermissionlessNotAttachedError, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedStore, PermissionlessQuotaTotals, PreparedDeployment, PreparedPriceFeedDeployment, PriceChartArgs, PriceFeedArgs, PriceFeedChartPoint, PriceFeedDecimals, PriceFeedNotInStoreError, PriceFeedPair, PriceFeedPrice, PriceFeedPriceChart, PriceFeedRef, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, RATE_FEED_TYPE, REVERT_SCORE, SCORE_MULTIPLIER, ScoredFeed, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs, TreeNode, UNBOUNDED_DOWN, UNBOUNDED_UP, classifySources, deriveEffectiveStalenessPeriod, factorOf, finalPrice, groupOverride, perturb, priceFeedSalt, rateStub, readForest, readRateTargets, readUnder, roundDataStub, runAssetScores, runStressTest, scoreGroup, scoreOfFactor, slotHarm, sourcesByFeed, verdictOf, worstOf };
|
|
@@ -194,17 +194,17 @@ export declare class PermissionlessOracles extends AbstractOffchainNamespace {
|
|
|
194
194
|
/**
|
|
195
195
|
* Every asset's score out of 10 for how its markets guard its price.
|
|
196
196
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
197
|
+
* Each source group behind an asset's feeds — Chainlink, Redstone, Lido and
|
|
198
|
+
* so on — is made in turn to answer five times what it answers now, and a
|
|
199
|
+
* market scores by how far that moves its final price, `min(main,
|
|
200
|
+
* reserve)`: 10 for not at all, 0 for the full five times, on a log scale.
|
|
201
|
+
* A price that stops answering scores 5. An asset scores its worst running
|
|
202
|
+
* market that takes it as collateral.
|
|
203
|
+
*
|
|
204
|
+
* Simulated on the chain as it stands, through state overrides in
|
|
205
|
+
* `eth_call`: one call per source group per chain, so the node behind the
|
|
206
|
+
* client has to accept overrides. A chain with no client configured, or
|
|
207
|
+
* whose node refuses, is left out with a warning rather than failing the
|
|
208
208
|
* rest.
|
|
209
209
|
*
|
|
210
210
|
* ```ts
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { AssetScore, AssetScoresArgs, MarketScore, ScoredFeed } from "./score/types.js";
|
|
1
|
+
import { AssetScore, AssetScoresArgs, GroupImpact, MarketScore, ScoredFeed } from "./score/types.js";
|
|
2
2
|
import { BreakingPoint, FeedOutcome, GroupReport, GroupScenarioOutcome, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs } from "./stress/types.js";
|
|
3
3
|
import { AssetArgs, AssetCap, AssetsArgs, FeedCap, MarketCap, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetQuota, PermissionlessAssetSummary, PermissionlessIndexedAssetDetails, PermissionlessIndexedAssetSummary, PermissionlessIndexedPriceFeedDetails, PermissionlessIndexedPriceFeedMarket, PermissionlessMarket, PermissionlessMarketSlot, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedStore, PermissionlessQuotaTotals, PriceFeedArgs, PriceFeedDecimals, PriceFeedPrice, PriceFeedRef } from "./types.js";
|
|
4
4
|
import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./PermissionlessOracles.js";
|
|
5
|
-
import {
|
|
5
|
+
import { REVERT_SCORE, SCORE_MULTIPLIER, factorOf, finalPrice, scoreOfFactor, worstOf } from "./score/formula.js";
|
|
6
6
|
import { runAssetScores } from "./score/run.js";
|
|
7
7
|
import "./score/index.js";
|
|
8
8
|
import { TreeNode, classifySources, sourcesByFeed } from "./stress/classify.js";
|
|
9
9
|
import { UNBOUNDED_DOWN, UNBOUNDED_UP, groupOverride, perturb, rateStub, roundDataStub } from "./stress/override.js";
|
|
10
|
-
import { DEFAULT_SCENARIOS, RATE_FEED_TYPE, readForest, readRateTargets, runStressTest } from "./stress/run.js";
|
|
10
|
+
import { DEFAULT_SCENARIOS, RATE_FEED_TYPE, readForest, readRateTargets, readUnder, runStressTest } from "./stress/run.js";
|
|
11
11
|
import { scoreGroup, slotHarm, verdictOf } from "./stress/score.js";
|
|
12
12
|
import "./stress/index.js";
|
|
13
|
-
export { AssetArgs, AssetCap, AssetScore, AssetScoresArgs, AssetsArgs,
|
|
13
|
+
export { AssetArgs, AssetCap, AssetScore, AssetScoresArgs, AssetsArgs, BreakingPoint, DEFAULT_SCENARIOS, FeedCap, FeedOutcome, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GroupImpact, GroupReport, GroupScenarioOutcome, MarketCap, MarketScore, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetQuota, PermissionlessAssetSummary, PermissionlessIndexedAssetDetails, PermissionlessIndexedAssetSummary, PermissionlessIndexedPriceFeedDetails, PermissionlessIndexedPriceFeedMarket, PermissionlessMarket, PermissionlessMarketSlot, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedStore, PermissionlessQuotaTotals, PriceFeedArgs, PriceFeedDecimals, PriceFeedPrice, PriceFeedRef, RATE_FEED_TYPE, REVERT_SCORE, SCORE_MULTIPLIER, ScoredFeed, SlotOutcome, StressReport, StressScenario, StressSource, StressSourceKind, StressTestArgs, TreeNode, UNBOUNDED_DOWN, UNBOUNDED_UP, classifySources, factorOf, finalPrice, groupOverride, perturb, rateStub, readForest, readRateTargets, readUnder, roundDataStub, runAssetScores, runStressTest, scoreGroup, scoreOfFactor, slotHarm, sourcesByFeed, verdictOf, worstOf };
|
|
@@ -1,46 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GroupImpact } from "./types.js";
|
|
2
2
|
//#region src/permissionless/api/oracles/score/formula.d.ts
|
|
3
|
+
/** What every source of a group is made to answer, as a multiple of now. */
|
|
4
|
+
export declare const SCORE_MULTIPLIER = 5;
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* The score of a price that stops answering under the lie.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* - Would the reserve disagree with a main feed that has gone wrong? Only if
|
|
9
|
-
* it is a second feed on other sources. A missing reserve, a
|
|
10
|
-
* `ZeroPriceFeed`, the main feed again, and a different feed on the same
|
|
11
|
-
* sources all answer no.
|
|
12
|
-
* - Is either feed bounded? A `BoundedPriceFeed` caps the answer from above,
|
|
13
|
-
* and a Gearbox LP feed clamps its exchange rate to a window.
|
|
14
|
-
*
|
|
15
|
-
* Independence costs more than the bound, 6 points against 5, because it is
|
|
16
|
-
* the broader protection: a bounded feed caps only from above, and an LP
|
|
17
|
-
* feed's window holds only its rate, not the price of what the rate is in.
|
|
18
|
-
* Either failure alone lands a market at 4 or 5; both together at 0.
|
|
8
|
+
* Half marks: nobody can borrow against a wrong number, but nobody can be
|
|
9
|
+
* liquidated either until the feed is replaced.
|
|
19
10
|
*/
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const BOUND_WEIGHT = 5;
|
|
22
|
-
/** A source, as the overlap between two feeds is counted. */
|
|
23
|
-
export interface ScoreSource {
|
|
24
|
-
/** What two feeds have to share to be on the same source. */
|
|
25
|
-
key: string;
|
|
26
|
-
/** What a reader is told. */
|
|
27
|
-
name: string;
|
|
28
|
-
/** A source the classifier named, rather than one grouped alone. */
|
|
29
|
-
identified: boolean;
|
|
30
|
-
}
|
|
11
|
+
export declare const REVERT_SCORE = 5;
|
|
31
12
|
/**
|
|
32
|
-
*
|
|
13
|
+
* 0 to 10 by how far the final price moved, on a log scale against the lie
|
|
14
|
+
* itself: 10 for a price that did not move, 0 for one that moved by the full
|
|
15
|
+
* {@link SCORE_MULTIPLIER} or more, either way. Rounded to a half point.
|
|
33
16
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
17
|
+
* A bound holding a price within a few percent keeps a 10; a price that let
|
|
18
|
+
* half the lie through, ×√5, scores 5.
|
|
19
|
+
*/
|
|
20
|
+
export declare function scoreOfFactor(factor: number | null): number;
|
|
21
|
+
/**
|
|
22
|
+
* The price a market settles on: the lower of main and reserve, or the main
|
|
23
|
+
* feed's alone where there is no reserve to compare it with. `null` where a
|
|
24
|
+
* feed it needs does not answer.
|
|
25
|
+
*/
|
|
26
|
+
export declare function finalPrice(main: bigint | null, reserve: bigint | null | undefined): bigint | null;
|
|
27
|
+
/** `stressed / base` as a float, `null` where the stressed price is gone. */
|
|
28
|
+
export declare function factorOf(base: bigint, stressed: bigint | null): number | null;
|
|
29
|
+
/**
|
|
30
|
+
* The market's score and the group it comes from: the lowest of its groups,
|
|
31
|
+
* ties going to the group that moved the price further. 10 where no source
|
|
32
|
+
* feeds the price at all, since nothing can be made to lie about it.
|
|
38
33
|
*/
|
|
39
|
-
export declare function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
sources: ScoreSource[];
|
|
45
|
-
} | null): MarketScore;
|
|
34
|
+
export declare function worstOf(impacts: GroupImpact[]): {
|
|
35
|
+
score: number;
|
|
36
|
+
impacts: GroupImpact[];
|
|
37
|
+
worst: GroupImpact | null;
|
|
38
|
+
};
|
|
46
39
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetScore, AssetScoresArgs, MarketScore, ScoredFeed } from "./types.js";
|
|
2
|
-
import {
|
|
1
|
+
import { AssetScore, AssetScoresArgs, GroupImpact, MarketScore, ScoredFeed } from "./types.js";
|
|
2
|
+
import { REVERT_SCORE, SCORE_MULTIPLIER, factorOf, finalPrice, scoreOfFactor, worstOf } from "./formula.js";
|
|
3
3
|
import { runAssetScores } from "./run.js";
|
|
4
|
-
export { AssetScore, AssetScoresArgs,
|
|
4
|
+
export { AssetScore, AssetScoresArgs, GroupImpact, MarketScore, REVERT_SCORE, SCORE_MULTIPLIER, ScoredFeed, factorOf, finalPrice, runAssetScores, scoreOfFactor, worstOf };
|
|
@@ -3,11 +3,14 @@ import { PermissionlessMarketSlot } from "../types.js";
|
|
|
3
3
|
import { Address, Chain, PublicClient, Transport } from "viem";
|
|
4
4
|
//#region src/permissionless/api/oracles/score/run.d.ts
|
|
5
5
|
/**
|
|
6
|
-
* Every asset of one chain, scored by
|
|
6
|
+
* Every asset of one chain, scored by what each of its source groups can do
|
|
7
|
+
* to the price its running markets hold for it.
|
|
7
8
|
*
|
|
8
|
-
* One read of
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* One read of the oracles' feed trees, one of the LP feeds' rate contracts,
|
|
10
|
+
* one of every market feed as it stands — then one `eth_call` per source
|
|
11
|
+
* group, with the group's sources overridden to answer
|
|
12
|
+
* {@link SCORE_MULTIPLIER} times what they answer now and every market feed
|
|
13
|
+
* read under it.
|
|
11
14
|
**/
|
|
12
15
|
export declare function runAssetScores({ client, chainId, slots, compressor, logger }: {
|
|
13
16
|
client: PublicClient<Transport, Chain>;
|