@gearbox-protocol/sdk 17.8.0 → 17.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dev/AccountOpener.js +3 -3
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/onchain/accounts/index.js +1 -0
- package/dist/cjs/onchain/accounts/intents/realize.js +7 -2
- package/dist/cjs/onchain/accounts/intents/testing/market.js +5 -1
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/onchain/accounts/intents/utils/index.js +1 -0
- package/dist/cjs/onchain/accounts/intents/utils/quotas-for-update.js +30 -0
- package/dist/cjs/onchain/accounts/quota-utils.js +6 -0
- package/dist/cjs/onchain/chain/chains.js +12 -0
- package/dist/cjs/onchain/chain/index.js +1 -0
- package/dist/cjs/onchain/index.js +2 -0
- package/dist/cjs/sdk/GearboxSDK.js +8 -1
- package/dist/cjs/sdk/index.js +6 -0
- package/dist/cjs/sdk/liquidations/LiquidationsNamespace.js +10 -0
- package/dist/cjs/sdk/rewards/RewardsNamespace.js +51 -0
- package/dist/cjs/{rewards → sdk/rewards}/errors.js +1 -1
- package/dist/cjs/{rewards → sdk/rewards}/helpers.js +4 -4
- package/dist/cjs/sdk/rewards/index.js +6 -0
- package/dist/cjs/{rewards → sdk/rewards}/merkl-api.js +3 -3
- package/dist/cjs/{rewards → sdk/rewards}/toMerklRewards.js +6 -6
- package/dist/cjs/{rewards → sdk/rewards}/toTurtleRewards.js +7 -7
- package/dist/cjs/{rewards → sdk/rewards}/turtle-api.js +3 -3
- package/dist/cjs/sdk/rewards/types.js +1 -0
- package/dist/esm/dev/AccountOpener.js +2 -2
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/history/trace/extractTransfers.js +1 -1
- package/dist/esm/model/index.js +1 -0
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/index.js +2 -2
- package/dist/esm/onchain/accounts/intents/realize.js +8 -3
- package/dist/esm/onchain/accounts/intents/testing/market.js +5 -1
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/onchain/accounts/intents/utils/index.js +2 -2
- package/dist/esm/onchain/accounts/intents/utils/quotas-for-update.js +31 -2
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/quota-utils.js +6 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/chain/chains.js +12 -1
- package/dist/esm/onchain/chain/index.js +2 -2
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/index.js +3 -3
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/sdk/GearboxSDK.js +8 -1
- package/dist/esm/sdk/index.js +4 -1
- package/dist/esm/sdk/liquidations/LiquidationsNamespace.js +10 -0
- package/dist/esm/{rewards/RewardsService.js → sdk/rewards/RewardsNamespace.js} +15 -12
- package/dist/esm/{rewards → sdk/rewards}/errors.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/helpers.js +4 -4
- package/dist/esm/sdk/rewards/index.js +3 -0
- package/dist/esm/{rewards → sdk/rewards}/merkl-api.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/toMerklRewards.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/toTurtleRewards.js +1 -1
- package/dist/esm/{rewards → sdk/rewards}/turtle-api.js +1 -1
- package/dist/esm/sdk/rewards/types.js +1 -0
- package/dist/types/model/errors/liquidation-errors.d.ts +4 -0
- package/dist/types/model/errors/operation-errors.d.ts +10 -0
- package/dist/types/model/errors/oracle-errors.d.ts +2 -0
- package/dist/types/model/index.d.ts +2 -1
- package/dist/types/{rewards/types.d.ts → model/rewards.d.ts} +4 -9
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/testing/market.d.ts +4 -0
- package/dist/types/onchain/accounts/intents/utils/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/utils/quotas-for-update.d.ts +7 -1
- package/dist/types/onchain/accounts/quota-utils.d.ts +6 -1
- package/dist/types/onchain/chain/chains.d.ts +15 -1
- package/dist/types/onchain/chain/index.d.ts +2 -2
- package/dist/types/onchain/index.d.ts +3 -3
- package/dist/types/sdk/GearboxSDK.d.ts +6 -0
- package/dist/types/sdk/index.d.ts +8 -2
- package/dist/types/sdk/liquidations/LiquidationsNamespace.d.ts +5 -1
- package/dist/types/sdk/liquidations/index.d.ts +2 -2
- package/dist/types/sdk/liquidations/types.d.ts +12 -2
- package/dist/types/sdk/rewards/RewardsNamespace.d.ts +24 -0
- package/dist/types/{rewards → sdk/rewards}/errors.d.ts +3 -3
- package/dist/types/{rewards → sdk/rewards}/helpers.d.ts +5 -4
- package/dist/types/sdk/rewards/index.d.ts +6 -0
- package/dist/types/{rewards → sdk/rewards}/merkl-api.d.ts +3 -3
- package/dist/types/{rewards → sdk/rewards}/toMerklRewards.d.ts +4 -2
- package/dist/types/{rewards → sdk/rewards}/toTurtleRewards.d.ts +4 -2
- package/dist/types/{rewards → sdk/rewards}/turtle-api.d.ts +3 -3
- package/dist/types/sdk/rewards/types.d.ts +35 -0
- package/dist/types/sdk/types.d.ts +9 -0
- package/package.json +1 -6
- package/dist/cjs/rewards/RewardsService.js +0 -48
- package/dist/cjs/rewards/index.js +0 -6
- package/dist/cjs/rewards/package.json +0 -1
- package/dist/esm/rewards/index.js +0 -3
- package/dist/esm/rewards/package.json +0 -1
- package/dist/types/rewards/RewardsService.d.ts +0 -29
- package/dist/types/rewards/index.d.ts +0 -6
- /package/dist/cjs/{rewards/types.js → model/rewards.js} +0 -0
- /package/dist/esm/{rewards/types.js → model/rewards.js} +0 -0
|
@@ -9,6 +9,7 @@ require("../onchain/constants/addresses.js");
|
|
|
9
9
|
const require_onchain_constants_math = require("../onchain/constants/math.js");
|
|
10
10
|
const require_onchain_base_SDKConstruct = require("../onchain/base/SDKConstruct.js");
|
|
11
11
|
const require_onchain_utils_viem_sendRawTx = require("../onchain/utils/viem/sendRawTx.js");
|
|
12
|
+
const require_onchain_accounts_quota_utils = require("../onchain/accounts/quota-utils.js");
|
|
12
13
|
const require_onchain_pools_PoolService = require("../onchain/pools/PoolService.js");
|
|
13
14
|
require("../onchain/index.js");
|
|
14
15
|
const require_dev_abi = require("./abi.js");
|
|
@@ -19,7 +20,6 @@ require("./mint/index.js");
|
|
|
19
20
|
let viem = require("viem");
|
|
20
21
|
let viem_accounts = require("viem/accounts");
|
|
21
22
|
//#region src/dev/AccountOpener.ts
|
|
22
|
-
const DIRECT_TRANSFERS_QUOTA = 10000n;
|
|
23
23
|
var OpenTxRevertedError = class extends viem.BaseError {
|
|
24
24
|
txHash;
|
|
25
25
|
constructor(txHash) {
|
|
@@ -258,11 +258,11 @@ var AccountOpener = class extends require_onchain_base_SDKConstruct.SDKConstruct
|
|
|
258
258
|
for (const token of directTransfer) {
|
|
259
259
|
averageQuota.push({
|
|
260
260
|
token,
|
|
261
|
-
balance: DIRECT_TRANSFERS_QUOTA
|
|
261
|
+
balance: require_onchain_accounts_quota_utils.DIRECT_TRANSFERS_QUOTA
|
|
262
262
|
});
|
|
263
263
|
minQuota.push({
|
|
264
264
|
token,
|
|
265
|
-
balance: DIRECT_TRANSFERS_QUOTA
|
|
265
|
+
balance: require_onchain_accounts_quota_utils.DIRECT_TRANSFERS_QUOTA
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
268
|
logger?.debug({
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -31,6 +31,7 @@ require("./primitives.js");
|
|
|
31
31
|
require("./response.js");
|
|
32
32
|
const require_model_response_schema = require("./response.schema.js");
|
|
33
33
|
const require_model_result = require("./result.js");
|
|
34
|
+
require("./rewards.js");
|
|
34
35
|
require("./withdrawals.js");
|
|
35
36
|
const require_model_withdrawals_schema = require("./withdrawals.schema.js");
|
|
36
37
|
exports.ANALYTICS_POSITIONS_DEFAULT_LIMIT = require_model_analytics_schema.ANALYTICS_POSITIONS_DEFAULT_LIMIT;
|
|
@@ -34,6 +34,7 @@ exports.CreditAccountOperationsService = require_onchain_accounts_intents_index.
|
|
|
34
34
|
exports.CreditAccountsServiceV310 = require_onchain_accounts_CreditAccountsServiceV310.CreditAccountsServiceV310;
|
|
35
35
|
exports.DELAYED_INTENT_TYPES = require_onchain_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_TYPES;
|
|
36
36
|
exports.DELAYED_INTENT_VERSION = require_onchain_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_VERSION;
|
|
37
|
+
exports.DIRECT_TRANSFERS_QUOTA = require_onchain_accounts_quota_utils.DIRECT_TRANSFERS_QUOTA;
|
|
37
38
|
exports.LIQUIDATION_APPROVAL_BUFFER = require_onchain_accounts_liquidations_constants.LIQUIDATION_APPROVAL_BUFFER;
|
|
38
39
|
exports.LIQUIDATION_COMPRESSOR_V313_ADDRESS = require_onchain_accounts_liquidations_constants.LIQUIDATION_COMPRESSOR_V313_ADDRESS;
|
|
39
40
|
exports.LiquidationsService = require_onchain_accounts_liquidations_LiquidationsService.LiquidationsService;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_onchain_chain_chains = require("../../chain/chains.js");
|
|
2
3
|
const require_onchain_constants_math = require("../../constants/math.js");
|
|
3
4
|
const require_model_errors_operation_errors = require("../../../model/errors/operation-errors.js");
|
|
4
5
|
const require_model_errors_prepare_errors = require("../../../model/errors/prepare-errors.js");
|
|
@@ -107,6 +108,8 @@ async function realize(steps, props) {
|
|
|
107
108
|
* judge the closing collateral check at safe prices.
|
|
108
109
|
*/
|
|
109
110
|
let withdrawsCollateral = false;
|
|
111
|
+
/** Token a sold collateral later transfers to the account; needs a quota. */
|
|
112
|
+
let directTransfer;
|
|
110
113
|
const amountOf = (a) => typeof a === "bigint" ? a : min(raised, a.max ?? raised);
|
|
111
114
|
const assertHolds = (token, amount, what) => {
|
|
112
115
|
const held = ledger.balanceOf(token);
|
|
@@ -179,6 +182,7 @@ async function realize(steps, props) {
|
|
|
179
182
|
raised = amountOut;
|
|
180
183
|
break;
|
|
181
184
|
}
|
|
185
|
+
directTransfer ??= require_onchain_chain_chains.getDirectTransferToken(step.from, sdk.networkType);
|
|
182
186
|
const held = ledger.balanceOf(step.from);
|
|
183
187
|
const leg = await paths.swap({
|
|
184
188
|
tokenIn: step.from,
|
|
@@ -259,6 +263,7 @@ async function realize(steps, props) {
|
|
|
259
263
|
const asset = await delayedConfig(sdk, creditAccount, step.token);
|
|
260
264
|
if (ledger.balanceOf(asset.withdrawalPhantomToken) > 0n) throw new require_onchain_validation_raise.IntentPreviewError(require_model_errors_prepare_errors.withdrawalInProgress(require_onchain_validation_helpers_token.toTokenAmount(sdk, asset.withdrawalPhantomToken, ledger.balanceOf(asset.withdrawalPhantomToken))), `request: ${asset.withdrawalPhantomToken} already holds a pending withdrawal`);
|
|
261
265
|
assertHolds(step.token, step.amount + step.reserve, "request");
|
|
266
|
+
if (step.record.type !== "CLOSE_ACCOUNT") directTransfer ??= require_onchain_chain_chains.getDirectTransferToken(step.token, sdk.networkType);
|
|
262
267
|
const preview = await sdk.accounts.previewDelayedWithdrawal({
|
|
263
268
|
creditAccount: creditAccount.creditAccount,
|
|
264
269
|
token: step.token,
|
|
@@ -330,7 +335,7 @@ async function realize(steps, props) {
|
|
|
330
335
|
const floor = ledger.snapshot();
|
|
331
336
|
const { assets, debt } = floor;
|
|
332
337
|
const projected = expected.snapshot();
|
|
333
|
-
const quotas = cleared ?? require_onchain_accounts_intents_utils_quotas_for_update.getQuotasForUpdate({
|
|
338
|
+
const quotas = cleared ?? require_onchain_accounts_intents_utils_quotas_for_update.withDirectTransferQuota(require_onchain_accounts_intents_utils_quotas_for_update.getQuotasForUpdate({
|
|
334
339
|
assetsBefore: creditAccount.tokens,
|
|
335
340
|
assetsAfter: assets,
|
|
336
341
|
initialQuotas: creditAccount.tokens,
|
|
@@ -340,7 +345,7 @@ async function realize(steps, props) {
|
|
|
340
345
|
quotas: market.pool.pqk.quotas,
|
|
341
346
|
maxDebt: suite.creditFacade.maxDebt,
|
|
342
347
|
convert: price
|
|
343
|
-
});
|
|
348
|
+
}), debt > 0n ? directTransfer : void 0, creditAccount.tokens, market.pool.pqk.quotas, suite.creditManager.maxEnabledTokens, suite.creditManager.collateralTokens);
|
|
344
349
|
const quotasAfter = require_onchain_accounts_intents_utils_quotas_for_update.quotasAfterUpdate(creditAccount.tokens, quotas.desiredQuota);
|
|
345
350
|
const quoted = Object.values(quotasAfter);
|
|
346
351
|
const snapshot = {
|
|
@@ -90,7 +90,10 @@ function buildMarketSdk(extras) {
|
|
|
90
90
|
...extras?.extraDecimals
|
|
91
91
|
},
|
|
92
92
|
quotas: extras?.quotas ?? QUOTAS,
|
|
93
|
-
liquidationThresholds:
|
|
93
|
+
liquidationThresholds: {
|
|
94
|
+
...LIQUIDATION_THRESHOLDS,
|
|
95
|
+
...extras?.extraLiquidationThresholds
|
|
96
|
+
},
|
|
94
97
|
maxDebt: MAX_DEBT,
|
|
95
98
|
minDebt: extras?.minDebt,
|
|
96
99
|
creditManager: CREDIT_MANAGER,
|
|
@@ -102,6 +105,7 @@ function buildMarketSdk(extras) {
|
|
|
102
105
|
phantoms: extras?.phantoms,
|
|
103
106
|
creditAccounts: extras?.creditAccounts,
|
|
104
107
|
delayed: extras?.delayed,
|
|
108
|
+
maxEnabledTokens: extras?.maxEnabledTokens,
|
|
105
109
|
facadePaused: extras?.facadePaused,
|
|
106
110
|
poolPaused: extras?.poolPaused,
|
|
107
111
|
expirationDate: extras?.expirationDate,
|
|
@@ -32,3 +32,4 @@ exports.toCreditAccountSlice = require_onchain_accounts_intents_utils_credit_acc
|
|
|
32
32
|
exports.toRouterCaSlice = require_onchain_accounts_intents_utils_common.toRouterCaSlice;
|
|
33
33
|
exports.toTargetDecimals = require_onchain_accounts_intents_utils_common.toTargetDecimals;
|
|
34
34
|
exports.unopenedAccountSlice = require_onchain_accounts_intents_utils_credit_account_slice.unopenedAccountSlice;
|
|
35
|
+
exports.withDirectTransferQuota = require_onchain_accounts_intents_utils_quotas_for_update.withDirectTransferQuota;
|
|
@@ -79,6 +79,35 @@ function clearedQuotas(initialQuotas) {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
+
* Raises `directTransfer`'s quota to at least {@link DIRECT_TRANSFERS_QUOTA};
|
|
83
|
+
* skips a token absent from the credit manager, one the pool can't quote, or
|
|
84
|
+
* one the account has no free enabled token slot for.
|
|
85
|
+
*/
|
|
86
|
+
function withDirectTransferQuota(update, directTransfer, initialQuotas, quotas, maxEnabledTokens, collateralTokens) {
|
|
87
|
+
if (!directTransfer) return update;
|
|
88
|
+
const token = directTransfer.toLowerCase();
|
|
89
|
+
const quota = quotas.get(token);
|
|
90
|
+
const initial = initialQuotas.find((q) => q.token.toLowerCase() === token)?.quota ?? 0n;
|
|
91
|
+
const change = require_onchain_accounts_quota_utils.DIRECT_TRANSFERS_QUOTA - initial;
|
|
92
|
+
if (!collateralTokens.some((t) => t.toLowerCase() === token) || !quota?.isActive || quota.limit - quota.totalQuoted < change || (update.desiredQuota[token]?.balance ?? initial) >= require_onchain_accounts_quota_utils.DIRECT_TRANSFERS_QUOTA || Object.keys(quotasAfterUpdate(initialQuotas, update.desiredQuota)).length >= maxEnabledTokens) return update;
|
|
93
|
+
const rest = (list) => list.filter((a) => a.token !== token);
|
|
94
|
+
const entry = {
|
|
95
|
+
token,
|
|
96
|
+
balance: change
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
desiredQuota: {
|
|
100
|
+
...update.desiredQuota,
|
|
101
|
+
[token]: {
|
|
102
|
+
token,
|
|
103
|
+
balance: require_onchain_accounts_quota_utils.DIRECT_TRANSFERS_QUOTA
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
quotaIncrease: change > 0n ? [...rest(update.quotaIncrease), entry] : rest(update.quotaIncrease),
|
|
107
|
+
quotaDecrease: change < 0n ? [...rest(update.quotaDecrease), entry] : rest(update.quotaDecrease)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
82
111
|
* The quotas the account stands at once an update lands: the ones it came with,
|
|
83
112
|
* with the ones the update names written over them.
|
|
84
113
|
*
|
|
@@ -170,3 +199,4 @@ function constructAssetRecord(a) {
|
|
|
170
199
|
exports.clearedQuotas = clearedQuotas;
|
|
171
200
|
exports.getQuotasForUpdate = getQuotasForUpdate;
|
|
172
201
|
exports.quotasAfterUpdate = quotasAfterUpdate;
|
|
202
|
+
exports.withDirectTransferQuota = withDirectTransferQuota;
|
|
@@ -3,6 +3,11 @@ const require_onchain_utils_bigint_math = require("../utils/bigint-math.js");
|
|
|
3
3
|
const require_onchain_constants_math = require("../constants/math.js");
|
|
4
4
|
//#region src/onchain/accounts/quota-utils.ts
|
|
5
5
|
/**
|
|
6
|
+
* Quota that keeps a directly transferred token enabled, so a liquidation
|
|
7
|
+
* counts it.
|
|
8
|
+
*/
|
|
9
|
+
const DIRECT_TRANSFERS_QUOTA = require_onchain_constants_math.PERCENTAGE_FACTOR;
|
|
10
|
+
/**
|
|
6
11
|
* Rounds quota deltas to protocol precision step (`PERCENTAGE_FACTOR`).
|
|
7
12
|
*
|
|
8
13
|
* The `MIN_INT96` sentinel is preserved as-is because it encodes
|
|
@@ -138,6 +143,7 @@ function getSingleQuotaChange(token, unsafeMaxQuotaIncrease, props) {
|
|
|
138
143
|
};
|
|
139
144
|
}
|
|
140
145
|
//#endregion
|
|
146
|
+
exports.DIRECT_TRANSFERS_QUOTA = DIRECT_TRANSFERS_QUOTA;
|
|
141
147
|
exports.calcDefaultQuota = calcDefaultQuota;
|
|
142
148
|
exports.calcQuotaUpdate = calcQuotaUpdate;
|
|
143
149
|
exports.calcRecommendedQuota = calcRecommendedQuota;
|
|
@@ -78,6 +78,7 @@ const chains = {
|
|
|
78
78
|
"0x238a700eD6165261Cf8b2e544ba797BC11e466Ba",
|
|
79
79
|
"0x7433806912Eae67919e66aea853d46Fa0aef98A8"
|
|
80
80
|
]),
|
|
81
|
+
directTransfers: require_onchain_utils_AddressMap.AddressMap.fromRecord({ "0x7433806912Eae67919e66aea853d46Fa0aef98A8": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" }),
|
|
81
82
|
legacyStrategyTargets: require_onchain_utils_AddressMap.AddressMap.fromRecord({
|
|
82
83
|
"0x1293a69e4ad4a93293a06b6303104be35bdd83af": "0x1a711a5bc48b5c1352c1882fa65dc14b5b9e829d",
|
|
83
84
|
"0x29350a3c2627fb78c7e915cd59af754edf8998c5": "0xe1d9b789da5b5375eacf66f036022b019a2af307",
|
|
@@ -545,6 +546,16 @@ function isSunsetStrategy(creditManager, network) {
|
|
|
545
546
|
return !!chains[network].sunsetStrategies?.has(creditManager);
|
|
546
547
|
}
|
|
547
548
|
/**
|
|
549
|
+
* Token a collateral's sale later transfers directly to the credit account,
|
|
550
|
+
* or `undefined` when the collateral is not in the table.
|
|
551
|
+
*
|
|
552
|
+
* @param collateral - Collateral token address.
|
|
553
|
+
* @param network - Chain id or {@link NetworkType} label.
|
|
554
|
+
**/
|
|
555
|
+
function getDirectTransferToken(collateral, network) {
|
|
556
|
+
return getChain(network).directTransfers?.get(collateral);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
548
559
|
* Hardcoded target collateral of a legacy credit manager, or `undefined` when
|
|
549
560
|
* the manager is not in the table and the on-chain rule should apply.
|
|
550
561
|
*
|
|
@@ -574,6 +585,7 @@ exports.getAccountTargetCollateral = getAccountTargetCollateral;
|
|
|
574
585
|
exports.getAssetType = getAssetType;
|
|
575
586
|
exports.getChain = getChain;
|
|
576
587
|
exports.getCuratorName = getCuratorName;
|
|
588
|
+
exports.getDirectTransferToken = getDirectTransferToken;
|
|
577
589
|
exports.getLegacyStrategyTarget = getLegacyStrategyTarget;
|
|
578
590
|
exports.getNetworkType = getNetworkType;
|
|
579
591
|
exports.isPublicNetwork = isPublicNetwork;
|
|
@@ -10,6 +10,7 @@ exports.getAccountTargetCollateral = require_onchain_chain_chains.getAccountTarg
|
|
|
10
10
|
exports.getAssetType = require_onchain_chain_chains.getAssetType;
|
|
11
11
|
exports.getChain = require_onchain_chain_chains.getChain;
|
|
12
12
|
exports.getCuratorName = require_onchain_chain_chains.getCuratorName;
|
|
13
|
+
exports.getDirectTransferToken = require_onchain_chain_chains.getDirectTransferToken;
|
|
13
14
|
exports.getLegacyStrategyTarget = require_onchain_chain_chains.getLegacyStrategyTarget;
|
|
14
15
|
exports.getNetworkType = require_onchain_chain_chains.getNetworkType;
|
|
15
16
|
exports.isPublicNetwork = require_onchain_chain_chains.isPublicNetwork;
|
|
@@ -396,6 +396,7 @@ exports.DEGEN_NFT_MIDAS = require_onchain_market_rwa_midas_constants.DEGEN_NFT_M
|
|
|
396
396
|
exports.DEGEN_NFT_SECURITIZE = require_onchain_market_rwa_securitize_constants.DEGEN_NFT_SECURITIZE;
|
|
397
397
|
exports.DELAYED_INTENT_TYPES = require_onchain_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_TYPES;
|
|
398
398
|
exports.DELAYED_INTENT_VERSION = require_onchain_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_VERSION;
|
|
399
|
+
exports.DIRECT_TRANSFERS_QUOTA = require_onchain_accounts_quota_utils.DIRECT_TRANSFERS_QUOTA;
|
|
399
400
|
exports.DUST_THRESHOLD = require_onchain_constants_math.DUST_THRESHOLD;
|
|
400
401
|
exports.DaiUsdsAdapterContract = require_onchain_market_adapters_contracts_DaiUsdsAdapterContract.DaiUsdsAdapterContract;
|
|
401
402
|
exports.ERC4626AdapterContract = require_onchain_market_adapters_contracts_ERC4626AdapterContract.ERC4626AdapterContract;
|
|
@@ -661,6 +662,7 @@ exports.getAssetType = require_onchain_chain_chains.getAssetType;
|
|
|
661
662
|
exports.getCastTraceArgs = require_onchain_utils_viem_cast.getCastTraceArgs;
|
|
662
663
|
exports.getChain = require_onchain_chain_chains.getChain;
|
|
663
664
|
exports.getCuratorName = require_onchain_chain_chains.getCuratorName;
|
|
665
|
+
exports.getDirectTransferToken = require_onchain_chain_chains.getDirectTransferToken;
|
|
664
666
|
exports.getFunctionSignature = require_onchain_utils_abi_decode.getFunctionSignature;
|
|
665
667
|
exports.getLegacyStrategyTarget = require_onchain_chain_chains.getLegacyStrategyTarget;
|
|
666
668
|
exports.getNetworkType = require_onchain_chain_chains.getNetworkType;
|
|
@@ -19,6 +19,8 @@ const require_sdk_positions_PositionsNamespace = require("./positions/PositionsN
|
|
|
19
19
|
require("./positions/index.js");
|
|
20
20
|
const require_sdk_preview_PreviewNamespace = require("./preview/PreviewNamespace.js");
|
|
21
21
|
require("./preview/index.js");
|
|
22
|
+
const require_sdk_rewards_RewardsNamespace = require("./rewards/RewardsNamespace.js");
|
|
23
|
+
require("./rewards/index.js");
|
|
22
24
|
//#region src/sdk/GearboxSDK.ts
|
|
23
25
|
/**
|
|
24
26
|
* Default {@link GearboxSDKOptions.maxStateAgeSeconds}: the fastest poll an
|
|
@@ -76,6 +78,10 @@ var GearboxSDK = class {
|
|
|
76
78
|
**/
|
|
77
79
|
preview;
|
|
78
80
|
/**
|
|
81
|
+
* Namespace for claimable rewards. Absent in `offchain` mode.
|
|
82
|
+
**/
|
|
83
|
+
rewards;
|
|
84
|
+
/**
|
|
79
85
|
* The banners the backend attaches to a pool opportunity or a strategy
|
|
80
86
|
* position, see {@link Notice}. Top-level because the subject is either
|
|
81
87
|
* kind of entity, so neither namespace owns it. Backend-only, hence gated
|
|
@@ -94,7 +100,7 @@ var GearboxSDK = class {
|
|
|
94
100
|
/** One sync in flight per chain: concurrent stale reads join it. */
|
|
95
101
|
#syncing = /* @__PURE__ */ new Map();
|
|
96
102
|
constructor(options) {
|
|
97
|
-
const { mode, networks, onchain, offchain, attach, logger, maxOffchainLagSeconds = 120, maxStateAgeSeconds = 30 } = options;
|
|
103
|
+
const { mode, networks, onchain, offchain, attach, rewards, logger, maxOffchainLagSeconds = 120, maxStateAgeSeconds = 30 } = options;
|
|
98
104
|
this.mode = mode;
|
|
99
105
|
this.networks = [...networks];
|
|
100
106
|
this.#attachOptions = attach;
|
|
@@ -140,6 +146,7 @@ var GearboxSDK = class {
|
|
|
140
146
|
this.positions = new require_sdk_positions_PositionsNamespace.PositionsNamespace(this.#onchain, this.#offchain, namespaceOptions);
|
|
141
147
|
this.liquidations = this.#onchain ? new require_sdk_liquidations_LiquidationsNamespace.LiquidationsNamespace(this.#onchain, namespaceOptions) : void 0;
|
|
142
148
|
this.preview = this.#onchain ? new require_sdk_preview_PreviewNamespace.PreviewNamespace(this.#onchain, namespaceOptions) : void 0;
|
|
149
|
+
this.rewards = this.#onchain ? new require_sdk_rewards_RewardsNamespace.RewardsNamespace(this.#onchain, rewards, namespaceOptions) : void 0;
|
|
143
150
|
const backend = this.#offchain;
|
|
144
151
|
this.notices = backend ? (subject) => backend.notices.list(subject) : void 0;
|
|
145
152
|
}
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -26,6 +26,9 @@ const require_sdk_positions_PositionsNamespace = require("./positions/PositionsN
|
|
|
26
26
|
require("./positions/index.js");
|
|
27
27
|
const require_sdk_preview_PreviewNamespace = require("./preview/PreviewNamespace.js");
|
|
28
28
|
require("./preview/index.js");
|
|
29
|
+
const require_sdk_rewards_errors = require("./rewards/errors.js");
|
|
30
|
+
const require_sdk_rewards_RewardsNamespace = require("./rewards/RewardsNamespace.js");
|
|
31
|
+
require("./rewards/index.js");
|
|
29
32
|
const require_sdk_GearboxSDK = require("./GearboxSDK.js");
|
|
30
33
|
require("./types.js");
|
|
31
34
|
exports.AbstractNamespace = require_sdk_AbstractNamespace.AbstractNamespace;
|
|
@@ -36,14 +39,17 @@ exports.DEFAULT_MAX_STATE_AGE = require_sdk_GearboxSDK.DEFAULT_MAX_STATE_AGE;
|
|
|
36
39
|
exports.ExecuteApi = require_sdk_execute_ExecuteApi.ExecuteApi;
|
|
37
40
|
exports.GearboxSDK = require_sdk_GearboxSDK.GearboxSDK;
|
|
38
41
|
exports.LiquidationsNamespace = require_sdk_liquidations_LiquidationsNamespace.LiquidationsNamespace;
|
|
42
|
+
exports.MerklRequestFailedError = require_sdk_rewards_errors.MerklRequestFailedError;
|
|
39
43
|
exports.MissingSourceError = require_sdk_errors_MissingSourceError.MissingSourceError;
|
|
40
44
|
exports.NoSourceServedError = require_sdk_errors_NoSourceServedError.NoSourceServedError;
|
|
41
45
|
exports.OpportunitiesNamespace = require_sdk_opportunities_OpportunitiesNamespace.OpportunitiesNamespace;
|
|
42
46
|
exports.PositionsNamespace = require_sdk_positions_PositionsNamespace.PositionsNamespace;
|
|
43
47
|
exports.PrepareApi = require_sdk_prepare_PrepareApi.PrepareApi;
|
|
44
48
|
exports.PreviewNamespace = require_sdk_preview_PreviewNamespace.PreviewNamespace;
|
|
49
|
+
exports.RewardsNamespace = require_sdk_rewards_RewardsNamespace.RewardsNamespace;
|
|
45
50
|
exports.SourceChainMismatchError = require_sdk_errors_SourceChainMismatchError.SourceChainMismatchError;
|
|
46
51
|
exports.SourceUnavailableError = require_sdk_errors_SourceUnavailableError.SourceUnavailableError;
|
|
52
|
+
exports.TurtleRequestFailedError = require_sdk_rewards_errors.TurtleRequestFailedError;
|
|
47
53
|
exports.assertSameChains = require_sdk_errors_assertSameChains.assertSameChains;
|
|
48
54
|
exports.creditAccountNotEmpty = require_model_errors_prepare_errors.creditAccountNotEmpty;
|
|
49
55
|
exports.creditAccountNotFound = require_model_errors_prepare_errors.creditAccountNotFound;
|
|
@@ -49,6 +49,16 @@ var LiquidationsNamespace = class {
|
|
|
49
49
|
const sdk = this.#onchain.chain(props.details.chainId);
|
|
50
50
|
return require_onchain_validation_checkLiquidation.checkLiquidation(sdk, props, options);
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritDoc ILiquidations.isEmergencyLiquidator}
|
|
54
|
+
**/
|
|
55
|
+
isEmergencyLiquidator(props) {
|
|
56
|
+
try {
|
|
57
|
+
return this.#onchain.chain(props.chainId).marketRegister.findByCreditManager(props.creditManager).isEmergencyLiquidator(props.liquidator);
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
52
62
|
};
|
|
53
63
|
//#endregion
|
|
54
64
|
exports.LiquidationsNamespace = LiquidationsNamespace;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_onchain_base_MultichainConstruct = require("../../onchain/base/MultichainConstruct.js");
|
|
3
|
+
require("../../onchain/index.js");
|
|
4
|
+
const require_sdk_rewards_merkl_api = require("./merkl-api.js");
|
|
5
|
+
const require_sdk_rewards_toMerklRewards = require("./toMerklRewards.js");
|
|
6
|
+
const require_sdk_rewards_toTurtleRewards = require("./toTurtleRewards.js");
|
|
7
|
+
const require_sdk_rewards_turtle_api = require("./turtle-api.js");
|
|
8
|
+
let viem = require("viem");
|
|
9
|
+
//#region src/sdk/rewards/RewardsNamespace.ts
|
|
10
|
+
/**
|
|
11
|
+
* {@inheritDoc IRewards}
|
|
12
|
+
**/
|
|
13
|
+
var RewardsNamespace = class extends require_onchain_base_MultichainConstruct.MultichainConstruct {
|
|
14
|
+
#keys;
|
|
15
|
+
#ensureFresh;
|
|
16
|
+
constructor(onchain, keys, options) {
|
|
17
|
+
super(onchain);
|
|
18
|
+
this.#keys = keys ?? {};
|
|
19
|
+
this.#ensureFresh = options.ensureFresh;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* {@inheritDoc IRewards.list}
|
|
23
|
+
**/
|
|
24
|
+
async list(wallet, chainIds) {
|
|
25
|
+
await this.#ensureFresh?.(chainIds);
|
|
26
|
+
const { merklApiKey, turtleApiKey } = this.#keys;
|
|
27
|
+
const user = (0, viem.getAddress)(wallet);
|
|
28
|
+
const turtle = turtleApiKey ? require_sdk_rewards_turtle_api.fetchTurtleWalletRewards(user, turtleApiKey) : void 0;
|
|
29
|
+
turtle?.catch(() => {});
|
|
30
|
+
return this.queryChains({
|
|
31
|
+
chainIds,
|
|
32
|
+
label: "list rewards",
|
|
33
|
+
block: "state",
|
|
34
|
+
run: async (sdk) => {
|
|
35
|
+
const sources = [require_sdk_rewards_merkl_api.fetchMerklUserRewards({
|
|
36
|
+
chainId: sdk.chainId,
|
|
37
|
+
user,
|
|
38
|
+
apiKey: merklApiKey
|
|
39
|
+
}).then((response) => require_sdk_rewards_toMerklRewards.toMerklRewards(sdk, response))];
|
|
40
|
+
if (turtle) sources.push(turtle.then(async (rewards) => require_sdk_rewards_toTurtleRewards.toTurtleRewards(sdk, rewards, await require_sdk_rewards_turtle_api.readTurtleClaimed(sdk, user, rewards))));
|
|
41
|
+
const settled = await Promise.allSettled(sources);
|
|
42
|
+
const failed = settled.flatMap((r) => r.status === "rejected" ? [r.reason] : []);
|
|
43
|
+
if (failed.length === settled.length) throw failed.length === 1 ? failed[0] : new AggregateError(failed, "no rewards source answered");
|
|
44
|
+
for (const reason of failed) (sdk.logger ?? this.sdk.logger)?.warn(reason, `rewards source failed on chain ${sdk.chainId}`);
|
|
45
|
+
return settled.flatMap((r) => r.status === "fulfilled" ? r.value : []);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.RewardsNamespace = RewardsNamespace;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_onchain_utils_AddressMap = require("
|
|
3
|
-
const require_onchain_utils_formatter = require("
|
|
4
|
-
require("
|
|
2
|
+
const require_onchain_utils_AddressMap = require("../../onchain/utils/AddressMap.js");
|
|
3
|
+
const require_onchain_utils_formatter = require("../../onchain/utils/formatter.js");
|
|
4
|
+
require("../../onchain/index.js");
|
|
5
5
|
let viem = require("viem");
|
|
6
|
-
//#region src/rewards/helpers.ts
|
|
6
|
+
//#region src/sdk/rewards/helpers.ts
|
|
7
7
|
/**
|
|
8
8
|
* The pool a source names, and its share token. A v3.1 pool is its own
|
|
9
9
|
* ERC-4626 share token, so its address is the only token a campaign can name;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sdk_rewards_errors = require("./errors.js");
|
|
3
|
+
const require_sdk_rewards_RewardsNamespace = require("./RewardsNamespace.js");
|
|
4
|
+
exports.MerklRequestFailedError = require_sdk_rewards_errors.MerklRequestFailedError;
|
|
5
|
+
exports.RewardsNamespace = require_sdk_rewards_RewardsNamespace.RewardsNamespace;
|
|
6
|
+
exports.TurtleRequestFailedError = require_sdk_rewards_errors.TurtleRequestFailedError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
//#region src/rewards/merkl-api.ts
|
|
2
|
+
const require_sdk_rewards_errors = require("./errors.js");
|
|
3
|
+
//#region src/sdk/rewards/merkl-api.ts
|
|
4
4
|
const MERKL_API_URL = "https://api.merkl.xyz";
|
|
5
5
|
const MERKL_API_KEY_HEADER = "X-API-Key";
|
|
6
6
|
/**
|
|
@@ -26,7 +26,7 @@ async function fetchMerklUserRewards({ chainId, user, apiKey }) {
|
|
|
26
26
|
if (!response.ok) throw new Error(`answered ${response.status}`);
|
|
27
27
|
return await response.json();
|
|
28
28
|
} catch (error) {
|
|
29
|
-
throw new
|
|
29
|
+
throw new require_sdk_rewards_errors.MerklRequestFailedError(chainId, path, error);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_sdk_rewards_helpers = require("./helpers.js");
|
|
3
3
|
let viem = require("viem");
|
|
4
|
-
//#region src/rewards/toMerklRewards.ts
|
|
4
|
+
//#region src/sdk/rewards/toMerklRewards.ts
|
|
5
5
|
/**
|
|
6
6
|
* Merkl's answer for one chain, one reward per pool and incentive token.
|
|
7
7
|
* A breakdown Merkl cannot be read from is skipped rather than thrown on: it
|
|
8
8
|
* must not sink the chain, which the caller would then be told is unreachable.
|
|
9
9
|
*/
|
|
10
10
|
function toMerklRewards(sdk, response) {
|
|
11
|
-
const poolOf =
|
|
11
|
+
const poolOf = require_sdk_rewards_helpers.resolvePool(sdk);
|
|
12
12
|
const parts = response.flatMap(({ rewards }) => rewards).flatMap(({ token, breakdowns }) => {
|
|
13
13
|
if (!(0, viem.isAddress)(token.address, { strict: false })) return [];
|
|
14
|
-
const rewardToken =
|
|
14
|
+
const rewardToken = require_sdk_rewards_helpers.toRewardToken(sdk, (0, viem.getAddress)(token.address), token);
|
|
15
15
|
return breakdowns.flatMap(({ reason, amount, claimed }) => {
|
|
16
16
|
const pool = poolOf(reason?.split("_").find((p) => p.startsWith("0x")));
|
|
17
|
-
const value =
|
|
17
|
+
const value = require_sdk_rewards_helpers.remaining(require_sdk_rewards_helpers.parseAmount(amount), require_sdk_rewards_helpers.parseAmount(claimed));
|
|
18
18
|
if (!pool || !value) return [];
|
|
19
19
|
return [{
|
|
20
20
|
...pool,
|
|
@@ -24,7 +24,7 @@ function toMerklRewards(sdk, response) {
|
|
|
24
24
|
}];
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
|
-
return
|
|
27
|
+
return require_sdk_rewards_helpers.mergeRewards(sdk, "merkl", parts);
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
30
|
exports.toMerklRewards = toMerklRewards;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_sdk_rewards_helpers = require("./helpers.js");
|
|
3
3
|
let viem = require("viem");
|
|
4
|
-
//#region src/rewards/toTurtleRewards.ts
|
|
4
|
+
//#region src/sdk/rewards/toTurtleRewards.ts
|
|
5
5
|
/**
|
|
6
6
|
* The streams targeting a pool on the SDK's chain, merged per pool and
|
|
7
7
|
* incentive. A token reward is what is committed and not yet claimed.
|
|
8
8
|
*/
|
|
9
9
|
function toTurtleRewards(sdk, { streams, proofs }, claimed) {
|
|
10
|
-
const poolOf =
|
|
10
|
+
const poolOf = require_sdk_rewards_helpers.resolvePool(sdk);
|
|
11
11
|
const committed = new Map(proofs.map((p) => [p.streamId, p.amount]));
|
|
12
12
|
const targeted = streams.flatMap((stream) => {
|
|
13
13
|
const target = stream.stream.customArgs.targetToken;
|
|
@@ -21,24 +21,24 @@ function toTurtleRewards(sdk, { streams, proofs }, claimed) {
|
|
|
21
21
|
const tokens = targeted.flatMap(({ stream, pool, poolToken }) => {
|
|
22
22
|
const { point, rewardToken, lastSnapshot } = stream.stream;
|
|
23
23
|
if (point || !rewardToken || !(0, viem.isAddress)(rewardToken.address, { strict: false })) return [];
|
|
24
|
-
const value =
|
|
24
|
+
const value = require_sdk_rewards_helpers.remaining(require_sdk_rewards_helpers.parseAmount(committed.get(stream.streamId)), claimed.get(stream.streamId));
|
|
25
25
|
if (!value) return [];
|
|
26
26
|
return [{
|
|
27
27
|
pool,
|
|
28
28
|
poolToken,
|
|
29
|
-
token:
|
|
29
|
+
token: require_sdk_rewards_helpers.toRewardToken(sdk, (0, viem.getAddress)(rewardToken.address), rewardToken),
|
|
30
30
|
value,
|
|
31
31
|
price: lastSnapshot?.rewardTokenPrice
|
|
32
32
|
}];
|
|
33
33
|
});
|
|
34
|
-
return [...
|
|
34
|
+
return [...require_sdk_rewards_helpers.mergeRewards(sdk, "turtle", tokens), ...toPoints(sdk, targeted)];
|
|
35
35
|
}
|
|
36
36
|
/** Points accrue per snapshot; the last one holds the running total. */
|
|
37
37
|
function toPoints(sdk, targeted) {
|
|
38
38
|
const merged = /* @__PURE__ */ new Map();
|
|
39
39
|
for (const { stream, pool, poolToken } of targeted) {
|
|
40
40
|
const { point } = stream.stream;
|
|
41
|
-
const raw =
|
|
41
|
+
const raw = require_sdk_rewards_helpers.parseAmount(stream.snapshots.at(-1)?.rewardsAccumulated);
|
|
42
42
|
if (!point || !raw) continue;
|
|
43
43
|
const key = `${pool}_${point.id}`;
|
|
44
44
|
const value = (merged.get(key)?.points.value ?? 0) + Number((0, viem.formatUnits)(raw, point.decimals));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
//#region src/rewards/turtle-api.ts
|
|
2
|
+
const require_sdk_rewards_errors = require("./errors.js");
|
|
3
|
+
//#region src/sdk/rewards/turtle-api.ts
|
|
4
4
|
const TURTLE_API_URL = "https://earn.turtle.xyz";
|
|
5
5
|
const GEARBOX_ORG_ID = "d171ba3d-ff89-4e6c-8f13-d94840b06edd";
|
|
6
6
|
const TIMEOUT = 1e4;
|
|
@@ -42,7 +42,7 @@ async function get(path, apiKey) {
|
|
|
42
42
|
if (!response.ok) throw new Error(`answered ${response.status}`);
|
|
43
43
|
return await response.json();
|
|
44
44
|
} catch (error) {
|
|
45
|
-
throw new
|
|
45
|
+
throw new require_sdk_rewards_errors.TurtleRequestFailedError(path, error);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
/** What each of the wallet's streams on the chain has paid out, at the latest block. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ierc20Abi } from "../abi/iERC20.js";
|
|
2
1
|
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
2
|
+
import { ierc20Abi } from "../abi/iERC20.js";
|
|
3
3
|
import { AddressMap } from "../onchain/utils/AddressMap.js";
|
|
4
4
|
import { AddressSet } from "../onchain/utils/AddressSet.js";
|
|
5
5
|
import { AssetsMap } from "../onchain/utils/AssetsMap.js";
|
|
@@ -8,6 +8,7 @@ import "../onchain/constants/addresses.js";
|
|
|
8
8
|
import { MAX_UINT256, PERCENTAGE_FACTOR } from "../onchain/constants/math.js";
|
|
9
9
|
import { SDKConstruct } from "../onchain/base/SDKConstruct.js";
|
|
10
10
|
import { sendRawTx } from "../onchain/utils/viem/sendRawTx.js";
|
|
11
|
+
import { DIRECT_TRANSFERS_QUOTA } from "../onchain/accounts/quota-utils.js";
|
|
11
12
|
import { PoolService } from "../onchain/pools/PoolService.js";
|
|
12
13
|
import "../onchain/index.js";
|
|
13
14
|
import { iDegenNftv2Abi } from "./abi.js";
|
|
@@ -18,7 +19,6 @@ import "./mint/index.js";
|
|
|
18
19
|
import { BaseError, erc20Abi, isAddress, parseEther, parseEventLogs } from "viem";
|
|
19
20
|
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
20
21
|
//#region src/dev/AccountOpener.ts
|
|
21
|
-
const DIRECT_TRANSFERS_QUOTA = 10000n;
|
|
22
22
|
var OpenTxRevertedError = class extends BaseError {
|
|
23
23
|
txHash;
|
|
24
24
|
constructor(txHash) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
2
1
|
import { getNetworkType } from "../onchain/chain/chains.js";
|
|
3
2
|
import { getWithdrawalCompressorAddress } from "../onchain/accounts/withdrawal-compressor/addresses.js";
|
|
3
|
+
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import "../onchain/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,5 +1,5 @@
|
|
|
1
|
-
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
1
|
import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
|
|
2
|
+
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
3
3
|
import { AddressMap } from "../../onchain/utils/AddressMap.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
5
5
|
import { UnexpectedFacadeEventOrderError } from "./errors.js";
|
package/dist/esm/model/index.js
CHANGED
|
@@ -30,6 +30,7 @@ import "./primitives.js";
|
|
|
30
30
|
import "./response.js";
|
|
31
31
|
import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema } from "./response.schema.js";
|
|
32
32
|
import { safeValue, sdkErr, sdkOk } from "./result.js";
|
|
33
|
+
import "./rewards.js";
|
|
33
34
|
import "./withdrawals.js";
|
|
34
35
|
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
35
36
|
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, FILTER_ALL, KYC_REGISTRATION_LINKS, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, accountNotMidasGreenlisted, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, reservePriceLimited, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
2
|
-
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
3
1
|
import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
|
|
4
2
|
import { ADDRESS_0X0 } from "../constants/addresses.js";
|
|
5
3
|
import { MAX_UINT256 } from "../constants/math.js";
|
|
@@ -10,6 +8,8 @@ import "../base/index.js";
|
|
|
10
8
|
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
11
9
|
import "./bots/index.js";
|
|
12
10
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
11
|
+
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
12
|
+
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
13
13
|
import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
|
|
14
14
|
import "../market/index.js";
|
|
15
15
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|