@gearbox-protocol/sdk 14.12.0-next.16 → 14.12.0-next.18
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/{IWithdrawalCompressorV312.js → IWithdrawalCompressorV313.js} +49 -6
- package/dist/cjs/abi/compressors/subcompressors/withdrawal/mellowWithdrawalSubcompressor.js +45 -1
- package/dist/cjs/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.js +45 -1
- package/dist/cjs/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.js +45 -1
- package/dist/cjs/abi/compressors/withdrawalCompressor.js +45 -1
- package/dist/cjs/dev/index.js +3 -1
- package/dist/cjs/dev/withdrawalAbi.js +2105 -0
- package/dist/cjs/dev/withdrawalUtils.js +271 -0
- package/dist/cjs/permissionless/bindings/factory/rate-keeper-factory.js +35 -0
- package/dist/cjs/permissionless/bindings/market-configurator.js +11 -0
- package/dist/cjs/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.js +1015 -0
- package/dist/cjs/plugins/adapters/abi/adapters/{iMidasIssuanceVaultAdapter.js → iMidasIssuanceVaultAdapterV310.js} +6 -6
- package/dist/cjs/plugins/adapters/abi/adapters/{iMidasRedemptionVault.js → iMidasRedemptionVaultAdapterV310.js} +9 -9
- package/dist/cjs/plugins/adapters/abi/adapters/index.js +6 -4
- package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +3 -0
- package/dist/cjs/plugins/adapters/abi/targetContractAbi.js +3 -3
- package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +121 -0
- package/dist/cjs/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +2 -2
- package/dist/cjs/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +2 -2
- package/dist/cjs/plugins/adapters/contracts/index.js +2 -0
- package/dist/cjs/plugins/adapters/createAdapter.js +2 -0
- package/dist/cjs/plugins/adapters/types.js +1 -0
- package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +20 -37
- package/dist/cjs/sdk/OnchainSDK.js +11 -0
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +11 -58
- package/dist/cjs/sdk/accounts/index.js +3 -1
- package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +229 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +40 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +40 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +40 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/addresses.js +52 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +53 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/index.js +36 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/intent.js +172 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/types.js +16 -0
- package/dist/esm/abi/{IWithdrawalCompressorV312.js → IWithdrawalCompressorV313.js} +45 -2
- package/dist/esm/abi/compressors/subcompressors/withdrawal/mellowWithdrawalSubcompressor.js +45 -1
- package/dist/esm/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.js +45 -1
- package/dist/esm/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.js +45 -1
- package/dist/esm/abi/compressors/withdrawalCompressor.js +45 -1
- package/dist/esm/dev/index.js +1 -0
- package/dist/esm/dev/withdrawalAbi.js +2074 -0
- package/dist/esm/dev/withdrawalUtils.js +259 -0
- package/dist/esm/permissionless/bindings/factory/rate-keeper-factory.js +11 -0
- package/dist/esm/permissionless/bindings/market-configurator.js +11 -0
- package/dist/esm/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.js +990 -0
- package/dist/esm/plugins/adapters/abi/adapters/{iMidasIssuanceVaultAdapter.js → iMidasIssuanceVaultAdapterV310.js} +2 -2
- package/dist/esm/plugins/adapters/abi/adapters/{iMidasRedemptionVault.js → iMidasRedemptionVaultAdapterV310.js} +4 -4
- package/dist/esm/plugins/adapters/abi/adapters/index.js +3 -2
- package/dist/esm/plugins/adapters/abi/conctructorAbi.js +3 -0
- package/dist/esm/plugins/adapters/abi/targetContractAbi.js +2 -2
- package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +104 -0
- package/dist/esm/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +4 -4
- package/dist/esm/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +4 -4
- package/dist/esm/plugins/adapters/contracts/index.js +1 -0
- package/dist/esm/plugins/adapters/createAdapter.js +3 -0
- package/dist/esm/plugins/adapters/types.js +1 -0
- package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +21 -39
- package/dist/esm/sdk/OnchainSDK.js +13 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +10 -56
- package/dist/esm/sdk/accounts/index.js +1 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +205 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +16 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +16 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +16 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/addresses.js +28 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +29 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/index.js +8 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/intent.js +137 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/types.js +0 -0
- package/dist/types/abi/{IWithdrawalCompressorV312.d.ts → IWithdrawalCompressorV313.d.ts} +74 -1
- package/dist/types/abi/compressors/subcompressors/withdrawal/mellowWithdrawalSubcompressor.d.ts +77 -0
- package/dist/types/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.d.ts +77 -0
- package/dist/types/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.d.ts +77 -0
- package/dist/types/abi/compressors/withdrawalCompressor.d.ts +77 -0
- package/dist/types/dev/index.d.ts +1 -0
- package/dist/types/dev/withdrawalAbi.d.ts +1584 -0
- package/dist/types/dev/withdrawalUtils.d.ts +19 -0
- package/dist/types/permissionless/bindings/compressors/withdrawal-compressor.d.ts +77 -0
- package/dist/types/permissionless/bindings/factory/rate-keeper-factory.d.ts +179 -0
- package/dist/types/permissionless/bindings/market-configurator.d.ts +2 -0
- package/dist/types/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.d.ts +754 -0
- package/dist/types/plugins/adapters/abi/adapters/{iMidasIssuanceVaultAdapter.d.ts → iMidasIssuanceVaultAdapterV310.d.ts} +1 -1
- package/dist/types/plugins/adapters/abi/adapters/{iMidasRedemptionVault.d.ts → iMidasRedemptionVaultAdapterV310.d.ts} +2 -2
- package/dist/types/plugins/adapters/abi/adapters/index.d.ts +3 -2
- package/dist/types/plugins/adapters/abi/targetContractAbi.d.ts +1 -1
- package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +790 -0
- package/dist/types/plugins/adapters/contracts/index.d.ts +1 -0
- package/dist/types/plugins/adapters/types.d.ts +2 -1
- package/dist/types/plugins/delayed-withdrawal/types.d.ts +4 -17
- package/dist/types/sdk/OnchainSDK.d.ts +10 -1
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +4 -12
- package/dist/types/sdk/accounts/index.d.ts +1 -0
- package/dist/types/sdk/accounts/types.d.ts +5 -19
- package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +35 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.d.ts +334 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.d.ts +338 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +300 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/addresses.d.ts +21 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.d.ts +11 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +8 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/intent.d.ts +106 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +122 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const iMidasIssuanceVaultAdapterV310Abi = [
|
|
2
2
|
{
|
|
3
3
|
type: "function",
|
|
4
4
|
inputs: [],
|
|
@@ -234,5 +234,5 @@ const iMidasIssuanceVaultAdapterAbi = [
|
|
|
234
234
|
}
|
|
235
235
|
];
|
|
236
236
|
export {
|
|
237
|
-
|
|
237
|
+
iMidasIssuanceVaultAdapterV310Abi
|
|
238
238
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const iMidasRedemptionVaultAdapterV310Abi = [
|
|
2
2
|
{
|
|
3
3
|
type: "function",
|
|
4
4
|
inputs: [],
|
|
@@ -361,7 +361,7 @@ const iMidasRedemptionVaultAdapterAbi = [
|
|
|
361
361
|
name: "TokenNotAllowedException"
|
|
362
362
|
}
|
|
363
363
|
];
|
|
364
|
-
const
|
|
364
|
+
const iMidasRedemptionVaultGatewayV310Abi = [
|
|
365
365
|
{
|
|
366
366
|
type: "function",
|
|
367
367
|
inputs: [],
|
|
@@ -592,6 +592,6 @@ const iMidasRedemptionVaultGatewayAbi = [
|
|
|
592
592
|
}
|
|
593
593
|
];
|
|
594
594
|
export {
|
|
595
|
-
|
|
596
|
-
|
|
595
|
+
iMidasRedemptionVaultAdapterV310Abi,
|
|
596
|
+
iMidasRedemptionVaultGatewayV310Abi
|
|
597
597
|
};
|
|
@@ -18,8 +18,9 @@ export * from "./iLidoV1Adapter.js";
|
|
|
18
18
|
export * from "./iMellow4626VaultAdapter.js";
|
|
19
19
|
export * from "./iMellowClaimerAdapter.js";
|
|
20
20
|
export * from "./iMellowWrapperAdapter.js";
|
|
21
|
-
export * from "./
|
|
22
|
-
export * from "./
|
|
21
|
+
export * from "./iMidasGatewayAdapterV311.js";
|
|
22
|
+
export * from "./iMidasIssuanceVaultAdapterV310.js";
|
|
23
|
+
export * from "./iMidasRedemptionVaultAdapterV310.js";
|
|
23
24
|
export * from "./iPendleRouterAdapter.js";
|
|
24
25
|
export * from "./iStakingRewardsAdapter.js";
|
|
25
26
|
export * from "./iTraderJoeRouterAdapter.js";
|
|
@@ -3275,7 +3275,7 @@ const iMellowWrapperAbi = [
|
|
|
3275
3275
|
stateMutability: "nonpayable"
|
|
3276
3276
|
}
|
|
3277
3277
|
];
|
|
3278
|
-
const
|
|
3278
|
+
const iMidasIssuanceVaultV310Abi = [
|
|
3279
3279
|
{
|
|
3280
3280
|
type: "function",
|
|
3281
3281
|
name: "depositInstant",
|
|
@@ -4812,7 +4812,7 @@ export {
|
|
|
4812
4812
|
iKelpLRTWithdrawalManagerGatewayAbi,
|
|
4813
4813
|
iMellowClaimerAbi,
|
|
4814
4814
|
iMellowWrapperAbi,
|
|
4815
|
-
|
|
4815
|
+
iMidasIssuanceVaultV310Abi,
|
|
4816
4816
|
iPendleRouterAbi,
|
|
4817
4817
|
iStakingRewardsAbi,
|
|
4818
4818
|
iTraderJoeRouterAbi,
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
decodeAbiParameters
|
|
3
|
+
} from "viem";
|
|
4
|
+
import {
|
|
5
|
+
MissingSerializedParamsError
|
|
6
|
+
} from "../../../sdk/index.js";
|
|
7
|
+
import {
|
|
8
|
+
iMidasGatewayAdapterV311Abi,
|
|
9
|
+
iMidasGatewayV311Abi
|
|
10
|
+
} from "../abi/adapters/index.js";
|
|
11
|
+
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
12
|
+
const abi = iMidasGatewayAdapterV311Abi;
|
|
13
|
+
const protocolAbi = iMidasGatewayV311Abi;
|
|
14
|
+
class MidasGatewayAdapterContract extends AbstractAdapterContract {
|
|
15
|
+
#gateway;
|
|
16
|
+
#mToken;
|
|
17
|
+
#referrerId;
|
|
18
|
+
#allowedInputTokens;
|
|
19
|
+
#allowedOutputTokens;
|
|
20
|
+
constructor(options, args) {
|
|
21
|
+
super(options, { ...args, abi, protocolAbi });
|
|
22
|
+
if (args.baseParams.serializedParams) {
|
|
23
|
+
const decoded = decodeAbiParameters(
|
|
24
|
+
[
|
|
25
|
+
{ type: "address", name: "creditManager" },
|
|
26
|
+
{ type: "address", name: "targetContract" },
|
|
27
|
+
{ type: "address", name: "gateway" },
|
|
28
|
+
{ type: "address", name: "mToken" },
|
|
29
|
+
{ type: "bytes32", name: "referrerId" },
|
|
30
|
+
{ type: "address[]", name: "allowedInputTokens" },
|
|
31
|
+
{ type: "address[]", name: "allowedOutputTokens" },
|
|
32
|
+
{ type: "address[]", name: "allowedPhantomTokens" }
|
|
33
|
+
],
|
|
34
|
+
args.baseParams.serializedParams
|
|
35
|
+
);
|
|
36
|
+
this.#gateway = decoded[2];
|
|
37
|
+
this.#mToken = decoded[3];
|
|
38
|
+
this.#referrerId = decoded[4];
|
|
39
|
+
this.#allowedInputTokens = [...decoded[5]];
|
|
40
|
+
this.#allowedOutputTokens = decoded[6].map((token, index) => ({
|
|
41
|
+
token,
|
|
42
|
+
phantomToken: decoded[7][index]
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
get gateway() {
|
|
47
|
+
if (!this.#gateway) throw new MissingSerializedParamsError("gateway");
|
|
48
|
+
return this.#gateway;
|
|
49
|
+
}
|
|
50
|
+
get mToken() {
|
|
51
|
+
if (!this.#mToken) throw new MissingSerializedParamsError("mToken");
|
|
52
|
+
return this.#mToken;
|
|
53
|
+
}
|
|
54
|
+
get referrerId() {
|
|
55
|
+
if (this.#referrerId === void 0)
|
|
56
|
+
throw new MissingSerializedParamsError("referrerId");
|
|
57
|
+
return this.#referrerId;
|
|
58
|
+
}
|
|
59
|
+
get allowedInputTokens() {
|
|
60
|
+
if (!this.#allowedInputTokens)
|
|
61
|
+
throw new MissingSerializedParamsError("allowedInputTokens");
|
|
62
|
+
return this.#allowedInputTokens;
|
|
63
|
+
}
|
|
64
|
+
get allowedOutputTokens() {
|
|
65
|
+
if (!this.#allowedOutputTokens)
|
|
66
|
+
throw new MissingSerializedParamsError("allowedOutputTokens");
|
|
67
|
+
return this.#allowedOutputTokens;
|
|
68
|
+
}
|
|
69
|
+
stateHuman(raw) {
|
|
70
|
+
return {
|
|
71
|
+
...super.stateHuman(raw),
|
|
72
|
+
gateway: this.#gateway ? this.labelAddress(this.#gateway) : void 0,
|
|
73
|
+
mToken: this.#mToken ? this.labelAddress(this.#mToken) : void 0,
|
|
74
|
+
referrerId: this.#referrerId,
|
|
75
|
+
allowedInputTokens: this.#allowedInputTokens?.map(
|
|
76
|
+
(t) => this.labelAddress(t)
|
|
77
|
+
),
|
|
78
|
+
allowedOutputTokens: this.#allowedOutputTokens?.map((t) => ({
|
|
79
|
+
token: this.labelAddress(t.token),
|
|
80
|
+
phantomToken: this.labelAddress(t.phantomToken)
|
|
81
|
+
}))
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
decodeDiffLeftovers(decoded, balances) {
|
|
85
|
+
switch (decoded.functionName) {
|
|
86
|
+
case "depositInstantDiff": {
|
|
87
|
+
const [tokenIn, leftoverAmount] = decoded.args;
|
|
88
|
+
return [{ tokenIn, leftoverAmount }];
|
|
89
|
+
}
|
|
90
|
+
// redemptions spend the mToken down to the leftover, tokenOut arg is
|
|
91
|
+
// the received token
|
|
92
|
+
case "redeemInstantDiff":
|
|
93
|
+
case "redeemRequestDiff": {
|
|
94
|
+
const [, leftoverAmount] = decoded.args;
|
|
95
|
+
return [{ tokenIn: this.mToken, leftoverAmount }];
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
return super.decodeDiffLeftovers(decoded, balances);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
MidasGatewayAdapterContract
|
|
104
|
+
};
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
MissingSerializedParamsError
|
|
6
6
|
} from "../../../sdk/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { iMidasIssuanceVaultAdapterV310Abi } from "../abi/adapters/index.js";
|
|
8
|
+
import { iMidasIssuanceVaultV310Abi } from "../abi/targetContractAbi.js";
|
|
9
9
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
10
|
-
const abi =
|
|
11
|
-
const protocolAbi =
|
|
10
|
+
const abi = iMidasIssuanceVaultAdapterV310Abi;
|
|
11
|
+
const protocolAbi = iMidasIssuanceVaultV310Abi;
|
|
12
12
|
class MidasIssuanceVaultAdapterContract extends AbstractAdapterContract {
|
|
13
13
|
#mToken;
|
|
14
14
|
#referrerId;
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
MissingSerializedParamsError
|
|
6
6
|
} from "../../../sdk/index.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
iMidasRedemptionVaultAdapterV310Abi,
|
|
9
|
+
iMidasRedemptionVaultGatewayV310Abi
|
|
10
10
|
} from "../abi/adapters/index.js";
|
|
11
11
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
12
|
-
const abi =
|
|
13
|
-
const protocolAbi =
|
|
12
|
+
const abi = iMidasRedemptionVaultAdapterV310Abi;
|
|
13
|
+
const protocolAbi = iMidasRedemptionVaultGatewayV310Abi;
|
|
14
14
|
class MidasRedemptionVaultAdapterContract extends AbstractAdapterContract {
|
|
15
15
|
#gateway;
|
|
16
16
|
#mToken;
|
|
@@ -23,6 +23,7 @@ export * from "./MellowClaimerAdapterContract.js";
|
|
|
23
23
|
export * from "./MellowDVVAdapterContract.js";
|
|
24
24
|
export * from "./MellowERC4626VaultAdapterContract.js";
|
|
25
25
|
export * from "./MellowWrapperAdapterContract.js";
|
|
26
|
+
export * from "./MidasGatewayAdapterContract.js";
|
|
26
27
|
export * from "./MidasIssuanceVaultAdapterContract.js";
|
|
27
28
|
export * from "./MidasRedemptionVaultAdapterContract.js";
|
|
28
29
|
export * from "./PendleRouterAdapterContract.js";
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
MellowDVVAdapterContract,
|
|
27
27
|
MellowERC4626VaultAdapterContract,
|
|
28
28
|
MellowWrapperAdapterContract,
|
|
29
|
+
MidasGatewayAdapterContract,
|
|
29
30
|
MidasIssuanceVaultAdapterContract,
|
|
30
31
|
MidasRedemptionVaultAdapterContract,
|
|
31
32
|
PendleRouterAdapterContract,
|
|
@@ -94,6 +95,8 @@ function createAdapter(options, data, strict) {
|
|
|
94
95
|
return new MellowERC4626VaultAdapterContract(options, data);
|
|
95
96
|
case "ADAPTER::MELLOW_WRAPPER":
|
|
96
97
|
return new MellowWrapperAdapterContract(options, data);
|
|
98
|
+
case "ADAPTER::MIDAS_GATEWAY":
|
|
99
|
+
return new MidasGatewayAdapterContract(options, data);
|
|
97
100
|
case "ADAPTER::MIDAS_ISSUANCE_VAULT":
|
|
98
101
|
return new MidasIssuanceVaultAdapterContract(options, data);
|
|
99
102
|
case "ADAPTER::MIDAS_REDEMPTION_VAULT":
|
|
@@ -24,6 +24,7 @@ var AdapterType = /* @__PURE__ */ ((AdapterType2) => {
|
|
|
24
24
|
AdapterType2["MELLOW_DVV"] = "MELLOW_DVV";
|
|
25
25
|
AdapterType2["MELLOW_ERC4626_VAULT"] = "MELLOW_ERC4626_VAULT";
|
|
26
26
|
AdapterType2["MELLOW_WRAPPER"] = "MELLOW_WRAPPER";
|
|
27
|
+
AdapterType2["MIDAS_GATEWAY"] = "MIDAS_GATEWAY";
|
|
27
28
|
AdapterType2["MIDAS_ISSUANCE_VAULT"] = "MIDAS_ISSUANCE_VAULT";
|
|
28
29
|
AdapterType2["MIDAS_REDEMPTION_VAULT"] = "MIDAS_REDEMPTION_VAULT";
|
|
29
30
|
AdapterType2["PENDLE_ROUTER"] = "PENDLE_ROUTER";
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
|
|
2
|
-
import { iWithdrawalCompressorV311Abi } from "../../abi/IWithdrawalCompressorV311.js";
|
|
3
1
|
import {
|
|
4
2
|
AddressMap,
|
|
5
|
-
BasePlugin
|
|
6
|
-
getWithdrawalCompressorAddress
|
|
3
|
+
BasePlugin
|
|
7
4
|
} from "../../sdk/index.js";
|
|
8
5
|
const MAP_LABEL = "delayedWithdrawal";
|
|
9
6
|
class DelayedWithdrawalPlugin extends BasePlugin {
|
|
@@ -12,44 +9,29 @@ class DelayedWithdrawalPlugin extends BasePlugin {
|
|
|
12
9
|
if (!force && this.loaded) {
|
|
13
10
|
return this.state;
|
|
14
11
|
}
|
|
15
|
-
|
|
12
|
+
this.#withdrawableAssets = new AddressMap(void 0, MAP_LABEL);
|
|
13
|
+
const compressor = this.sdk.withdrawalCompressor();
|
|
16
14
|
this.sdk.logger?.debug(
|
|
17
|
-
`loading delayed withdrawal plugin with compressor ${compressor}`
|
|
15
|
+
`loading delayed withdrawal plugin with compressor ${compressor.address}`
|
|
18
16
|
);
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
const resp = await compressor.getWithdrawableAssetsBatch();
|
|
18
|
+
const byCreditManager = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const cfg of resp) {
|
|
20
|
+
const assets = byCreditManager.get(cfg.creditManager) ?? [];
|
|
21
|
+
assets.push({
|
|
22
|
+
...cfg,
|
|
23
|
+
disabled: isConfigToOmit({
|
|
24
|
+
creditManager: cfg.creditManager,
|
|
25
|
+
token: cfg.token,
|
|
26
|
+
withdrawalPhantomToken: cfg.withdrawalPhantomToken,
|
|
27
|
+
underlying: cfg.underlying
|
|
27
28
|
})
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const cm = creditManagers[index];
|
|
35
|
-
if (r.status === "success" && r.result?.length > 0) {
|
|
36
|
-
const configsToShow = r.result;
|
|
37
|
-
this.#withdrawableAssets?.upsert(
|
|
38
|
-
cm.creditManager.address,
|
|
39
|
-
configsToShow.map((cfg) => ({
|
|
40
|
-
...cfg,
|
|
41
|
-
creditManager: cm.creditManager.address,
|
|
42
|
-
disabled: isConfigToOmit({
|
|
43
|
-
creditManager: cm.creditManager.address,
|
|
44
|
-
token: cfg.token,
|
|
45
|
-
withdrawalPhantomToken: cfg.withdrawalPhantomToken,
|
|
46
|
-
underlying: cfg.underlying
|
|
47
|
-
})
|
|
48
|
-
}))
|
|
49
|
-
);
|
|
50
|
-
} else {
|
|
51
|
-
}
|
|
52
|
-
});
|
|
29
|
+
});
|
|
30
|
+
byCreditManager.set(cfg.creditManager, assets);
|
|
31
|
+
}
|
|
32
|
+
for (const [creditManager, assets] of byCreditManager) {
|
|
33
|
+
this.#withdrawableAssets.upsert(creditManager, assets);
|
|
34
|
+
}
|
|
53
35
|
return this.state;
|
|
54
36
|
}
|
|
55
37
|
get loaded() {
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
parseEventLogs
|
|
6
6
|
} from "viem";
|
|
7
7
|
import {
|
|
8
|
-
CreditAccountsServiceV310
|
|
8
|
+
CreditAccountsServiceV310,
|
|
9
|
+
createWithdrawalCompressor
|
|
9
10
|
} from "./accounts/index.js";
|
|
10
11
|
import { ChainContractsRegister } from "./base/index.js";
|
|
11
12
|
import { getChain } from "./chain/index.js";
|
|
@@ -534,6 +535,17 @@ class OnchainSDK extends ChainContractsRegister {
|
|
|
534
535
|
const [routerAddr, routerV] = routerEntry;
|
|
535
536
|
return createRouter(this, routerAddr, routerV);
|
|
536
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Lazily returns a withdrawal compressor contract for the current chain.
|
|
540
|
+
*
|
|
541
|
+
* @param version - Desired compressor version; when omitted, the latest
|
|
542
|
+
* version supported on the current chain is used.
|
|
543
|
+
* @throws If no withdrawal compressor of the given version is supported
|
|
544
|
+
* on the current chain.
|
|
545
|
+
**/
|
|
546
|
+
withdrawalCompressor(version) {
|
|
547
|
+
return createWithdrawalCompressor(this, version);
|
|
548
|
+
}
|
|
537
549
|
}
|
|
538
550
|
export {
|
|
539
551
|
OnchainSDK,
|
|
@@ -6,13 +6,10 @@ import {
|
|
|
6
6
|
import { creditAccountCompressorAbi } from "../../abi/compressors/creditAccountCompressor.js";
|
|
7
7
|
import { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
|
|
8
8
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
9
|
-
import { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
|
|
10
|
-
import { iWithdrawalCompressorV311Abi } from "../../abi/IWithdrawalCompressorV311.js";
|
|
11
9
|
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
12
10
|
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
13
11
|
import { iRWAFactoryAbi } from "../../abi/rwa/iRWAFactory.js";
|
|
14
12
|
import { SDKConstruct } from "../base/index.js";
|
|
15
|
-
import { chains } from "../chain/chains.js";
|
|
16
13
|
import {
|
|
17
14
|
ADDRESS_0X0,
|
|
18
15
|
AP_CREDIT_ACCOUNT_COMPRESSOR,
|
|
@@ -34,19 +31,6 @@ import {
|
|
|
34
31
|
extractQuotaTokens,
|
|
35
32
|
mergePriceUpdates
|
|
36
33
|
} from "./multicall-utils.js";
|
|
37
|
-
const COMPRESSORS = {
|
|
38
|
-
[chains.Mainnet.id]: {
|
|
39
|
-
address: "0x36F3d0Bb73CBC2E94fE24dF0f26a689409cF9023",
|
|
40
|
-
version: 310
|
|
41
|
-
},
|
|
42
|
-
[chains.Monad.id]: {
|
|
43
|
-
address: "0x36F3d0Bb73CBC2E94fE24dF0f26a689409cF9023",
|
|
44
|
-
version: 310
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
function getWithdrawalCompressorAddress(chainId) {
|
|
48
|
-
return COMPRESSORS[chainId];
|
|
49
|
-
}
|
|
50
34
|
class CreditAccountsServiceV310 extends SDKConstruct {
|
|
51
35
|
#compressor;
|
|
52
36
|
#batchSize;
|
|
@@ -797,22 +781,8 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
797
781
|
amount,
|
|
798
782
|
token
|
|
799
783
|
}) {
|
|
800
|
-
const compressor =
|
|
801
|
-
|
|
802
|
-
throw new Error(
|
|
803
|
-
`No compressor for current chain ${this.sdk.networkType}`
|
|
804
|
-
);
|
|
805
|
-
const contract = getContract({
|
|
806
|
-
address: compressor.address,
|
|
807
|
-
abi: compressor.version === 310 ? iWithdrawalCompressorV310Abi : iWithdrawalCompressorV311Abi,
|
|
808
|
-
client: this.client
|
|
809
|
-
});
|
|
810
|
-
const resp = await contract.read.getWithdrawalRequestResult([
|
|
811
|
-
creditAccount,
|
|
812
|
-
token,
|
|
813
|
-
amount
|
|
814
|
-
]);
|
|
815
|
-
return resp;
|
|
784
|
+
const compressor = this.sdk.withdrawalCompressor();
|
|
785
|
+
return compressor.getWithdrawalRequestResult(creditAccount, token, amount);
|
|
816
786
|
}
|
|
817
787
|
/**
|
|
818
788
|
* {@inheritDoc ICreditAccountsService.getPendingWithdrawals}
|
|
@@ -820,26 +790,12 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
820
790
|
async getPendingWithdrawals({
|
|
821
791
|
creditAccount
|
|
822
792
|
}) {
|
|
823
|
-
const compressor =
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
const contract = getContract({
|
|
829
|
-
address: compressor.address,
|
|
830
|
-
abi: compressor.version === 310 ? iWithdrawalCompressorV310Abi : iWithdrawalCompressorV311Abi,
|
|
831
|
-
client: this.client
|
|
832
|
-
});
|
|
833
|
-
const resp = await contract.read.getCurrentWithdrawals([creditAccount]);
|
|
834
|
-
const claimableNow = resp?.[0] || [];
|
|
835
|
-
const pendingResult = [...resp?.[1] || []].sort(
|
|
836
|
-
(a, b) => a.claimableAt < b.claimableAt ? -1 : 1
|
|
837
|
-
);
|
|
838
|
-
const respResult = {
|
|
839
|
-
claimableNow: [...claimableNow],
|
|
840
|
-
pending: pendingResult
|
|
793
|
+
const compressor = this.sdk.withdrawalCompressor();
|
|
794
|
+
const { claimable, pending } = await compressor.getCurrentWithdrawals(creditAccount);
|
|
795
|
+
return {
|
|
796
|
+
claimableNow: claimable,
|
|
797
|
+
pending
|
|
841
798
|
};
|
|
842
|
-
return respResult;
|
|
843
799
|
}
|
|
844
800
|
/**
|
|
845
801
|
* {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
|
|
@@ -1593,8 +1549,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
1593
1549
|
*/
|
|
1594
1550
|
assembleCaOperations({
|
|
1595
1551
|
operations,
|
|
1596
|
-
creditFacade
|
|
1597
|
-
withdrawTo
|
|
1552
|
+
creditFacade
|
|
1598
1553
|
}) {
|
|
1599
1554
|
const calls = [];
|
|
1600
1555
|
for (const op of operations) {
|
|
@@ -1620,7 +1575,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
1620
1575
|
creditFacade,
|
|
1621
1576
|
op.token,
|
|
1622
1577
|
op.amount,
|
|
1623
|
-
|
|
1578
|
+
op.to
|
|
1624
1579
|
)
|
|
1625
1580
|
);
|
|
1626
1581
|
break;
|
|
@@ -1874,6 +1829,5 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
1874
1829
|
}
|
|
1875
1830
|
}
|
|
1876
1831
|
export {
|
|
1877
|
-
CreditAccountsServiceV310
|
|
1878
|
-
getWithdrawalCompressorAddress
|
|
1832
|
+
CreditAccountsServiceV310
|
|
1879
1833
|
};
|