@gearbox-protocol/sdk 14.0.0 → 14.1.0
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/kyc/iDSRegistryService.js +149 -0
- package/dist/cjs/abi/kyc/iDSToken.js +71 -0
- package/dist/cjs/abi/kyc/iKYCCompressor.js +196 -0
- package/dist/cjs/abi/kyc/iKYCFactory.js +122 -0
- package/dist/cjs/abi/kyc/iKYCUnderlying.js +401 -0
- package/dist/cjs/abi/kyc/iSecuritizeDegenNFT.js +326 -0
- package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +319 -0
- package/dist/cjs/dev/AccountOpener.js +45 -5
- package/dist/cjs/sdk/OnchainSDK.js +55 -5
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +335 -21
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +7 -1
- package/dist/cjs/sdk/base/TokensMeta.js +22 -42
- package/dist/cjs/sdk/base/token-types.js +9 -0
- package/dist/cjs/sdk/chain/chains.js +18 -1
- package/dist/cjs/sdk/constants/address-provider.js +3 -0
- package/dist/cjs/sdk/market/MarketRegister.js +70 -116
- package/dist/cjs/sdk/market/MarketSuite.js +3 -0
- package/dist/cjs/sdk/market/index.js +2 -0
- package/dist/cjs/sdk/market/kyc/KYCRegistry.js +269 -0
- package/dist/cjs/sdk/market/kyc/index.js +26 -0
- package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +242 -0
- package/dist/cjs/sdk/market/kyc/securitize/constants.js +28 -0
- package/dist/cjs/sdk/market/kyc/securitize/index.js +26 -0
- package/dist/cjs/sdk/market/kyc/securitize/types.js +16 -0
- package/dist/cjs/sdk/{accounts/utils.js → market/kyc/types.js} +11 -15
- package/dist/cjs/sdk/market/pool/PoolSuite.js +3 -0
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +11 -2
- package/dist/cjs/sdk/market/pool/index.js +2 -0
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
- package/dist/cjs/sdk/options.js +6 -0
- package/dist/cjs/sdk/pools/PoolService.js +104 -12
- package/dist/cjs/sdk/utils/viem/executeDelegatedMulticalls.js +38 -0
- package/dist/cjs/sdk/utils/viem/index.js +2 -0
- package/dist/esm/abi/kyc/iDSRegistryService.js +125 -0
- package/dist/esm/abi/kyc/iDSToken.js +47 -0
- package/dist/esm/abi/kyc/iKYCCompressor.js +172 -0
- package/dist/esm/abi/kyc/iKYCFactory.js +98 -0
- package/dist/esm/abi/kyc/iKYCUnderlying.js +377 -0
- package/dist/esm/abi/kyc/iSecuritizeDegenNFT.js +302 -0
- package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +295 -0
- package/dist/esm/dev/AccountOpener.js +47 -6
- package/dist/esm/sdk/OnchainSDK.js +57 -5
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +336 -22
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +7 -1
- package/dist/esm/sdk/base/TokensMeta.js +22 -44
- package/dist/esm/sdk/base/token-types.js +6 -0
- package/dist/esm/sdk/chain/chains.js +18 -1
- package/dist/esm/sdk/constants/address-provider.js +2 -0
- package/dist/esm/sdk/market/MarketRegister.js +74 -118
- package/dist/esm/sdk/market/MarketSuite.js +3 -0
- package/dist/esm/sdk/market/index.js +1 -0
- package/dist/esm/sdk/market/kyc/KYCRegistry.js +253 -0
- package/dist/esm/sdk/market/kyc/index.js +3 -0
- package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +218 -0
- package/dist/esm/sdk/market/kyc/securitize/constants.js +4 -0
- package/dist/esm/sdk/market/kyc/securitize/index.js +3 -0
- package/dist/esm/sdk/market/kyc/securitize/types.js +0 -0
- package/dist/esm/sdk/market/kyc/types.js +9 -0
- package/dist/esm/sdk/market/pool/PoolSuite.js +3 -0
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +11 -2
- package/dist/esm/sdk/market/pool/index.js +1 -0
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
- package/dist/esm/sdk/options.js +6 -0
- package/dist/esm/sdk/pools/PoolService.js +109 -13
- package/dist/esm/sdk/utils/viem/executeDelegatedMulticalls.js +14 -0
- package/dist/esm/sdk/utils/viem/index.js +1 -0
- package/dist/types/abi/kyc/iDSRegistryService.d.ts +191 -0
- package/dist/types/abi/kyc/iDSToken.d.ts +67 -0
- package/dist/types/abi/kyc/iKYCCompressor.d.ts +228 -0
- package/dist/types/abi/kyc/iKYCFactory.d.ts +139 -0
- package/dist/types/abi/kyc/iKYCUnderlying.d.ts +548 -0
- package/dist/types/abi/kyc/iSecuritizeDegenNFT.d.ts +404 -0
- package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +376 -0
- package/dist/types/sdk/OnchainSDK.d.ts +19 -1
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +59 -6
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +114 -14
- package/dist/types/sdk/base/TokensMeta.d.ts +14 -3
- package/dist/types/sdk/base/token-types.d.ts +44 -4
- package/dist/types/sdk/base/types.d.ts +116 -2
- package/dist/types/sdk/chain/chains.d.ts +5 -1
- package/dist/types/sdk/constants/address-provider.d.ts +1 -0
- package/dist/types/sdk/market/MarketRegister.d.ts +6 -9
- package/dist/types/sdk/market/MarketSuite.d.ts +2 -0
- package/dist/types/sdk/market/index.d.ts +1 -0
- package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +52 -0
- package/dist/types/sdk/market/kyc/index.d.ts +3 -0
- package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +429 -0
- package/dist/types/sdk/market/kyc/securitize/constants.d.ts +1 -0
- package/dist/types/sdk/market/kyc/securitize/index.d.ts +3 -0
- package/dist/types/sdk/market/kyc/securitize/types.d.ts +136 -0
- package/dist/types/sdk/market/kyc/types.d.ts +171 -0
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +3 -2
- package/dist/types/sdk/market/oracle/types.d.ts +3 -10
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +2 -0
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +6 -2
- package/dist/types/sdk/market/pool/index.d.ts +1 -0
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +1 -1
- package/dist/types/sdk/market/types.d.ts +1 -1
- package/dist/types/sdk/options.d.ts +1 -0
- package/dist/types/sdk/pools/PoolService.d.ts +8 -8
- package/dist/types/sdk/pools/types.d.ts +1 -1
- package/dist/types/sdk/types/state-human.d.ts +2 -0
- package/dist/types/sdk/types/state.d.ts +5 -0
- package/dist/types/sdk/utils/viem/executeDelegatedMulticalls.d.ts +28 -0
- package/dist/types/sdk/utils/viem/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/esm/sdk/accounts/utils.js +0 -14
- package/dist/types/sdk/accounts/utils.d.ts +0 -2
|
@@ -2,7 +2,8 @@ import type { Address, ContractFunctionArgs, GetContractReturnType, Hex, PublicC
|
|
|
2
2
|
import type { creditAccountCompressorAbi } from "../../abi/compressors/creditAccountCompressor.js";
|
|
3
3
|
import type { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
|
|
4
4
|
import type { ConnectedBotData, Construct, CreditAccountData } from "../base/index.js";
|
|
5
|
-
import type { CreditSuite, PriceUpdate } from "../market/index.js";
|
|
5
|
+
import type { CreditSuite, KYCOperationParams, PriceUpdate } from "../market/index.js";
|
|
6
|
+
import type { KYCOpenAccountRequirements } from "../market/kyc/index.js";
|
|
6
7
|
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
7
8
|
import type { Asset, RouterCASlice, RouterCloseResult } from "../router/index.js";
|
|
8
9
|
import type { MultiCall, RawTx } from "../types/index.js";
|
|
@@ -182,6 +183,10 @@ export interface CloseCreditAccountProps {
|
|
|
182
183
|
closePath?: RouterCloseResult;
|
|
183
184
|
}
|
|
184
185
|
export interface RepayCreditAccountProps extends RepayAndLiquidateCreditAccountProps {
|
|
186
|
+
/**
|
|
187
|
+
* Swap calls for repay
|
|
188
|
+
*/
|
|
189
|
+
calls?: Array<MultiCall>;
|
|
185
190
|
/**
|
|
186
191
|
* close or zeroDebt
|
|
187
192
|
*/
|
|
@@ -422,6 +427,15 @@ export interface OpenCAProps extends PrepareUpdateQuotasProps {
|
|
|
422
427
|
* Referral code to open credit account with
|
|
423
428
|
*/
|
|
424
429
|
referralCode: bigint;
|
|
430
|
+
/**
|
|
431
|
+
* KYC options to open credit account with, required for KYC factories
|
|
432
|
+
* First we ask for getOpenAccountRequirements,
|
|
433
|
+
* then perform necessary actions (e.g. for Securitize, convert requiredSignatures to signaturesToCache)
|
|
434
|
+
* to produce KYCOperationParams
|
|
435
|
+
* If getOpenAccountRequirements returned undefined, we need to pass undefined here too;
|
|
436
|
+
* It means that no KYC actions are required (e.g. when we open second credit account)
|
|
437
|
+
*/
|
|
438
|
+
kycOptions?: KYCOperationParams;
|
|
425
439
|
}
|
|
426
440
|
export interface ChangeDeptProps {
|
|
427
441
|
/**
|
|
@@ -439,6 +453,10 @@ export interface ChangeDeptProps {
|
|
|
439
453
|
* Assets to add as collateral
|
|
440
454
|
*/
|
|
441
455
|
collateral?: [Asset];
|
|
456
|
+
/**
|
|
457
|
+
* Assets to wrap
|
|
458
|
+
*/
|
|
459
|
+
wrapAsset?: [Asset];
|
|
442
460
|
}
|
|
443
461
|
export interface FullyLiquidateProps {
|
|
444
462
|
/**
|
|
@@ -532,6 +550,16 @@ export interface Rewards {
|
|
|
532
550
|
**/
|
|
533
551
|
rewards: Array<Asset>;
|
|
534
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Options to get open account requirements
|
|
555
|
+
* Compatible with StrategyConfigPayload
|
|
556
|
+
*/
|
|
557
|
+
export interface GetOpenAccountRequirementsProps {
|
|
558
|
+
/**
|
|
559
|
+
* Token address of the strategy
|
|
560
|
+
*/
|
|
561
|
+
tokenOutAddress: Address;
|
|
562
|
+
}
|
|
535
563
|
interface CMSlice {
|
|
536
564
|
creditManager: Address;
|
|
537
565
|
creditFacade: Address;
|
|
@@ -582,25 +610,46 @@ export type GetConnectedMigrationBotsResult = {
|
|
|
582
610
|
})[];
|
|
583
611
|
botAddress: Address;
|
|
584
612
|
} | undefined;
|
|
613
|
+
/**
|
|
614
|
+
* Options to get approval address for collateral token
|
|
615
|
+
*/
|
|
616
|
+
export type GetApprovalAddressProps = {
|
|
617
|
+
creditManager: Address;
|
|
618
|
+
borrower: Address;
|
|
619
|
+
} | {
|
|
620
|
+
creditManager: Address;
|
|
621
|
+
creditAccount: Address;
|
|
622
|
+
};
|
|
585
623
|
export interface ICreditAccountsService extends Construct {
|
|
586
624
|
sdk: OnchainSDK;
|
|
587
625
|
/**
|
|
588
|
-
* Returns single credit account data, or undefined
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
* @param
|
|
592
|
-
* @
|
|
626
|
+
* Returns single credit account data with investor resolved, or undefined
|
|
627
|
+
* if the account is not found.
|
|
628
|
+
* Performs all necessary price feed updates under the hood.
|
|
629
|
+
* @param account - Credit account address
|
|
630
|
+
* @param blockNumber - Optional block number for the read
|
|
631
|
+
* @returns Credit account data with investor, or undefined
|
|
593
632
|
*/
|
|
594
|
-
getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData | undefined>;
|
|
633
|
+
getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData<true> | undefined>;
|
|
595
634
|
/**
|
|
596
|
-
*
|
|
597
|
-
* Performs all necessary price feed updates under the hood
|
|
635
|
+
* Returns all credit accounts with optional filtering.
|
|
636
|
+
* Performs all necessary price feed updates under the hood.
|
|
598
637
|
*
|
|
599
|
-
* @param options
|
|
600
|
-
* @param blockNumber
|
|
601
|
-
* @returns
|
|
638
|
+
* @param options - Filter options
|
|
639
|
+
* @param blockNumber - Optional block number for the read
|
|
640
|
+
* @returns Credit accounts sorted by health factor ascending
|
|
602
641
|
*/
|
|
603
642
|
getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
|
|
643
|
+
/**
|
|
644
|
+
* Returns all credit accounts for a borrower,
|
|
645
|
+
* both normal and KYC accounts with investor resolved on each.
|
|
646
|
+
*
|
|
647
|
+
* @param borrower - Actual owner of credit account
|
|
648
|
+
* @param options - Filter options (creditManager, health factor, etc.)
|
|
649
|
+
* @param blockNumber - Optional block number for the read
|
|
650
|
+
* @returns Credit accounts (with investor) sorted by health factor ascending
|
|
651
|
+
*/
|
|
652
|
+
getBorrowerCreditAccounts(borrower: Address, options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData<true>>>;
|
|
604
653
|
/**
|
|
605
654
|
* Method to get all claimable rewards for credit account (ex. stkUSDS SKY rewards).
|
|
606
655
|
* Associates rewards by adapter + stakedPhantomToken.
|
|
@@ -629,9 +678,9 @@ export interface ICreditAccountsService extends Construct {
|
|
|
629
678
|
/**
|
|
630
679
|
* Generates transaction to liquidate credit account
|
|
631
680
|
* @param props - {@link FullyLiquidateProps}
|
|
632
|
-
* @returns
|
|
681
|
+
* @returns Transaction data and optional loss policy data
|
|
633
682
|
*/
|
|
634
|
-
fullyLiquidate(props: FullyLiquidateProps): Promise<
|
|
683
|
+
fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
|
|
635
684
|
/**
|
|
636
685
|
* Closes credit account or closes credit account and keeps it open with zero debt.
|
|
637
686
|
* - Ca is closed in the following order: price update -> close path to swap all tokens into underlying ->
|
|
@@ -694,6 +743,21 @@ export interface ICreditAccountsService extends Construct {
|
|
|
694
743
|
* @returns
|
|
695
744
|
*/
|
|
696
745
|
claimDelayed(props: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
|
|
746
|
+
/**
|
|
747
|
+
* Returns address to which approval should be given on collateral token
|
|
748
|
+
* It's credit manager for classical markets and special wallet for KYC markets
|
|
749
|
+
* @param props - {@link GetApprovalAddressProps}
|
|
750
|
+
* @returns
|
|
751
|
+
*/
|
|
752
|
+
getApprovalAddress(props: GetApprovalAddressProps): Promise<Address>;
|
|
753
|
+
/**
|
|
754
|
+
* Returns open account requirements for a borrower
|
|
755
|
+
* @param borrower - Borrower address
|
|
756
|
+
* @param creditManager - Credit manager address
|
|
757
|
+
* @param props - {@link GetOpenAccountRequirementsProps} you can pass StrategyConfigPayload here
|
|
758
|
+
* @returns Open account requirements or undefined if the user can open a credit account without any further actions
|
|
759
|
+
*/
|
|
760
|
+
getOpenAccountRequirements(borrower: Address, creditManager: Address, props: GetOpenAccountRequirementsProps): Promise<KYCOpenAccountRequirements | undefined>;
|
|
697
761
|
/**
|
|
698
762
|
* Executes swap specified by given calls, update quotas of affected tokens
|
|
699
763
|
* - Open credit account is executed in the following order: price update -> increase debt -> add collateral ->
|
|
@@ -749,6 +813,42 @@ export interface ICreditAccountsService extends Construct {
|
|
|
749
813
|
botMulticall(creditAccount: RouterCASlice, calls: Array<MultiCall>, options?: {
|
|
750
814
|
ignoreReservePrices?: boolean;
|
|
751
815
|
}): Promise<RawTx>;
|
|
816
|
+
/**
|
|
817
|
+
* Returns multicall entries to redeem (unwrap) KYC ERC-4626 vault shares into underlying for the given credit manager.
|
|
818
|
+
* Used when withdrawing debt from a KYC market: redeems adapter vault shares so the underlying can be withdrawn.
|
|
819
|
+
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
820
|
+
* @param amount - Number of vault shares (adapter tokens) to redeem
|
|
821
|
+
* @param creditManager - Credit manager address
|
|
822
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
823
|
+
*/
|
|
824
|
+
getKYCUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
825
|
+
/**
|
|
826
|
+
* Returns multicall entries to deposit (wrap) underlying into KYC ERC-4626 vault shares for the given credit manager.
|
|
827
|
+
* Used when adding debt on a KYC market: deposits underlying into the adapter vault so shares are minted on the account.
|
|
828
|
+
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
829
|
+
* @param amount - Amount of underlying assets to deposit into the vault (in underlying decimals)
|
|
830
|
+
* @param creditManager - Credit manager address
|
|
831
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
832
|
+
*/
|
|
833
|
+
getKYCWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
834
|
+
/**
|
|
835
|
+
* Returns multicall entries to call redeemDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
836
|
+
* Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess KYC vault tokens.
|
|
837
|
+
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
838
|
+
* @param amount - Leftover vault share amount to redeem (in adapter/vault decimals)
|
|
839
|
+
* @param creditManager - Credit manager address
|
|
840
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
841
|
+
*/
|
|
842
|
+
getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
843
|
+
/**
|
|
844
|
+
* Returns multicall entries to call depositDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
845
|
+
* Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
|
|
846
|
+
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
847
|
+
* @param amount - Leftover underlying amount to deposit into the vault (in underlying decimals)
|
|
848
|
+
* @param creditManager - Credit manager address
|
|
849
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
850
|
+
*/
|
|
851
|
+
getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
752
852
|
/**
|
|
753
853
|
* Withdraws a single collateral from credit account to wallet to and updates quotas;
|
|
754
854
|
* technically can withdraw several tokens at once
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Address, Chain, PublicClient, Transport } from "viem";
|
|
2
2
|
import type { Asset } from "../router/index.js";
|
|
3
3
|
import type { ILogger } from "../types/logger.js";
|
|
4
4
|
import { AddressMap } from "../utils/index.js";
|
|
5
|
-
import type { PhantomTokenMeta, TokenMetaData } from "./token-types.js";
|
|
5
|
+
import type { KYCTokenMeta, PhantomTokenMeta, TokenMetaData } from "./token-types.js";
|
|
6
6
|
/**
|
|
7
7
|
* Options for {@link TokensMeta.formatBN}.
|
|
8
8
|
**/
|
|
@@ -50,11 +50,22 @@ export declare class TokensMeta extends AddressMap<TokenMetaData> {
|
|
|
50
50
|
* @returns
|
|
51
51
|
*/
|
|
52
52
|
isPhantomToken(t: TokenMetaData): t is PhantomTokenMeta;
|
|
53
|
+
/**
|
|
54
|
+
* Returns true if the token is a KYC underlying token, throws if the token data is not loaded
|
|
55
|
+
* @param t
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
isKYCUnderlying(t: TokenMetaData): t is KYCTokenMeta;
|
|
53
59
|
/**
|
|
54
60
|
* Returns a map of all phantom tokens
|
|
55
61
|
* Throws if token data is not loaded
|
|
56
62
|
*/
|
|
57
63
|
get phantomTokens(): AddressMap<PhantomTokenMeta>;
|
|
64
|
+
/**
|
|
65
|
+
* Returns a map of all KYC underlying tokens
|
|
66
|
+
* Throws if token data is not loaded
|
|
67
|
+
*/
|
|
68
|
+
get kycUnderlyings(): AddressMap<KYCTokenMeta>;
|
|
58
69
|
/**
|
|
59
70
|
* Formats a raw token amount into a human-readable decimal string,
|
|
60
71
|
* dividing by `10^decimals` for the token.
|
|
@@ -85,7 +96,7 @@ export declare class TokensMeta extends AddressMap<TokenMetaData> {
|
|
|
85
96
|
mustFindBySymbol(symbol: string): TokenMetaData;
|
|
86
97
|
/**
|
|
87
98
|
* Loads token information about phantom tokens
|
|
88
|
-
*
|
|
99
|
+
* In future other custom tokens types that do not have compressors might be handled here
|
|
89
100
|
*
|
|
90
101
|
* @param tokens - tokens to load data for, defaults to all tokens
|
|
91
102
|
*/
|
|
@@ -1,13 +1,53 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
1
2
|
import type { MarketData, Unarray } from "./types.js";
|
|
2
3
|
type TokenData = Unarray<MarketData["tokens"]>;
|
|
3
4
|
export declare const PHANTOM_TOKEN_CONTRACT_TYPES: readonly ["PHANTOM_TOKEN::CONVEX", "PHANTOM_TOKEN::INFINIFI_UNWIND", "PHANTOM_TOKEN::INFRARED", "PHANTOM_TOKEN::MELLOW_WITHDRAWAL", "PHANTOM_TOKEN::MIDAS_REDEMPTION", "PHANTOM_TOKEN::STAKING_REWARDS", "PHANTOM_TOKEN::UPSHIFT_WITHDRAW"];
|
|
5
|
+
export declare const KYC_UNDERLYING_DEFAULT = "KYC_UNDERLYING::DEFAULT";
|
|
6
|
+
export declare const KYC_UNDERLYING_ON_DEMAND = "KYC_UNDERLYING::ON_DEMAND";
|
|
7
|
+
export type KYCUnderlyingContractType = typeof KYC_UNDERLYING_DEFAULT | typeof KYC_UNDERLYING_ON_DEMAND;
|
|
8
|
+
export declare const KYC_ON_DEMAND_LP_MONOPOLIZED = "ON_DEMAND_LP::MONOPOLIZED";
|
|
9
|
+
export type KYCOnDemandLpContractType = typeof KYC_ON_DEMAND_LP_MONOPOLIZED;
|
|
4
10
|
export type PhantomTokenContractType = (typeof PHANTOM_TOKEN_CONTRACT_TYPES)[number];
|
|
5
|
-
export
|
|
6
|
-
isDSToken?: boolean;
|
|
11
|
+
export interface SimpleTokenMeta extends TokenData {
|
|
7
12
|
contractType?: string;
|
|
8
|
-
}
|
|
13
|
+
}
|
|
9
14
|
export type PhantomTokenMeta = SimpleTokenMeta & {
|
|
10
15
|
contractType: PhantomTokenContractType;
|
|
11
16
|
};
|
|
12
|
-
export
|
|
17
|
+
export interface KYCDefaultTokenMeta extends SimpleTokenMeta {
|
|
18
|
+
contractType: typeof KYC_UNDERLYING_DEFAULT;
|
|
19
|
+
kycFactory: Address;
|
|
20
|
+
asset: Address;
|
|
21
|
+
}
|
|
22
|
+
export interface LPMonopolizedPoolMeta {
|
|
23
|
+
pool: Address;
|
|
24
|
+
wrappedUnderlying: Address;
|
|
25
|
+
unwrappedUnderlying: Address;
|
|
26
|
+
depositAllowance: bigint;
|
|
27
|
+
claimableAmount: bigint;
|
|
28
|
+
}
|
|
29
|
+
export interface KYCOnDemandLPMonopolizedMeta {
|
|
30
|
+
addr: Address;
|
|
31
|
+
version: bigint;
|
|
32
|
+
contractType: typeof KYC_ON_DEMAND_LP_MONOPOLIZED;
|
|
33
|
+
marketConfigurator: Address;
|
|
34
|
+
/**
|
|
35
|
+
* Only this user can deposit into the pool and withdraw
|
|
36
|
+
* Other users should not see it at all
|
|
37
|
+
*/
|
|
38
|
+
depositor: Address;
|
|
39
|
+
pools: LPMonopolizedPoolMeta[];
|
|
40
|
+
}
|
|
41
|
+
export type KYCOnDemandLPMeta = KYCOnDemandLPMonopolizedMeta;
|
|
42
|
+
export interface KYCOnDemandTokenMeta extends SimpleTokenMeta {
|
|
43
|
+
contractType: typeof KYC_UNDERLYING_ON_DEMAND;
|
|
44
|
+
kycFactory: Address;
|
|
45
|
+
asset: Address;
|
|
46
|
+
pool: Address;
|
|
47
|
+
marketConfigurator: Address;
|
|
48
|
+
allowedDepositors: Address[];
|
|
49
|
+
liquidityProvider: KYCOnDemandLPMeta;
|
|
50
|
+
}
|
|
51
|
+
export type KYCTokenMeta = KYCDefaultTokenMeta | KYCOnDemandTokenMeta;
|
|
52
|
+
export type TokenMetaData = SimpleTokenMeta | PhantomTokenMeta | KYCTokenMeta;
|
|
13
53
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype";
|
|
2
2
|
import type { Address, Hex } from "viem";
|
|
3
|
-
import type { creditAccountCompressorAbi } from "../../abi/compressors/creditAccountCompressor.js";
|
|
4
3
|
import type { gaugeCompressorAbi } from "../../abi/compressors/gaugeCompressor.js";
|
|
5
4
|
import type { marketCompressorAbi } from "../../abi/compressors/marketCompressor.js";
|
|
6
5
|
import type { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
|
|
@@ -63,10 +62,125 @@ export interface BaseState {
|
|
|
63
62
|
* Filter criteria for querying markets.
|
|
64
63
|
**/
|
|
65
64
|
export type MarketFilter = AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof marketCompressorAbi, "getMarkets">["inputs"]>[0];
|
|
65
|
+
/**
|
|
66
|
+
* Info on credit account's assets
|
|
67
|
+
**/
|
|
68
|
+
export interface TokenInfo {
|
|
69
|
+
/**
|
|
70
|
+
* Token address.
|
|
71
|
+
**/
|
|
72
|
+
token: Address;
|
|
73
|
+
/**
|
|
74
|
+
* Token mask in the credit manager.
|
|
75
|
+
**/
|
|
76
|
+
mask: bigint;
|
|
77
|
+
/**
|
|
78
|
+
* Account's balance of token.
|
|
79
|
+
**/
|
|
80
|
+
balance: bigint;
|
|
81
|
+
/**
|
|
82
|
+
* Account's quota of token.
|
|
83
|
+
**/
|
|
84
|
+
quota: bigint;
|
|
85
|
+
/**
|
|
86
|
+
* Whether balance call was successful.
|
|
87
|
+
**/
|
|
88
|
+
success: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* On-chain state of a credit account.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* Fields from `totalDebtUSD` through `healthFactor` are not filled when
|
|
95
|
+
* `success` is `false`.
|
|
96
|
+
*
|
|
97
|
+
**/
|
|
98
|
+
export interface CreditAccountDataPayload {
|
|
99
|
+
/**
|
|
100
|
+
* Credit account address.
|
|
101
|
+
**/
|
|
102
|
+
creditAccount: Address;
|
|
103
|
+
/**
|
|
104
|
+
* Credit manager account is opened in.
|
|
105
|
+
**/
|
|
106
|
+
creditManager: Address;
|
|
107
|
+
/**
|
|
108
|
+
* Facade connected to account's credit manager.
|
|
109
|
+
**/
|
|
110
|
+
creditFacade: Address;
|
|
111
|
+
/**
|
|
112
|
+
* Credit manager's underlying token.
|
|
113
|
+
**/
|
|
114
|
+
underlying: Address;
|
|
115
|
+
/**
|
|
116
|
+
* Credit account's owner (contract address for KYC accounts, EOA for
|
|
117
|
+
* normal accounts).
|
|
118
|
+
**/
|
|
119
|
+
owner: Address;
|
|
120
|
+
/**
|
|
121
|
+
* Expiration timestamp, in case facade is expirable.
|
|
122
|
+
**/
|
|
123
|
+
expirationDate: number;
|
|
124
|
+
/**
|
|
125
|
+
* Bitmask of tokens enabled on credit account as collateral.
|
|
126
|
+
**/
|
|
127
|
+
enabledTokensMask: bigint;
|
|
128
|
+
/**
|
|
129
|
+
* Credit account's debt principal in underlying.
|
|
130
|
+
**/
|
|
131
|
+
debt: bigint;
|
|
132
|
+
/**
|
|
133
|
+
* Base and quota interest accrued on the credit account.
|
|
134
|
+
**/
|
|
135
|
+
accruedInterest: bigint;
|
|
136
|
+
/**
|
|
137
|
+
* Fees accrued on the credit account.
|
|
138
|
+
**/
|
|
139
|
+
accruedFees: bigint;
|
|
140
|
+
/**
|
|
141
|
+
* Account's total debt in USD.
|
|
142
|
+
**/
|
|
143
|
+
totalDebtUSD: bigint;
|
|
144
|
+
/**
|
|
145
|
+
* Account's total value in USD.
|
|
146
|
+
**/
|
|
147
|
+
totalValueUSD: bigint;
|
|
148
|
+
/**
|
|
149
|
+
* Account's threshold-weighted value in USD.
|
|
150
|
+
**/
|
|
151
|
+
twvUSD: bigint;
|
|
152
|
+
/**
|
|
153
|
+
* Account's total value in underlying.
|
|
154
|
+
**/
|
|
155
|
+
totalValue: bigint;
|
|
156
|
+
/**
|
|
157
|
+
* Account's health factor, i.e. ratio of `twvUSD` to `totalDebtUSD`,
|
|
158
|
+
* with 18 decimals precision.
|
|
159
|
+
**/
|
|
160
|
+
healthFactor: bigint;
|
|
161
|
+
/**
|
|
162
|
+
* Whether collateral calculation was successful.
|
|
163
|
+
**/
|
|
164
|
+
success: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Info on credit account's enabled tokens and tokens with non-zero balance.
|
|
167
|
+
**/
|
|
168
|
+
tokens: readonly TokenInfo[];
|
|
169
|
+
}
|
|
66
170
|
/**
|
|
67
171
|
* Full on-chain snapshot of a single credit account.
|
|
172
|
+
*
|
|
173
|
+
* @typeParam WithInvestor - When `true`, the result includes an `investor`
|
|
174
|
+
* field (`Address | undefined`). Defaults to `false` (no investor field).
|
|
68
175
|
**/
|
|
69
|
-
export type CreditAccountData =
|
|
176
|
+
export type CreditAccountData<WithInvestor extends boolean = false> = WithInvestor extends true ? CreditAccountDataPayload & {
|
|
177
|
+
/**
|
|
178
|
+
* Investor EOA address (the real person behind the account).
|
|
179
|
+
* - KYC accounts: resolved from KYC factory, always defined.
|
|
180
|
+
* - Normal accounts: `undefined` (owner IS the investor).
|
|
181
|
+
**/
|
|
182
|
+
investor: Address | undefined;
|
|
183
|
+
} : CreditAccountDataPayload;
|
|
70
184
|
/**
|
|
71
185
|
* Reward distribution details for a single reward token.
|
|
72
186
|
**/
|
|
@@ -4,7 +4,7 @@ import { z } from "zod/v4";
|
|
|
4
4
|
* Known curator names that manage Gearbox markets.
|
|
5
5
|
*
|
|
6
6
|
**/
|
|
7
|
-
export type Curator = "Chaos Labs" | "K3" | "cp0x" | "Re7" | "Invariant Group" | "Tulipa" | "M11 Credit" | "kpk" | "Hyperithm" | "UltraYield" | "TelosC" | "Gami Labs";
|
|
7
|
+
export type Curator = "Chaos Labs" | "K3" | "cp0x" | "Re7" | "Invariant Group" | "Tulipa" | "M11 Credit" | "kpk" | "Hyperithm" | "UltraYield" | "TelosC" | "Gami Labs" | "Securitize";
|
|
8
8
|
/**
|
|
9
9
|
* Extended viem {@link Chain} with Gearbox-specific metadata.
|
|
10
10
|
*
|
|
@@ -20,6 +20,10 @@ export interface GearboxChain extends Chain {
|
|
|
20
20
|
* Market configurator addresses operated by known curators on this chain.
|
|
21
21
|
**/
|
|
22
22
|
defaultMarketConfigurators: Record<Address, Curator>;
|
|
23
|
+
/**
|
|
24
|
+
* Known KYC factory addresses on this chain
|
|
25
|
+
*/
|
|
26
|
+
kycFactories: Address[];
|
|
23
27
|
/**
|
|
24
28
|
* Market configurators used in test/staging environments.
|
|
25
29
|
**/
|
|
@@ -31,6 +31,7 @@ export declare const AP_WETH_GATEWAY = "WETH_GATEWAY";
|
|
|
31
31
|
export declare const AP_WETH_TOKEN = "WETH_TOKEN";
|
|
32
32
|
export declare const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
|
|
33
33
|
export declare const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
|
|
34
|
+
export declare const AP_KYC_COMPRESSOR = "GLOBAL::KYC_COMPRESSOR";
|
|
34
35
|
/**
|
|
35
36
|
* Default address provider address for v3.1.0
|
|
36
37
|
* Is determenistic and does not depend on the network type
|
|
@@ -3,6 +3,7 @@ import type { MarketData, MarketFilter } from "../base/index.js";
|
|
|
3
3
|
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
4
4
|
import type { MarketStateHuman } from "../types/index.js";
|
|
5
5
|
import { AddressMap } from "../utils/index.js";
|
|
6
|
+
import { type DelegatedMulticall } from "../utils/viem/index.js";
|
|
6
7
|
import type { CreditSuite } from "./credit/index.js";
|
|
7
8
|
import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
|
|
8
9
|
import { MarketSuite } from "./MarketSuite.js";
|
|
@@ -30,13 +31,13 @@ export declare class MarketRegister extends ZapperRegister {
|
|
|
30
31
|
**/
|
|
31
32
|
hydrate(state: MarketData[]): void;
|
|
32
33
|
/**
|
|
33
|
-
*
|
|
34
|
+
* @internal
|
|
35
|
+
* Returns delegated multicalls for loading all markets from the on-chain
|
|
36
|
+
* market compressor. Used by the SDK to compose batched RPC calls.
|
|
34
37
|
*
|
|
35
|
-
* @param
|
|
36
|
-
* @param ignoreUpdateablePrices - When `true`, skips generating off-chain
|
|
37
|
-
* price updates before loading
|
|
38
|
+
* @param configurators - Addresses of market configurator contracts to query.
|
|
38
39
|
**/
|
|
39
|
-
|
|
40
|
+
getLoadMulticalls(configurators: Address[]): DelegatedMulticall[];
|
|
40
41
|
/**
|
|
41
42
|
* The active filter used to scope market compressor queries.
|
|
42
43
|
* @throws If the register has not been hydrated or attached yet.
|
|
@@ -52,10 +53,6 @@ export declare class MarketRegister extends ZapperRegister {
|
|
|
52
53
|
* @param ignoreUpdateablePrices - When `true`, skips off-chain price updates.
|
|
53
54
|
**/
|
|
54
55
|
syncState(ignoreUpdateablePrices?: boolean): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Loads new prices and price feeds for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
57
|
-
*/
|
|
58
|
-
updatePrices(oracles?: Address[]): Promise<void>;
|
|
59
56
|
get watchAddresses(): Set<Address>;
|
|
60
57
|
/**
|
|
61
58
|
* Serializable snapshot of all loaded markets, suitable for hydration.
|
|
@@ -4,6 +4,7 @@ import { SDKConstruct } from "../base/index.js";
|
|
|
4
4
|
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
5
5
|
import type { MarketStateHuman } from "../types/index.js";
|
|
6
6
|
import { CreditSuite } from "./credit/index.js";
|
|
7
|
+
import type { IKYCFactory } from "./kyc/types.js";
|
|
7
8
|
import { type ILossPolicyContract } from "./loss-policy/index.js";
|
|
8
9
|
import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
|
|
9
10
|
import type { IPriceOracleContract } from "./oracle/index.js";
|
|
@@ -22,6 +23,7 @@ export declare class MarketSuite extends SDKConstruct {
|
|
|
22
23
|
readonly state: MarketData;
|
|
23
24
|
constructor(sdk: OnchainSDK, marketData: MarketData);
|
|
24
25
|
get underlying(): Address;
|
|
26
|
+
get kycFactory(): IKYCFactory | undefined;
|
|
25
27
|
get dirty(): boolean;
|
|
26
28
|
get watchAddresses(): Set<Address>;
|
|
27
29
|
stateHuman(raw?: boolean): MarketStateHuman;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Address } from "abitype";
|
|
2
|
+
import { SDKConstruct } from "../../base/index.js";
|
|
3
|
+
import type { DelegatedMulticall } from "../../utils/viem/index.js";
|
|
4
|
+
import { SecuritizeKYCFactory } from "./securitize/index.js";
|
|
5
|
+
import type { KYCCompressorResponse, KYCInvestorData, KYCState, KYCStateHuman } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Registry of KYC underlying tokens and KYC factory contracts.
|
|
8
|
+
*
|
|
9
|
+
* Populated from the on-chain {@link https://github.com/Gearbox-protocol/periphery-v3 KYCCompressor}
|
|
10
|
+
* during SDK attach/hydrate. Provides methods to query investor-level data and
|
|
11
|
+
* to resolve KYC factory instances by address.
|
|
12
|
+
**/
|
|
13
|
+
export declare class KYCRegistry extends SDKConstruct {
|
|
14
|
+
#private;
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*
|
|
18
|
+
* Returns delegated multicalls for loading all KYC underlying tokens from the on-chain KYC compressor.
|
|
19
|
+
* Used by the SDK to compose batched RPC calls.
|
|
20
|
+
*
|
|
21
|
+
* @param configurators - Market configurators to query.
|
|
22
|
+
* @param kycFactories - KYC factory contracts to query.
|
|
23
|
+
*/
|
|
24
|
+
getLoadMulticalls(configurators: Address[], kycFactories?: Address[]): DelegatedMulticall[];
|
|
25
|
+
/**
|
|
26
|
+
* Fetches decoded investor data from the on-chain KYC compressor.
|
|
27
|
+
*
|
|
28
|
+
* Each factory produces its own investor data (e.g. registered tokens,
|
|
29
|
+
* cached signatures, EIP-712 messages to sign).
|
|
30
|
+
*
|
|
31
|
+
* @param investor - Investor EOA address.
|
|
32
|
+
* @param factories_ - Optional subset of factory addresses to query.
|
|
33
|
+
* When omitted, all loaded factories are used.
|
|
34
|
+
*/
|
|
35
|
+
getInvestorData(investor: Address, factories_?: Address[]): Promise<KYCInvestorData[]>;
|
|
36
|
+
/** All loaded KYC factory instances. */
|
|
37
|
+
get factories(): SecuritizeKYCFactory[];
|
|
38
|
+
/** Raw KYC compressor response, or `undefined` before attach/hydrate. */
|
|
39
|
+
get state(): KYCState | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a human-readable snapshot of the KYC state.
|
|
42
|
+
*/
|
|
43
|
+
stateHuman(raw?: boolean): KYCStateHuman;
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*
|
|
47
|
+
* Replaces the internal state with a new KYC compressor response.
|
|
48
|
+
* Rebuilds token metadata for KYC underlyings and re-instantiates factory
|
|
49
|
+
* wrappers.
|
|
50
|
+
*/
|
|
51
|
+
setState(resp?: KYCCompressorResponse): void;
|
|
52
|
+
}
|