@gvnrdao/dh-sdk 0.0.286 → 0.0.288
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/browser/dist/397.browser.js +2 -0
- package/browser/dist/397.browser.js.LICENSE.txt +1 -0
- package/browser/dist/833.browser.js +1 -1
- package/browser/dist/browser.js +1 -1
- package/browser/dist/browser.js.LICENSE.txt +10 -5
- package/dist/deployments.js +45 -21
- package/dist/deployments.mjs +45 -21
- package/dist/index.js +620 -1103
- package/dist/index.mjs +620 -1103
- package/package.json +1 -1
- package/dist/constants/chunks/contract-abis.d.ts +0 -20
- package/dist/constants/chunks/deployment-addresses.d.ts +0 -79
- package/dist/constants/chunks/encrypted-provider-params.d.ts +0 -21
- package/dist/constants/chunks/environment.browser.d.ts +0 -44
- package/dist/constants/chunks/environment.d.ts +0 -57
- package/dist/constants/chunks/network-configs.d.ts +0 -72
- package/dist/constants/chunks/sdk-config.d.ts +0 -33
- package/dist/constants/chunks/sdk-limits.d.ts +0 -66
- package/dist/constants/index.d.ts +0 -15
- package/dist/contracts/typechain-contracts/common.d.ts +0 -50
- package/dist/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.d.ts +0 -1996
- package/dist/contracts/typechain-contracts/src/psm/SimplePSMV2.d.ts +0 -1198
- package/dist/graphs/client.d.ts +0 -22
- package/dist/graphs/diamond-hands.d.ts +0 -259
- package/dist/index.d.ts +0 -56
- package/dist/interfaces/chunks/btc.i.d.ts +0 -36
- package/dist/interfaces/chunks/config.i.d.ts +0 -270
- package/dist/interfaces/chunks/contract-interactions.i.d.ts +0 -64
- package/dist/interfaces/chunks/contract-types.i.d.ts +0 -171
- package/dist/interfaces/chunks/lit-actions-results.i.d.ts +0 -165
- package/dist/interfaces/chunks/lit-actions.i.d.ts +0 -98
- package/dist/interfaces/chunks/loan-operations.i.d.ts +0 -331
- package/dist/interfaces/chunks/pkp-integration.i.d.ts +0 -87
- package/dist/interfaces/chunks/position-query.i.d.ts +0 -76
- package/dist/interfaces/chunks/requests.i.d.ts +0 -55
- package/dist/interfaces/chunks/ucd-minting.i.d.ts +0 -34
- package/dist/interfaces/chunks/utility.i.d.ts +0 -64
- package/dist/interfaces/index.d.ts +0 -17
- package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +0 -254
- package/dist/modules/cache/cache-manager.module.d.ts +0 -259
- package/dist/modules/contract/contract-manager.module.d.ts +0 -152
- package/dist/modules/diamond-hands-sdk.d.ts +0 -969
- package/dist/modules/loan/loan-creator.module.d.ts +0 -132
- package/dist/modules/loan/loan-query.module.d.ts +0 -204
- package/dist/modules/mock/mock-token-manager.module.d.ts +0 -83
- package/dist/modules/pkp/pkp-manager.module.d.ts +0 -136
- package/dist/modules/withdrawal-address/withdrawal-address.module.d.ts +0 -78
- package/dist/protocol/protocol-pause.d.ts +0 -19
- package/dist/server.d.ts +0 -17
- package/dist/types/authorization-params.d.ts +0 -160
- package/dist/types/branded/domain-values.d.ts +0 -138
- package/dist/types/branded/ids.d.ts +0 -23
- package/dist/types/event-types.d.ts +0 -261
- package/dist/types/graph-dtos.d.ts +0 -228
- package/dist/types/loanStatus.d.ts +0 -10
- package/dist/types/protocol-event-types.d.ts +0 -99
- package/dist/types/result.d.ts +0 -120
- package/dist/utils/address-conversion.utils.d.ts +0 -51
- package/dist/utils/bitcoin-address-cache.utils.d.ts +0 -87
- package/dist/utils/bitcoin-provider.utils.d.ts +0 -84
- package/dist/utils/btc-withdrawal-message.d.ts +0 -60
- package/dist/utils/chunks/bitcoin-utils.d.ts +0 -85
- package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +0 -33
- package/dist/utils/eip712-login.d.ts +0 -34
- package/dist/utils/error-handler.d.ts +0 -106
- package/dist/utils/ethers-interop.utils.d.ts +0 -146
- package/dist/utils/extend-authorization.utils.d.ts +0 -61
- package/dist/utils/lit-signature.utils.d.ts +0 -6
- package/dist/utils/logger.utils.d.ts +0 -142
- package/dist/utils/mint-authorization.utils.d.ts +0 -248
- package/dist/utils/position-delegate.utils.d.ts +0 -41
- package/dist/utils/quantum-timing.d.ts +0 -75
- package/dist/utils/server-session.d.ts +0 -50
- package/dist/utils/service-endpoint-policy.d.ts +0 -16
- package/dist/utils/signature-tempering.utils.d.ts +0 -34
- package/dist/utils/telegram-messaging.utils.d.ts +0 -188
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed Authorization Parameters using Discriminated Unions
|
|
3
|
-
*
|
|
4
|
-
* This file defines type-safe authorization parameter types that replace
|
|
5
|
-
* the generic `Record<string, any>` previously used in AuthorizationRequest.
|
|
6
|
-
*
|
|
7
|
-
* Each authorization action has its own specific parameter type, ensuring
|
|
8
|
-
* compile-time safety and better IDE support.
|
|
9
|
-
*/
|
|
10
|
-
import { UCD, Satoshis, UnixTimestamp } from "./branded/domain-values";
|
|
11
|
-
/**
|
|
12
|
-
* Base authorization parameters shared by all authorization types
|
|
13
|
-
*/
|
|
14
|
-
interface BaseAuthParams {
|
|
15
|
-
/** Unix timestamp when the authorization request was created */
|
|
16
|
-
timestamp: UnixTimestamp;
|
|
17
|
-
/** Chain ID where the operation will be executed */
|
|
18
|
-
chainId: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Parameters for creating a new loan/position
|
|
22
|
-
*/
|
|
23
|
-
export interface CreateLoanAuthParams extends BaseAuthParams {
|
|
24
|
-
type: "create";
|
|
25
|
-
/** Selected loan term in months (e.g., 12, 24, 36) */
|
|
26
|
-
selectedTerm: number;
|
|
27
|
-
/** Borrower's Ethereum address */
|
|
28
|
-
borrower: string;
|
|
29
|
-
/** PKP public key for Bitcoin custody */
|
|
30
|
-
publicKey: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Parameters for minting UCD against existing collateral
|
|
34
|
-
*/
|
|
35
|
-
export interface MintUCDAuthParams extends BaseAuthParams {
|
|
36
|
-
type: "mint";
|
|
37
|
-
/** Position/loan identifier */
|
|
38
|
-
positionId: string;
|
|
39
|
-
/** Amount of UCD to mint (in wei, 18 decimals) */
|
|
40
|
-
amount: UCD;
|
|
41
|
-
/** PKP public key (optional - validator PKP is passed separately to authorizeMintUCD) */
|
|
42
|
-
publicKey?: string;
|
|
43
|
-
/** Bitcoin provider URL for balance verification */
|
|
44
|
-
bitcoinProviderUrl?: string;
|
|
45
|
-
/** Selected term in months (override when contract state is zero) */
|
|
46
|
-
selectedTerm?: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Parameters for withdrawing Bitcoin from vault
|
|
50
|
-
*/
|
|
51
|
-
export interface WithdrawBTCAuthParams extends BaseAuthParams {
|
|
52
|
-
type: "withdraw";
|
|
53
|
-
/** Position/loan identifier */
|
|
54
|
-
positionId: string;
|
|
55
|
-
/** Destination Bitcoin address */
|
|
56
|
-
destinationAddress: string;
|
|
57
|
-
/** Amount to withdraw in satoshis */
|
|
58
|
-
amount: Satoshis;
|
|
59
|
-
/** PKP public key */
|
|
60
|
-
publicKey: string;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Parameters for repaying UCD debt
|
|
64
|
-
*/
|
|
65
|
-
export interface RepayDebtAuthParams extends BaseAuthParams {
|
|
66
|
-
type: "repay";
|
|
67
|
-
/** Position/loan identifier */
|
|
68
|
-
positionId: string;
|
|
69
|
-
/** Amount of UCD to repay (in wei, 18 decimals) */
|
|
70
|
-
amount: UCD;
|
|
71
|
-
/** Whether this is a full repayment closing the position */
|
|
72
|
-
closeLoan: boolean;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Parameters for extending loan term
|
|
76
|
-
*/
|
|
77
|
-
export interface ExtendTermAuthParams extends BaseAuthParams {
|
|
78
|
-
type: "extend";
|
|
79
|
-
/** Position/loan identifier */
|
|
80
|
-
positionId: string;
|
|
81
|
-
/** New term length in months */
|
|
82
|
-
newTerm: number;
|
|
83
|
-
/** Expected extension fee in UCD */
|
|
84
|
-
extensionFee: UCD;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Parameters for closing a position
|
|
88
|
-
*/
|
|
89
|
-
export interface ClosePositionAuthParams extends BaseAuthParams {
|
|
90
|
-
type: "close";
|
|
91
|
-
/** Position/loan identifier */
|
|
92
|
-
positionId: string;
|
|
93
|
-
/** Final debt amount being repaid */
|
|
94
|
-
finalDebt: UCD;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Union type of all possible authorization parameters
|
|
98
|
-
*
|
|
99
|
-
* This is a discriminated union keyed by the 'type' field.
|
|
100
|
-
* TypeScript can narrow the type based on the 'type' value.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* function handleAuth(params: AuthorizationParams) {
|
|
105
|
-
* switch (params.type) {
|
|
106
|
-
* case 'mint':
|
|
107
|
-
* // TypeScript knows params has positionId, amount, publicKey
|
|
108
|
-
* return handleMint(params.positionId, params.amount);
|
|
109
|
-
* case 'withdraw':
|
|
110
|
-
* // TypeScript knows params has destinationAddress
|
|
111
|
-
* return handleWithdraw(params.destinationAddress, params.amount);
|
|
112
|
-
* }
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
export type AuthorizationParams = CreateLoanAuthParams | MintUCDAuthParams | WithdrawBTCAuthParams | RepayDebtAuthParams | ExtendTermAuthParams | ClosePositionAuthParams;
|
|
117
|
-
/**
|
|
118
|
-
* Type guard to check if params are for loan creation
|
|
119
|
-
*/
|
|
120
|
-
export declare function isCreateLoanAuth(params: AuthorizationParams): params is CreateLoanAuthParams;
|
|
121
|
-
/**
|
|
122
|
-
* Type guard to check if params are for UCD minting
|
|
123
|
-
*/
|
|
124
|
-
export declare function isMintUCDAuth(params: AuthorizationParams): params is MintUCDAuthParams;
|
|
125
|
-
/**
|
|
126
|
-
* Type guard to check if params are for BTC withdrawal
|
|
127
|
-
*/
|
|
128
|
-
export declare function isWithdrawBTCAuth(params: AuthorizationParams): params is WithdrawBTCAuthParams;
|
|
129
|
-
/**
|
|
130
|
-
* Type guard to check if params are for debt repayment
|
|
131
|
-
*/
|
|
132
|
-
export declare function isRepayDebtAuth(params: AuthorizationParams): params is RepayDebtAuthParams;
|
|
133
|
-
/**
|
|
134
|
-
* Type guard to check if params are for term extension
|
|
135
|
-
*/
|
|
136
|
-
export declare function isExtendTermAuth(params: AuthorizationParams): params is ExtendTermAuthParams;
|
|
137
|
-
/**
|
|
138
|
-
* Type guard to check if params are for position closure
|
|
139
|
-
*/
|
|
140
|
-
export declare function isClosePositionAuth(params: AuthorizationParams): params is ClosePositionAuthParams;
|
|
141
|
-
/**
|
|
142
|
-
* Helper to extract the action type from authorization params
|
|
143
|
-
*/
|
|
144
|
-
export declare function getAuthActionType(params: AuthorizationParams): string;
|
|
145
|
-
/**
|
|
146
|
-
* Validation helpers for authorization parameters
|
|
147
|
-
*/
|
|
148
|
-
export declare namespace AuthParamsValidation {
|
|
149
|
-
function validateCreateLoan(params: CreateLoanAuthParams): string[];
|
|
150
|
-
function validateMintUCD(params: MintUCDAuthParams): string[];
|
|
151
|
-
function validateWithdrawBTC(params: WithdrawBTCAuthParams): string[];
|
|
152
|
-
function validateRepayDebt(params: RepayDebtAuthParams): string[];
|
|
153
|
-
function validateExtendTerm(params: ExtendTermAuthParams): string[];
|
|
154
|
-
function validateClosePosition(params: ClosePositionAuthParams): string[];
|
|
155
|
-
/**
|
|
156
|
-
* Validates authorization params based on their type
|
|
157
|
-
*/
|
|
158
|
-
function validate(params: AuthorizationParams): string[];
|
|
159
|
-
}
|
|
160
|
-
export {};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Branded types for domain-specific values to prevent mixing incompatible units
|
|
3
|
-
*
|
|
4
|
-
* These types provide compile-time safety to ensure we don't accidentally
|
|
5
|
-
* use Bitcoin satoshis where UCD is expected, or vice versa.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const debt: UCD = UCD(1000000n);
|
|
10
|
-
* const balance: Satoshis = Satoshis(50000000n);
|
|
11
|
-
*
|
|
12
|
-
* // This will cause a TypeScript error:
|
|
13
|
-
* await mintUCD(balance); // Error: Cannot use Satoshis where UCD expected
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
declare const __brand: unique symbol;
|
|
17
|
-
/**
|
|
18
|
-
* UCD (USD Coin Diamond) - The stablecoin minted against Bitcoin collateral
|
|
19
|
-
* Base unit: 1 UCD = 10^18 wei (matches ERC20 decimals)
|
|
20
|
-
*/
|
|
21
|
-
export type UCD = bigint & {
|
|
22
|
-
readonly [__brand]: 'UCD';
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Satoshis - Bitcoin base unit
|
|
26
|
-
* Base unit: 1 BTC = 100,000,000 satoshis
|
|
27
|
-
*/
|
|
28
|
-
export type Satoshis = bigint & {
|
|
29
|
-
readonly [__brand]: 'Satoshis';
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Wei - Ethereum base unit for ETH and ERC20 tokens (18 decimals)
|
|
33
|
-
* Base unit: 1 token = 10^18 wei
|
|
34
|
-
*/
|
|
35
|
-
export type Wei = bigint & {
|
|
36
|
-
readonly [__brand]: 'Wei';
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* BPS - Basis Points for percentage calculations
|
|
40
|
-
* Base unit: 1% = 100 BPS, 100% = 10,000 BPS
|
|
41
|
-
*/
|
|
42
|
-
export type BPS = number & {
|
|
43
|
-
readonly [__brand]: 'BPS';
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* UnixTimestamp - Unix timestamp in seconds
|
|
47
|
-
*/
|
|
48
|
-
export type UnixTimestamp = number & {
|
|
49
|
-
readonly [__brand]: 'UnixTimestamp';
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* BlockNumber - Ethereum block number
|
|
53
|
-
*/
|
|
54
|
-
export type BlockNumber = number & {
|
|
55
|
-
readonly [__brand]: 'BlockNumber';
|
|
56
|
-
};
|
|
57
|
-
export declare const UCD: (value: bigint) => UCD;
|
|
58
|
-
export declare const Satoshis: (value: bigint) => Satoshis;
|
|
59
|
-
export declare const Wei: (value: bigint) => Wei;
|
|
60
|
-
export declare const BPS: (value: number) => BPS;
|
|
61
|
-
export declare const UnixTimestamp: (value: number) => UnixTimestamp;
|
|
62
|
-
export declare const BlockNumber: (value: number) => BlockNumber;
|
|
63
|
-
export declare function isUCD(value: unknown): value is UCD;
|
|
64
|
-
export declare function isSatoshis(value: unknown): value is Satoshis;
|
|
65
|
-
export declare function isWei(value: unknown): value is Wei;
|
|
66
|
-
export declare function isBPS(value: unknown): value is BPS;
|
|
67
|
-
export declare function isUnixTimestamp(value: unknown): value is UnixTimestamp;
|
|
68
|
-
export declare function isBlockNumber(value: unknown): value is BlockNumber;
|
|
69
|
-
export declare namespace UCDConversions {
|
|
70
|
-
function fromWhole(whole: number | string): UCD;
|
|
71
|
-
function toWhole(ucd: UCD): number;
|
|
72
|
-
function format(ucd: UCD, decimals?: number): string;
|
|
73
|
-
/**
|
|
74
|
-
* Convert UCD to JSON-serializable string
|
|
75
|
-
*/
|
|
76
|
-
function toJSON(ucd: UCD): string;
|
|
77
|
-
/**
|
|
78
|
-
* Parse UCD from JSON string
|
|
79
|
-
*/
|
|
80
|
-
function fromJSON(json: string): UCD;
|
|
81
|
-
/**
|
|
82
|
-
* Convert to structured serializable format with metadata
|
|
83
|
-
*/
|
|
84
|
-
function toSerializable(ucd: UCD): {
|
|
85
|
-
value: string;
|
|
86
|
-
decimals: number;
|
|
87
|
-
type: 'UCD';
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
export declare namespace SatoshisConversions {
|
|
91
|
-
function fromBTC(btc: number | string): Satoshis;
|
|
92
|
-
function toBTC(satoshis: Satoshis): number;
|
|
93
|
-
function format(satoshis: Satoshis, unit?: 'BTC' | 'sats'): string;
|
|
94
|
-
/**
|
|
95
|
-
* Convert Satoshis to JSON-serializable string
|
|
96
|
-
*/
|
|
97
|
-
function toJSON(satoshis: Satoshis): string;
|
|
98
|
-
/**
|
|
99
|
-
* Parse Satoshis from JSON string
|
|
100
|
-
*/
|
|
101
|
-
function fromJSON(json: string): Satoshis;
|
|
102
|
-
/**
|
|
103
|
-
* Convert to structured serializable format with metadata
|
|
104
|
-
*/
|
|
105
|
-
function toSerializable(satoshis: Satoshis): {
|
|
106
|
-
value: string;
|
|
107
|
-
unit: 'satoshis';
|
|
108
|
-
type: 'Satoshis';
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
export declare namespace WeiConversions {
|
|
112
|
-
function fromWhole(whole: number | string): Wei;
|
|
113
|
-
function toWhole(wei: Wei): number;
|
|
114
|
-
function format(wei: Wei, decimals?: number): string;
|
|
115
|
-
/**
|
|
116
|
-
* Convert Wei to JSON-serializable string
|
|
117
|
-
*/
|
|
118
|
-
function toJSON(wei: Wei): string;
|
|
119
|
-
/**
|
|
120
|
-
* Parse Wei from JSON string
|
|
121
|
-
*/
|
|
122
|
-
function fromJSON(json: string): Wei;
|
|
123
|
-
/**
|
|
124
|
-
* Convert to structured serializable format with metadata
|
|
125
|
-
*/
|
|
126
|
-
function toSerializable(wei: Wei): {
|
|
127
|
-
value: string;
|
|
128
|
-
decimals: number;
|
|
129
|
-
type: 'Wei';
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
export declare namespace BPSConversions {
|
|
133
|
-
function fromPercent(percent: number): BPS;
|
|
134
|
-
function toPercent(bps: BPS): number;
|
|
135
|
-
function toDecimal(bps: BPS): number;
|
|
136
|
-
function format(bps: BPS): string;
|
|
137
|
-
}
|
|
138
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Branded identifier types for PKP and Position IDs.
|
|
3
|
-
*
|
|
4
|
-
* These provide lightweight nominal typing so that internal helpers can
|
|
5
|
-
* distinguish between generic strings and protocol identifiers, while
|
|
6
|
-
* still being freely assignable to `string` where needed.
|
|
7
|
-
*/
|
|
8
|
-
declare const __idBrand: unique symbol;
|
|
9
|
-
/**
|
|
10
|
-
* PKP token identifier (decimal string or hex string, depending on context).
|
|
11
|
-
*/
|
|
12
|
-
export type PkpId = string & {
|
|
13
|
-
readonly [__idBrand]: "PkpId";
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Position identifier (on-chain bytes32, represented as hex string in SDK).
|
|
17
|
-
*/
|
|
18
|
-
export type PositionId = string & {
|
|
19
|
-
readonly [__idBrand]: "PositionId";
|
|
20
|
-
};
|
|
21
|
-
export declare const PkpId: (value: string) => PkpId;
|
|
22
|
-
export declare const PositionId: (value: string) => PositionId;
|
|
23
|
-
export {};
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loan Event Types
|
|
3
|
-
*
|
|
4
|
-
* Type definitions for all loan-related events tracked by the Diamond Hands Protocol.
|
|
5
|
-
* These events are indexed by The Graph subgraph and can be queried via the SDK.
|
|
6
|
-
*/
|
|
7
|
-
export declare enum PaymentType {
|
|
8
|
-
FULL_REPAYMENT = "FULL_REPAYMENT",
|
|
9
|
-
PARTIAL_PAYMENT = "PARTIAL_PAYMENT",
|
|
10
|
-
EXTENSION_FEE = "EXTENSION_FEE"
|
|
11
|
-
}
|
|
12
|
-
export declare enum PositionStatus {
|
|
13
|
-
PENDING_DEPOSIT = "PENDING_DEPOSIT",
|
|
14
|
-
PENDING_MINT = "PENDING_MINT",
|
|
15
|
-
ACTIVE = "ACTIVE",
|
|
16
|
-
EXPIRED = "EXPIRED",
|
|
17
|
-
LIQUIDATABLE = "LIQUIDATABLE",
|
|
18
|
-
LIQUIDATED = "LIQUIDATED",
|
|
19
|
-
REPAID = "REPAID",
|
|
20
|
-
CLOSED = "CLOSED"
|
|
21
|
-
}
|
|
22
|
-
export interface PositionCreatedEvent {
|
|
23
|
-
id: string;
|
|
24
|
-
positionId: string;
|
|
25
|
-
pkpId: string;
|
|
26
|
-
borrower: string;
|
|
27
|
-
requestedCollateralRatio: string;
|
|
28
|
-
selectedTerm: string;
|
|
29
|
-
expiryAt: string;
|
|
30
|
-
timestamp: string;
|
|
31
|
-
blockNumber: string;
|
|
32
|
-
transactionHash: string;
|
|
33
|
-
}
|
|
34
|
-
export interface PaymentEvent {
|
|
35
|
-
id: string;
|
|
36
|
-
positionId: string;
|
|
37
|
-
payer: string;
|
|
38
|
-
amount: string;
|
|
39
|
-
type: PaymentType;
|
|
40
|
-
transactionHash: string;
|
|
41
|
-
timestamp: string;
|
|
42
|
-
blockNumber: string;
|
|
43
|
-
logIndex: string;
|
|
44
|
-
newDebt: string;
|
|
45
|
-
newCollateralRatio: string;
|
|
46
|
-
}
|
|
47
|
-
export interface StatusUpdateEvent {
|
|
48
|
-
id: string;
|
|
49
|
-
positionId: string;
|
|
50
|
-
oldStatus: PositionStatus;
|
|
51
|
-
newStatus: PositionStatus;
|
|
52
|
-
reason?: string;
|
|
53
|
-
timestamp: string;
|
|
54
|
-
blockNumber: string;
|
|
55
|
-
transactionHash: string;
|
|
56
|
-
}
|
|
57
|
-
export interface LiquidationEvent {
|
|
58
|
-
id: string;
|
|
59
|
-
positionId: string;
|
|
60
|
-
liquidator: string;
|
|
61
|
-
liquidatedAmount: string;
|
|
62
|
-
collateralSeized: string;
|
|
63
|
-
transactionHash: string;
|
|
64
|
-
timestamp: string;
|
|
65
|
-
blockNumber: string;
|
|
66
|
-
commitHash?: string;
|
|
67
|
-
commitTimestamp?: string;
|
|
68
|
-
revealDelay?: string;
|
|
69
|
-
}
|
|
70
|
-
export interface UCDMintEvent {
|
|
71
|
-
id: string;
|
|
72
|
-
positionId: string;
|
|
73
|
-
amount: string;
|
|
74
|
-
proof: string;
|
|
75
|
-
minter: string;
|
|
76
|
-
isCommunityMint: boolean;
|
|
77
|
-
timestamp: string;
|
|
78
|
-
blockNumber: string;
|
|
79
|
-
transactionHash: string;
|
|
80
|
-
}
|
|
81
|
-
export interface WithdrawalEvent {
|
|
82
|
-
id: string;
|
|
83
|
-
positionId: string;
|
|
84
|
-
withdrawalAmount: string;
|
|
85
|
-
withdrawalAddress: string;
|
|
86
|
-
networkFee?: string;
|
|
87
|
-
timestamp: string;
|
|
88
|
-
blockNumber: string;
|
|
89
|
-
transactionHash: string;
|
|
90
|
-
logIndex: string;
|
|
91
|
-
}
|
|
92
|
-
export interface RenewalEvent {
|
|
93
|
-
id: string;
|
|
94
|
-
positionId: string;
|
|
95
|
-
extensionTerm: string;
|
|
96
|
-
extensionFee: string;
|
|
97
|
-
newExpiryDate: string;
|
|
98
|
-
timestamp: string;
|
|
99
|
-
blockNumber: string;
|
|
100
|
-
transactionHash: string;
|
|
101
|
-
logIndex: string;
|
|
102
|
-
}
|
|
103
|
-
export interface OperationFailureEvent {
|
|
104
|
-
id: string;
|
|
105
|
-
positionId: string;
|
|
106
|
-
operationType: string;
|
|
107
|
-
reason: string;
|
|
108
|
-
errorCode?: string;
|
|
109
|
-
amount?: string;
|
|
110
|
-
timestamp: string;
|
|
111
|
-
blockNumber: string;
|
|
112
|
-
transactionHash: string;
|
|
113
|
-
logIndex: string;
|
|
114
|
-
}
|
|
115
|
-
export interface MintRequestEvent {
|
|
116
|
-
id: string;
|
|
117
|
-
positionId: string;
|
|
118
|
-
pkpId: string;
|
|
119
|
-
borrower: string;
|
|
120
|
-
mintAmount: string;
|
|
121
|
-
originationFee: string;
|
|
122
|
-
newDebt: string;
|
|
123
|
-
newCollateralRatio: string;
|
|
124
|
-
btcPrice: string;
|
|
125
|
-
quantumTimestamp: string;
|
|
126
|
-
opId: string;
|
|
127
|
-
timestamp: string;
|
|
128
|
-
blockNumber: string;
|
|
129
|
-
transactionHash: string;
|
|
130
|
-
logIndex: string;
|
|
131
|
-
}
|
|
132
|
-
export interface BurnRequestEvent {
|
|
133
|
-
id: string;
|
|
134
|
-
positionId: string;
|
|
135
|
-
pkpId: string;
|
|
136
|
-
borrower: string;
|
|
137
|
-
burnAmount: string;
|
|
138
|
-
remainingDebt: string;
|
|
139
|
-
newCollateralRatio: string;
|
|
140
|
-
opId: string;
|
|
141
|
-
timestamp: string;
|
|
142
|
-
blockNumber: string;
|
|
143
|
-
transactionHash: string;
|
|
144
|
-
logIndex: string;
|
|
145
|
-
}
|
|
146
|
-
/** Origination fee charged when UCD is minted via LIT Action (mintFee > 0). */
|
|
147
|
-
export interface MintingFeeEvent {
|
|
148
|
-
id: string;
|
|
149
|
-
positionId: string;
|
|
150
|
-
borrower: string;
|
|
151
|
-
feeAmount: string;
|
|
152
|
-
mintAmount: string;
|
|
153
|
-
newDebt: string;
|
|
154
|
-
btcPrice: string;
|
|
155
|
-
quantumTimestamp: string;
|
|
156
|
-
timestamp: string;
|
|
157
|
-
blockNumber: string;
|
|
158
|
-
transactionHash: string;
|
|
159
|
-
logIndex: string;
|
|
160
|
-
}
|
|
161
|
-
/** Extension fee charged when a position term is renewed (extensionFee > 0). */
|
|
162
|
-
export interface RenewalFeeEvent {
|
|
163
|
-
id: string;
|
|
164
|
-
positionId: string;
|
|
165
|
-
borrower: string;
|
|
166
|
-
feeAmount: string;
|
|
167
|
-
extensionTerm: string;
|
|
168
|
-
newExpiryDate: string;
|
|
169
|
-
timestamp: string;
|
|
170
|
-
blockNumber: string;
|
|
171
|
-
transactionHash: string;
|
|
172
|
-
logIndex: string;
|
|
173
|
-
}
|
|
174
|
-
/** Position-level collateral manager outcomes (POSITION_CLOSED, NETWORK_FEE_DEDUCTED) */
|
|
175
|
-
export interface CollateralContractEvent {
|
|
176
|
-
id: string;
|
|
177
|
-
positionId: string;
|
|
178
|
-
eventType: string;
|
|
179
|
-
networkFee?: string;
|
|
180
|
-
remainingCollateral?: string;
|
|
181
|
-
collateralRatio?: string;
|
|
182
|
-
timestamp: string;
|
|
183
|
-
blockNumber: string;
|
|
184
|
-
transactionHash: string;
|
|
185
|
-
logIndex: string;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Aggregate container for all position-scoped loan events.
|
|
189
|
-
* Protocol-global admin events (circuit breaker, term fees, price bounds, etc.)
|
|
190
|
-
* are available via sdk.getAllEvents({ kinds: ['admin'] }).
|
|
191
|
-
*/
|
|
192
|
-
export interface LoanEvents {
|
|
193
|
-
positionId: string;
|
|
194
|
-
positionCreated?: PositionCreatedEvent;
|
|
195
|
-
payments: PaymentEvent[];
|
|
196
|
-
statusUpdates: StatusUpdateEvent[];
|
|
197
|
-
liquidation?: LiquidationEvent;
|
|
198
|
-
mints: UCDMintEvent[];
|
|
199
|
-
withdrawals: WithdrawalEvent[];
|
|
200
|
-
renewals: RenewalEvent[];
|
|
201
|
-
operationFailures: OperationFailureEvent[];
|
|
202
|
-
mintRequests: MintRequestEvent[];
|
|
203
|
-
burnRequests: BurnRequestEvent[];
|
|
204
|
-
collateralEvents: CollateralContractEvent[];
|
|
205
|
-
/** Origination fees charged on UCD mints. Populated when the subgraph indexes MintingFeeEvent. */
|
|
206
|
-
mintingFees: MintingFeeEvent[];
|
|
207
|
-
/** Extension fees charged on position renewals. Populated when the subgraph indexes RenewalFeeEvent. */
|
|
208
|
-
renewalFees: RenewalFeeEvent[];
|
|
209
|
-
totalEvents: number;
|
|
210
|
-
}
|
|
211
|
-
export interface LoanEventsFilter {
|
|
212
|
-
eventTypes?: Array<'positionCreated' | 'payment' | 'status' | 'liquidation' | 'mint' | 'withdrawal' | 'renewal' | 'operationFailure' | 'mintRequest' | 'burnRequest' | 'collateralEvent' | 'mintingFee' | 'renewalFee'>;
|
|
213
|
-
fromTimestamp?: string;
|
|
214
|
-
toTimestamp?: string;
|
|
215
|
-
fromBlock?: string;
|
|
216
|
-
toBlock?: string;
|
|
217
|
-
limit?: number;
|
|
218
|
-
orderDirection?: 'asc' | 'desc';
|
|
219
|
-
}
|
|
220
|
-
export declare function isValidPositionStatus(status: string): status is PositionStatus;
|
|
221
|
-
export declare function isValidPaymentType(type: string): type is PaymentType;
|
|
222
|
-
export declare function numericToPositionStatus(status: number): PositionStatus;
|
|
223
|
-
export declare const EventHelpers: {
|
|
224
|
-
sortByTimestamp<T extends {
|
|
225
|
-
timestamp: string;
|
|
226
|
-
}>(events: T[], direction?: "asc" | "desc"): T[];
|
|
227
|
-
filterByTimestamp<T extends {
|
|
228
|
-
timestamp: string;
|
|
229
|
-
}>(events: T[], fromTimestamp?: string, toTimestamp?: string): T[];
|
|
230
|
-
filterByBlock<T extends {
|
|
231
|
-
blockNumber: string;
|
|
232
|
-
}>(events: T[], fromBlock?: string, toBlock?: string): T[];
|
|
233
|
-
getTotalCount(events: LoanEvents): number;
|
|
234
|
-
getAllEventsSorted(events: LoanEvents, direction?: "asc" | "desc"): Array<(PositionCreatedEvent & {
|
|
235
|
-
eventType: "positionCreated";
|
|
236
|
-
}) | (PaymentEvent & {
|
|
237
|
-
eventType: "payment";
|
|
238
|
-
}) | (StatusUpdateEvent & {
|
|
239
|
-
eventType: "status";
|
|
240
|
-
}) | (LiquidationEvent & {
|
|
241
|
-
eventType: "liquidation";
|
|
242
|
-
}) | (UCDMintEvent & {
|
|
243
|
-
eventType: "mint";
|
|
244
|
-
}) | (WithdrawalEvent & {
|
|
245
|
-
eventType: "withdrawal";
|
|
246
|
-
}) | (RenewalEvent & {
|
|
247
|
-
eventType: "renewal";
|
|
248
|
-
}) | (OperationFailureEvent & {
|
|
249
|
-
eventType: "operationFailure";
|
|
250
|
-
}) | (MintRequestEvent & {
|
|
251
|
-
eventType: "mintRequest";
|
|
252
|
-
}) | (BurnRequestEvent & {
|
|
253
|
-
eventType: "burnRequest";
|
|
254
|
-
}) | (CollateralContractEvent & {
|
|
255
|
-
eventType: "collateralEvent";
|
|
256
|
-
}) | (MintingFeeEvent & {
|
|
257
|
-
eventType: "mintingFee";
|
|
258
|
-
}) | (RenewalFeeEvent & {
|
|
259
|
-
eventType: "renewalFee";
|
|
260
|
-
})>;
|
|
261
|
-
};
|