@gearbox-protocol/sdk 14.12.0-next.62 → 14.12.0-next.64
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/dev/index.js +0 -1
- package/dist/cjs/dev/securitizeUtils.js +35 -107
- package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +2 -2
- package/dist/cjs/sdk/accounts/liquidations/helpers.js +33 -16
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/index.js +2 -2
- package/dist/esm/dev/securitizeUtils.js +36 -107
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/permissionless/bindings/factory/credit-factory.js +1 -1
- package/dist/esm/plugins/adapters/abi/conctructorAbi.js +2 -2
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/sdk/accounts/liquidations/helpers.js +33 -16
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +2 -2
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/dev/index.d.ts +2 -2
- package/dist/types/dev/securitizeUtils.d.ts +1 -11
- package/dist/types/sdk/accounts/liquidations/helpers.d.ts +3 -3
- package/dist/types/sdk/accounts/liquidations/types.d.ts +7 -10
- package/package.json +1 -1
package/dist/cjs/dev/index.js
CHANGED
|
@@ -46,7 +46,6 @@ exports.createAnvilClient = require_dev_createAnvilClient.createAnvilClient;
|
|
|
46
46
|
exports.createMinter = require_dev_mint_factory.createMinter;
|
|
47
47
|
exports.deployUsingPublicCreate2 = require_dev_create2.deployUsingPublicCreate2;
|
|
48
48
|
exports.detectChain = require_dev_detectChain.detectChain;
|
|
49
|
-
exports.disableDSTokenLockPeriods = require_dev_securitizeUtils.disableDSTokenLockPeriods;
|
|
50
49
|
exports.evmMineDetailed = require_dev_createAnvilClient.evmMineDetailed;
|
|
51
50
|
exports.extendAnvilClient = require_dev_createAnvilClient.extendAnvilClient;
|
|
52
51
|
exports.faucetAbi = require_dev_abi.faucetAbi;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sdk_utils_AddressSet = require("../sdk/utils/AddressSet.js");
|
|
3
2
|
const require_sdk_OnchainSDK = require("../sdk/OnchainSDK.js");
|
|
4
3
|
require("../sdk/index.js");
|
|
5
4
|
const require_abi_rwa_iDSToken = require("../abi/rwa/iDSToken.js");
|
|
@@ -18,11 +17,10 @@ const iDSComplianceConfigurationServiceAbi = (0, viem.parseAbi)([
|
|
|
18
17
|
"function setNonUSLockPeriod(uint256) external"
|
|
19
18
|
]);
|
|
20
19
|
/**
|
|
21
|
-
* Returns
|
|
22
|
-
*
|
|
23
|
-
* has no compliance configuration service (e.g. MockDSToken)
|
|
20
|
+
* Returns the longest of US and non-US compliance lock periods, or `undefined`
|
|
21
|
+
* when the token has no compliance configuration service (e.g. MockDSToken)
|
|
24
22
|
*/
|
|
25
|
-
async function
|
|
23
|
+
async function getLockPeriod({ anvil, token, logger }) {
|
|
26
24
|
try {
|
|
27
25
|
const complianceConfiguration = await anvil.readContract({
|
|
28
26
|
address: token,
|
|
@@ -43,10 +41,8 @@ async function getUnlockedIssuanceTime({ anvil, token, logger }) {
|
|
|
43
41
|
}],
|
|
44
42
|
allowFailure: false
|
|
45
43
|
});
|
|
46
|
-
const lockPeriod = usLockPeriod > nonUSLockPeriod ? usLockPeriod : nonUSLockPeriod;
|
|
47
|
-
const { timestamp } = await anvil.getBlock();
|
|
48
44
|
logger?.debug(`Lock periods: US ${usLockPeriod}, non-US ${nonUSLockPeriod} (compliance configuration service ${complianceConfiguration})`);
|
|
49
|
-
return
|
|
45
|
+
return usLockPeriod > nonUSLockPeriod ? usLockPeriod : nonUSLockPeriod;
|
|
50
46
|
} catch (e) {
|
|
51
47
|
logger?.debug(`Failed to get compliance lock periods: ${e}`);
|
|
52
48
|
return;
|
|
@@ -61,27 +57,39 @@ async function getUnlockedIssuanceTime({ anvil, token, logger }) {
|
|
|
61
57
|
*/
|
|
62
58
|
async function issueDSTokens(props) {
|
|
63
59
|
const { anvil, account, token, investor, amount, logger } = props;
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
const lockPeriod = await getLockPeriod(props);
|
|
61
|
+
if (lockPeriod !== void 0) {
|
|
62
|
+
const { timestamp } = await anvil.getBlock();
|
|
63
|
+
const issuanceTime = timestamp - lockPeriod - 1n;
|
|
64
|
+
try {
|
|
65
|
+
await require_dev_kycUtils.writeAndWait(anvil, {
|
|
66
|
+
account,
|
|
67
|
+
chain: anvil.chain,
|
|
68
|
+
address: token,
|
|
69
|
+
abi: require_abi_rwa_iDSToken.iDSTokenAbi,
|
|
70
|
+
functionName: "issueTokensCustom",
|
|
71
|
+
args: [
|
|
72
|
+
investor,
|
|
73
|
+
amount,
|
|
74
|
+
issuanceTime,
|
|
75
|
+
0n,
|
|
76
|
+
"",
|
|
77
|
+
0n
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
logger?.debug({
|
|
75
81
|
issuanceTime,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
logger?.debug(`issueTokensCustom failed: ${e}`);
|
|
82
|
+
investor,
|
|
83
|
+
amount
|
|
84
|
+
}, "issueTokensCustom successful");
|
|
85
|
+
} catch (e) {
|
|
86
|
+
logger?.debug(`issueTokensCustom failed: ${e}`);
|
|
87
|
+
}
|
|
83
88
|
}
|
|
84
|
-
logger?.debug(
|
|
89
|
+
logger?.debug({
|
|
90
|
+
investor,
|
|
91
|
+
amount
|
|
92
|
+
}, "Falling back to issueTokens");
|
|
85
93
|
return require_dev_kycUtils.writeAndWait(anvil, {
|
|
86
94
|
account,
|
|
87
95
|
chain: anvil.chain,
|
|
@@ -91,85 +99,6 @@ async function issueDSTokens(props) {
|
|
|
91
99
|
args: [investor, amount]
|
|
92
100
|
});
|
|
93
101
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Zeros US and non-US compliance lock periods on each DSToken's compliance
|
|
96
|
-
* configuration service so collateral can be transferred during testnet
|
|
97
|
-
* liquidations (e.g. STAC). No-ops for tokens without a compliance service
|
|
98
|
-
* (MockDSToken) or when both periods are already 0.
|
|
99
|
-
*
|
|
100
|
-
* Must be signed by a DS admin with sufficient trust (same key as
|
|
101
|
-
* `issueTokens` / registerInvestor); Ownable `owner()` alone is not enough.
|
|
102
|
-
*/
|
|
103
|
-
async function disableDSTokenLockPeriods(props) {
|
|
104
|
-
const { anvil, adminPrivateKey, logger } = props;
|
|
105
|
-
const account = (0, viem_accounts.privateKeyToAccount)(adminPrivateKey);
|
|
106
|
-
const tokens = [...new require_sdk_utils_AddressSet.AddressSet(props.tokens)];
|
|
107
|
-
for (const token of tokens) {
|
|
108
|
-
const symbol = await anvil.readContract({
|
|
109
|
-
address: token,
|
|
110
|
-
abi: viem.erc20Abi,
|
|
111
|
-
functionName: "symbol",
|
|
112
|
-
args: []
|
|
113
|
-
}).catch(() => token);
|
|
114
|
-
const tokenLogger = logger?.child?.({ symbol }) ?? logger;
|
|
115
|
-
let complianceConfiguration;
|
|
116
|
-
try {
|
|
117
|
-
complianceConfiguration = await anvil.readContract({
|
|
118
|
-
address: token,
|
|
119
|
-
abi: require_abi_rwa_iDSToken.iDSTokenAbi,
|
|
120
|
-
functionName: "getDSService",
|
|
121
|
-
args: [COMPLIANCE_CONFIGURATION_SERVICE]
|
|
122
|
-
});
|
|
123
|
-
} catch (e) {
|
|
124
|
-
tokenLogger?.debug(`Skipping lock-period disable for ${symbol}: no compliance service (${e})`);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if ((0, viem.isAddressEqual)(complianceConfiguration, viem.zeroAddress)) {
|
|
128
|
-
tokenLogger?.debug(`Skipping lock-period disable for ${symbol}: compliance configuration service is zero`);
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
let usLockPeriod;
|
|
132
|
-
let nonUSLockPeriod;
|
|
133
|
-
try {
|
|
134
|
-
[usLockPeriod, nonUSLockPeriod] = await anvil.multicall({
|
|
135
|
-
contracts: [{
|
|
136
|
-
address: complianceConfiguration,
|
|
137
|
-
abi: iDSComplianceConfigurationServiceAbi,
|
|
138
|
-
functionName: "getUSLockPeriod"
|
|
139
|
-
}, {
|
|
140
|
-
address: complianceConfiguration,
|
|
141
|
-
abi: iDSComplianceConfigurationServiceAbi,
|
|
142
|
-
functionName: "getNonUSLockPeriod"
|
|
143
|
-
}],
|
|
144
|
-
allowFailure: false
|
|
145
|
-
});
|
|
146
|
-
} catch (e) {
|
|
147
|
-
tokenLogger?.debug(`Skipping lock-period disable for ${symbol}: failed to read lock periods (${e})`);
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (usLockPeriod === 0n && nonUSLockPeriod === 0n) {
|
|
151
|
-
tokenLogger?.debug(`Lock periods already 0 for ${symbol} (${complianceConfiguration})`);
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
tokenLogger?.info(`Zeroing lock periods for ${symbol}: US ${usLockPeriod} → 0, non-US ${nonUSLockPeriod} → 0 (${complianceConfiguration})`);
|
|
155
|
-
if (usLockPeriod !== 0n) await require_dev_kycUtils.writeAndWait(anvil, {
|
|
156
|
-
account,
|
|
157
|
-
chain: anvil.chain,
|
|
158
|
-
address: complianceConfiguration,
|
|
159
|
-
abi: iDSComplianceConfigurationServiceAbi,
|
|
160
|
-
functionName: "setUSLockPeriod",
|
|
161
|
-
args: [0n]
|
|
162
|
-
});
|
|
163
|
-
if (nonUSLockPeriod !== 0n) await require_dev_kycUtils.writeAndWait(anvil, {
|
|
164
|
-
account,
|
|
165
|
-
chain: anvil.chain,
|
|
166
|
-
address: complianceConfiguration,
|
|
167
|
-
abi: iDSComplianceConfigurationServiceAbi,
|
|
168
|
-
functionName: "setNonUSLockPeriod",
|
|
169
|
-
args: [0n]
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
102
|
async function claimDSToken(props) {
|
|
174
103
|
const { anvil, investor, adminPrivateKey, token, marketConfigurators, rwaFactories, usdAmount: usdAmountProp = "100000" } = props;
|
|
175
104
|
const account = (0, viem_accounts.privateKeyToAccount)(adminPrivateKey);
|
|
@@ -235,4 +164,3 @@ async function claimDSTokens(props) {
|
|
|
235
164
|
//#endregion
|
|
236
165
|
exports.claimDSToken = claimDSToken;
|
|
237
166
|
exports.claimDSTokens = claimDSTokens;
|
|
238
|
-
exports.disableDSTokenLockPeriods = disableDSTokenLockPeriods;
|
|
@@ -20,6 +20,7 @@ const adapterConstructorAbi = {
|
|
|
20
20
|
["INFINIFI_GATEWAY"]: { 310: require_plugins_adapters_abi_conctructorAbiPatterns.BASIC_ADAPTER_ABI },
|
|
21
21
|
["LIDO_V1"]: { 310: require_plugins_adapters_abi_conctructorAbiPatterns.BASIC_ADAPTER_ABI },
|
|
22
22
|
["LIDO_WSTETH_V1"]: { 310: require_plugins_adapters_abi_conctructorAbiPatterns.BASIC_ADAPTER_ABI },
|
|
23
|
+
["MIDAS_GATEWAY"]: { 311: require_plugins_adapters_abi_conctructorAbiPatterns.REFERER_ID_ADAPTER_ABI },
|
|
23
24
|
["MIDAS_REDEMPTION_VAULT"]: {
|
|
24
25
|
310: require_plugins_adapters_abi_conctructorAbiPatterns.BASIC_ADAPTER_ABI,
|
|
25
26
|
311: require_plugins_adapters_abi_conctructorAbiPatterns.BASIC_ADAPTER_ABI
|
|
@@ -71,8 +72,7 @@ const adapterConstructorAbi = {
|
|
|
71
72
|
["MIDAS_ISSUANCE_VAULT"]: {
|
|
72
73
|
310: require_plugins_adapters_abi_conctructorAbiPatterns.REFERER_ID_ADAPTER_ABI,
|
|
73
74
|
311: require_plugins_adapters_abi_conctructorAbiPatterns.REFERER_ID_ADAPTER_ABI
|
|
74
|
-
}
|
|
75
|
-
["MIDAS_GATEWAY"]: { 311: require_plugins_adapters_abi_conctructorAbiPatterns.REFERER_ID_ADAPTER_ABI }
|
|
75
|
+
}
|
|
76
76
|
};
|
|
77
77
|
//#endregion
|
|
78
78
|
exports.adapterConstructorAbi = adapterConstructorAbi;
|
|
@@ -63,9 +63,36 @@ function pickMainAsset(ca, convert) {
|
|
|
63
63
|
return bestToken;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
66
|
+
* Converts the single output of a liquidator's delayed withdrawal into an asset.
|
|
67
|
+
*
|
|
68
|
+
* @param outputs - `outputs` or `expectedOutputs` of a withdrawal
|
|
69
|
+
* @param sourceToken - Source token of the withdrawal, for error reporting
|
|
70
|
+
**/
|
|
71
|
+
function toWithdrawalOutputAsset(outputs, sourceToken) {
|
|
72
|
+
const [output] = outputs;
|
|
73
|
+
if (outputs.length !== 1 || !output) throw new Error(`expected exactly one output for withdrawal of ${sourceToken}, got ${outputs.length}`);
|
|
74
|
+
return {
|
|
75
|
+
balance: output.amount,
|
|
76
|
+
token: output.token
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Converts the claim calls of a liquidator's delayed withdrawal into a
|
|
81
|
+
* transaction.
|
|
82
|
+
*
|
|
83
|
+
* @param claimCalls - `claimCalls` of a claimable withdrawal
|
|
84
|
+
* @param sourceToken - Source token of the withdrawal, for error reporting
|
|
85
|
+
* @returns The claim transaction, or `undefined` when there is no claim call
|
|
86
|
+
**/
|
|
87
|
+
function toWithdrawalClaimTx(claimCalls, sourceToken) {
|
|
88
|
+
if (claimCalls.length > 1) throw new Error(`expected at most one claim call for withdrawal of ${sourceToken}, got ${claimCalls.length}`);
|
|
89
|
+
const [call] = claimCalls;
|
|
90
|
+
return call ? liquidationCallToRawTx(call) : void 0;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Flattens delayed withdrawals of a liquidator into rows: claimable
|
|
94
|
+
* withdrawals have no `claimableAt` (claimable now) and carry a `claimTx`,
|
|
95
|
+
* pending ones carry the estimated claim timestamp.
|
|
69
96
|
*
|
|
70
97
|
* @param current - Claimable and pending withdrawals from the withdrawal compressor
|
|
71
98
|
* @param network - Network the withdrawals live on
|
|
@@ -76,25 +103,15 @@ function toLiquidatorWithdrawals(current, network, chainId) {
|
|
|
76
103
|
network,
|
|
77
104
|
chainId,
|
|
78
105
|
sourceToken: w.token,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
balance: o.amount,
|
|
82
|
-
token: o.token
|
|
83
|
-
};
|
|
84
|
-
}),
|
|
85
|
-
claimCalls: w.claimCalls,
|
|
106
|
+
output: toWithdrawalOutputAsset(w.outputs, w.token),
|
|
107
|
+
claimTx: toWithdrawalClaimTx(w.claimCalls, w.token),
|
|
86
108
|
redeemer: w.redeemer
|
|
87
109
|
});
|
|
88
110
|
for (const w of current.pending) rows.push({
|
|
89
111
|
network,
|
|
90
112
|
chainId,
|
|
91
113
|
sourceToken: w.token,
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
balance: o.amount,
|
|
95
|
-
token: o.token
|
|
96
|
-
};
|
|
97
|
-
}),
|
|
114
|
+
output: toWithdrawalOutputAsset(w.expectedOutputs, w.token),
|
|
98
115
|
claimableAt: w.claimableAt,
|
|
99
116
|
redeemer: w.redeemer
|
|
100
117
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { ierc20Abi } from "../abi/iERC20.js";
|
|
1
2
|
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../sdk/utils/AddressMap.js";
|
|
3
4
|
import { AddressSet } from "../sdk/utils/AddressSet.js";
|
|
4
5
|
import { AssetsMap } from "../sdk/utils/AssetsMap.js";
|
|
5
6
|
import { childLogger } from "../sdk/utils/childLogger.js";
|
|
6
|
-
import { ierc20Abi } from "../abi/iERC20.js";
|
|
7
7
|
import "../sdk/constants/addresses.js";
|
|
8
8
|
import { MAX_UINT256, PERCENTAGE_FACTOR } from "../sdk/constants/math.js";
|
|
9
9
|
import { SDKConstruct } from "../sdk/base/SDKConstruct.js";
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -21,8 +21,8 @@ import { migrateFaucet } from "./migrateFaucet.js";
|
|
|
21
21
|
import { SUPPORTED_RPC_PROVIDERS, getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getRpcProviderUrl, getThirdWebUrl, rpcProvidersSchema } from "./providers.js";
|
|
22
22
|
import { replaceStorage } from "./replaceStorage.js";
|
|
23
23
|
import { resilientTransport, resilientTransportOptionsSchema } from "./resilientTransport.js";
|
|
24
|
-
import { claimDSToken, claimDSTokens
|
|
24
|
+
import { claimDSToken, claimDSTokens } from "./securitizeUtils.js";
|
|
25
25
|
import "./types.js";
|
|
26
26
|
import { ONCHAIN_EXECUTION_ID_ADDRESS, verifyTestnet } from "./verifyTestnet.js";
|
|
27
27
|
import { makePendingWithdrawalsClaimable } from "./withdrawalUtils.js";
|
|
28
|
-
export { AccountOpener, Create2Deployer, DEFAULT_CREATE2_SALT, EthCallSpy, NoAvailableTransportsError, ONCHAIN_EXECUTION_ID_ADDRESS, OpenTxRevertedError, PUBLIC_CREATE2_FACTORY, RevolverTransport, SUPPORTED_RPC_PROVIDERS, SelectionStrategy, anvilNodeInfo, calcLiquidatableLTs, claimDSToken, claimDSTokens, claimFromFaucet, createAnvilClient, createMinter, deployUsingPublicCreate2, detectChain,
|
|
28
|
+
export { AccountOpener, Create2Deployer, DEFAULT_CREATE2_SALT, EthCallSpy, NoAvailableTransportsError, ONCHAIN_EXECUTION_ID_ADDRESS, OpenTxRevertedError, PUBLIC_CREATE2_FACTORY, RevolverTransport, SUPPORTED_RPC_PROVIDERS, SelectionStrategy, anvilNodeInfo, calcLiquidatableLTs, claimDSToken, claimDSTokens, claimFromFaucet, createAnvilClient, createMinter, deployUsingPublicCreate2, detectChain, evmMineDetailed, extendAnvilClient, faucetAbi, getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getPublicCreate2Address, getRpcProviderUrl, getThirdWebUrl, greenlistMidasGateway, httpTransportOptionsSchema, iDegenNftv2Abi, iOnchainExecutionIdAbi, iOwnableAbi, iaclTraitAbi, isAnvil, isDeployedUsingPublicCreate2, isOutOfSyncError, isRangeError, isRateLimitError, isTransientError, logSplitterTransport, makePendingWithdrawalsClaimable, migrateFaucet, prependMidasReceiveGreenlist, providerConfigSchema, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor, replaceStorage, resilientTransport, resilientTransportOptionsSchema, revolverTransportConfigBaseSchema, revolverTransportConfigSchema, rpcProvidersSchema, setLTZero, setLTs, verifyTestnet, writeAndWait };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AddressSet } from "../sdk/utils/AddressSet.js";
|
|
2
1
|
import { OnchainSDK } from "../sdk/OnchainSDK.js";
|
|
3
2
|
import "../sdk/index.js";
|
|
4
3
|
import { iDSTokenAbi } from "../abi/rwa/iDSToken.js";
|
|
@@ -17,11 +16,10 @@ const iDSComplianceConfigurationServiceAbi = parseAbi([
|
|
|
17
16
|
"function setNonUSLockPeriod(uint256) external"
|
|
18
17
|
]);
|
|
19
18
|
/**
|
|
20
|
-
* Returns
|
|
21
|
-
*
|
|
22
|
-
* has no compliance configuration service (e.g. MockDSToken)
|
|
19
|
+
* Returns the longest of US and non-US compliance lock periods, or `undefined`
|
|
20
|
+
* when the token has no compliance configuration service (e.g. MockDSToken)
|
|
23
21
|
*/
|
|
24
|
-
async function
|
|
22
|
+
async function getLockPeriod({ anvil, token, logger }) {
|
|
25
23
|
try {
|
|
26
24
|
const complianceConfiguration = await anvil.readContract({
|
|
27
25
|
address: token,
|
|
@@ -42,10 +40,8 @@ async function getUnlockedIssuanceTime({ anvil, token, logger }) {
|
|
|
42
40
|
}],
|
|
43
41
|
allowFailure: false
|
|
44
42
|
});
|
|
45
|
-
const lockPeriod = usLockPeriod > nonUSLockPeriod ? usLockPeriod : nonUSLockPeriod;
|
|
46
|
-
const { timestamp } = await anvil.getBlock();
|
|
47
43
|
logger?.debug(`Lock periods: US ${usLockPeriod}, non-US ${nonUSLockPeriod} (compliance configuration service ${complianceConfiguration})`);
|
|
48
|
-
return
|
|
44
|
+
return usLockPeriod > nonUSLockPeriod ? usLockPeriod : nonUSLockPeriod;
|
|
49
45
|
} catch (e) {
|
|
50
46
|
logger?.debug(`Failed to get compliance lock periods: ${e}`);
|
|
51
47
|
return;
|
|
@@ -60,27 +56,39 @@ async function getUnlockedIssuanceTime({ anvil, token, logger }) {
|
|
|
60
56
|
*/
|
|
61
57
|
async function issueDSTokens(props) {
|
|
62
58
|
const { anvil, account, token, investor, amount, logger } = props;
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
59
|
+
const lockPeriod = await getLockPeriod(props);
|
|
60
|
+
if (lockPeriod !== void 0) {
|
|
61
|
+
const { timestamp } = await anvil.getBlock();
|
|
62
|
+
const issuanceTime = timestamp - lockPeriod - 1n;
|
|
63
|
+
try {
|
|
64
|
+
await writeAndWait(anvil, {
|
|
65
|
+
account,
|
|
66
|
+
chain: anvil.chain,
|
|
67
|
+
address: token,
|
|
68
|
+
abi: iDSTokenAbi,
|
|
69
|
+
functionName: "issueTokensCustom",
|
|
70
|
+
args: [
|
|
71
|
+
investor,
|
|
72
|
+
amount,
|
|
73
|
+
issuanceTime,
|
|
74
|
+
0n,
|
|
75
|
+
"",
|
|
76
|
+
0n
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
logger?.debug({
|
|
74
80
|
issuanceTime,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
logger?.debug(`issueTokensCustom failed: ${e}`);
|
|
81
|
+
investor,
|
|
82
|
+
amount
|
|
83
|
+
}, "issueTokensCustom successful");
|
|
84
|
+
} catch (e) {
|
|
85
|
+
logger?.debug(`issueTokensCustom failed: ${e}`);
|
|
86
|
+
}
|
|
82
87
|
}
|
|
83
|
-
logger?.debug(
|
|
88
|
+
logger?.debug({
|
|
89
|
+
investor,
|
|
90
|
+
amount
|
|
91
|
+
}, "Falling back to issueTokens");
|
|
84
92
|
return writeAndWait(anvil, {
|
|
85
93
|
account,
|
|
86
94
|
chain: anvil.chain,
|
|
@@ -90,85 +98,6 @@ async function issueDSTokens(props) {
|
|
|
90
98
|
args: [investor, amount]
|
|
91
99
|
});
|
|
92
100
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Zeros US and non-US compliance lock periods on each DSToken's compliance
|
|
95
|
-
* configuration service so collateral can be transferred during testnet
|
|
96
|
-
* liquidations (e.g. STAC). No-ops for tokens without a compliance service
|
|
97
|
-
* (MockDSToken) or when both periods are already 0.
|
|
98
|
-
*
|
|
99
|
-
* Must be signed by a DS admin with sufficient trust (same key as
|
|
100
|
-
* `issueTokens` / registerInvestor); Ownable `owner()` alone is not enough.
|
|
101
|
-
*/
|
|
102
|
-
async function disableDSTokenLockPeriods(props) {
|
|
103
|
-
const { anvil, adminPrivateKey, logger } = props;
|
|
104
|
-
const account = privateKeyToAccount(adminPrivateKey);
|
|
105
|
-
const tokens = [...new AddressSet(props.tokens)];
|
|
106
|
-
for (const token of tokens) {
|
|
107
|
-
const symbol = await anvil.readContract({
|
|
108
|
-
address: token,
|
|
109
|
-
abi: erc20Abi,
|
|
110
|
-
functionName: "symbol",
|
|
111
|
-
args: []
|
|
112
|
-
}).catch(() => token);
|
|
113
|
-
const tokenLogger = logger?.child?.({ symbol }) ?? logger;
|
|
114
|
-
let complianceConfiguration;
|
|
115
|
-
try {
|
|
116
|
-
complianceConfiguration = await anvil.readContract({
|
|
117
|
-
address: token,
|
|
118
|
-
abi: iDSTokenAbi,
|
|
119
|
-
functionName: "getDSService",
|
|
120
|
-
args: [COMPLIANCE_CONFIGURATION_SERVICE]
|
|
121
|
-
});
|
|
122
|
-
} catch (e) {
|
|
123
|
-
tokenLogger?.debug(`Skipping lock-period disable for ${symbol}: no compliance service (${e})`);
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (isAddressEqual(complianceConfiguration, zeroAddress)) {
|
|
127
|
-
tokenLogger?.debug(`Skipping lock-period disable for ${symbol}: compliance configuration service is zero`);
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
let usLockPeriod;
|
|
131
|
-
let nonUSLockPeriod;
|
|
132
|
-
try {
|
|
133
|
-
[usLockPeriod, nonUSLockPeriod] = await anvil.multicall({
|
|
134
|
-
contracts: [{
|
|
135
|
-
address: complianceConfiguration,
|
|
136
|
-
abi: iDSComplianceConfigurationServiceAbi,
|
|
137
|
-
functionName: "getUSLockPeriod"
|
|
138
|
-
}, {
|
|
139
|
-
address: complianceConfiguration,
|
|
140
|
-
abi: iDSComplianceConfigurationServiceAbi,
|
|
141
|
-
functionName: "getNonUSLockPeriod"
|
|
142
|
-
}],
|
|
143
|
-
allowFailure: false
|
|
144
|
-
});
|
|
145
|
-
} catch (e) {
|
|
146
|
-
tokenLogger?.debug(`Skipping lock-period disable for ${symbol}: failed to read lock periods (${e})`);
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (usLockPeriod === 0n && nonUSLockPeriod === 0n) {
|
|
150
|
-
tokenLogger?.debug(`Lock periods already 0 for ${symbol} (${complianceConfiguration})`);
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
tokenLogger?.info(`Zeroing lock periods for ${symbol}: US ${usLockPeriod} → 0, non-US ${nonUSLockPeriod} → 0 (${complianceConfiguration})`);
|
|
154
|
-
if (usLockPeriod !== 0n) await writeAndWait(anvil, {
|
|
155
|
-
account,
|
|
156
|
-
chain: anvil.chain,
|
|
157
|
-
address: complianceConfiguration,
|
|
158
|
-
abi: iDSComplianceConfigurationServiceAbi,
|
|
159
|
-
functionName: "setUSLockPeriod",
|
|
160
|
-
args: [0n]
|
|
161
|
-
});
|
|
162
|
-
if (nonUSLockPeriod !== 0n) await writeAndWait(anvil, {
|
|
163
|
-
account,
|
|
164
|
-
chain: anvil.chain,
|
|
165
|
-
address: complianceConfiguration,
|
|
166
|
-
abi: iDSComplianceConfigurationServiceAbi,
|
|
167
|
-
functionName: "setNonUSLockPeriod",
|
|
168
|
-
args: [0n]
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
101
|
async function claimDSToken(props) {
|
|
173
102
|
const { anvil, investor, adminPrivateKey, token, marketConfigurators, rwaFactories, usdAmount: usdAmountProp = "100000" } = props;
|
|
174
103
|
const account = privateKeyToAccount(adminPrivateKey);
|
|
@@ -232,4 +161,4 @@ async function claimDSTokens(props) {
|
|
|
232
161
|
});
|
|
233
162
|
}
|
|
234
163
|
//#endregion
|
|
235
|
-
export { claimDSToken, claimDSTokens
|
|
164
|
+
export { claimDSToken, claimDSTokens };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { getNetworkType } from "../sdk/chain/chains.js";
|
|
2
3
|
import { getWithdrawalCompressorAddress } from "../sdk/accounts/withdrawal-compressor/addresses.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import "../sdk/index.js";
|
|
5
5
|
import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
|
|
6
6
|
import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iCreditConfigureActionsAbi } from "../../../abi/310/configure/iCreditConfigureActions.js";
|
|
2
1
|
import { adapterConstructorAbi } from "../../../plugins/adapters/abi/conctructorAbi.js";
|
|
3
2
|
import { parseAdapterAction, parseAdapterDeployParams } from "../../../plugins/adapters/abi/utils.js";
|
|
4
3
|
import "../../../plugins/adapters/index.js";
|
|
4
|
+
import { iCreditConfigureActionsAbi } from "../../../abi/310/configure/iCreditConfigureActions.js";
|
|
5
5
|
import { AbstractFactory } from "./abstract-factory.js";
|
|
6
6
|
import { decodeFunctionData, hexToString } from "viem";
|
|
7
7
|
//#region src/permissionless/bindings/factory/credit-factory.ts
|
|
@@ -19,6 +19,7 @@ const adapterConstructorAbi = {
|
|
|
19
19
|
["INFINIFI_GATEWAY"]: { 310: BASIC_ADAPTER_ABI },
|
|
20
20
|
["LIDO_V1"]: { 310: BASIC_ADAPTER_ABI },
|
|
21
21
|
["LIDO_WSTETH_V1"]: { 310: BASIC_ADAPTER_ABI },
|
|
22
|
+
["MIDAS_GATEWAY"]: { 311: REFERER_ID_ADAPTER_ABI },
|
|
22
23
|
["MIDAS_REDEMPTION_VAULT"]: {
|
|
23
24
|
310: BASIC_ADAPTER_ABI,
|
|
24
25
|
311: BASIC_ADAPTER_ABI
|
|
@@ -70,8 +71,7 @@ const adapterConstructorAbi = {
|
|
|
70
71
|
["MIDAS_ISSUANCE_VAULT"]: {
|
|
71
72
|
310: REFERER_ID_ADAPTER_ABI,
|
|
72
73
|
311: REFERER_ID_ADAPTER_ABI
|
|
73
|
-
}
|
|
74
|
-
["MIDAS_GATEWAY"]: { 311: REFERER_ID_ADAPTER_ABI }
|
|
74
|
+
}
|
|
75
75
|
};
|
|
76
76
|
//#endregion
|
|
77
77
|
export { adapterConstructorAbi };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
2
1
|
import { iZapperAbi } from "../../abi/iZapper.js";
|
|
2
|
+
import { iPoolV310Abi } from "../../abi/310/generated.js";
|
|
3
3
|
import { asPreviewSimulationError } from "./errors.js";
|
|
4
4
|
//#region src/preview/simulate/simulatePoolOperation.ts
|
|
5
5
|
function previewRead(operation) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
1
2
|
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../../sdk/utils/AddressMap.js";
|
|
3
|
-
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
4
4
|
import "../../sdk/index.js";
|
|
5
5
|
import { UnexpectedFacadeEventOrderError } from "./errors.js";
|
|
6
6
|
import { getAddress, isAddressEqual, parseEventLogs } from "viem";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
2
|
+
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
1
3
|
import { iBotListV310Abi, iCreditFacadeMulticallV310Abi } from "../../abi/310/generated.js";
|
|
2
4
|
import { creditAccountCompressorAbi } from "../../abi/compressors/creditAccountCompressor.js";
|
|
3
5
|
import { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompressor.js";
|
|
4
6
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
5
|
-
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
6
|
-
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
7
7
|
import { iRWAFactoryAbi } from "../../abi/rwa/iRWAFactory.js";
|
|
8
8
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
9
9
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
1
2
|
import { AddressSet } from "../../utils/AddressSet.js";
|
|
2
3
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
4
|
import { ADDRESS_0X0 } from "../../constants/addresses.js";
|
|
@@ -14,7 +15,6 @@ import { RWA_LIQUIDATOR_SECURITIZE } from "../../market/rwa/securitize/constants
|
|
|
14
15
|
import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/SecuritizeLiquidatorContract.js";
|
|
15
16
|
import "../../market/rwa/securitize/index.js";
|
|
16
17
|
import { LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
17
|
-
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
18
18
|
import { calcEstimatedProfit, calcRepaymentAmount, liquidationCallToRawTx, pickMainAsset, toLiquidationApproval, toLiquidatorWithdrawals, toReceivedAssets } from "./helpers.js";
|
|
19
19
|
//#region src/sdk/accounts/liquidations/LiquidationsService.ts
|
|
20
20
|
/**
|
|
@@ -62,9 +62,36 @@ function pickMainAsset(ca, convert) {
|
|
|
62
62
|
return bestToken;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
65
|
+
* Converts the single output of a liquidator's delayed withdrawal into an asset.
|
|
66
|
+
*
|
|
67
|
+
* @param outputs - `outputs` or `expectedOutputs` of a withdrawal
|
|
68
|
+
* @param sourceToken - Source token of the withdrawal, for error reporting
|
|
69
|
+
**/
|
|
70
|
+
function toWithdrawalOutputAsset(outputs, sourceToken) {
|
|
71
|
+
const [output] = outputs;
|
|
72
|
+
if (outputs.length !== 1 || !output) throw new Error(`expected exactly one output for withdrawal of ${sourceToken}, got ${outputs.length}`);
|
|
73
|
+
return {
|
|
74
|
+
balance: output.amount,
|
|
75
|
+
token: output.token
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Converts the claim calls of a liquidator's delayed withdrawal into a
|
|
80
|
+
* transaction.
|
|
81
|
+
*
|
|
82
|
+
* @param claimCalls - `claimCalls` of a claimable withdrawal
|
|
83
|
+
* @param sourceToken - Source token of the withdrawal, for error reporting
|
|
84
|
+
* @returns The claim transaction, or `undefined` when there is no claim call
|
|
85
|
+
**/
|
|
86
|
+
function toWithdrawalClaimTx(claimCalls, sourceToken) {
|
|
87
|
+
if (claimCalls.length > 1) throw new Error(`expected at most one claim call for withdrawal of ${sourceToken}, got ${claimCalls.length}`);
|
|
88
|
+
const [call] = claimCalls;
|
|
89
|
+
return call ? liquidationCallToRawTx(call) : void 0;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Flattens delayed withdrawals of a liquidator into rows: claimable
|
|
93
|
+
* withdrawals have no `claimableAt` (claimable now) and carry a `claimTx`,
|
|
94
|
+
* pending ones carry the estimated claim timestamp.
|
|
68
95
|
*
|
|
69
96
|
* @param current - Claimable and pending withdrawals from the withdrawal compressor
|
|
70
97
|
* @param network - Network the withdrawals live on
|
|
@@ -75,25 +102,15 @@ function toLiquidatorWithdrawals(current, network, chainId) {
|
|
|
75
102
|
network,
|
|
76
103
|
chainId,
|
|
77
104
|
sourceToken: w.token,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
balance: o.amount,
|
|
81
|
-
token: o.token
|
|
82
|
-
};
|
|
83
|
-
}),
|
|
84
|
-
claimCalls: w.claimCalls,
|
|
105
|
+
output: toWithdrawalOutputAsset(w.outputs, w.token),
|
|
106
|
+
claimTx: toWithdrawalClaimTx(w.claimCalls, w.token),
|
|
85
107
|
redeemer: w.redeemer
|
|
86
108
|
});
|
|
87
109
|
for (const w of current.pending) rows.push({
|
|
88
110
|
network,
|
|
89
111
|
chainId,
|
|
90
112
|
sourceToken: w.token,
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
balance: o.amount,
|
|
94
|
-
token: o.token
|
|
95
|
-
};
|
|
96
|
-
}),
|
|
113
|
+
output: toWithdrawalOutputAsset(w.expectedOutputs, w.token),
|
|
97
114
|
claimableAt: w.claimableAt,
|
|
98
115
|
redeemer: w.redeemer
|
|
99
116
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
4
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
4
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
5
5
|
import { InvalidDelayedIntentError } from "./errors.js";
|
|
6
6
|
//#region src/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
7
7
|
const abi = iRedemptionLoggerV310Abi;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV310Abi;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV311Abi;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
2
3
|
import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import { toWithdrawalStatus } from "./types.js";
|
|
5
5
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
|
|
6
6
|
const abi = iWithdrawalCompressorV313Abi;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
2
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
3
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
2
4
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
5
|
import { bytes32ToString } from "../utils/bytes32ToString.js";
|
|
4
6
|
import { formatBN } from "../utils/formatter.js";
|
|
5
7
|
import "../utils/index.js";
|
|
6
|
-
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
7
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
8
8
|
//#region src/sdk/base/TokensMeta.ts
|
|
9
9
|
/**
|
|
10
10
|
* Registry of token metadata (symbol, decimals, phantom type) keyed by address.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
2
|
import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
|
|
2
3
|
import { isV310 } from "../constants/versions.js";
|
|
3
4
|
import "../constants/index.js";
|
|
4
5
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/sdk/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = { Mainnet: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
1
2
|
import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
|
|
2
3
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
4
|
import "../../base/index.js";
|
|
4
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
5
5
|
//#region src/sdk/market/credit/CreditFacadeV310BaseContract.ts
|
|
6
6
|
const abi = [
|
|
7
7
|
...iCreditFacadeV310Abi,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
1
2
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
2
3
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
3
4
|
import { formatBN, formatBNvalue, percentFmt } from "../../utils/formatter.js";
|
|
4
5
|
import "../../utils/index.js";
|
|
5
6
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
6
7
|
import "../../base/index.js";
|
|
7
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
8
8
|
//#region src/sdk/market/pool/PoolV310Contract.ts
|
|
9
9
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
10
10
|
var PoolV310Contract = class extends BaseContract {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ZapperContract } from "./ZapperContract.js";
|
|
2
1
|
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
|
+
import { ZapperContract } from "./ZapperContract.js";
|
|
3
3
|
//#region src/sdk/market/zapper/IETHZapperContract.ts
|
|
4
4
|
const abi = iethZapperAbi;
|
|
5
5
|
var IETHZapperContract = class extends ZapperContract {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
4
4
|
import { UnsupportedZapperFunctionError } from "./errors.js";
|
|
5
5
|
//#region src/sdk/market/zapper/ZapperContract.ts
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AddressSet } from "../utils/AddressSet.js";
|
|
2
1
|
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
|
+
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
3
|
import "../constants/addresses.js";
|
|
4
4
|
import "../constants/index.js";
|
|
5
5
|
import { hexEq } from "../utils/hex.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorAbis } from "../../../abi/errors.js";
|
|
2
|
-
import { generateCastTraceCall } from "./cast.js";
|
|
3
2
|
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
|
+
import { generateCastTraceCall } from "./cast.js";
|
|
4
4
|
import { simulateMulticall } from "./simulateMulticall.js";
|
|
5
5
|
import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
|
6
6
|
import { getAction, parseAccount } from "viem/utils";
|
|
@@ -22,8 +22,8 @@ import "./mint/index.js";
|
|
|
22
22
|
import { RpcProvider, SUPPORTED_RPC_PROVIDERS, getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getRpcProviderUrl, getThirdWebUrl, rpcProvidersSchema } from "./providers.js";
|
|
23
23
|
import { ReplaceStorageParams, replaceStorage } from "./replaceStorage.js";
|
|
24
24
|
import { ResilientTransportOptions, resilientTransport, resilientTransportOptionsSchema } from "./resilientTransport.js";
|
|
25
|
-
import { DisableDSTokenLockPeriodsProps, claimDSToken, claimDSTokens
|
|
25
|
+
import { DisableDSTokenLockPeriodsProps, claimDSToken, claimDSTokens } from "./securitizeUtils.js";
|
|
26
26
|
import { httpTransportOptionsSchema } from "./transports.js";
|
|
27
27
|
import { ONCHAIN_EXECUTION_ID_ADDRESS, VerifyTestnetParams, verifyTestnet } from "./verifyTestnet.js";
|
|
28
28
|
import { MakePendingWithdrawalsClaimableOptions, makePendingWithdrawalsClaimable } from "./withdrawalUtils.js";
|
|
29
|
-
export { AccountOpener, AccountOpenerOptions, AnvilActions, AnvilClient, AnvilClientConfig, AnvilDealParameters, AnvilNodeInfo, AnvilRPCSchema, CheckMulticallFn, Create2Deployer, Create2Parameters, DEFAULT_CREATE2_SALT, DetectedCall, DisableDSTokenLockPeriodsProps, EnsureExistsUsingPublicCreate2ReturnType, EthCallMethod, EthCallRequest, EthCallSpy, GetCreate2AddressParameters, GreenlistMidasGatewayProps, IMinter, type LogSplitterTransportOptions, MakePendingWithdrawalsClaimableOptions, NoAvailableTransportsError, ONCHAIN_EXECUTION_ID_ADDRESS, OpenAccountHumanizedPreview, OpenAccountResult, OpenAccountsResult, OpenTxRevertedError, PUBLIC_CREATE2_FACTORY, PoolDepositResult, PrependMidasReceiveGreenlistProps, ProviderConfig, ProviderStatus, RWAKycFailure, RegisterMidasInvestorProps, RegisterRWAInvestorProps, RegisterRWAInvestorResult, RegisterSecuritizeInvestorProps, ReplaceStorageParams, ResilientTransportOptions, RevolverTransport, RevolverTransportConfig, RevolverTransportValue, RpcErrorResult, RpcProvider, RpcResponse, RpcSuccessResult, SUPPORTED_RPC_PROVIDERS, SelectionStrategy, TargetAccount, VerifyTestnetParams, anvilNodeInfo, calcLiquidatableLTs, claimDSToken, claimDSTokens, claimFromFaucet, createAnvilClient, createMinter, deployUsingPublicCreate2, detectChain,
|
|
29
|
+
export { AccountOpener, AccountOpenerOptions, AnvilActions, AnvilClient, AnvilClientConfig, AnvilDealParameters, AnvilNodeInfo, AnvilRPCSchema, CheckMulticallFn, Create2Deployer, Create2Parameters, DEFAULT_CREATE2_SALT, DetectedCall, DisableDSTokenLockPeriodsProps, EnsureExistsUsingPublicCreate2ReturnType, EthCallMethod, EthCallRequest, EthCallSpy, GetCreate2AddressParameters, GreenlistMidasGatewayProps, IMinter, type LogSplitterTransportOptions, MakePendingWithdrawalsClaimableOptions, NoAvailableTransportsError, ONCHAIN_EXECUTION_ID_ADDRESS, OpenAccountHumanizedPreview, OpenAccountResult, OpenAccountsResult, OpenTxRevertedError, PUBLIC_CREATE2_FACTORY, PoolDepositResult, PrependMidasReceiveGreenlistProps, ProviderConfig, ProviderStatus, RWAKycFailure, RegisterMidasInvestorProps, RegisterRWAInvestorProps, RegisterRWAInvestorResult, RegisterSecuritizeInvestorProps, ReplaceStorageParams, ResilientTransportOptions, RevolverTransport, RevolverTransportConfig, RevolverTransportValue, RpcErrorResult, RpcProvider, RpcResponse, RpcSuccessResult, SUPPORTED_RPC_PROVIDERS, SelectionStrategy, TargetAccount, VerifyTestnetParams, anvilNodeInfo, calcLiquidatableLTs, claimDSToken, claimDSTokens, claimFromFaucet, createAnvilClient, createMinter, deployUsingPublicCreate2, detectChain, evmMineDetailed, extendAnvilClient, faucetAbi, getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getPublicCreate2Address, getRpcProviderUrl, getThirdWebUrl, greenlistMidasGateway, httpTransportOptionsSchema, iDegenNftv2Abi, iOnchainExecutionIdAbi, iOwnableAbi, iaclTraitAbi, isAnvil, isDeployedUsingPublicCreate2, isOutOfSyncError, isRangeError, isRateLimitError, isTransientError, logSplitterTransport, makePendingWithdrawalsClaimable, migrateFaucet, prependMidasReceiveGreenlist, providerConfigSchema, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor, replaceStorage, resilientTransport, resilientTransportOptionsSchema, revolverTransportConfigBaseSchema, revolverTransportConfigSchema, rpcProvidersSchema, setLTZero, setLTs, verifyTestnet, writeAndWait };
|
|
@@ -35,16 +35,6 @@ interface DisableDSTokenLockPeriodsProps {
|
|
|
35
35
|
tokens: Address[];
|
|
36
36
|
logger?: ILogger;
|
|
37
37
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Zeros US and non-US compliance lock periods on each DSToken's compliance
|
|
40
|
-
* configuration service so collateral can be transferred during testnet
|
|
41
|
-
* liquidations (e.g. STAC). No-ops for tokens without a compliance service
|
|
42
|
-
* (MockDSToken) or when both periods are already 0.
|
|
43
|
-
*
|
|
44
|
-
* Must be signed by a DS admin with sufficient trust (same key as
|
|
45
|
-
* `issueTokens` / registerInvestor); Ownable `owner()` alone is not enough.
|
|
46
|
-
*/
|
|
47
|
-
declare function disableDSTokenLockPeriods(props: DisableDSTokenLockPeriodsProps): Promise<void>;
|
|
48
38
|
declare function claimDSToken(props: ClaimDSTokenProps): Promise<void>;
|
|
49
39
|
/**
|
|
50
40
|
* Helper function to claim DSToken from the faucet.
|
|
@@ -56,4 +46,4 @@ declare function claimDSToken(props: ClaimDSTokenProps): Promise<void>;
|
|
|
56
46
|
*/
|
|
57
47
|
declare function claimDSTokens(props: ClaimDSTokensProps): Promise<void>;
|
|
58
48
|
//#endregion
|
|
59
|
-
export { DisableDSTokenLockPeriodsProps, claimDSToken, claimDSTokens
|
|
49
|
+
export { DisableDSTokenLockPeriodsProps, claimDSToken, claimDSTokens };
|
|
@@ -68,9 +68,9 @@ declare function calcEstimatedProfit(totalValue: bigint, liquidationDiscount: nu
|
|
|
68
68
|
**/
|
|
69
69
|
declare function pickMainAsset(ca: CreditAccountData, convert: (token: Address, balance: bigint) => bigint): Address | undefined;
|
|
70
70
|
/**
|
|
71
|
-
* Flattens delayed withdrawals of a liquidator into
|
|
72
|
-
*
|
|
73
|
-
* carry the estimated claim timestamp.
|
|
71
|
+
* Flattens delayed withdrawals of a liquidator into rows: claimable
|
|
72
|
+
* withdrawals have no `claimableAt` (claimable now) and carry a `claimTx`,
|
|
73
|
+
* pending ones carry the estimated claim timestamp.
|
|
74
74
|
*
|
|
75
75
|
* @param current - Claimable and pending withdrawals from the withdrawal compressor
|
|
76
76
|
* @param network - Network the withdrawals live on
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NetworkType } from "../../chain/chains.js";
|
|
2
2
|
import "../../chain/index.js";
|
|
3
3
|
import { Asset } from "../../base/types.js";
|
|
4
|
-
import {
|
|
4
|
+
import { RawTx } from "../../types/transactions.js";
|
|
5
5
|
import "../../types/index.js";
|
|
6
6
|
import "../../base/index.js";
|
|
7
7
|
import { Address } from "viem";
|
|
@@ -233,23 +233,20 @@ interface LiquidatorWithdrawal {
|
|
|
233
233
|
**/
|
|
234
234
|
sourceToken: Address;
|
|
235
235
|
/**
|
|
236
|
-
* Receivable asset (e.g. USDC)
|
|
236
|
+
* Receivable asset (e.g. USDC) and its amount: exact for claimable
|
|
237
|
+
* withdrawals, estimated for pending ones.
|
|
237
238
|
**/
|
|
238
|
-
|
|
239
|
-
* Amount of `token` receivable: exact for claimable withdrawals, estimated
|
|
240
|
-
* for pending ones.
|
|
241
|
-
**/
|
|
242
|
-
outputs: Array<Asset>;
|
|
239
|
+
output: Asset;
|
|
243
240
|
/**
|
|
244
241
|
* Estimated unix timestamp (in seconds) when a pending withdrawal becomes
|
|
245
242
|
* claimable. `undefined` means the withdrawal is claimable now.
|
|
246
243
|
**/
|
|
247
244
|
claimableAt?: bigint;
|
|
248
245
|
/**
|
|
249
|
-
*
|
|
250
|
-
*
|
|
246
|
+
* Transaction that claims the withdrawal. `undefined` for pending
|
|
247
|
+
* withdrawals and when the compressor reports no claim call.
|
|
251
248
|
**/
|
|
252
|
-
|
|
249
|
+
claimTx?: RawTx;
|
|
253
250
|
/**
|
|
254
251
|
* Redeemer contract the withdrawal is claimed from, owned by the liquidator.
|
|
255
252
|
* `undefined` on compressor versions below 313, which do not report it.
|