@gearbox-protocol/sdk 14.12.0-next.36 → 14.12.0-next.37
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/iRedemptionLoggerV310.js +119 -0
- package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +12 -0
- package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +12 -0
- package/dist/cjs/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +16 -0
- package/dist/cjs/preview/preview/detectDelayedClaim.js +53 -0
- package/dist/cjs/preview/preview/detectDelayedOperation.js +1 -2
- package/dist/cjs/preview/preview/errors.js +0 -17
- package/dist/cjs/preview/preview/index.js +2 -0
- package/dist/cjs/preview/preview/previewOperation.js +18 -1
- package/dist/cjs/sdk/OnchainSDK.js +11 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +72 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/createRedemptionLogger.js +43 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/errors.js +38 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/index.js +6 -0
- package/dist/cjs/sdk/constants/address-provider.js +3 -0
- package/dist/esm/abi/iRedemptionLoggerV310.js +95 -0
- package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +12 -0
- package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +12 -0
- package/dist/esm/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +16 -0
- package/dist/esm/preview/preview/detectDelayedClaim.js +30 -0
- package/dist/esm/preview/preview/detectDelayedOperation.js +3 -3
- package/dist/esm/preview/preview/errors.js +0 -16
- package/dist/esm/preview/preview/index.js +1 -0
- package/dist/esm/preview/preview/previewOperation.js +18 -1
- package/dist/esm/sdk/OnchainSDK.js +12 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +48 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/createRedemptionLogger.js +23 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/errors.js +14 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/index.js +3 -0
- package/dist/esm/sdk/constants/address-provider.js +2 -0
- package/dist/types/abi/iRedemptionLoggerV310.d.ts +122 -0
- package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +11 -1
- package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +6 -1
- package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +7 -1
- package/dist/types/plugins/adapters/types.d.ts +11 -0
- package/dist/types/preview/preview/detectDelayedClaim.d.ts +45 -0
- package/dist/types/preview/preview/errors.d.ts +0 -15
- package/dist/types/preview/preview/index.d.ts +1 -0
- package/dist/types/preview/preview/types.d.ts +15 -0
- package/dist/types/sdk/OnchainSDK.d.ts +8 -1
- package/dist/types/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +149 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/createRedemptionLogger.d.ts +10 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/errors.d.ts +13 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +3 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +43 -1
- package/dist/types/sdk/constants/address-provider.d.ts +1 -0
- package/package.json +1 -1
|
@@ -162,6 +162,18 @@ class AbstractAdapterContract extends BaseContract {
|
|
|
162
162
|
parseDelayedWithdrawalRequest(_calldata) {
|
|
163
163
|
return void 0;
|
|
164
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* When the given adapter calldata is a delayed-withdrawal claim (a call
|
|
167
|
+
* created by the withdrawal compressor that burns a withdrawal phantom
|
|
168
|
+
* token and receives the claim token from a redeemer), returns its
|
|
169
|
+
* descriptor; `undefined` for any other call.
|
|
170
|
+
*
|
|
171
|
+
* The base implementation returns `undefined`; adapters whose gateways log
|
|
172
|
+
* redemption intents (Securitize, Midas) override it.
|
|
173
|
+
*/
|
|
174
|
+
parseDelayedWithdrawalClaim(_calldata) {
|
|
175
|
+
return void 0;
|
|
176
|
+
}
|
|
165
177
|
/**
|
|
166
178
|
* Diff-call semantics of a diff-style adapter call: the call spends the
|
|
167
179
|
* consumed token down to the exact `leftoverAmount` encoded in its
|
|
@@ -99,6 +99,18 @@ class MidasGatewayAdapterContract extends AbstractAdapterContract {
|
|
|
99
99
|
extraData
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* `withdrawFromRedeemer(address redeemer, uint256 amount)` claims a matured
|
|
104
|
+
* redemption from a redeemer contract.
|
|
105
|
+
*/
|
|
106
|
+
parseDelayedWithdrawalClaim(calldata) {
|
|
107
|
+
const decoded = decodeFunctionData({ abi: this.abi, data: calldata });
|
|
108
|
+
if (decoded.functionName !== "withdrawFromRedeemer") {
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
const [redeemer] = decoded.args;
|
|
112
|
+
return { redeemer };
|
|
113
|
+
}
|
|
102
114
|
async applyBalanceChanges(balances, decoded) {
|
|
103
115
|
switch (decoded.functionName) {
|
|
104
116
|
case "depositInstantDiff": {
|
|
@@ -72,6 +72,22 @@ class SecuritizeRedemptionGatewayAdapterContract extends AbstractAdapterContract
|
|
|
72
72
|
extraData
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* `claim(address[] redeemers)` claims matured redemptions from redeemer
|
|
77
|
+
* contracts. Transactions built by the withdrawal compressor always claim
|
|
78
|
+
* from a single redeemer, so only the first one is reported.
|
|
79
|
+
*/
|
|
80
|
+
parseDelayedWithdrawalClaim(calldata) {
|
|
81
|
+
const decoded = decodeFunctionData({ abi: this.abi, data: calldata });
|
|
82
|
+
if (decoded.functionName !== "claim") {
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
const [redeemers] = decoded.args;
|
|
86
|
+
if (redeemers.length === 0) {
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
return { redeemer: redeemers[0] };
|
|
90
|
+
}
|
|
75
91
|
async applyBalanceChanges(balances, decoded) {
|
|
76
92
|
switch (decoded.functionName) {
|
|
77
93
|
// no-op:
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbstractAdapterContract
|
|
3
|
+
} from "../../plugins/adapters/index.js";
|
|
4
|
+
function detectDelayedClaim(sdk, multicall) {
|
|
5
|
+
for (const op of multicall) {
|
|
6
|
+
if (op.operation !== "Execute") {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
const adapter = sdk.getContract(op.adapter);
|
|
10
|
+
if (!(adapter instanceof AbstractAdapterContract)) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const claim = adapter.parseDelayedWithdrawalClaim(op.calldata);
|
|
14
|
+
if (claim) {
|
|
15
|
+
return { adapter: op.adapter, redeemer: claim.redeemer };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
async function resolveDelayedClaimIntent(sdk, multicall, blockNumber) {
|
|
21
|
+
const claim = detectDelayedClaim(sdk, multicall);
|
|
22
|
+
if (!claim) {
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
return sdk.redemptionLogger?.getDelayedIntent(claim.redeemer, blockNumber);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
detectDelayedClaim,
|
|
29
|
+
resolveDelayedClaimIntent
|
|
30
|
+
};
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
AbstractAdapterContract
|
|
4
4
|
} from "../../plugins/adapters/index.js";
|
|
5
5
|
import {
|
|
6
|
-
decodeDelayedIntent
|
|
6
|
+
decodeDelayedIntent,
|
|
7
|
+
InvalidDelayedIntentError
|
|
7
8
|
} from "../../sdk/index.js";
|
|
8
|
-
import { InvalidDelayedIntentError } from "./errors.js";
|
|
9
9
|
function detectDelayedOperation(sdk, multicall) {
|
|
10
10
|
let bracketDeltas = [];
|
|
11
11
|
for (const op of multicall) {
|
|
@@ -39,7 +39,7 @@ function detectDelayedOperation(sdk, multicall) {
|
|
|
39
39
|
try {
|
|
40
40
|
intent = decodeDelayedIntent(request.extraData);
|
|
41
41
|
} catch (e) {
|
|
42
|
-
throw new InvalidDelayedIntentError(
|
|
42
|
+
throw new InvalidDelayedIntentError(request.extraData, e);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
return { request, intent };
|
|
@@ -7,22 +7,6 @@ class UnsupportedOperationError extends Error {
|
|
|
7
7
|
this.operation = operation;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
class InvalidDelayedIntentError extends Error {
|
|
11
|
-
/** Adapter the withdrawal request was addressed to. */
|
|
12
|
-
adapter;
|
|
13
|
-
/** Raw `extraData` that failed to decode. */
|
|
14
|
-
extraData;
|
|
15
|
-
constructor(adapter, extraData, cause) {
|
|
16
|
-
super(
|
|
17
|
-
`cannot decode delayed intent from extraData ${extraData} of withdrawal request to adapter ${adapter}`,
|
|
18
|
-
{ cause }
|
|
19
|
-
);
|
|
20
|
-
this.name = "InvalidDelayedIntentError";
|
|
21
|
-
this.adapter = adapter;
|
|
22
|
-
this.extraData = extraData;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
10
|
export {
|
|
26
|
-
InvalidDelayedIntentError,
|
|
27
11
|
UnsupportedOperationError
|
|
28
12
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./buildDelayedPreview.js";
|
|
2
2
|
export * from "./CreditAccountState.js";
|
|
3
3
|
export * from "./detectCloseOrRepay.js";
|
|
4
|
+
export * from "./detectDelayedClaim.js";
|
|
4
5
|
export * from "./detectDelayedOperation.js";
|
|
5
6
|
export * from "./errors.js";
|
|
6
7
|
export * from "./previewAdjustCreditAccount.js";
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from "../parse/index.js";
|
|
5
5
|
import { buildDelayedPreview } from "./buildDelayedPreview.js";
|
|
6
6
|
import { isCloseOrRepay } from "./detectCloseOrRepay.js";
|
|
7
|
+
import { resolveDelayedClaimIntent } from "./detectDelayedClaim.js";
|
|
7
8
|
import { detectDelayedOperation } from "./detectDelayedOperation.js";
|
|
8
9
|
import { UnsupportedOperationError } from "./errors.js";
|
|
9
10
|
import { previewAdjustCreditAccount } from "./previewAdjustCreditAccount.js";
|
|
@@ -23,7 +24,18 @@ async function previewOperation(input, options) {
|
|
|
23
24
|
}
|
|
24
25
|
if (operation.operation === "CloseCreditAccount") {
|
|
25
26
|
const resolved = await resolveCreditAccount(input, operation, options);
|
|
26
|
-
|
|
27
|
+
const preview = await previewCloseOrRepayCreditAccount(
|
|
28
|
+
input,
|
|
29
|
+
operation,
|
|
30
|
+
true,
|
|
31
|
+
resolved
|
|
32
|
+
);
|
|
33
|
+
preview.intent = await resolveDelayedClaimIntent(
|
|
34
|
+
input.sdk,
|
|
35
|
+
operation.multicall,
|
|
36
|
+
options?.blockNumber
|
|
37
|
+
);
|
|
38
|
+
return preview;
|
|
27
39
|
}
|
|
28
40
|
if (operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "RWAMulticall") {
|
|
29
41
|
const resolved = await resolveCreditAccount(input, operation, options);
|
|
@@ -49,6 +61,11 @@ async function previewMulticallOperation(input, operation, options) {
|
|
|
49
61
|
const instantPreview = isCloseOrRepay(operation.multicall) ? await previewCloseOrRepayCreditAccount(input, operation, false, options) : await previewAdjustCreditAccount(input, operation, options);
|
|
50
62
|
const delayed = detectDelayedOperation(sdk, operation.multicall);
|
|
51
63
|
if (!delayed) {
|
|
64
|
+
instantPreview.intent = await resolveDelayedClaimIntent(
|
|
65
|
+
sdk,
|
|
66
|
+
operation.multicall,
|
|
67
|
+
options?.blockNumber
|
|
68
|
+
);
|
|
52
69
|
return instantPreview;
|
|
53
70
|
}
|
|
54
71
|
const { before, after } = await replayMulticall(sdk, operation, options);
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "viem";
|
|
7
7
|
import {
|
|
8
8
|
CreditAccountsServiceV310,
|
|
9
|
+
createRedemptionLogger,
|
|
9
10
|
createWithdrawalCompressor,
|
|
10
11
|
LiquidationsService
|
|
11
12
|
} from "./accounts/index.js";
|
|
@@ -69,6 +70,7 @@ class OnchainSDK extends ChainContractsRegister {
|
|
|
69
70
|
#marketRegister;
|
|
70
71
|
#priceFeeds;
|
|
71
72
|
#withdrawalCompressor;
|
|
73
|
+
#redemptionLogger;
|
|
72
74
|
/**
|
|
73
75
|
* Gas limit applied to read-only `eth_call` requests.
|
|
74
76
|
**/
|
|
@@ -554,6 +556,16 @@ class OnchainSDK extends ChainContractsRegister {
|
|
|
554
556
|
get withdrawalCompressor() {
|
|
555
557
|
return this.#withdrawalCompressor;
|
|
556
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* `RedemptionLogger` contract for the current chain, or `undefined` when
|
|
561
|
+
* it is not deployed on it. Created lazily on first access: the contract
|
|
562
|
+
* is resolved from the address provider, which is only available after
|
|
563
|
+
* the SDK is attached or hydrated.
|
|
564
|
+
**/
|
|
565
|
+
get redemptionLogger() {
|
|
566
|
+
this.#redemptionLogger ??= createRedemptionLogger(this);
|
|
567
|
+
return this.#redemptionLogger;
|
|
568
|
+
}
|
|
557
569
|
}
|
|
558
570
|
export {
|
|
559
571
|
OnchainSDK,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
2
|
+
import { BaseContract } from "../../base/index.js";
|
|
3
|
+
import { InvalidDelayedIntentError } from "./errors.js";
|
|
4
|
+
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
5
|
+
const abi = iRedemptionLoggerV310Abi;
|
|
6
|
+
class RedemptionLoggerV310Contract extends BaseContract {
|
|
7
|
+
constructor(sdk, address, version) {
|
|
8
|
+
super(sdk, {
|
|
9
|
+
addr: address,
|
|
10
|
+
name: "RedemptionLogger",
|
|
11
|
+
abi,
|
|
12
|
+
version
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the redemption data logged for a redeemer; all-zero fields when
|
|
17
|
+
* nothing was logged for it.
|
|
18
|
+
**/
|
|
19
|
+
async getRedemptionLog(redeemer, blockNumber) {
|
|
20
|
+
return this.contract.read.redemptionLogs([redeemer], {
|
|
21
|
+
blockNumber
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Reads the redemption log of a redeemer and decodes the recorded intent.
|
|
26
|
+
*
|
|
27
|
+
* @param redeemer - Redeemer contract the withdrawal is claimed from.
|
|
28
|
+
* @param blockNumber - Optional block number to read the log at.
|
|
29
|
+
* @returns The decoded intent, or `undefined` when the log carries none
|
|
30
|
+
* (including when nothing was logged for the redeemer).
|
|
31
|
+
* @throws InvalidDelayedIntentError when the logged `extraData` is
|
|
32
|
+
* non-empty but cannot be decoded as a `DelayedIntent`.
|
|
33
|
+
**/
|
|
34
|
+
async getDelayedIntent(redeemer, blockNumber) {
|
|
35
|
+
const log = await this.getRedemptionLog(redeemer, blockNumber);
|
|
36
|
+
if (!log.extraData || log.extraData === "0x") {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return decodeDelayedIntent(log.extraData);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
throw new InvalidDelayedIntentError(log.extraData, e);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
RedemptionLoggerV310Contract
|
|
48
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AP_REDEMPTION_LOGGER,
|
|
3
|
+
isV310,
|
|
4
|
+
VERSION_RANGE_310
|
|
5
|
+
} from "../../constants/index.js";
|
|
6
|
+
import { RedemptionLoggerV310Contract } from "./RedemptionLoggerV310Contract.js";
|
|
7
|
+
function createRedemptionLogger(sdk) {
|
|
8
|
+
const latest = sdk.addressProvider.getLatest(
|
|
9
|
+
AP_REDEMPTION_LOGGER,
|
|
10
|
+
VERSION_RANGE_310
|
|
11
|
+
);
|
|
12
|
+
if (!latest) {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
const [address, version] = latest;
|
|
16
|
+
if (isV310(version)) {
|
|
17
|
+
return new RedemptionLoggerV310Contract(sdk, address, version);
|
|
18
|
+
}
|
|
19
|
+
throw new Error(`Unsupported redemption logger version: ${version}`);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
createRedemptionLogger
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class InvalidDelayedIntentError extends Error {
|
|
2
|
+
/** Raw `extraData` that failed to decode. */
|
|
3
|
+
extraData;
|
|
4
|
+
constructor(extraData, cause) {
|
|
5
|
+
super(`cannot decode delayed intent from extraData ${extraData}`, {
|
|
6
|
+
cause
|
|
7
|
+
});
|
|
8
|
+
this.name = "InvalidDelayedIntentError";
|
|
9
|
+
this.extraData = extraData;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
InvalidDelayedIntentError
|
|
14
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from "./AbstractWithdrawalCompressorContract.js";
|
|
2
2
|
export * from "./addresses.js";
|
|
3
|
+
export * from "./createRedemptionLogger.js";
|
|
3
4
|
export * from "./createWithdrawalCompressor.js";
|
|
5
|
+
export * from "./errors.js";
|
|
4
6
|
export * from "./intent-codec.js";
|
|
7
|
+
export * from "./RedemptionLoggerV310Contract.js";
|
|
5
8
|
export * from "./types.js";
|
|
6
9
|
export * from "./WithdrawalCompressorV310Contract.js";
|
|
7
10
|
export * from "./WithdrawalCompressorV311Contract.js";
|
|
@@ -32,6 +32,7 @@ const AP_WETH_TOKEN = "WETH_TOKEN";
|
|
|
32
32
|
const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
|
|
33
33
|
const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
|
|
34
34
|
const AP_RWA_COMPRESSOR = "GLOBAL::RWA_COMPRESSOR";
|
|
35
|
+
const AP_REDEMPTION_LOGGER = "LOCAL::REDEMPTION_LOGGER";
|
|
35
36
|
const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
|
|
36
37
|
export {
|
|
37
38
|
ADDRESS_PROVIDER_V310,
|
|
@@ -59,6 +60,7 @@ export {
|
|
|
59
60
|
AP_PRICE_FEED_COMPRESSOR,
|
|
60
61
|
AP_PRICE_FEED_STORE,
|
|
61
62
|
AP_PRICE_ORACLE,
|
|
63
|
+
AP_REDEMPTION_LOGGER,
|
|
62
64
|
AP_REWARDS_COMPRESSOR,
|
|
63
65
|
AP_ROUTER,
|
|
64
66
|
AP_RWA_COMPRESSOR,
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ABI of `IRedemptionLogger` from `@gearbox-protocol/integrations-v3`,
|
|
3
|
+
* copied from the forge artifact `out/IRedemptionLogger.sol/IRedemptionLogger.json`
|
|
4
|
+
*/
|
|
5
|
+
export declare const iRedemptionLoggerV310Abi: readonly [{
|
|
6
|
+
readonly type: "function";
|
|
7
|
+
readonly name: "allowedGateways";
|
|
8
|
+
readonly inputs: readonly [{
|
|
9
|
+
readonly name: "gateway";
|
|
10
|
+
readonly type: "address";
|
|
11
|
+
readonly internalType: "address";
|
|
12
|
+
}];
|
|
13
|
+
readonly outputs: readonly [{
|
|
14
|
+
readonly name: "";
|
|
15
|
+
readonly type: "bool";
|
|
16
|
+
readonly internalType: "bool";
|
|
17
|
+
}];
|
|
18
|
+
readonly stateMutability: "view";
|
|
19
|
+
}, {
|
|
20
|
+
readonly type: "function";
|
|
21
|
+
readonly name: "contractType";
|
|
22
|
+
readonly inputs: readonly [];
|
|
23
|
+
readonly outputs: readonly [{
|
|
24
|
+
readonly name: "";
|
|
25
|
+
readonly type: "bytes32";
|
|
26
|
+
readonly internalType: "bytes32";
|
|
27
|
+
}];
|
|
28
|
+
readonly stateMutability: "view";
|
|
29
|
+
}, {
|
|
30
|
+
readonly type: "function";
|
|
31
|
+
readonly name: "logRedemption";
|
|
32
|
+
readonly inputs: readonly [{
|
|
33
|
+
readonly name: "creditAccount";
|
|
34
|
+
readonly type: "address";
|
|
35
|
+
readonly internalType: "address";
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "redeemer";
|
|
38
|
+
readonly type: "address";
|
|
39
|
+
readonly internalType: "address";
|
|
40
|
+
}, {
|
|
41
|
+
readonly name: "extraData";
|
|
42
|
+
readonly type: "bytes";
|
|
43
|
+
readonly internalType: "bytes";
|
|
44
|
+
}];
|
|
45
|
+
readonly outputs: readonly [];
|
|
46
|
+
readonly stateMutability: "nonpayable";
|
|
47
|
+
}, {
|
|
48
|
+
readonly type: "function";
|
|
49
|
+
readonly name: "redemptionLogs";
|
|
50
|
+
readonly inputs: readonly [{
|
|
51
|
+
readonly name: "redeemer";
|
|
52
|
+
readonly type: "address";
|
|
53
|
+
readonly internalType: "address";
|
|
54
|
+
}];
|
|
55
|
+
readonly outputs: readonly [{
|
|
56
|
+
readonly name: "";
|
|
57
|
+
readonly type: "tuple";
|
|
58
|
+
readonly internalType: "struct IRedemptionLogger.RedemptionLog";
|
|
59
|
+
readonly components: readonly [{
|
|
60
|
+
readonly name: "creditAccount";
|
|
61
|
+
readonly type: "address";
|
|
62
|
+
readonly internalType: "address";
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "redeemer";
|
|
65
|
+
readonly type: "address";
|
|
66
|
+
readonly internalType: "address";
|
|
67
|
+
}, {
|
|
68
|
+
readonly name: "extraData";
|
|
69
|
+
readonly type: "bytes";
|
|
70
|
+
readonly internalType: "bytes";
|
|
71
|
+
}];
|
|
72
|
+
}];
|
|
73
|
+
readonly stateMutability: "view";
|
|
74
|
+
}, {
|
|
75
|
+
readonly type: "function";
|
|
76
|
+
readonly name: "setGatewayAllowed";
|
|
77
|
+
readonly inputs: readonly [{
|
|
78
|
+
readonly name: "gateway";
|
|
79
|
+
readonly type: "address";
|
|
80
|
+
readonly internalType: "address";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "allowed";
|
|
83
|
+
readonly type: "bool";
|
|
84
|
+
readonly internalType: "bool";
|
|
85
|
+
}];
|
|
86
|
+
readonly outputs: readonly [];
|
|
87
|
+
readonly stateMutability: "nonpayable";
|
|
88
|
+
}, {
|
|
89
|
+
readonly type: "function";
|
|
90
|
+
readonly name: "version";
|
|
91
|
+
readonly inputs: readonly [];
|
|
92
|
+
readonly outputs: readonly [{
|
|
93
|
+
readonly name: "";
|
|
94
|
+
readonly type: "uint256";
|
|
95
|
+
readonly internalType: "uint256";
|
|
96
|
+
}];
|
|
97
|
+
readonly stateMutability: "view";
|
|
98
|
+
}, {
|
|
99
|
+
readonly type: "event";
|
|
100
|
+
readonly name: "RedemptionLogged";
|
|
101
|
+
readonly inputs: readonly [{
|
|
102
|
+
readonly name: "creditAccount";
|
|
103
|
+
readonly type: "address";
|
|
104
|
+
readonly indexed: true;
|
|
105
|
+
readonly internalType: "address";
|
|
106
|
+
}, {
|
|
107
|
+
readonly name: "redeemer";
|
|
108
|
+
readonly type: "address";
|
|
109
|
+
readonly indexed: true;
|
|
110
|
+
readonly internalType: "address";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "extraData";
|
|
113
|
+
readonly type: "bytes";
|
|
114
|
+
readonly indexed: false;
|
|
115
|
+
readonly internalType: "bytes";
|
|
116
|
+
}];
|
|
117
|
+
readonly anonymous: false;
|
|
118
|
+
}, {
|
|
119
|
+
readonly type: "error";
|
|
120
|
+
readonly name: "GatewayNotAllowedException";
|
|
121
|
+
readonly inputs: readonly [];
|
|
122
|
+
}];
|
|
@@ -3,7 +3,7 @@ import { type CallTrace } from "../../../common-utils/utils/trace.js";
|
|
|
3
3
|
import type { AssetsMap, OnchainSDK, ParsedCallV2, RelaxedBaseParams } from "../../../sdk/index.js";
|
|
4
4
|
import { BaseContract } from "../../../sdk/index.js";
|
|
5
5
|
import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
|
|
6
|
-
import type { AdapterContractStateHuman, AdapterContractType, AdapterProtocolOperation, DelayedWithdrawalRequest } from "../types.js";
|
|
6
|
+
import type { AdapterContractStateHuman, AdapterContractType, AdapterProtocolOperation, DelayedWithdrawalClaim, DelayedWithdrawalRequest } from "../types.js";
|
|
7
7
|
export interface ConcreteAdapterContractOptions {
|
|
8
8
|
baseParams: RelaxedBaseParams;
|
|
9
9
|
}
|
|
@@ -74,6 +74,16 @@ export declare class AbstractAdapterContract<const abi extends Abi | readonly un
|
|
|
74
74
|
* {@link applyBalanceChanges} cases for the same methods.
|
|
75
75
|
*/
|
|
76
76
|
parseDelayedWithdrawalRequest(_calldata: Hex): DelayedWithdrawalRequest | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* When the given adapter calldata is a delayed-withdrawal claim (a call
|
|
79
|
+
* created by the withdrawal compressor that burns a withdrawal phantom
|
|
80
|
+
* token and receives the claim token from a redeemer), returns its
|
|
81
|
+
* descriptor; `undefined` for any other call.
|
|
82
|
+
*
|
|
83
|
+
* The base implementation returns `undefined`; adapters whose gateways log
|
|
84
|
+
* redemption intents (Securitize, Midas) override it.
|
|
85
|
+
*/
|
|
86
|
+
parseDelayedWithdrawalClaim(_calldata: Hex): DelayedWithdrawalClaim | undefined;
|
|
77
87
|
/**
|
|
78
88
|
* Diff-call semantics of a diff-style adapter call: the call spends the
|
|
79
89
|
* consumed token down to the exact `leftoverAmount` encoded in its
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType, type Hex } from "viem";
|
|
2
2
|
import { type AssetsMap, type OnchainSDK } from "../../../sdk/index.js";
|
|
3
|
-
import type { DelayedWithdrawalRequest } from "../types.js";
|
|
3
|
+
import type { DelayedWithdrawalClaim, DelayedWithdrawalRequest } from "../types.js";
|
|
4
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
5
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
6
|
declare const abi: readonly [{
|
|
@@ -604,6 +604,11 @@ export declare class MidasGatewayAdapterContract extends AbstractAdapterContract
|
|
|
604
604
|
* the intent `extraData`.
|
|
605
605
|
*/
|
|
606
606
|
parseDelayedWithdrawalRequest(calldata: Hex): DelayedWithdrawalRequest | undefined;
|
|
607
|
+
/**
|
|
608
|
+
* `withdrawFromRedeemer(address redeemer, uint256 amount)` claims a matured
|
|
609
|
+
* redemption from a redeemer contract.
|
|
610
|
+
*/
|
|
611
|
+
parseDelayedWithdrawalClaim(calldata: Hex): DelayedWithdrawalClaim | undefined;
|
|
607
612
|
protected applyBalanceChanges(balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
|
|
608
613
|
}
|
|
609
614
|
export {};
|
package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType, type Hex } from "viem";
|
|
2
2
|
import { type AssetsMap, type OnchainSDK } from "../../../sdk/index.js";
|
|
3
|
-
import type { DelayedWithdrawalRequest } from "../types.js";
|
|
3
|
+
import type { DelayedWithdrawalClaim, DelayedWithdrawalRequest } from "../types.js";
|
|
4
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
5
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
6
|
declare const abi: readonly [{
|
|
@@ -446,6 +446,12 @@ export declare class SecuritizeRedemptionGatewayAdapterContract extends Abstract
|
|
|
446
446
|
* intent `extraData`.
|
|
447
447
|
*/
|
|
448
448
|
parseDelayedWithdrawalRequest(calldata: Hex): DelayedWithdrawalRequest | undefined;
|
|
449
|
+
/**
|
|
450
|
+
* `claim(address[] redeemers)` claims matured redemptions from redeemer
|
|
451
|
+
* contracts. Transactions built by the withdrawal compressor always claim
|
|
452
|
+
* from a single redeemer, so only the first one is reported.
|
|
453
|
+
*/
|
|
454
|
+
parseDelayedWithdrawalClaim(calldata: Hex): DelayedWithdrawalClaim | undefined;
|
|
449
455
|
protected applyBalanceChanges(balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
|
|
450
456
|
}
|
|
451
457
|
export {};
|
|
@@ -89,6 +89,17 @@ export interface DelayedWithdrawalRequest {
|
|
|
89
89
|
*/
|
|
90
90
|
extraData?: Hex;
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Descriptor of a delayed-withdrawal claim performed by an adapter call
|
|
94
|
+
* (constructed by the withdrawal compressor): the withdrawal phantom token
|
|
95
|
+
* is burned and the claim token is received from the redeemer.
|
|
96
|
+
*/
|
|
97
|
+
export interface DelayedWithdrawalClaim {
|
|
98
|
+
/**
|
|
99
|
+
* Redeemer contract the withdrawal is claimed from
|
|
100
|
+
*/
|
|
101
|
+
redeemer: Address;
|
|
102
|
+
}
|
|
92
103
|
/**
|
|
93
104
|
* True when the plugin map `P` contains the {@link AdaptersPlugin} under any key
|
|
94
105
|
*/
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { type SdkWithAdapters } from "../../plugins/adapters/index.js";
|
|
3
|
+
import type { DelayedIntent, PluginsMap } from "../../sdk/index.js";
|
|
4
|
+
import type { InnerOperation } from "../parse/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* A delayed-withdrawal claim detected in a credit-facade multicall,
|
|
7
|
+
* produced by `detectDelayedClaim`.
|
|
8
|
+
*/
|
|
9
|
+
export interface DetectedDelayedClaim {
|
|
10
|
+
/**
|
|
11
|
+
* Adapter the claim call is addressed to
|
|
12
|
+
*/
|
|
13
|
+
adapter: Address;
|
|
14
|
+
/**
|
|
15
|
+
* Redeemer contract the withdrawal is claimed from. Transactions built by
|
|
16
|
+
* the withdrawal compressor always claim from a single redeemer, so when
|
|
17
|
+
* the adapter method accepts multiple redeemers, only the first one is
|
|
18
|
+
* reported.
|
|
19
|
+
*/
|
|
20
|
+
redeemer: Address;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Scans a credit-facade multicall for a delayed-withdrawal claim call.
|
|
24
|
+
*
|
|
25
|
+
* @param sdk - SDK with the adapters plugin attached.
|
|
26
|
+
* @param multicall - Parsed inner operations of the multicall.
|
|
27
|
+
* @returns The detected claim, or `undefined` when the multicall contains no
|
|
28
|
+
* delayed-withdrawal claim call.
|
|
29
|
+
*/
|
|
30
|
+
export declare function detectDelayedClaim<P extends PluginsMap>(sdk: SdkWithAdapters<P>, multicall: InnerOperation[]): DetectedDelayedClaim | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the delayed intent of the withdrawal a multicall claims: detects
|
|
33
|
+
* the claim call and reads the recorded intent of the claimed redeemer from
|
|
34
|
+
* the `RedemptionLogger` contract.
|
|
35
|
+
*
|
|
36
|
+
* @param sdk - SDK with the adapters plugin attached.
|
|
37
|
+
* @param multicall - Parsed inner operations of the multicall.
|
|
38
|
+
* @param blockNumber - Optional block number to read the log at.
|
|
39
|
+
* @returns The decoded intent, or `undefined` when the multicall claims
|
|
40
|
+
* nothing, the redemption logger is not deployed, or the log carries no
|
|
41
|
+
* intent.
|
|
42
|
+
* @throws InvalidDelayedIntentError when the logged `extraData` is non-empty
|
|
43
|
+
* but cannot be decoded as a `DelayedIntent`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveDelayedClaimIntent<P extends PluginsMap>(sdk: SdkWithAdapters<P>, multicall: InnerOperation[], blockNumber?: bigint): Promise<DelayedIntent | undefined>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
2
1
|
/**
|
|
3
2
|
* Thrown by `previewOperation` for parsed operations it cannot preview yet.
|
|
4
3
|
* Currently only pool operations and credit account opening are supported.
|
|
@@ -8,17 +7,3 @@ export declare class UnsupportedOperationError extends Error {
|
|
|
8
7
|
readonly operation: string;
|
|
9
8
|
constructor(operation: string);
|
|
10
9
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Thrown when a delayed-withdrawal request carries non-empty `extraData`
|
|
13
|
-
* that cannot be decoded as a `DelayedIntent`. Requests produced by our
|
|
14
|
-
* stack always encode a valid intent, so garbage here means a
|
|
15
|
-
* malformed/foreign transaction that must not be previewed as if it were
|
|
16
|
-
* fine.
|
|
17
|
-
*/
|
|
18
|
-
export declare class InvalidDelayedIntentError extends Error {
|
|
19
|
-
/** Adapter the withdrawal request was addressed to. */
|
|
20
|
-
readonly adapter: Address;
|
|
21
|
-
/** Raw `extraData` that failed to decode. */
|
|
22
|
-
readonly extraData: Hex;
|
|
23
|
-
constructor(adapter: Address, extraData: Hex, cause?: unknown);
|
|
24
|
-
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./buildDelayedPreview.js";
|
|
2
2
|
export * from "./CreditAccountState.js";
|
|
3
3
|
export * from "./detectCloseOrRepay.js";
|
|
4
|
+
export * from "./detectDelayedClaim.js";
|
|
4
5
|
export * from "./detectDelayedOperation.js";
|
|
5
6
|
export * from "./errors.js";
|
|
6
7
|
export * from "./previewAdjustCreditAccount.js";
|
|
@@ -194,6 +194,11 @@ export interface AdjustCreditAccountPreview {
|
|
|
194
194
|
* Assets after minus assets before
|
|
195
195
|
*/
|
|
196
196
|
assetsChange: Asset[];
|
|
197
|
+
/**
|
|
198
|
+
* Intent of the delayed withdrawal this transaction claims; set when the
|
|
199
|
+
* multicall claims a delayed withdrawal
|
|
200
|
+
*/
|
|
201
|
+
intent?: DelayedIntent;
|
|
197
202
|
/**
|
|
198
203
|
* Set when preview encountered non-fatal errors, all fields are
|
|
199
204
|
* still computed best-effort, but derived fields (`assets`, `assetsChange`,
|
|
@@ -225,6 +230,11 @@ export interface CloseCreditAccountPreview {
|
|
|
225
230
|
* underlying share converts 1:1 into)
|
|
226
231
|
*/
|
|
227
232
|
receivedAmount: Asset;
|
|
233
|
+
/**
|
|
234
|
+
* Intent of the delayed withdrawal this transaction claims; set when the
|
|
235
|
+
* multicall claims a delayed withdrawal
|
|
236
|
+
*/
|
|
237
|
+
intent?: DelayedIntent;
|
|
228
238
|
/**
|
|
229
239
|
* Set when preview encountered non-fatal errors, all fields are
|
|
230
240
|
* still computed best-effort, but the
|
|
@@ -265,6 +275,11 @@ export interface RepayCreditAccountPreview {
|
|
|
265
275
|
* Total debt repaid: principal + accrued interest + fees, in underlying
|
|
266
276
|
*/
|
|
267
277
|
debtRepaid: bigint;
|
|
278
|
+
/**
|
|
279
|
+
* Intent of the delayed withdrawal this transaction claims; set when the
|
|
280
|
+
* multicall claims a delayed withdrawal
|
|
281
|
+
*/
|
|
282
|
+
intent?: DelayedIntent;
|
|
268
283
|
/**
|
|
269
284
|
* Set when preview encountered non-fatal errors, all fields are
|
|
270
285
|
* still computed best-effort, but the
|