@gearbox-protocol/sdk 3.0.0-vfourabi.1 → 3.0.0-vfourabi.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +3 -0
- package/.github/workflows/lint_pr.yml +18 -0
- package/.github/workflows/pr.yml +39 -0
- package/.github/workflows/release.yml +47 -0
- package/.gitignore +19 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/.nvmrc +1 -0
- package/.releaserc.json +34 -0
- package/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +16 -0
- package/.yarn/install-state.gz +0 -0
- package/.yarnrc.yml +1 -0
- package/ContributionAgreement +72 -0
- package/dist/cjs/abi/iZapper.cjs +85 -0
- package/dist/cjs/abi/iZapper.d.ts +123 -0
- package/dist/cjs/sdk/index.cjs +19830 -19764
- package/dist/cjs/sdk/index.d.ts +3746 -3061
- package/dist/esm/abi/iZapper.d.mts +123 -0
- package/dist/esm/abi/iZapper.mjs +83 -0
- package/dist/esm/sdk/index.d.mts +3746 -3061
- package/dist/esm/sdk/index.mjs +19807 -19765
- package/jest.config.js +7 -0
- package/package.json +32 -2
- package/scripts/example.ts +30 -0
- package/src/abi/compressors.ts +3962 -0
- package/src/abi/errors.ts +196 -0
- package/src/abi/iERC20.ts +122 -0
- package/src/abi/iPausable.ts +35 -0
- package/src/abi/iPriceFeedStore.ts +227 -0
- package/src/abi/iUpdatablePriceFeed.ts +16 -0
- package/src/abi/iVersion.ts +28 -0
- package/src/abi/iZapper.ts +84 -0
- package/src/abi/routerV300.ts +378 -0
- package/src/abi/v300.ts +4151 -0
- package/src/abi/v310.ts +5179 -0
- package/src/adapters/AbstractAdapter.ts +28 -0
- package/src/adapters/BalancerV2VaultAdapterContract.ts +19 -0
- package/src/adapters/BalancerV3RouterAdapterContract.ts +19 -0
- package/src/adapters/CamelotV3AdapterContract.ts +20 -0
- package/src/adapters/ConvexV1BaseRewardPoolAdapterContract.ts +20 -0
- package/src/adapters/ConvexV1BoosterAdapterContract.ts +20 -0
- package/src/adapters/Curve2AssetsAdapterContract.ts +20 -0
- package/src/adapters/Curve3AssetsAdapterContract.ts +20 -0
- package/src/adapters/Curve4AssetsAdapterContract.ts +20 -0
- package/src/adapters/CurveV1AdapterStETHContract.ts +20 -0
- package/src/adapters/CurveV1StableNGAdapterContract.ts +20 -0
- package/src/adapters/DaiUsdsAdapterContract.ts +21 -0
- package/src/adapters/ERC4626AdapterContract.ts +20 -0
- package/src/adapters/MellowERC4626VaultAdapterContract.ts +20 -0
- package/src/adapters/MellowVaultAdapterContract.ts +20 -0
- package/src/adapters/PendleRouterAdapterContract.ts +21 -0
- package/src/adapters/StakingRewardsAdapterContract.ts +21 -0
- package/src/adapters/UniswapV2AdapterContract.ts +20 -0
- package/src/adapters/UniswapV3AdapterContract.ts +170 -0
- package/src/adapters/VelodromeV2AdapterContract.ts +20 -0
- package/src/adapters/WstETHV1AdapterContract.ts +20 -0
- package/src/adapters/YearnV2AdapterContract.ts +20 -0
- package/src/adapters/abi/adapters.ts +4325 -0
- package/src/adapters/abi/iBalancerV3RouterAdapter.ts +126 -0
- package/src/adapters/abi/index.ts +2 -0
- package/src/adapters/index.ts +2 -0
- package/src/adapters/plugin.ts +90 -0
- package/src/adapters/types.ts +62 -0
- package/src/dev/AccountOpener.ts +611 -0
- package/src/dev/PriceFeedStore.ts +95 -0
- package/src/dev/SDKExample.ts +167 -0
- package/src/dev/abi.ts +14 -0
- package/src/dev/calcLiquidatableLTs.ts +77 -0
- package/src/dev/createAnvilClient.ts +155 -0
- package/src/dev/index.ts +7 -0
- package/src/dev/setLTZero.ts +127 -0
- package/src/dev/setLTs.ts +68 -0
- package/src/sdk/GearboxSDK.ts +488 -0
- package/src/sdk/abi/index.ts +1 -0
- package/src/sdk/abi/oracles.ts +4614 -0
- package/src/sdk/accounts/CreditAccountsService.ts +1123 -0
- package/src/sdk/accounts/index.ts +1 -0
- package/src/sdk/base/AddressLabeller.ts +35 -0
- package/src/sdk/base/BaseContract.ts +237 -0
- package/src/sdk/base/IAddressLabeller.ts +13 -0
- package/src/sdk/base/PlaceholderContract.ts +12 -0
- package/src/sdk/base/SDKConstruct.ts +35 -0
- package/src/sdk/base/TokensMeta.ts +45 -0
- package/src/sdk/base/index.ts +6 -0
- package/src/sdk/base/types.ts +102 -0
- package/src/sdk/bots/BotsService.ts +92 -0
- package/src/sdk/bots/index.ts +2 -0
- package/src/sdk/bots/utils.ts +19 -0
- package/src/sdk/chain/Provider.ts +99 -0
- package/src/sdk/chain/chains.ts +41 -0
- package/src/sdk/chain/detectChain.ts +21 -0
- package/src/sdk/chain/index.ts +3 -0
- package/src/sdk/constants/address-provider.ts +47 -0
- package/src/sdk/constants/addresses.ts +82 -0
- package/src/sdk/constants/bot-permissions.ts +36 -0
- package/src/sdk/constants/index.ts +6 -0
- package/src/sdk/constants/math.ts +23 -0
- package/src/sdk/constants/networks.ts +38 -0
- package/src/sdk/constants/periphery.ts +7 -0
- package/src/sdk/core/BotListV3Contract.ts +103 -0
- package/src/sdk/core/GearStakingV3Contract.ts +84 -0
- package/src/sdk/core/address-provider/AbstractAddressProviderContract.ts +101 -0
- package/src/sdk/core/address-provider/AddressProviderV3Contract.ts +105 -0
- package/src/sdk/core/address-provider/AddressProviderV3_1Contract.ts +92 -0
- package/src/sdk/core/address-provider/getAddressProvider.ts +45 -0
- package/src/sdk/core/address-provider/index.ts +4 -0
- package/src/sdk/core/address-provider/types.ts +17 -0
- package/src/sdk/core/index.ts +3 -0
- package/src/sdk/gauges/GaugeStakingService.ts +100 -0
- package/src/sdk/gauges/index.ts +2 -0
- package/src/sdk/gauges/utils.ts +25 -0
- package/src/sdk/index.ts +17 -0
- package/src/sdk/market/MarketConfiguratorContract.ts +78 -0
- package/src/sdk/market/MarketRegister.ts +330 -0
- package/src/sdk/market/MarketSuite.ts +83 -0
- package/src/sdk/market/adapters/PlaceholderAdapterContracts.ts +18 -0
- package/src/sdk/market/adapters/factory.ts +34 -0
- package/src/sdk/market/adapters/index.ts +3 -0
- package/src/sdk/market/adapters/types.ts +7 -0
- package/src/sdk/market/credit/CreditConfiguratorV300Contract.ts +164 -0
- package/src/sdk/market/credit/CreditConfiguratorV310Contract.ts +139 -0
- package/src/sdk/market/credit/CreditFacadeV300Contract.ts +206 -0
- package/src/sdk/market/credit/CreditFacadeV310Contract.ts +190 -0
- package/src/sdk/market/credit/CreditManagerV300Contract.ts +122 -0
- package/src/sdk/market/credit/CreditManagerV310Contract.ts +122 -0
- package/src/sdk/market/credit/CreditSuite.ts +65 -0
- package/src/sdk/market/credit/createCreditConfigurator.ts +18 -0
- package/src/sdk/market/credit/createCreditFacade.ts +18 -0
- package/src/sdk/market/credit/createCreditManager.ts +18 -0
- package/src/sdk/market/credit/index.ts +8 -0
- package/src/sdk/market/credit/types.ts +42 -0
- package/src/sdk/market/index.ts +7 -0
- package/src/sdk/market/oracle/PriceOracleBaseContract.ts +376 -0
- package/src/sdk/market/oracle/PriceOracleV300Contract.ts +71 -0
- package/src/sdk/market/oracle/PriceOracleV310Contract.ts +43 -0
- package/src/sdk/market/oracle/createPriceOracle.ts +22 -0
- package/src/sdk/market/oracle/index.ts +4 -0
- package/src/sdk/market/oracle/types.ts +48 -0
- package/src/sdk/market/pool/GaugeContract.ts +120 -0
- package/src/sdk/market/pool/LinearInterestRateModelContract.ts +75 -0
- package/src/sdk/market/pool/PoolQuotaKeeperV300Contract.ts +89 -0
- package/src/sdk/market/pool/PoolQuotaKeeperV310Contract.ts +89 -0
- package/src/sdk/market/pool/PoolSuite.ts +76 -0
- package/src/sdk/market/pool/PoolV300Contract.ts +144 -0
- package/src/sdk/market/pool/PoolV310Contract.ts +144 -0
- package/src/sdk/market/pool/TumblerContract.ts +73 -0
- package/src/sdk/market/pool/createInterestRateModel.ts +33 -0
- package/src/sdk/market/pool/createPool.ts +19 -0
- package/src/sdk/market/pool/createPoolQuotaKeeper.ts +20 -0
- package/src/sdk/market/pool/createRateKeeper.ts +25 -0
- package/src/sdk/market/pool/index.ts +6 -0
- package/src/sdk/market/pool/types.ts +28 -0
- package/src/sdk/market/pricefeeds/AbstractLPPriceFeed.ts +71 -0
- package/src/sdk/market/pricefeeds/AbstractPriceFeed.ts +137 -0
- package/src/sdk/market/pricefeeds/BalancerStablePriceFeed.ts +24 -0
- package/src/sdk/market/pricefeeds/BalancerWeightedPriceFeed.ts +70 -0
- package/src/sdk/market/pricefeeds/BoundedPriceFeed.ts +34 -0
- package/src/sdk/market/pricefeeds/ChainlinkPriceFeed.ts +16 -0
- package/src/sdk/market/pricefeeds/CompositePriceFeed.ts +25 -0
- package/src/sdk/market/pricefeeds/CurveCryptoPriceFeed.ts +24 -0
- package/src/sdk/market/pricefeeds/CurveStablePriceFeed.ts +24 -0
- package/src/sdk/market/pricefeeds/CurveUSDPriceFeed.ts +24 -0
- package/src/sdk/market/pricefeeds/Erc4626PriceFeed.ts +36 -0
- package/src/sdk/market/pricefeeds/MellowLRTPriceFeed.ts +26 -0
- package/src/sdk/market/pricefeeds/PendleTWAPPTPriceFeed.ts +44 -0
- package/src/sdk/market/pricefeeds/PriceFeedRef.ts +34 -0
- package/src/sdk/market/pricefeeds/PriceFeedsRegister.ts +293 -0
- package/src/sdk/market/pricefeeds/RedstonePriceFeed.ts +65 -0
- package/src/sdk/market/pricefeeds/RedstoneUpdater.ts +304 -0
- package/src/sdk/market/pricefeeds/WstETHPriceFeed.ts +24 -0
- package/src/sdk/market/pricefeeds/YearnPriceFeed.ts +24 -0
- package/src/sdk/market/pricefeeds/ZeroPriceFeed.ts +17 -0
- package/src/sdk/market/pricefeeds/index.ts +20 -0
- package/src/sdk/market/pricefeeds/types.ts +82 -0
- package/src/sdk/market/pricefeeds/utils.ts +24 -0
- package/src/sdk/plugins/index.ts +10 -0
- package/src/sdk/router/PathOptionFactory.ts +147 -0
- package/src/sdk/router/RouterV3Contract.ts +558 -0
- package/src/sdk/router/index.ts +2 -0
- package/src/sdk/router/types.ts +48 -0
- package/src/sdk/sdk-gov-legacy/contracts/adapters.ts +39 -0
- package/src/sdk/sdk-gov-legacy/contracts/contracts.ts +647 -0
- package/src/sdk/sdk-gov-legacy/contracts/index.ts +2 -0
- package/src/sdk/sdk-gov-legacy/core/constants.ts +11 -0
- package/src/sdk/sdk-gov-legacy/index.ts +4 -0
- package/src/sdk/sdk-gov-legacy/oracles/PriceFeedType.ts +24 -0
- package/src/sdk/sdk-gov-legacy/oracles/index.ts +1 -0
- package/src/sdk/sdk-gov-legacy/tokens/aave.ts +101 -0
- package/src/sdk/sdk-gov-legacy/tokens/aura.ts +284 -0
- package/src/sdk/sdk-gov-legacy/tokens/balancer.ts +421 -0
- package/src/sdk/sdk-gov-legacy/tokens/compound.ts +79 -0
- package/src/sdk/sdk-gov-legacy/tokens/convex.ts +561 -0
- package/src/sdk/sdk-gov-legacy/tokens/curveLP.ts +480 -0
- package/src/sdk/sdk-gov-legacy/tokens/decimals.ts +301 -0
- package/src/sdk/sdk-gov-legacy/tokens/erc4626.ts +75 -0
- package/src/sdk/sdk-gov-legacy/tokens/gear.ts +273 -0
- package/src/sdk/sdk-gov-legacy/tokens/index.ts +18 -0
- package/src/sdk/sdk-gov-legacy/tokens/normal.ts +613 -0
- package/src/sdk/sdk-gov-legacy/tokens/quoted.ts +10 -0
- package/src/sdk/sdk-gov-legacy/tokens/stakingRewards.ts +41 -0
- package/src/sdk/sdk-gov-legacy/tokens/token.ts +2354 -0
- package/src/sdk/sdk-gov-legacy/tokens/tokenData.ts +44 -0
- package/src/sdk/sdk-gov-legacy/tokens/tokenType.ts +33 -0
- package/src/sdk/sdk-gov-legacy/tokens/wrapped.ts +28 -0
- package/src/sdk/sdk-gov-legacy/tokens/yearn.ts +122 -0
- package/src/sdk/sdk-gov-legacy/tokens/zircuit.ts +44 -0
- package/src/sdk/sdk-legacy/apy/index.ts +149 -0
- package/src/sdk/sdk-legacy/core/assets.ts +200 -0
- package/src/sdk/sdk-legacy/core/creditAccount.spec.ts +1966 -0
- package/src/sdk/sdk-legacy/core/creditAccount.ts +816 -0
- package/src/sdk/sdk-legacy/core/creditManager.ts +316 -0
- package/src/sdk/sdk-legacy/core/creditSession.ts +352 -0
- package/src/sdk/sdk-legacy/core/endpoint.ts +131 -0
- package/src/sdk/sdk-legacy/core/eventOrTx.ts +101 -0
- package/src/sdk/sdk-legacy/core/pool.ts +439 -0
- package/src/sdk/sdk-legacy/core/strategy.ts +82 -0
- package/src/sdk/sdk-legacy/core/transactions.ts +865 -0
- package/src/sdk/sdk-legacy/gearboxRewards/api.ts +704 -0
- package/src/sdk/sdk-legacy/gearboxRewards/apy.ts +267 -0
- package/src/sdk/sdk-legacy/gearboxRewards/extraAPY.ts +165 -0
- package/src/sdk/sdk-legacy/gearboxRewards/index.ts +3 -0
- package/src/sdk/sdk-legacy/gearboxRewards/merklAPI.ts +151 -0
- package/src/sdk/sdk-legacy/index.ts +21 -0
- package/src/sdk/sdk-legacy/pathfinder/core.ts +18 -0
- package/src/sdk/sdk-legacy/pathfinder/index.ts +1 -0
- package/src/sdk/sdk-legacy/payload/creditAccount.ts +48 -0
- package/src/sdk/sdk-legacy/payload/creditManager.ts +133 -0
- package/src/sdk/sdk-legacy/payload/creditSession.ts +143 -0
- package/src/sdk/sdk-legacy/payload/graphPayload.ts +10 -0
- package/src/sdk/sdk-legacy/payload/pool.ts +198 -0
- package/src/sdk/sdk-legacy/payload/token.ts +13 -0
- package/src/sdk/sdk-legacy/tokens/tokenData.ts +57 -0
- package/src/sdk/sdk-legacy/types/IAirdropDistributor.ts +103 -0
- package/src/sdk/sdk-legacy/types/IBaseRewardPool.ts +249 -0
- package/src/sdk/sdk-legacy/types/IDataCompressorV3.ts +957 -0
- package/src/sdk/sdk-legacy/types/IDegenDistributor.ts +70 -0
- package/src/sdk/sdk-legacy/types/IERC20Permit.ts +35 -0
- package/src/sdk/sdk-legacy/types/IERC20ZapperDeposits.ts +99 -0
- package/src/sdk/sdk-legacy/types/IETHZapperDeposits.ts +27 -0
- package/src/sdk/sdk-legacy/types/IFarmingPool.ts +229 -0
- package/src/sdk/sdk-legacy/types/IInterestRateModel.ts +23 -0
- package/src/sdk/sdk-legacy/types/IMulticall3.ts +242 -0
- package/src/sdk/sdk-legacy/types/IOffchainOracle.ts +31 -0
- package/src/sdk/sdk-legacy/types/index.ts +11 -0
- package/src/sdk/sdk-legacy/utils/formatter.ts +46 -0
- package/src/sdk/sdk-legacy/utils/index.ts +3 -0
- package/src/sdk/sdk-legacy/utils/math.ts +6 -0
- package/src/sdk/sdk-legacy/utils/price.ts +27 -0
- package/src/sdk/types/index.ts +5 -0
- package/src/sdk/types/logger.ts +13 -0
- package/src/sdk/types/state-human.ts +224 -0
- package/src/sdk/types/state.ts +8 -0
- package/src/sdk/types/transactions.ts +22 -0
- package/src/sdk/types/tvl.ts +4 -0
- package/src/sdk/utils/AddressMap.ts +111 -0
- package/src/sdk/utils/bytes32ToString.ts +6 -0
- package/src/sdk/utils/childLogger.ts +8 -0
- package/src/sdk/utils/createRawTx.ts +86 -0
- package/src/sdk/utils/etherscan.ts +42 -0
- package/src/sdk/utils/filterDust.ts +20 -0
- package/src/sdk/utils/formatter.ts +124 -0
- package/src/sdk/utils/index.ts +10 -0
- package/src/sdk/utils/internal/Hooks.ts +51 -0
- package/src/sdk/utils/internal/index.ts +1 -0
- package/src/sdk/utils/json.ts +27 -0
- package/src/sdk/utils/mappers.ts +38 -0
- package/src/sdk/utils/retry.ts +24 -0
- package/src/sdk/utils/viem/detectNetwork.ts +27 -0
- package/src/sdk/utils/viem/index.ts +3 -0
- package/src/sdk/utils/viem/sendRawTx.ts +36 -0
- package/src/sdk/utils/viem/simulateMulticall.ts +262 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +16 -0
- package/tsup.config.ts +77 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Address, ContractEventName, Log } from "viem";
|
|
2
|
+
|
|
3
|
+
import { iPausableAbi } from "../../../abi/iPausable";
|
|
4
|
+
import { iPriceOracleV300Abi } from "../../../abi/v300";
|
|
5
|
+
import type { PriceOracleData } from "../../base";
|
|
6
|
+
import type { GearboxSDK } from "../../GearboxSDK";
|
|
7
|
+
import { tickerInfoTokensByNetwork } from "../../sdk-gov-legacy";
|
|
8
|
+
import { PriceOracleBaseContract } from "./PriceOracleBaseContract";
|
|
9
|
+
|
|
10
|
+
const abi = [...iPriceOracleV300Abi, ...iPausableAbi];
|
|
11
|
+
type abi = typeof abi;
|
|
12
|
+
|
|
13
|
+
export class PriceOracleV300Contract extends PriceOracleBaseContract<abi> {
|
|
14
|
+
constructor(sdk: GearboxSDK, data: PriceOracleData, underlying: Address) {
|
|
15
|
+
super(
|
|
16
|
+
sdk,
|
|
17
|
+
{
|
|
18
|
+
...data.baseParams,
|
|
19
|
+
name: "PriceOracleV3",
|
|
20
|
+
abi,
|
|
21
|
+
},
|
|
22
|
+
data,
|
|
23
|
+
underlying,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public override processLog(
|
|
28
|
+
log: Log<
|
|
29
|
+
bigint,
|
|
30
|
+
number,
|
|
31
|
+
false,
|
|
32
|
+
undefined,
|
|
33
|
+
undefined,
|
|
34
|
+
abi,
|
|
35
|
+
ContractEventName<abi>
|
|
36
|
+
>,
|
|
37
|
+
): void {
|
|
38
|
+
switch (log.eventName) {
|
|
39
|
+
case "Paused":
|
|
40
|
+
case "Unpaused":
|
|
41
|
+
break;
|
|
42
|
+
case "SetPriceFeed":
|
|
43
|
+
case "SetReservePriceFeed":
|
|
44
|
+
case "SetReservePriceFeedStatus":
|
|
45
|
+
this.dirty = true;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected override findTokenForPriceFeed(
|
|
51
|
+
priceFeed: Address,
|
|
52
|
+
): [token: Address | undefined, reserve: boolean] {
|
|
53
|
+
const [token, reserve] = super.findTokenForPriceFeed(priceFeed);
|
|
54
|
+
if (token) {
|
|
55
|
+
return [token, reserve];
|
|
56
|
+
}
|
|
57
|
+
const tickers = Object.values(
|
|
58
|
+
tickerInfoTokensByNetwork[this.sdk.provider.networkType],
|
|
59
|
+
).flat();
|
|
60
|
+
const ticker = tickers.find(
|
|
61
|
+
t => t.priceFeed.toLowerCase() === priceFeed.toLowerCase(),
|
|
62
|
+
);
|
|
63
|
+
if (ticker) {
|
|
64
|
+
this.logger?.debug(
|
|
65
|
+
`will use ticker ${ticker.symbol} (${ticker.address}) for price feed ${priceFeed}`,
|
|
66
|
+
);
|
|
67
|
+
return [ticker.address, false];
|
|
68
|
+
}
|
|
69
|
+
return [undefined, false];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Address, ContractEventName, Log } from "viem";
|
|
2
|
+
|
|
3
|
+
import { iPriceOracleV310Abi } from "../../../abi/v310";
|
|
4
|
+
import type { PriceOracleData } from "../../base";
|
|
5
|
+
import type { GearboxSDK } from "../../GearboxSDK";
|
|
6
|
+
import { PriceOracleBaseContract } from "./PriceOracleBaseContract";
|
|
7
|
+
|
|
8
|
+
const abi = iPriceOracleV310Abi;
|
|
9
|
+
type abi = typeof abi;
|
|
10
|
+
|
|
11
|
+
export class PriceOracleV310Contract extends PriceOracleBaseContract<abi> {
|
|
12
|
+
constructor(sdk: GearboxSDK, data: PriceOracleData, underlying: Address) {
|
|
13
|
+
super(
|
|
14
|
+
sdk,
|
|
15
|
+
{
|
|
16
|
+
...data.baseParams,
|
|
17
|
+
name: "PriceOracleV3",
|
|
18
|
+
abi,
|
|
19
|
+
},
|
|
20
|
+
data,
|
|
21
|
+
underlying,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public override processLog(
|
|
26
|
+
log: Log<
|
|
27
|
+
bigint,
|
|
28
|
+
number,
|
|
29
|
+
false,
|
|
30
|
+
undefined,
|
|
31
|
+
undefined,
|
|
32
|
+
abi,
|
|
33
|
+
ContractEventName<abi>
|
|
34
|
+
>,
|
|
35
|
+
): void {
|
|
36
|
+
switch (log.eventName) {
|
|
37
|
+
case "SetPriceFeed":
|
|
38
|
+
case "SetReservePriceFeed":
|
|
39
|
+
this.dirty = true;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Address } from "abitype";
|
|
2
|
+
|
|
3
|
+
import type { PriceOracleData } from "../../base";
|
|
4
|
+
import type { GearboxSDK } from "../../GearboxSDK";
|
|
5
|
+
import { PriceOracleV300Contract } from "./PriceOracleV300Contract";
|
|
6
|
+
import { PriceOracleV310Contract } from "./PriceOracleV310Contract";
|
|
7
|
+
import type { PriceOracleContract } from "./types";
|
|
8
|
+
|
|
9
|
+
export function createPriceOracle(
|
|
10
|
+
sdk: GearboxSDK,
|
|
11
|
+
data: PriceOracleData,
|
|
12
|
+
underlying: Address,
|
|
13
|
+
): PriceOracleContract {
|
|
14
|
+
const v = data.baseParams.version;
|
|
15
|
+
if (v >= 300n && v < 310n) {
|
|
16
|
+
return new PriceOracleV300Contract(sdk, data, underlying);
|
|
17
|
+
}
|
|
18
|
+
if (v === 310n) {
|
|
19
|
+
return new PriceOracleV310Contract(sdk, data, underlying);
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`Unsupported oracle version ${v}`);
|
|
22
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
|
|
3
|
+
import type { IBaseContract } from "../../base";
|
|
4
|
+
import type { PriceOracleV310Contract } from "..";
|
|
5
|
+
import type { IPriceFeedContract, UpdatePriceFeedsResult } from "../pricefeeds";
|
|
6
|
+
import type { PriceOracleV300Contract } from "./PriceOracleV300Contract";
|
|
7
|
+
|
|
8
|
+
export type PriceOracleContract =
|
|
9
|
+
| PriceOracleV300Contract
|
|
10
|
+
| PriceOracleV310Contract;
|
|
11
|
+
|
|
12
|
+
export interface PriceFeedsForTokensOptions {
|
|
13
|
+
main?: boolean;
|
|
14
|
+
reserve?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Data to be passed to credit facade's multicall
|
|
19
|
+
* Compatible with both v300 and v310 facades
|
|
20
|
+
*/
|
|
21
|
+
export interface OnDemandPriceUpdate {
|
|
22
|
+
priceFeed: Address;
|
|
23
|
+
token: Address;
|
|
24
|
+
reserve: boolean;
|
|
25
|
+
data: Hex;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IPriceOracleContract extends IBaseContract {
|
|
29
|
+
priceFeedsForTokens: (
|
|
30
|
+
tokens: Address[],
|
|
31
|
+
opts?: PriceFeedsForTokensOptions,
|
|
32
|
+
) => IPriceFeedContract[];
|
|
33
|
+
updatePriceFeeds: () => Promise<UpdatePriceFeedsResult>;
|
|
34
|
+
onDemandPriceUpdates: (
|
|
35
|
+
updates?: UpdatePriceFeedsResult,
|
|
36
|
+
) => OnDemandPriceUpdate[];
|
|
37
|
+
convertToUnderlying: (
|
|
38
|
+
token: Address,
|
|
39
|
+
amount: bigint,
|
|
40
|
+
reserve?: boolean,
|
|
41
|
+
) => bigint;
|
|
42
|
+
convert: (
|
|
43
|
+
from: Address,
|
|
44
|
+
to: Address,
|
|
45
|
+
amount: bigint,
|
|
46
|
+
reserve?: boolean,
|
|
47
|
+
) => bigint;
|
|
48
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { ContractEventName, Log } from "viem";
|
|
2
|
+
import { decodeAbiParameters } from "viem";
|
|
3
|
+
|
|
4
|
+
import { iGaugeV300Abi } from "../../../abi/v300";
|
|
5
|
+
import type { PoolData, RateKeeperData } from "../../base";
|
|
6
|
+
import { BaseContract } from "../../base";
|
|
7
|
+
import { WAD } from "../../constants";
|
|
8
|
+
import type { GearboxSDK } from "../../GearboxSDK";
|
|
9
|
+
import type { GaugeStateHuman } from "../../types";
|
|
10
|
+
import { AddressMap, percentFmt } from "../../utils";
|
|
11
|
+
import type { IRateKeeperContract } from "./types";
|
|
12
|
+
|
|
13
|
+
const abi = iGaugeV300Abi;
|
|
14
|
+
type abi = typeof abi;
|
|
15
|
+
|
|
16
|
+
export interface GaugeParams {
|
|
17
|
+
minRate: number;
|
|
18
|
+
maxRate: number;
|
|
19
|
+
totalVotesLpSide: bigint;
|
|
20
|
+
totalVotesCaSide: bigint;
|
|
21
|
+
rate: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class GaugeContract
|
|
25
|
+
extends BaseContract<abi>
|
|
26
|
+
implements IRateKeeperContract
|
|
27
|
+
{
|
|
28
|
+
public readonly quotaParams: AddressMap<GaugeParams>;
|
|
29
|
+
public readonly epochFrozen: boolean;
|
|
30
|
+
public readonly epochLastUpdate: number;
|
|
31
|
+
public readonly rates: AddressMap<number>;
|
|
32
|
+
|
|
33
|
+
constructor(sdk: GearboxSDK, pool: PoolData, gauge: RateKeeperData) {
|
|
34
|
+
super(sdk, {
|
|
35
|
+
...gauge.baseParams,
|
|
36
|
+
name: `Gauge(${pool.name})`,
|
|
37
|
+
abi: iGaugeV300Abi,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const [_voter, epochLastUpdate, epochFrozen, gaugeTokens, gaugeParams] =
|
|
41
|
+
decodeAbiParameters(
|
|
42
|
+
[
|
|
43
|
+
{ name: "voter", type: "address" },
|
|
44
|
+
{ name: "epochLastUpdate", type: "uint16" },
|
|
45
|
+
{ name: "epochFrozen", type: "bool" },
|
|
46
|
+
{ name: "tokens", type: "address[]" },
|
|
47
|
+
{
|
|
48
|
+
name: "quotaParams",
|
|
49
|
+
type: "tuple[]",
|
|
50
|
+
components: [
|
|
51
|
+
{ name: "minRate", type: "uint16" },
|
|
52
|
+
{ name: "maxRate", type: "uint16" },
|
|
53
|
+
{ name: "totalVotesLpSide", type: "uint96" },
|
|
54
|
+
{ name: "totalVotesCaSide", type: "uint96" },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
gauge.baseParams.serializedParams,
|
|
59
|
+
);
|
|
60
|
+
this.epochFrozen = epochFrozen;
|
|
61
|
+
this.epochLastUpdate = epochLastUpdate;
|
|
62
|
+
this.rates = new AddressMap(gauge.rates.map(r => [r.token, r.rate]));
|
|
63
|
+
this.quotaParams = new AddressMap();
|
|
64
|
+
for (let i = 0; i < gaugeParams.length; i++) {
|
|
65
|
+
const token = gaugeTokens[i];
|
|
66
|
+
const params = gaugeParams[i];
|
|
67
|
+
this.quotaParams.upsert(token, {
|
|
68
|
+
minRate: params.minRate,
|
|
69
|
+
maxRate: params.maxRate,
|
|
70
|
+
totalVotesLpSide: params.totalVotesLpSide,
|
|
71
|
+
totalVotesCaSide: params.totalVotesCaSide,
|
|
72
|
+
rate: this.rates.get(token) ?? 0,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public override processLog(
|
|
78
|
+
log: Log<
|
|
79
|
+
bigint,
|
|
80
|
+
number,
|
|
81
|
+
false,
|
|
82
|
+
undefined,
|
|
83
|
+
undefined,
|
|
84
|
+
abi,
|
|
85
|
+
ContractEventName<abi>
|
|
86
|
+
>,
|
|
87
|
+
): void {
|
|
88
|
+
switch (log.eventName) {
|
|
89
|
+
case "AddQuotaToken":
|
|
90
|
+
case "SetFrozenEpoch":
|
|
91
|
+
case "SetQuotaTokenParams":
|
|
92
|
+
case "Unvote":
|
|
93
|
+
case "UpdateEpoch":
|
|
94
|
+
case "Vote":
|
|
95
|
+
this.dirty = true;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public override stateHuman(raw?: boolean): GaugeStateHuman {
|
|
101
|
+
return {
|
|
102
|
+
...super.stateHuman(raw),
|
|
103
|
+
epochLastUpdate: Number(this.epochLastUpdate),
|
|
104
|
+
epochFrozen: this.epochFrozen,
|
|
105
|
+
quotaParams: this.quotaParams.entries().reduce(
|
|
106
|
+
(acc, [address, params]) => ({
|
|
107
|
+
...acc,
|
|
108
|
+
[this.labelAddress(address)]: {
|
|
109
|
+
minRate: percentFmt(params.minRate, raw),
|
|
110
|
+
maxRate: percentFmt(params.maxRate, raw),
|
|
111
|
+
totalVotesLpSide: params.totalVotesLpSide / WAD,
|
|
112
|
+
totalVotesCaSide: params.totalVotesCaSide / WAD,
|
|
113
|
+
rate: percentFmt(params.rate, raw),
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
{},
|
|
117
|
+
),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { decodeAbiParameters } from "viem";
|
|
2
|
+
|
|
3
|
+
import { iLinearInterestRateModelV300Abi } from "../../../abi/v300";
|
|
4
|
+
import type { BaseState } from "../../base";
|
|
5
|
+
import { BaseContract } from "../../base";
|
|
6
|
+
import type { GearboxSDK } from "../../GearboxSDK";
|
|
7
|
+
import type { LinearInterestRateModelStateHuman } from "../../types";
|
|
8
|
+
import { percentFmt } from "../../utils";
|
|
9
|
+
import type { IInterestRateModelContract } from "./types";
|
|
10
|
+
|
|
11
|
+
const abi = iLinearInterestRateModelV300Abi;
|
|
12
|
+
type abi = typeof abi;
|
|
13
|
+
|
|
14
|
+
export class LinearInterestRateModelContract
|
|
15
|
+
extends BaseContract<abi>
|
|
16
|
+
implements IInterestRateModelContract
|
|
17
|
+
{
|
|
18
|
+
public readonly U1: number;
|
|
19
|
+
public readonly U2: number;
|
|
20
|
+
public readonly Rbase: number;
|
|
21
|
+
public readonly Rslope1: number;
|
|
22
|
+
public readonly Rslope2: number;
|
|
23
|
+
public readonly Rslope3: number;
|
|
24
|
+
public readonly isBorrowingMoreU2Forbidden: boolean;
|
|
25
|
+
|
|
26
|
+
constructor(sdk: GearboxSDK, params: BaseState) {
|
|
27
|
+
super(sdk, {
|
|
28
|
+
...params.baseParams,
|
|
29
|
+
name: "LinearInterestRateModel",
|
|
30
|
+
abi,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const [
|
|
34
|
+
U1,
|
|
35
|
+
U2,
|
|
36
|
+
Rbase,
|
|
37
|
+
Rslope1,
|
|
38
|
+
Rslope2,
|
|
39
|
+
Rslope3,
|
|
40
|
+
isBorrowingMoreU2Forbidden,
|
|
41
|
+
] = decodeAbiParameters(
|
|
42
|
+
[
|
|
43
|
+
{ type: "uint16", name: "U1" },
|
|
44
|
+
{ type: "uint16", name: "U2" },
|
|
45
|
+
{ type: "uint16", name: "Rbase" },
|
|
46
|
+
{ type: "uint16", name: "Rslope1" },
|
|
47
|
+
{ type: "uint16", name: "Rslope2" },
|
|
48
|
+
{ type: "uint16", name: "Rslope3" },
|
|
49
|
+
{ type: "bool", name: "isBorrowingMoreU2Forbidden" },
|
|
50
|
+
],
|
|
51
|
+
params.baseParams.serializedParams,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
this.U1 = U1;
|
|
55
|
+
this.U2 = U2;
|
|
56
|
+
this.Rbase = Rbase;
|
|
57
|
+
this.Rslope1 = Rslope1;
|
|
58
|
+
this.Rslope2 = Rslope2;
|
|
59
|
+
this.Rslope3 = Rslope3;
|
|
60
|
+
this.isBorrowingMoreU2Forbidden = isBorrowingMoreU2Forbidden;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public override stateHuman(raw?: boolean): LinearInterestRateModelStateHuman {
|
|
64
|
+
return {
|
|
65
|
+
...super.stateHuman(raw),
|
|
66
|
+
U1: percentFmt(this.U1, raw),
|
|
67
|
+
U2: percentFmt(this.U2, raw),
|
|
68
|
+
Rbase: percentFmt(this.Rbase, raw),
|
|
69
|
+
Rslope1: percentFmt(this.Rslope1, raw),
|
|
70
|
+
Rslope2: percentFmt(this.Rslope2, raw),
|
|
71
|
+
Rslope3: percentFmt(this.Rslope3, raw),
|
|
72
|
+
isBorrowingMoreU2Forbidden: this.isBorrowingMoreU2Forbidden,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ContractEventName, Log } from "viem";
|
|
2
|
+
|
|
3
|
+
import { iPoolQuotaKeeperV300Abi } from "../../../abi/v300";
|
|
4
|
+
import type {
|
|
5
|
+
IBaseContract,
|
|
6
|
+
PoolData,
|
|
7
|
+
PoolQuotaKeeperData,
|
|
8
|
+
QuotaState,
|
|
9
|
+
} from "../../base";
|
|
10
|
+
import { BaseContract } from "../../base";
|
|
11
|
+
import type { GearboxSDK } from "../../GearboxSDK";
|
|
12
|
+
import type { PoolQuotaKeeperStateHuman } from "../../types";
|
|
13
|
+
import { AddressMap, formatBNvalue, percentFmt } from "../../utils";
|
|
14
|
+
|
|
15
|
+
const abi = iPoolQuotaKeeperV300Abi;
|
|
16
|
+
type abi = typeof abi;
|
|
17
|
+
|
|
18
|
+
export class PoolQuotaKeeperV300Contract
|
|
19
|
+
extends BaseContract<abi>
|
|
20
|
+
implements IBaseContract
|
|
21
|
+
{
|
|
22
|
+
public readonly decimals: number;
|
|
23
|
+
public readonly quotas: AddressMap<QuotaState>;
|
|
24
|
+
|
|
25
|
+
constructor(sdk: GearboxSDK, pool: PoolData, pqk: PoolQuotaKeeperData) {
|
|
26
|
+
super(sdk, {
|
|
27
|
+
...pqk.baseParams,
|
|
28
|
+
name: `PoolQuotaKeeper(${pool.name})`,
|
|
29
|
+
abi,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
this.decimals = pool.decimals;
|
|
33
|
+
|
|
34
|
+
this.quotas = new AddressMap(
|
|
35
|
+
pqk.quotas.map(q => {
|
|
36
|
+
return [q.token, q];
|
|
37
|
+
}),
|
|
38
|
+
"quotas",
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public override stateHuman(raw = true): PoolQuotaKeeperStateHuman {
|
|
43
|
+
return {
|
|
44
|
+
...super.stateHuman(raw),
|
|
45
|
+
quotas: this.quotas.entries().reduce(
|
|
46
|
+
(acc, [address, params]) => ({
|
|
47
|
+
...acc,
|
|
48
|
+
[this.labelAddress(address)]: {
|
|
49
|
+
rate: percentFmt(params.rate, raw),
|
|
50
|
+
quotaIncreaseFee: percentFmt(params.quotaIncreaseFee, raw),
|
|
51
|
+
totalQuoted: formatBNvalue(
|
|
52
|
+
params.totalQuoted,
|
|
53
|
+
this.decimals,
|
|
54
|
+
2,
|
|
55
|
+
raw,
|
|
56
|
+
),
|
|
57
|
+
limit: formatBNvalue(params.limit, this.decimals, 2, raw),
|
|
58
|
+
isActive: params.isActive,
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
{},
|
|
62
|
+
),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public override processLog(
|
|
67
|
+
log: Log<
|
|
68
|
+
bigint,
|
|
69
|
+
number,
|
|
70
|
+
false,
|
|
71
|
+
undefined,
|
|
72
|
+
undefined,
|
|
73
|
+
abi,
|
|
74
|
+
ContractEventName<abi>
|
|
75
|
+
>,
|
|
76
|
+
): void {
|
|
77
|
+
switch (log.eventName) {
|
|
78
|
+
case "AddCreditManager":
|
|
79
|
+
case "AddQuotaToken":
|
|
80
|
+
case "SetGauge":
|
|
81
|
+
case "SetQuotaIncreaseFee":
|
|
82
|
+
case "SetTokenLimit":
|
|
83
|
+
case "UpdateQuota":
|
|
84
|
+
case "UpdateTokenQuotaRate":
|
|
85
|
+
this.dirty = true;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ContractEventName, Log } from "viem";
|
|
2
|
+
|
|
3
|
+
import { iPoolQuotaKeeperV310Abi } from "../../../abi/v310";
|
|
4
|
+
import type {
|
|
5
|
+
IBaseContract,
|
|
6
|
+
PoolData,
|
|
7
|
+
PoolQuotaKeeperData,
|
|
8
|
+
QuotaState,
|
|
9
|
+
} from "../../base";
|
|
10
|
+
import { BaseContract } from "../../base";
|
|
11
|
+
import type { GearboxSDK } from "../../GearboxSDK";
|
|
12
|
+
import type { PoolQuotaKeeperStateHuman } from "../../types";
|
|
13
|
+
import { AddressMap, formatBNvalue, percentFmt } from "../../utils";
|
|
14
|
+
|
|
15
|
+
const abi = iPoolQuotaKeeperV310Abi;
|
|
16
|
+
type abi = typeof abi;
|
|
17
|
+
|
|
18
|
+
export class PoolQuotaKeeperV310Contract
|
|
19
|
+
extends BaseContract<abi>
|
|
20
|
+
implements IBaseContract
|
|
21
|
+
{
|
|
22
|
+
public readonly decimals: number;
|
|
23
|
+
public readonly quotas: AddressMap<QuotaState>;
|
|
24
|
+
|
|
25
|
+
constructor(sdk: GearboxSDK, pool: PoolData, pqk: PoolQuotaKeeperData) {
|
|
26
|
+
super(sdk, {
|
|
27
|
+
...pqk.baseParams,
|
|
28
|
+
name: `PoolQuotaKeeper(${pool.name})`,
|
|
29
|
+
abi,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
this.decimals = pool.decimals;
|
|
33
|
+
|
|
34
|
+
this.quotas = new AddressMap(
|
|
35
|
+
pqk.quotas.map(q => {
|
|
36
|
+
return [q.token, q];
|
|
37
|
+
}),
|
|
38
|
+
"quotas",
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public override stateHuman(raw = true): PoolQuotaKeeperStateHuman {
|
|
43
|
+
return {
|
|
44
|
+
...super.stateHuman(raw),
|
|
45
|
+
quotas: this.quotas.entries().reduce(
|
|
46
|
+
(acc, [address, params]) => ({
|
|
47
|
+
...acc,
|
|
48
|
+
[this.labelAddress(address)]: {
|
|
49
|
+
rate: percentFmt(params.rate, raw),
|
|
50
|
+
quotaIncreaseFee: percentFmt(params.quotaIncreaseFee, raw),
|
|
51
|
+
totalQuoted: formatBNvalue(
|
|
52
|
+
params.totalQuoted,
|
|
53
|
+
this.decimals,
|
|
54
|
+
2,
|
|
55
|
+
raw,
|
|
56
|
+
),
|
|
57
|
+
limit: formatBNvalue(params.limit, this.decimals, 2, raw),
|
|
58
|
+
isActive: params.isActive,
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
{},
|
|
62
|
+
),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public override processLog(
|
|
67
|
+
log: Log<
|
|
68
|
+
bigint,
|
|
69
|
+
number,
|
|
70
|
+
false,
|
|
71
|
+
undefined,
|
|
72
|
+
undefined,
|
|
73
|
+
abi,
|
|
74
|
+
ContractEventName<abi>
|
|
75
|
+
>,
|
|
76
|
+
): void {
|
|
77
|
+
switch (log.eventName) {
|
|
78
|
+
case "AddCreditManager":
|
|
79
|
+
case "AddQuotaToken":
|
|
80
|
+
case "SetGauge":
|
|
81
|
+
case "SetQuotaIncreaseFee":
|
|
82
|
+
case "SetTokenLimit":
|
|
83
|
+
case "UpdateQuota":
|
|
84
|
+
case "UpdateTokenQuotaRate":
|
|
85
|
+
this.dirty = true;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
import type { MarketData } from "../../base";
|
|
4
|
+
import { SDKConstruct } from "../../base";
|
|
5
|
+
import type { GearboxSDK } from "../../GearboxSDK";
|
|
6
|
+
import type { PoolSuiteStateHuman } from "../../types";
|
|
7
|
+
import createInterestRateModel from "./createInterestRateModel";
|
|
8
|
+
import createPool from "./createPool";
|
|
9
|
+
import createPoolQuotaKeeper from "./createPoolQuotaKeeper";
|
|
10
|
+
import createRateKeeper from "./createRateKeeper";
|
|
11
|
+
import { GaugeContract } from "./GaugeContract";
|
|
12
|
+
import { LinearInterestRateModelContract } from "./LinearInterestRateModelContract";
|
|
13
|
+
import type {
|
|
14
|
+
IInterestRateModelContract,
|
|
15
|
+
IRateKeeperContract,
|
|
16
|
+
PoolContract,
|
|
17
|
+
PoolQuotaKeeperContract,
|
|
18
|
+
} from "./types";
|
|
19
|
+
|
|
20
|
+
export class PoolSuite extends SDKConstruct {
|
|
21
|
+
public readonly pool: PoolContract;
|
|
22
|
+
public readonly pqk: PoolQuotaKeeperContract;
|
|
23
|
+
public readonly rateKeeper: IRateKeeperContract;
|
|
24
|
+
public readonly interestRateModel: IInterestRateModelContract;
|
|
25
|
+
|
|
26
|
+
constructor(sdk: GearboxSDK, data: MarketData) {
|
|
27
|
+
super(sdk);
|
|
28
|
+
this.pool = createPool(sdk, data.pool);
|
|
29
|
+
this.pqk = createPoolQuotaKeeper(sdk, data.pool, data.poolQuotaKeeper);
|
|
30
|
+
this.rateKeeper = createRateKeeper(sdk, data.pool, data.rateKeeper);
|
|
31
|
+
this.interestRateModel = createInterestRateModel(
|
|
32
|
+
sdk,
|
|
33
|
+
data.interestRateModel,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public get gauge(): GaugeContract {
|
|
38
|
+
if (this.rateKeeper instanceof GaugeContract) {
|
|
39
|
+
return this.rateKeeper;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(
|
|
42
|
+
"Rate keeper is not a gauge, but a " + this.rateKeeper.contractType,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public get linearModel(): LinearInterestRateModelContract {
|
|
47
|
+
if (this.interestRateModel instanceof LinearInterestRateModelContract) {
|
|
48
|
+
return this.interestRateModel;
|
|
49
|
+
}
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Interest rate model is not a linear model, but a ${this.interestRateModel.contractType}`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public get underlying(): Address {
|
|
56
|
+
return this.pool.underlying;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
override get dirty(): boolean {
|
|
60
|
+
return (
|
|
61
|
+
this.pool.dirty ||
|
|
62
|
+
this.gauge.dirty ||
|
|
63
|
+
this.pqk.dirty ||
|
|
64
|
+
this.interestRateModel.dirty
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public stateHuman(raw = true): PoolSuiteStateHuman {
|
|
69
|
+
return {
|
|
70
|
+
pool: this.pool.stateHuman(raw),
|
|
71
|
+
poolQuotaKeeper: this.pqk.stateHuman(raw),
|
|
72
|
+
interestRateModel: this.interestRateModel.stateHuman(raw),
|
|
73
|
+
rateKeeper: this.rateKeeper.stateHuman(raw),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|