@strkfarm/sdk 2.0.0-dev.9 → 2.0.0-staging.2
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/index.browser.global.js +111371 -93151
- package/dist/index.browser.mjs +27815 -32690
- package/dist/index.d.ts +1095 -2011
- package/dist/index.js +27425 -32309
- package/dist/index.mjs +27590 -32452
- package/package.json +6 -5
- package/src/data/ekubo-price-fethcer.abi.json +265 -0
- package/src/data/universal-vault.abi.json +20 -135
- package/src/dataTypes/address.ts +0 -7
- package/src/dataTypes/index.ts +3 -2
- package/src/dataTypes/mynumber.ts +141 -0
- package/src/global.ts +296 -288
- package/src/index.browser.ts +6 -5
- package/src/interfaces/common.tsx +324 -184
- package/src/modules/apollo-client-config.ts +28 -0
- package/src/modules/avnu.ts +4 -17
- package/src/modules/ekubo-pricer.ts +79 -0
- package/src/modules/ekubo-quoter.ts +11 -88
- package/src/modules/erc20.ts +21 -67
- package/src/modules/harvests.ts +26 -15
- package/src/modules/index.ts +11 -13
- package/src/modules/lst-apr.ts +0 -36
- package/src/modules/pragma.ts +23 -8
- package/src/modules/pricer-from-api.ts +150 -14
- package/src/modules/pricer.ts +2 -1
- package/src/modules/pricerBase.ts +2 -1
- package/src/node/deployer.ts +36 -1
- package/src/node/pricer-redis.ts +2 -1
- package/src/strategies/autoCompounderStrk.ts +1 -1
- package/src/strategies/base-strategy.ts +5 -22
- package/src/strategies/ekubo-cl-vault.tsx +2904 -2175
- package/src/strategies/factory.ts +165 -0
- package/src/strategies/index.ts +10 -11
- package/src/strategies/registry.ts +268 -0
- package/src/strategies/sensei.ts +416 -292
- package/src/strategies/universal-adapters/adapter-utils.ts +1 -5
- package/src/strategies/universal-adapters/baseAdapter.ts +153 -181
- package/src/strategies/universal-adapters/common-adapter.ts +77 -98
- package/src/strategies/universal-adapters/index.ts +1 -5
- package/src/strategies/universal-adapters/vesu-adapter.ts +218 -220
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +51 -58
- package/src/strategies/universal-lst-muliplier-strategy.tsx +1952 -992
- package/src/strategies/universal-strategy.tsx +1713 -1150
- package/src/strategies/vesu-rebalance.tsx +1189 -986
- package/src/utils/health-factor-math.ts +5 -11
- package/src/utils/index.ts +8 -9
- package/src/utils/strategy-utils.ts +57 -0
- package/src/data/extended-deposit.abi.json +0 -3613
- package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
- package/src/modules/ExtendedWrapperSDk/types.ts +0 -311
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -395
- package/src/modules/midas.ts +0 -159
- package/src/modules/token-market-data.ts +0 -202
- package/src/strategies/svk-strategy.ts +0 -247
- package/src/strategies/universal-adapters/adapter-optimizer.ts +0 -65
- package/src/strategies/universal-adapters/avnu-adapter.ts +0 -413
- package/src/strategies/universal-adapters/extended-adapter.ts +0 -972
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +0 -1306
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -34
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -77
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -49
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -370
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1379
|
@@ -4,7 +4,7 @@ import { SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGAT
|
|
|
4
4
|
import { ContractAddr, Web3Number } from "@/dataTypes";
|
|
5
5
|
import { AdapterLeafType, BaseAdapter, GenerateCallFn, LeafAdapterFn, ManageCall } from "./baseAdapter";
|
|
6
6
|
import VesuSingletonAbi from '../../data/vesu-singleton.abi.json';
|
|
7
|
-
import { getMainnetConfig, IConfig,
|
|
7
|
+
import { getMainnetConfig, IConfig, TokenInfo, VaultPosition } from "@/interfaces";
|
|
8
8
|
import { PricerBase } from "@/modules/pricerBase";
|
|
9
9
|
import VesuPoolIDs from "@/data/vesu_pools.json";
|
|
10
10
|
import { getAPIUsingHeadlessBrowser } from "@/node/headless";
|
|
@@ -15,7 +15,6 @@ import VesuMultiplyAbi from '@/data/vesu-multiple.abi.json';
|
|
|
15
15
|
import { EkuboPoolKey } from "../ekubo-cl-vault";
|
|
16
16
|
import VesuPoolV2Abi from '@/data/vesu-pool-v2.abi.json';
|
|
17
17
|
import VesuExtensionAbi from '@/data/vesu-extension.abi.json';
|
|
18
|
-
import { CacheClass } from "@/utils/cacheClass";
|
|
19
18
|
|
|
20
19
|
interface VesuPoolsInfo { pools: any[]; isErrorPoolsAPI: boolean };
|
|
21
20
|
|
|
@@ -233,8 +232,7 @@ function getVesuMultiplyParams(isIncrease: boolean, params: IncreaseLeverParams
|
|
|
233
232
|
export const VesuPools = {
|
|
234
233
|
Genesis: ContractAddr.from('0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28'),
|
|
235
234
|
Re7xSTRK: ContractAddr.from('0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161'),
|
|
236
|
-
Re7xBTC: ContractAddr.from('0x3a8416bf20d036df5b1cf3447630a2e1cb04685f6b0c3a70ed7fb1473548ecf')
|
|
237
|
-
Re7USDCPrime: ContractAddr.from('0x02eef0c13b10b487ea5916b54c0a7f98ec43fb3048f60fdeedaf5b08f6f88aaf'),
|
|
235
|
+
Re7xBTC: ContractAddr.from('0x3a8416bf20d036df5b1cf3447630a2e1cb04685f6b0c3a70ed7fb1473548ecf')
|
|
238
236
|
}
|
|
239
237
|
|
|
240
238
|
export const extensionMap: {[key: string]: ContractAddr} = {};
|
|
@@ -248,7 +246,7 @@ export function getVesuSingletonAddress(vesuPool: ContractAddr) {
|
|
|
248
246
|
return {addr: vesuPool, isV2: true}; // Vesu v2
|
|
249
247
|
}
|
|
250
248
|
|
|
251
|
-
export class VesuAdapter extends
|
|
249
|
+
export class VesuAdapter extends BaseAdapter {
|
|
252
250
|
VESU_MULTIPLY_V1 = ContractAddr.from('0x3630f1f8e5b8f5c4c4ae9b6620f8a570ae55cddebc0276c37550e7c118edf67');
|
|
253
251
|
VESU_MULTIPLY = ContractAddr.from('0x027fef272d0a9a3844767c851a64b36fe4f0115141d81134baade95d2b27b781');
|
|
254
252
|
config: VesuAdapterConfig;
|
|
@@ -260,184 +258,184 @@ export class VesuAdapter extends CacheClass {
|
|
|
260
258
|
this.config = config;
|
|
261
259
|
}
|
|
262
260
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
261
|
+
getModifyPosition = (): AdapterLeafType<VesuModifyPositionCallParams> => {
|
|
262
|
+
const positionData: bigint[] = [0n];
|
|
263
|
+
const { addr, isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
264
|
+
const commonPackedData: bigint[] = [
|
|
265
|
+
toBigInt(this.config.collateral.address.toString()), // collateral
|
|
266
|
+
toBigInt(this.config.debt.address.toString()), // debt
|
|
267
|
+
toBigInt(this.config.vaultAllocator.toString()), // vault allocator
|
|
268
|
+
];
|
|
269
|
+
const packedArguments: bigint[] = isV2 ? [
|
|
270
|
+
...commonPackedData
|
|
271
|
+
] : [
|
|
272
|
+
toBigInt(this.config.poolId.toString()), // pool id
|
|
273
|
+
...commonPackedData,
|
|
274
|
+
toBigInt(positionData.length),
|
|
275
|
+
...positionData
|
|
276
|
+
];
|
|
277
|
+
const output = this.constructSimpleLeafData({
|
|
278
|
+
id: this.config.id,
|
|
279
|
+
target: addr,
|
|
280
|
+
method: 'modify_position',
|
|
281
|
+
packedArguments
|
|
282
|
+
}, isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER);
|
|
283
|
+
|
|
284
|
+
return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
static getDefaultModifyPositionCallParams(params: {
|
|
288
|
+
collateralAmount: Web3Number,
|
|
289
|
+
isAddCollateral: boolean,
|
|
290
|
+
debtAmount: Web3Number,
|
|
291
|
+
isBorrow: boolean
|
|
292
|
+
}) {
|
|
293
|
+
return {
|
|
294
|
+
collateralAmount: {
|
|
295
|
+
amount_type: VesuAmountType.Delta,
|
|
296
|
+
denomination: VesuAmountDenomination.Assets,
|
|
297
|
+
value: {
|
|
298
|
+
abs: params.collateralAmount,
|
|
299
|
+
is_negative: !params.isAddCollateral
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
debtAmount: {
|
|
303
|
+
amount_type: VesuAmountType.Delta,
|
|
304
|
+
denomination: VesuAmountDenomination.Assets,
|
|
305
|
+
value: {
|
|
306
|
+
abs: params.debtAmount,
|
|
307
|
+
is_negative: !params.isBorrow
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
getModifyPositionCall = (params: VesuModifyPositionCallParams): ManageCall => {
|
|
314
|
+
// pub pool_id: felt252,
|
|
315
|
+
// pub collateral_asset: ContractAddress,
|
|
316
|
+
// pub debt_asset: ContractAddress,
|
|
317
|
+
// pub user: ContractAddress,
|
|
318
|
+
// pub collateral: Amount,
|
|
319
|
+
// pub debt: Amount,
|
|
320
|
+
// pub data: Span<felt252>,
|
|
321
|
+
const _collateral = {
|
|
322
|
+
amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
|
|
323
|
+
denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
|
|
324
|
+
value: {
|
|
325
|
+
abs: uint256.bnToUint256(params.collateralAmount.value.abs.toWei()),
|
|
326
|
+
is_negative: params.collateralAmount.value.abs.isZero() ? false: params.collateralAmount.value.is_negative
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
logger.verbose(`VesuAdapter::ConstructingModify::Collateral::${JSON.stringify(_collateral)}`)
|
|
330
|
+
const _debt = {
|
|
331
|
+
amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
|
|
332
|
+
denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
|
|
333
|
+
value: {
|
|
334
|
+
abs: uint256.bnToUint256(params.debtAmount.value.abs.toWei()),
|
|
335
|
+
is_negative: params.debtAmount.value.abs.isZero() ? false: params.debtAmount.value.is_negative
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`)
|
|
339
|
+
const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
|
|
340
|
+
const call = contract.populate('modify_position', {
|
|
341
|
+
params: isV2 ? {
|
|
342
|
+
collateral_asset: this.config.collateral.address.toBigInt(),
|
|
343
|
+
debt_asset: this.config.debt.address.toBigInt(),
|
|
344
|
+
user: this.config.vaultAllocator.toBigInt(),
|
|
345
|
+
collateral: _collateral,
|
|
346
|
+
debt: _debt,
|
|
347
|
+
} : {
|
|
348
|
+
pool_id: this.config.poolId.toBigInt(),
|
|
349
|
+
collateral_asset: this.config.collateral.address.toBigInt(),
|
|
350
|
+
debt_asset: this.config.debt.address.toBigInt(),
|
|
351
|
+
user: this.config.vaultAllocator.toBigInt(),
|
|
352
|
+
collateral: _collateral,
|
|
353
|
+
debt: _debt,
|
|
354
|
+
data: [0]
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
return {
|
|
358
|
+
sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
|
|
359
|
+
call: {
|
|
360
|
+
contractAddress: ContractAddr.from(contract.address),
|
|
361
|
+
selector: hash.getSelectorFromName('modify_position'),
|
|
362
|
+
calldata: [
|
|
363
|
+
...call.calldata as bigint[]
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
getMultiplyAdapter = (id: string): LeafAdapterFn<VesuMultiplyCallParams> => {
|
|
370
|
+
return () => {
|
|
371
|
+
const packedArguments: bigint[] = [
|
|
372
|
+
toBigInt(this.config.poolId.toString()), // pool id
|
|
373
|
+
toBigInt(this.config.collateral.address.toString()), // collateral
|
|
374
|
+
toBigInt(this.config.debt.address.toString()), // debt
|
|
375
|
+
toBigInt(this.config.vaultAllocator.toString()), // vault allocator
|
|
376
|
+
];
|
|
377
|
+
const { isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
378
|
+
const output = this.constructSimpleLeafData({
|
|
379
|
+
id: id,
|
|
380
|
+
target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
|
|
381
|
+
method: 'modify_lever',
|
|
382
|
+
packedArguments
|
|
383
|
+
}, SIMPLE_SANITIZER_V2);
|
|
384
|
+
|
|
385
|
+
return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
getMultiplyCall = (params: VesuMultiplyCallParams): ManageCall => {
|
|
390
|
+
const isIncrease = params.isIncrease;
|
|
391
|
+
const multiplyParams = isIncrease ? params.increaseParams : params.decreaseParams;
|
|
392
|
+
if (!multiplyParams) {
|
|
393
|
+
throw new Error('Multiply params are not provided');
|
|
394
|
+
}
|
|
395
|
+
const { isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
396
|
+
const VESU_MULTIPLY = isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1;
|
|
397
|
+
const multiplyContract = new Contract({abi: VesuMultiplyAbi, address: VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider({nodeUrl: ''})});
|
|
398
|
+
const call = multiplyContract.populate('modify_lever', {
|
|
399
|
+
modify_lever_params: getVesuMultiplyParams(isIncrease, {
|
|
400
|
+
...multiplyParams,
|
|
401
|
+
user: this.config.vaultAllocator,
|
|
402
|
+
pool_id: this.config.poolId,
|
|
403
|
+
collateral_asset: this.config.collateral.address,
|
|
404
|
+
debt_asset: this.config.debt.address,
|
|
405
|
+
recipient: this.config.vaultAllocator
|
|
406
|
+
})
|
|
407
|
+
});
|
|
408
|
+
return {
|
|
409
|
+
sanitizer: SIMPLE_SANITIZER_V2,
|
|
410
|
+
call: {
|
|
411
|
+
contractAddress: VESU_MULTIPLY,
|
|
412
|
+
selector: hash.getSelectorFromName('modify_lever'),
|
|
413
|
+
calldata: [
|
|
414
|
+
...call.calldata as bigint[]
|
|
415
|
+
]
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
getVesuModifyDelegationAdapter = (id: string): LeafAdapterFn<VesuModifyDelegationCallParams> => {
|
|
421
|
+
return () => {
|
|
422
|
+
const { addr: VESU_SINGLETON, isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
423
|
+
const packedArguments: bigint[] = isV2 ? [
|
|
424
|
+
toBigInt(this.VESU_MULTIPLY.toString()), // v2
|
|
425
|
+
] : [
|
|
426
|
+
this.config.poolId.toBigInt(),
|
|
427
|
+
toBigInt(this.VESU_MULTIPLY_V1.toString()), // v1
|
|
428
|
+
];
|
|
429
|
+
const output = this.constructSimpleLeafData({
|
|
430
|
+
id: id,
|
|
431
|
+
target: VESU_SINGLETON,
|
|
432
|
+
method: 'modify_delegation',
|
|
433
|
+
packedArguments
|
|
434
|
+
}, isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS);
|
|
435
|
+
|
|
436
|
+
return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
|
|
437
|
+
}
|
|
438
|
+
}
|
|
441
439
|
|
|
442
440
|
getVesuModifyDelegationCall = (params: VesuModifyDelegationCallParams): ManageCall => {
|
|
443
441
|
const VESU_SINGLETON = getVesuSingletonAddress(this.config.poolId).addr;
|
|
@@ -462,38 +460,38 @@ export class VesuAdapter extends CacheClass {
|
|
|
462
460
|
}
|
|
463
461
|
}
|
|
464
462
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
463
|
+
getDefispringRewardsAdapter = (id: string): () => AdapterLeafType<VesuDefiSpringRewardsCallParams> => {
|
|
464
|
+
return () => {
|
|
465
|
+
const packedArguments: bigint[] = [];
|
|
466
|
+
const output = {
|
|
467
|
+
id: BigInt(num.getDecimalString(shortString.encodeShortString(id))),
|
|
468
|
+
readableId: id,
|
|
469
|
+
data: [
|
|
470
|
+
SIMPLE_SANITIZER.toBigInt(), // sanitizer address
|
|
471
|
+
VESU_REWARDS_CONTRACT.toBigInt(), // contract
|
|
472
|
+
toBigInt(hash.getSelectorFromName("claim")), // method name
|
|
473
|
+
BigInt(packedArguments.length),
|
|
474
|
+
...packedArguments
|
|
475
|
+
]
|
|
476
|
+
};
|
|
477
|
+
return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
getDefiSpringClaimCall = (): GenerateCallFn<VesuDefiSpringRewardsCallParams> => {
|
|
482
|
+
return (params: VesuDefiSpringRewardsCallParams) => ({
|
|
483
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
484
|
+
call: {
|
|
485
|
+
contractAddress: VESU_REWARDS_CONTRACT,
|
|
486
|
+
selector: hash.getSelectorFromName('claim'),
|
|
487
|
+
calldata: [
|
|
488
|
+
BigInt(params.amount.toWei()),
|
|
489
|
+
BigInt(params.proofs.length),
|
|
490
|
+
...params.proofs.map(proof => BigInt(num.hexToDecimalString(proof)))
|
|
491
|
+
]
|
|
492
|
+
}
|
|
493
|
+
})
|
|
494
|
+
}
|
|
497
495
|
|
|
498
496
|
formatAmountTypeEnum(amountType: VesuAmountType) {
|
|
499
497
|
switch(amountType) {
|
|
@@ -602,7 +600,7 @@ export class VesuAdapter extends CacheClass {
|
|
|
602
600
|
}
|
|
603
601
|
|
|
604
602
|
async getLTVConfig(config: IConfig, blockNumber: BlockIdentifier = 'latest') {
|
|
605
|
-
const CACHE_KEY = `ltv_config_${blockNumber}
|
|
603
|
+
const CACHE_KEY = `ltv_config_${blockNumber}`;
|
|
606
604
|
const cacheData = this.getCache<number>(CACHE_KEY);
|
|
607
605
|
if (cacheData) {
|
|
608
606
|
return cacheData as number;
|
|
@@ -628,7 +626,7 @@ export class VesuAdapter extends CacheClass {
|
|
|
628
626
|
throw new Error('Pricer is not initialized');
|
|
629
627
|
}
|
|
630
628
|
// { '0': { collateral_shares: 0n, nominal_debt: 0n }, '1': 0n, '2': 0n }
|
|
631
|
-
const CACHE_KEY = `positions_${blockNumber}
|
|
629
|
+
const CACHE_KEY = `positions_${blockNumber}`;
|
|
632
630
|
const cacheData = this.getCache<VaultPosition[]>(CACHE_KEY);
|
|
633
631
|
if (cacheData) {
|
|
634
632
|
return cacheData;
|
|
@@ -662,7 +660,7 @@ export class VesuAdapter extends CacheClass {
|
|
|
662
660
|
remarks: "Debt"
|
|
663
661
|
}];
|
|
664
662
|
this.setCache(CACHE_KEY, value, 60000); // ttl: 1min
|
|
665
|
-
return value
|
|
663
|
+
return value;
|
|
666
664
|
}
|
|
667
665
|
|
|
668
666
|
async getCollateralization(config: IConfig, blockNumber: BlockIdentifier = 'latest'): Promise<Omit<VaultPosition, 'amount'>[]> {
|
|
@@ -670,7 +668,7 @@ export class VesuAdapter extends CacheClass {
|
|
|
670
668
|
throw new Error('Pricer is not initialized');
|
|
671
669
|
}
|
|
672
670
|
// { '0': bool, '1': 0n, '2': 0n }
|
|
673
|
-
const CACHE_KEY = `collateralization_${blockNumber}
|
|
671
|
+
const CACHE_KEY = `collateralization_${blockNumber}`;
|
|
674
672
|
const cacheData = this.getCache<Omit<VaultPosition, 'amount'>[]>(CACHE_KEY);
|
|
675
673
|
if (cacheData) {
|
|
676
674
|
return cacheData;
|
|
@@ -698,7 +696,7 @@ export class VesuAdapter extends CacheClass {
|
|
|
698
696
|
remarks: "Debt"
|
|
699
697
|
}];
|
|
700
698
|
this.setCache(CACHE_KEY, value, 60000); // ttl: 1min
|
|
701
|
-
return value
|
|
699
|
+
return value;
|
|
702
700
|
}
|
|
703
701
|
|
|
704
702
|
async getAssetPrices() {
|