@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,267 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
PERCENTAGE_DECIMALS,
|
|
5
|
+
PERCENTAGE_FACTOR,
|
|
6
|
+
RAY,
|
|
7
|
+
SECONDS_PER_YEAR,
|
|
8
|
+
WAD,
|
|
9
|
+
} from "../../constants";
|
|
10
|
+
import type { Asset } from "../../router";
|
|
11
|
+
import type { SupportedToken } from "../../sdk-gov-legacy";
|
|
12
|
+
import { toBigInt } from "../../utils";
|
|
13
|
+
import type { PoolData_Legacy } from "../core/pool";
|
|
14
|
+
import type { TokenData } from "../tokens/tokenData";
|
|
15
|
+
import { PriceUtils } from "../utils/price";
|
|
16
|
+
import type { FarmInfo } from "./api";
|
|
17
|
+
|
|
18
|
+
interface CalculateV3PoolLmAPYProps {
|
|
19
|
+
currentTimestamp: number;
|
|
20
|
+
info: FarmInfo;
|
|
21
|
+
|
|
22
|
+
supply: {
|
|
23
|
+
decimals: number;
|
|
24
|
+
amount: bigint;
|
|
25
|
+
price: bigint;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
reward: {
|
|
29
|
+
decimals: number;
|
|
30
|
+
price: bigint;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const PERCENTAGE_FACTOR_1KK = PERCENTAGE_DECIMALS * PERCENTAGE_FACTOR;
|
|
35
|
+
const ONE = PERCENTAGE_FACTOR_1KK * 10n;
|
|
36
|
+
|
|
37
|
+
export interface ExtraRewardApy {
|
|
38
|
+
token: Address;
|
|
39
|
+
balance: bigint | null;
|
|
40
|
+
|
|
41
|
+
apy: number;
|
|
42
|
+
rewardToken: Address;
|
|
43
|
+
rewardTokenSymbol: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface GetPoolExtraAPY_V3Props {
|
|
47
|
+
stakedDieselToken: Address | undefined;
|
|
48
|
+
pool: PoolData_Legacy;
|
|
49
|
+
prices: Record<Address, bigint>;
|
|
50
|
+
|
|
51
|
+
rewardPoolsInfo: Record<Address, Array<FarmInfo>>;
|
|
52
|
+
rewardPoolsSupply: Record<Address, bigint>;
|
|
53
|
+
|
|
54
|
+
tokensList: Record<Address, TokenData>;
|
|
55
|
+
currentTokenData: Record<SupportedToken, Address>;
|
|
56
|
+
|
|
57
|
+
currentTimestamp: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface GetPoolExtraLmAPYProps
|
|
61
|
+
extends Omit<
|
|
62
|
+
GetPoolExtraAPY_V3Props,
|
|
63
|
+
"rewardPoolsInfo" | "stakedDieselToken"
|
|
64
|
+
> {
|
|
65
|
+
stakedDieselToken: Address;
|
|
66
|
+
rewardPoolsInfo: FarmInfo;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface GetCAExtraAPYProps {
|
|
70
|
+
assets: Array<Asset>;
|
|
71
|
+
supply: Record<Address, bigint> | Record<Address, Asset>;
|
|
72
|
+
rewardInfo: Record<Address, Array<FarmInfo>>;
|
|
73
|
+
currentTimestamp: number;
|
|
74
|
+
|
|
75
|
+
prices: Record<Address, bigint>;
|
|
76
|
+
tokensList: Record<Address, TokenData>;
|
|
77
|
+
currentTokenData: Record<SupportedToken, Address>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface GetCASingleExtraAPYProps
|
|
81
|
+
extends Omit<GetCAExtraAPYProps, "rewardInfo" | "assets"> {
|
|
82
|
+
asset: Asset;
|
|
83
|
+
rewardInfo: FarmInfo;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class GearboxRewardsApy {
|
|
87
|
+
static getPoolExtraAPY_V3({
|
|
88
|
+
rewardPoolsInfo,
|
|
89
|
+
stakedDieselToken,
|
|
90
|
+
...restProps
|
|
91
|
+
}: GetPoolExtraAPY_V3Props): Array<ExtraRewardApy> {
|
|
92
|
+
const { version } = restProps.pool;
|
|
93
|
+
const isV3 = version >= 300 && version < 400;
|
|
94
|
+
if (!isV3 || !stakedDieselToken) return [];
|
|
95
|
+
|
|
96
|
+
const info = rewardPoolsInfo[stakedDieselToken];
|
|
97
|
+
if (!info) return [];
|
|
98
|
+
|
|
99
|
+
const extra = info.map(inf =>
|
|
100
|
+
this.getPoolSingleExtraLmAPY_V3({
|
|
101
|
+
...restProps,
|
|
102
|
+
stakedDieselToken,
|
|
103
|
+
rewardPoolsInfo: inf,
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return extra;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private static getPoolSingleExtraLmAPY_V3({
|
|
111
|
+
stakedDieselToken,
|
|
112
|
+
pool,
|
|
113
|
+
prices,
|
|
114
|
+
|
|
115
|
+
rewardPoolsInfo,
|
|
116
|
+
rewardPoolsSupply,
|
|
117
|
+
|
|
118
|
+
tokensList,
|
|
119
|
+
currentTokenData,
|
|
120
|
+
|
|
121
|
+
currentTimestamp,
|
|
122
|
+
}: GetPoolExtraLmAPYProps): ExtraRewardApy {
|
|
123
|
+
const { underlyingToken, dieselRateRay } = pool;
|
|
124
|
+
|
|
125
|
+
const safeSupply = rewardPoolsSupply[stakedDieselToken] ?? 0n;
|
|
126
|
+
|
|
127
|
+
const { decimals: underlyingDecimals = 18 } =
|
|
128
|
+
tokensList[underlyingToken] || {};
|
|
129
|
+
const underlyingPrice = prices[underlyingToken] ?? 0n;
|
|
130
|
+
const dieselPrice = (underlyingPrice * dieselRateRay) / RAY;
|
|
131
|
+
|
|
132
|
+
const rewardAddress = currentTokenData[rewardPoolsInfo.symbol];
|
|
133
|
+
const { decimals: rewardDecimals = 18 } = tokensList[rewardAddress] || {};
|
|
134
|
+
const rewardPrice = prices[rewardAddress] ?? 0n;
|
|
135
|
+
|
|
136
|
+
const r =
|
|
137
|
+
this.calculateAPY_V3({
|
|
138
|
+
currentTimestamp,
|
|
139
|
+
info: rewardPoolsInfo,
|
|
140
|
+
supply: {
|
|
141
|
+
amount: safeSupply,
|
|
142
|
+
decimals: underlyingDecimals,
|
|
143
|
+
price: dieselPrice,
|
|
144
|
+
},
|
|
145
|
+
reward: {
|
|
146
|
+
price: rewardPrice,
|
|
147
|
+
decimals: rewardDecimals,
|
|
148
|
+
},
|
|
149
|
+
}) / Number(PERCENTAGE_FACTOR);
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
token: stakedDieselToken,
|
|
153
|
+
balance: null,
|
|
154
|
+
|
|
155
|
+
apy: r,
|
|
156
|
+
rewardToken: rewardAddress,
|
|
157
|
+
rewardTokenSymbol: rewardPoolsInfo.symbol,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static calculateAPY_V3({
|
|
162
|
+
info,
|
|
163
|
+
supply,
|
|
164
|
+
reward,
|
|
165
|
+
currentTimestamp,
|
|
166
|
+
}: CalculateV3PoolLmAPYProps) {
|
|
167
|
+
const finished = info.finished <= currentTimestamp;
|
|
168
|
+
if (finished) return 0;
|
|
169
|
+
|
|
170
|
+
if (supply.amount <= 0n) return 0;
|
|
171
|
+
if (supply.price === 0n || reward.price === 0n) return 0;
|
|
172
|
+
if (info.duration === 0n) return 0;
|
|
173
|
+
|
|
174
|
+
const supplyMoney = PriceUtils.calcTotalPrice(
|
|
175
|
+
supply.price,
|
|
176
|
+
supply.amount,
|
|
177
|
+
supply.decimals,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const rewardMoney = PriceUtils.calcTotalPrice(
|
|
181
|
+
reward.price,
|
|
182
|
+
info.reward,
|
|
183
|
+
reward.decimals,
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const durationRatio = (toBigInt(SECONDS_PER_YEAR) * WAD) / info.duration;
|
|
187
|
+
|
|
188
|
+
const apyBn = (((rewardMoney * ONE) / supplyMoney) * durationRatio) / WAD;
|
|
189
|
+
|
|
190
|
+
return Math.round(Number(apyBn) / 10);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
static getCAExtraAPY_V3({
|
|
194
|
+
rewardInfo,
|
|
195
|
+
assets,
|
|
196
|
+
...restProps
|
|
197
|
+
}: GetCAExtraAPYProps): Array<ExtraRewardApy> {
|
|
198
|
+
const extra = assets.reduce((acc, asset) => {
|
|
199
|
+
const { token } = asset;
|
|
200
|
+
const info = rewardInfo[token || ""];
|
|
201
|
+
|
|
202
|
+
if (!info || info.length === 0) return acc;
|
|
203
|
+
|
|
204
|
+
const extra = info.map(inf =>
|
|
205
|
+
this.getCASingleExtraAPY_V3({
|
|
206
|
+
...restProps,
|
|
207
|
+
asset,
|
|
208
|
+
rewardInfo: inf,
|
|
209
|
+
}),
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
acc.push(...extra);
|
|
213
|
+
|
|
214
|
+
return acc;
|
|
215
|
+
}, [] as Array<ExtraRewardApy>);
|
|
216
|
+
|
|
217
|
+
return extra;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private static getCASingleExtraAPY_V3({
|
|
221
|
+
asset,
|
|
222
|
+
prices,
|
|
223
|
+
rewardInfo,
|
|
224
|
+
supply,
|
|
225
|
+
|
|
226
|
+
tokensList,
|
|
227
|
+
currentTokenData,
|
|
228
|
+
|
|
229
|
+
currentTimestamp,
|
|
230
|
+
}: GetCASingleExtraAPYProps): ExtraRewardApy {
|
|
231
|
+
const { token, balance } = asset;
|
|
232
|
+
|
|
233
|
+
const safeSupply = supply[token] ?? 0n;
|
|
234
|
+
|
|
235
|
+
const { decimals: tokenDecimals = 18 } = tokensList[token] || {};
|
|
236
|
+
const tokenPrice = prices[token] ?? 0n;
|
|
237
|
+
|
|
238
|
+
const rewardAddress = currentTokenData[rewardInfo.symbol];
|
|
239
|
+
const { decimals: rewardDecimals = 18 } = tokensList[rewardAddress] || {};
|
|
240
|
+
const rewardPrice = prices[rewardAddress] ?? 0n;
|
|
241
|
+
|
|
242
|
+
const r =
|
|
243
|
+
this.calculateAPY_V3({
|
|
244
|
+
currentTimestamp,
|
|
245
|
+
info: rewardInfo,
|
|
246
|
+
supply: {
|
|
247
|
+
amount:
|
|
248
|
+
typeof safeSupply === "bigint" ? safeSupply : safeSupply.balance,
|
|
249
|
+
decimals: tokenDecimals,
|
|
250
|
+
price: tokenPrice,
|
|
251
|
+
},
|
|
252
|
+
reward: {
|
|
253
|
+
price: rewardPrice,
|
|
254
|
+
decimals: rewardDecimals,
|
|
255
|
+
},
|
|
256
|
+
}) / Number(PERCENTAGE_FACTOR);
|
|
257
|
+
|
|
258
|
+
return {
|
|
259
|
+
token,
|
|
260
|
+
balance,
|
|
261
|
+
|
|
262
|
+
apy: r,
|
|
263
|
+
rewardToken: rewardAddress,
|
|
264
|
+
rewardTokenSymbol: rewardInfo.symbol,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
|
|
4
|
+
import type { NetworkType } from "../../chain";
|
|
5
|
+
import { chains } from "../../chain";
|
|
6
|
+
import { PERCENTAGE_FACTOR } from "../../constants";
|
|
7
|
+
import type { Asset } from "../../router";
|
|
8
|
+
import { GearboxBackendApi } from "../core/endpoint";
|
|
9
|
+
import type { PoolData_Legacy } from "../core/pool";
|
|
10
|
+
import type { TokenData } from "../tokens/tokenData";
|
|
11
|
+
import { toBN } from "../utils/formatter";
|
|
12
|
+
import { BigIntMath } from "../utils/math";
|
|
13
|
+
|
|
14
|
+
export interface PoolPointsInfo {
|
|
15
|
+
pool: Address;
|
|
16
|
+
token: Address;
|
|
17
|
+
symbol: string;
|
|
18
|
+
|
|
19
|
+
amount: bigint;
|
|
20
|
+
duration: string;
|
|
21
|
+
name: string;
|
|
22
|
+
estimation: "absolute" | "relative";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface GetPointsByPoolProps {
|
|
26
|
+
poolRewards: Record<Address, Record<Address, PoolPointsInfo>>;
|
|
27
|
+
|
|
28
|
+
totalTokenBalances: Record<Address, Asset>;
|
|
29
|
+
pools: Array<PoolData_Legacy>;
|
|
30
|
+
tokensList: Record<Address, TokenData>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface WalletResult {
|
|
34
|
+
borrower: Address;
|
|
35
|
+
effective_balance: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface GetBalanceAtResponse {
|
|
39
|
+
result: Array<WalletResult>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface GetTotalTokensOnProtocolProps {
|
|
43
|
+
tokensToCheck: Array<Address>;
|
|
44
|
+
|
|
45
|
+
tokensList: Record<Address, TokenData>;
|
|
46
|
+
network: NetworkType;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class GearboxRewardsExtraApy {
|
|
50
|
+
static async getTotalTokensOnProtocol({
|
|
51
|
+
tokensToCheck,
|
|
52
|
+
|
|
53
|
+
tokensList,
|
|
54
|
+
network,
|
|
55
|
+
}: GetTotalTokensOnProtocolProps) {
|
|
56
|
+
const list = [...new Set(tokensToCheck)];
|
|
57
|
+
|
|
58
|
+
const res = await Promise.allSettled(
|
|
59
|
+
list.map(t => this.getTokenTotal(t, network, tokensList)),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return res.map((r, i): [Address, PromiseSettledResult<Asset>] => [
|
|
63
|
+
list[i],
|
|
64
|
+
r,
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private static async getTokenTotal(
|
|
69
|
+
token: Address,
|
|
70
|
+
network: NetworkType,
|
|
71
|
+
tokensList: Record<Address, TokenData>,
|
|
72
|
+
) {
|
|
73
|
+
const chainId = chains[network]?.id;
|
|
74
|
+
|
|
75
|
+
const url = GearboxBackendApi.getChartsUrl("getBalanceAt", chainId, {
|
|
76
|
+
params: {
|
|
77
|
+
asset: token,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const result = await axios.get<GetBalanceAtResponse>(url);
|
|
82
|
+
const balance = result.data.result.reduce(
|
|
83
|
+
(sum, r) => r.effective_balance + sum,
|
|
84
|
+
0,
|
|
85
|
+
);
|
|
86
|
+
const { decimals = 18 } = tokensList[token] || {};
|
|
87
|
+
|
|
88
|
+
return { token, balance: toBN(String(balance), decimals) };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static getPointsByPool({
|
|
92
|
+
poolRewards,
|
|
93
|
+
|
|
94
|
+
totalTokenBalances,
|
|
95
|
+
pools,
|
|
96
|
+
tokensList,
|
|
97
|
+
}: GetPointsByPoolProps) {
|
|
98
|
+
const r = pools.reduce<Record<Address, Array<Asset>>>((acc, p) => {
|
|
99
|
+
const pointsInfo = Object.values(poolRewards[p.address] || {});
|
|
100
|
+
|
|
101
|
+
const poolPointsList = pointsInfo.reduce<Array<Asset>>(
|
|
102
|
+
(acc, pointsInfo) => {
|
|
103
|
+
const { address: tokenAddress } = tokensList[pointsInfo.token];
|
|
104
|
+
const tokenBalance = totalTokenBalances[tokenAddress || ""];
|
|
105
|
+
|
|
106
|
+
const points = this.getPoolTokenPoints(
|
|
107
|
+
tokenBalance,
|
|
108
|
+
p,
|
|
109
|
+
tokensList,
|
|
110
|
+
pointsInfo,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
if (points !== null) {
|
|
114
|
+
acc.push({ balance: points, token: tokenBalance.token });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return acc;
|
|
118
|
+
},
|
|
119
|
+
[],
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
acc[p.address] = poolPointsList;
|
|
123
|
+
|
|
124
|
+
return acc;
|
|
125
|
+
}, {});
|
|
126
|
+
|
|
127
|
+
return r;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private static getPoolTokenPoints(
|
|
131
|
+
tokenBalanceInPool: Asset | undefined,
|
|
132
|
+
pool: PoolData_Legacy,
|
|
133
|
+
tokensList: Record<Address, TokenData>,
|
|
134
|
+
pointsInfo: PoolPointsInfo,
|
|
135
|
+
) {
|
|
136
|
+
if (!tokenBalanceInPool) return null;
|
|
137
|
+
if (pool.expectedLiquidity <= 0) return 0n;
|
|
138
|
+
const { decimals = 18 } = tokensList[tokenBalanceInPool.token] || {};
|
|
139
|
+
const targetFactor = 10n ** BigInt(decimals);
|
|
140
|
+
|
|
141
|
+
const { decimals: underlyingDecimals = 18 } =
|
|
142
|
+
tokensList[pool.underlyingToken] || {};
|
|
143
|
+
const underlyingFactor = 10n ** BigInt(underlyingDecimals);
|
|
144
|
+
|
|
145
|
+
const defaultPoints =
|
|
146
|
+
(pointsInfo.amount * targetFactor) / PERCENTAGE_FACTOR;
|
|
147
|
+
|
|
148
|
+
const points =
|
|
149
|
+
pointsInfo.estimation === "absolute"
|
|
150
|
+
? defaultPoints
|
|
151
|
+
: (tokenBalanceInPool.balance * defaultPoints) /
|
|
152
|
+
((pool.expectedLiquidity * targetFactor) / underlyingFactor);
|
|
153
|
+
|
|
154
|
+
return BigIntMath.min(points, defaultPoints);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
static getPoolPointsTip(
|
|
158
|
+
poolRewards: Record<Address, Record<Address, PoolPointsInfo>>,
|
|
159
|
+
pool: Address,
|
|
160
|
+
token: Address,
|
|
161
|
+
) {
|
|
162
|
+
const p = poolRewards[pool]?.[token];
|
|
163
|
+
return p;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
import type { BigNumberish } from "../utils/formatter";
|
|
4
|
+
|
|
5
|
+
interface UserOptions {
|
|
6
|
+
params: {
|
|
7
|
+
user: string;
|
|
8
|
+
chainId: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface MerkleXYZUserRewardsV4 {
|
|
13
|
+
chain: MerkleXYZChain;
|
|
14
|
+
rewards: Array<{
|
|
15
|
+
root: Address;
|
|
16
|
+
recipient: Address;
|
|
17
|
+
amount: BigNumberish;
|
|
18
|
+
claimed: BigNumberish;
|
|
19
|
+
pending: BigNumberish;
|
|
20
|
+
proofs: Array<Address>;
|
|
21
|
+
token: {
|
|
22
|
+
address: Address;
|
|
23
|
+
chainId: number;
|
|
24
|
+
symbol: string;
|
|
25
|
+
decimals: number;
|
|
26
|
+
};
|
|
27
|
+
breakdowns: Array<{
|
|
28
|
+
reason: string;
|
|
29
|
+
amount: BigNumberish;
|
|
30
|
+
claimed: BigNumberish;
|
|
31
|
+
pending: BigNumberish;
|
|
32
|
+
campaignId: Address;
|
|
33
|
+
}>;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
export type MerkleXYZUserRewardsV4Response = Array<MerkleXYZUserRewardsV4>;
|
|
37
|
+
|
|
38
|
+
interface MerkleXYZChain {
|
|
39
|
+
id: number;
|
|
40
|
+
name: string;
|
|
41
|
+
icon: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface MerkleXYZToken {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
chainId: number;
|
|
48
|
+
address: Address;
|
|
49
|
+
decimals: number;
|
|
50
|
+
icon: string;
|
|
51
|
+
verified: boolean;
|
|
52
|
+
isTest: boolean;
|
|
53
|
+
price: number | null;
|
|
54
|
+
symbol: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface MerklXYZV4Campaign {
|
|
58
|
+
chainId: number;
|
|
59
|
+
type: string;
|
|
60
|
+
identifier: Address;
|
|
61
|
+
name: string;
|
|
62
|
+
status: "LIVE" | "PAST";
|
|
63
|
+
action: "LEND" | "BORROW";
|
|
64
|
+
tvl: number;
|
|
65
|
+
apr: number;
|
|
66
|
+
dailyRewards: number;
|
|
67
|
+
tags: Array<string>;
|
|
68
|
+
id: string;
|
|
69
|
+
tokens: Array<MerkleXYZToken>;
|
|
70
|
+
chain: MerkleXYZChain;
|
|
71
|
+
aprRecord: {
|
|
72
|
+
cumulated: number;
|
|
73
|
+
timestamp: string;
|
|
74
|
+
breakdowns: Array<{
|
|
75
|
+
id: number;
|
|
76
|
+
identifier: Address;
|
|
77
|
+
type: "CAMPAIGN";
|
|
78
|
+
value: number;
|
|
79
|
+
aprRecordId: string;
|
|
80
|
+
}>;
|
|
81
|
+
};
|
|
82
|
+
tvlRecord: {
|
|
83
|
+
id: string;
|
|
84
|
+
total: number;
|
|
85
|
+
timestamp: string;
|
|
86
|
+
breakdowns: [];
|
|
87
|
+
};
|
|
88
|
+
rewardsRecord: {
|
|
89
|
+
id: string;
|
|
90
|
+
total: number;
|
|
91
|
+
timestamp: string;
|
|
92
|
+
breakdowns: Array<{
|
|
93
|
+
token: MerkleXYZToken;
|
|
94
|
+
amount: string;
|
|
95
|
+
id: number;
|
|
96
|
+
value: number;
|
|
97
|
+
campaignId: string;
|
|
98
|
+
dailyRewardsRecordid: string;
|
|
99
|
+
}>;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export type MerkleXYZV4CampaignsResponse = Array<MerklXYZV4Campaign>;
|
|
103
|
+
|
|
104
|
+
export interface MerklXYZV4RewardCampaign {
|
|
105
|
+
id: string;
|
|
106
|
+
computeChainId: number;
|
|
107
|
+
distributionChainId: number;
|
|
108
|
+
campaignId: Address;
|
|
109
|
+
rewardTokenId: string;
|
|
110
|
+
amount: string;
|
|
111
|
+
opportunityId: string;
|
|
112
|
+
startTimestamp: string;
|
|
113
|
+
endTimestamp: string;
|
|
114
|
+
creatorAddress: Address;
|
|
115
|
+
params: {
|
|
116
|
+
url: string;
|
|
117
|
+
duration: number;
|
|
118
|
+
blacklist: Array<Address>;
|
|
119
|
+
whitelist: Array<Address>;
|
|
120
|
+
forwarders: Array<Address>;
|
|
121
|
+
targetToken: Address;
|
|
122
|
+
symbolRewardToken: string;
|
|
123
|
+
symbolTargetToken: string;
|
|
124
|
+
decimalsRewardToken: number;
|
|
125
|
+
decimalsTargetToken: number;
|
|
126
|
+
};
|
|
127
|
+
chain: MerkleXYZChain;
|
|
128
|
+
rewardToken: MerkleXYZToken;
|
|
129
|
+
distributionChain: MerkleXYZChain;
|
|
130
|
+
campaignStatus: {
|
|
131
|
+
campaignId: string;
|
|
132
|
+
computedUntil: string;
|
|
133
|
+
processingStarted: string;
|
|
134
|
+
status: "SUCCESS";
|
|
135
|
+
error: string;
|
|
136
|
+
details: string;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
export type MerkleXYZV4RewardCampaignResponse = Array<MerklXYZV4RewardCampaign>;
|
|
140
|
+
|
|
141
|
+
// https://api.merkl.xyz/v3/campaignsForMainParameter?chainId=1&mainParameter=0xE2037090f896A858E3168B978668F22026AC52e7
|
|
142
|
+
|
|
143
|
+
export class MerkleXYZApi {
|
|
144
|
+
static getUserRewardsUrl = (options: UserOptions) =>
|
|
145
|
+
`https://api.merkl.xyz/v4/users/${options.params.user}/rewards?chainId=${options.params.chainId}`;
|
|
146
|
+
|
|
147
|
+
static getGearboxCampaignsUrl = () =>
|
|
148
|
+
"https://api.merkl.xyz/v4/opportunities?name=gearbox";
|
|
149
|
+
static getGearboxRewardCampaignUrl = (campaignId: Address) =>
|
|
150
|
+
`https://api.merkl.xyz/v4/campaigns?campaignId=${campaignId}`;
|
|
151
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from "./apy";
|
|
2
|
+
export * from "./core/assets";
|
|
3
|
+
export * from "./core/creditAccount";
|
|
4
|
+
export * from "./core/creditManager";
|
|
5
|
+
export * from "./core/creditSession";
|
|
6
|
+
export * from "./core/endpoint";
|
|
7
|
+
export * from "./core/eventOrTx";
|
|
8
|
+
export * from "./core/pool";
|
|
9
|
+
export * from "./core/strategy";
|
|
10
|
+
export * from "./core/transactions";
|
|
11
|
+
export * from "./gearboxRewards";
|
|
12
|
+
export * from "./pathfinder";
|
|
13
|
+
export * from "./payload/creditAccount";
|
|
14
|
+
export * from "./payload/creditManager";
|
|
15
|
+
export * from "./payload/creditSession";
|
|
16
|
+
export * from "./payload/graphPayload";
|
|
17
|
+
export * from "./payload/pool";
|
|
18
|
+
export * from "./payload/token";
|
|
19
|
+
export * from "./tokens/tokenData";
|
|
20
|
+
export * from "./types";
|
|
21
|
+
export * from "./utils";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
import type { MultiCall } from "../../types";
|
|
4
|
+
|
|
5
|
+
export interface PathFinderResult {
|
|
6
|
+
amount: bigint;
|
|
7
|
+
minAmount: bigint;
|
|
8
|
+
calls: MultiCall[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface PathFinderOpenStrategyResult extends PathFinderResult {
|
|
12
|
+
balances: Record<Address, bigint>;
|
|
13
|
+
minBalances: Record<Address, bigint>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PathFinderCloseResult extends PathFinderResult {
|
|
17
|
+
underlyingBalance: bigint;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
import type { ConnectedBotData } from "../../base";
|
|
4
|
+
|
|
5
|
+
export interface CaTokenBalance {
|
|
6
|
+
success: boolean;
|
|
7
|
+
token: Address;
|
|
8
|
+
balance: bigint;
|
|
9
|
+
isForbidden: boolean;
|
|
10
|
+
isEnabled: boolean;
|
|
11
|
+
isQuoted: boolean;
|
|
12
|
+
quota: bigint;
|
|
13
|
+
quotaRate: bigint;
|
|
14
|
+
mask: bigint;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface CreditAccountDataPayload {
|
|
18
|
+
isSuccessful: boolean;
|
|
19
|
+
addr: Address;
|
|
20
|
+
borrower: Address;
|
|
21
|
+
creditManager: Address;
|
|
22
|
+
creditFacade: Address;
|
|
23
|
+
underlying: Address;
|
|
24
|
+
debt: bigint;
|
|
25
|
+
accruedInterest: bigint;
|
|
26
|
+
accruedFees: bigint;
|
|
27
|
+
totalDebtUSD: bigint;
|
|
28
|
+
totalValue: bigint;
|
|
29
|
+
totalValueUSD: bigint;
|
|
30
|
+
twvUSD: bigint;
|
|
31
|
+
enabledTokensMask: bigint;
|
|
32
|
+
healthFactor: bigint;
|
|
33
|
+
baseBorrowRate: bigint;
|
|
34
|
+
balances: readonly {
|
|
35
|
+
success: boolean;
|
|
36
|
+
token: Address;
|
|
37
|
+
balance: bigint;
|
|
38
|
+
isForbidden: boolean;
|
|
39
|
+
isEnabled: boolean;
|
|
40
|
+
isQuoted: boolean;
|
|
41
|
+
quota: bigint;
|
|
42
|
+
quotaRate: number;
|
|
43
|
+
mask: bigint;
|
|
44
|
+
}[];
|
|
45
|
+
cfVersion: bigint;
|
|
46
|
+
expirationDate: number;
|
|
47
|
+
activeBots: ConnectedBotData[];
|
|
48
|
+
}
|