@townsq/mm-sdk 1.8.0 → 2.1.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/chains/evm/common/constant/tokens.js +16 -0
- package/dist/chains/evm/common/constant/tokens.js.map +1 -1
- package/dist/chains/evm/hub/constants/chain.js +24 -0
- package/dist/chains/evm/hub/constants/chain.js.map +1 -1
- package/dist/chains/evm/hub/modules/ts-hub-loan.js.map +1 -1
- package/dist/common/constants/chain.js +20 -0
- package/dist/common/constants/chain.js.map +1 -1
- package/dist/common/constants/pool.d.ts +2 -0
- package/dist/common/constants/pool.js +2 -0
- package/dist/common/constants/pool.js.map +1 -1
- package/dist/common/types/token.d.ts +2 -0
- package/dist/common/types/token.js +2 -0
- package/dist/common/types/token.js.map +1 -1
- package/dist/lifeline/modules/ts-loan.d.ts +2 -2
- package/dist/lifeline/modules/ts-loan.js +3 -2
- package/dist/lifeline/modules/ts-loan.js.map +1 -1
- package/package.json +1 -1
- package/src/chains/evm/common/constant/tokens.ts +16 -1
- package/src/chains/evm/hub/constants/chain.ts +55 -25
- package/src/chains/evm/hub/modules/ts-hub-loan.ts +1 -0
- package/src/common/constants/chain.ts +68 -36
- package/src/common/constants/pool.ts +2 -0
- package/src/common/types/token.ts +3 -0
- package/src/lifeline/modules/ts-loan.ts +87 -85
|
@@ -98,7 +98,7 @@ export const prepare = {
|
|
|
98
98
|
nonce: Nonce,
|
|
99
99
|
loanTypeId: LoanTypeId,
|
|
100
100
|
loanName: LoanName,
|
|
101
|
-
adapters: MessageAdapters
|
|
101
|
+
adapters: MessageAdapters,
|
|
102
102
|
) {
|
|
103
103
|
const tsChain = TSCore.getSelectedTsChain();
|
|
104
104
|
|
|
@@ -135,13 +135,13 @@ export const prepare = {
|
|
|
135
135
|
TSCore.getHubProvider(),
|
|
136
136
|
tsChain.network,
|
|
137
137
|
MessageDirection.SpokeToHub,
|
|
138
|
-
messageBuilderParams
|
|
138
|
+
messageBuilderParams,
|
|
139
139
|
);
|
|
140
140
|
|
|
141
141
|
const messageToSend = buildMessageToSend(
|
|
142
142
|
tsChain.chainType,
|
|
143
143
|
messageBuilderParams,
|
|
144
|
-
feeParams
|
|
144
|
+
feeParams,
|
|
145
145
|
);
|
|
146
146
|
|
|
147
147
|
switch (tsChain.chainType) {
|
|
@@ -154,7 +154,7 @@ export const prepare = {
|
|
|
154
154
|
nonce,
|
|
155
155
|
loanTypeId,
|
|
156
156
|
loanName,
|
|
157
|
-
spokeChain
|
|
157
|
+
spokeChain,
|
|
158
158
|
);
|
|
159
159
|
default:
|
|
160
160
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -169,7 +169,7 @@ export const prepare = {
|
|
|
169
169
|
tsTokenIdToSeize: TSTokenId,
|
|
170
170
|
repayingAmount: bigint,
|
|
171
171
|
minSeizedAmount: bigint,
|
|
172
|
-
liquidatorAddress: GenericAddress
|
|
172
|
+
liquidatorAddress: GenericAddress,
|
|
173
173
|
) {
|
|
174
174
|
const tsChain = TSCore.getSelectedTsChain();
|
|
175
175
|
assertHubChainSelected(tsChain.tsChainId, tsChain.network);
|
|
@@ -177,11 +177,11 @@ export const prepare = {
|
|
|
177
177
|
|
|
178
178
|
const hubTokenToLiquidateData = getHubTokenData(
|
|
179
179
|
tsTokenIdToLiq,
|
|
180
|
-
tsChain.network
|
|
180
|
+
tsChain.network,
|
|
181
181
|
);
|
|
182
182
|
const hubTokenToSeizeData = getHubTokenData(
|
|
183
183
|
tsTokenIdToSeize,
|
|
184
|
-
tsChain.network
|
|
184
|
+
tsChain.network,
|
|
185
185
|
);
|
|
186
186
|
|
|
187
187
|
// const userAddress = getSignerGenericAddress({
|
|
@@ -203,7 +203,7 @@ export const prepare = {
|
|
|
203
203
|
convertFromGenericAddress(liquidatorAddress, tsChain.chainType),
|
|
204
204
|
data,
|
|
205
205
|
accountId,
|
|
206
|
-
hubChain
|
|
206
|
+
hubChain,
|
|
207
207
|
);
|
|
208
208
|
},
|
|
209
209
|
|
|
@@ -212,7 +212,7 @@ export const prepare = {
|
|
|
212
212
|
loanId: LoanId,
|
|
213
213
|
tsTokenId: TSTokenId,
|
|
214
214
|
amount: bigint,
|
|
215
|
-
adapters: MessageAdapters
|
|
215
|
+
adapters: MessageAdapters,
|
|
216
216
|
) {
|
|
217
217
|
const tsChain = TSCore.getSelectedTsChain();
|
|
218
218
|
const network = tsChain.network;
|
|
@@ -256,13 +256,13 @@ export const prepare = {
|
|
|
256
256
|
TSCore.getHubProvider(),
|
|
257
257
|
tsChain.network,
|
|
258
258
|
MessageDirection.SpokeToHub,
|
|
259
|
-
messageBuilderParams
|
|
259
|
+
messageBuilderParams,
|
|
260
260
|
);
|
|
261
261
|
|
|
262
262
|
const messageToSend = buildMessageToSend(
|
|
263
263
|
tsChain.chainType,
|
|
264
264
|
messageBuilderParams,
|
|
265
|
-
feeParams
|
|
265
|
+
feeParams,
|
|
266
266
|
);
|
|
267
267
|
|
|
268
268
|
switch (tsChain.chainType) {
|
|
@@ -276,7 +276,7 @@ export const prepare = {
|
|
|
276
276
|
loanId,
|
|
277
277
|
tsTokenId,
|
|
278
278
|
amount,
|
|
279
|
-
spokeChain
|
|
279
|
+
spokeChain,
|
|
280
280
|
);
|
|
281
281
|
default:
|
|
282
282
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -286,7 +286,7 @@ export const prepare = {
|
|
|
286
286
|
async deleteLoan(
|
|
287
287
|
accountId: AccountId,
|
|
288
288
|
loanId: LoanId,
|
|
289
|
-
adapters: MessageAdapters
|
|
289
|
+
adapters: MessageAdapters,
|
|
290
290
|
) {
|
|
291
291
|
const tsChain = TSCore.getSelectedTsChain();
|
|
292
292
|
|
|
@@ -322,13 +322,13 @@ export const prepare = {
|
|
|
322
322
|
TSCore.getHubProvider(),
|
|
323
323
|
tsChain.network,
|
|
324
324
|
MessageDirection.SpokeToHub,
|
|
325
|
-
messageBuilderParams
|
|
325
|
+
messageBuilderParams,
|
|
326
326
|
);
|
|
327
327
|
|
|
328
328
|
const messageToSend = buildMessageToSend(
|
|
329
329
|
tsChain.chainType,
|
|
330
330
|
messageBuilderParams,
|
|
331
|
-
feeParams
|
|
331
|
+
feeParams,
|
|
332
332
|
);
|
|
333
333
|
|
|
334
334
|
switch (tsChain.chainType) {
|
|
@@ -339,28 +339,28 @@ export const prepare = {
|
|
|
339
339
|
messageToSend,
|
|
340
340
|
accountId,
|
|
341
341
|
loanId,
|
|
342
|
-
spokeChain
|
|
342
|
+
spokeChain,
|
|
343
343
|
);
|
|
344
344
|
default:
|
|
345
345
|
return exhaustiveCheck(tsChain.chainType);
|
|
346
346
|
}
|
|
347
347
|
},
|
|
348
348
|
|
|
349
|
-
async
|
|
349
|
+
async initiateLoanAccountWithDeposit(
|
|
350
350
|
accountId: AccountId,
|
|
351
351
|
nonce: Nonce,
|
|
352
352
|
loanTypeId: LoanTypeId,
|
|
353
353
|
loanName: LoanName,
|
|
354
354
|
tsTokenId: TSTokenId,
|
|
355
355
|
amount: bigint,
|
|
356
|
-
adapters: MessageAdapters
|
|
356
|
+
adapters: MessageAdapters,
|
|
357
357
|
) {
|
|
358
358
|
const tsChain = TSCore.getSelectedTsChain();
|
|
359
359
|
|
|
360
360
|
assertSpokeChainSupportTsToken(
|
|
361
361
|
tsChain.tsChainId,
|
|
362
362
|
tsTokenId,
|
|
363
|
-
tsChain.network
|
|
363
|
+
tsChain.network,
|
|
364
364
|
);
|
|
365
365
|
assertLoanTypeSupported(loanTypeId, tsTokenId, tsChain.network);
|
|
366
366
|
const spokeChain = getSpokeChain(tsChain.tsChainId, tsChain.network);
|
|
@@ -373,7 +373,7 @@ export const prepare = {
|
|
|
373
373
|
assertAdapterSupportsCrossChainToken(
|
|
374
374
|
tsChain.tsChainId,
|
|
375
375
|
spokeTokenData.token,
|
|
376
|
-
adapters.adapterId
|
|
376
|
+
adapters.adapterId,
|
|
377
377
|
);
|
|
378
378
|
else
|
|
379
379
|
assertAdapterSupportsDataMessage(tsChain.tsChainId, adapters.adapterId);
|
|
@@ -406,6 +406,8 @@ export const prepare = {
|
|
|
406
406
|
data,
|
|
407
407
|
extraArgs,
|
|
408
408
|
};
|
|
409
|
+
|
|
410
|
+
console.log(messageBuilderParams);
|
|
409
411
|
const feeParams: OptionalFeeParams = {};
|
|
410
412
|
|
|
411
413
|
feeParams.gasLimit = await estimateAdapterReceiveGasLimit(
|
|
@@ -414,14 +416,14 @@ export const prepare = {
|
|
|
414
416
|
TSCore.getHubProvider(),
|
|
415
417
|
tsChain.network,
|
|
416
418
|
MessageDirection.SpokeToHub,
|
|
417
|
-
messageBuilderParams
|
|
419
|
+
messageBuilderParams,
|
|
418
420
|
);
|
|
419
421
|
feeParams.returnGasLimit = SEND_TOKEN_ACTION_RETURN_GAS_LIMIT;
|
|
420
422
|
|
|
421
423
|
const messageToSend = buildMessageToSend(
|
|
422
424
|
tsChain.chainType,
|
|
423
425
|
messageBuilderParams,
|
|
424
|
-
feeParams
|
|
426
|
+
feeParams,
|
|
425
427
|
);
|
|
426
428
|
|
|
427
429
|
switch (tsChain.chainType) {
|
|
@@ -436,7 +438,7 @@ export const prepare = {
|
|
|
436
438
|
loanName,
|
|
437
439
|
amount,
|
|
438
440
|
spokeChain,
|
|
439
|
-
spokeTokenData
|
|
441
|
+
spokeTokenData,
|
|
440
442
|
);
|
|
441
443
|
default:
|
|
442
444
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -449,14 +451,14 @@ export const prepare = {
|
|
|
449
451
|
loanTypeId: LoanTypeId,
|
|
450
452
|
tsTokenId: TSTokenId,
|
|
451
453
|
amount: bigint,
|
|
452
|
-
adapters: MessageAdapters
|
|
454
|
+
adapters: MessageAdapters,
|
|
453
455
|
) {
|
|
454
456
|
const tsChain = TSCore.getSelectedTsChain();
|
|
455
457
|
|
|
456
458
|
assertSpokeChainSupportTsToken(
|
|
457
459
|
tsChain.tsChainId,
|
|
458
460
|
tsTokenId,
|
|
459
|
-
tsChain.network
|
|
461
|
+
tsChain.network,
|
|
460
462
|
);
|
|
461
463
|
assertLoanTypeSupported(loanTypeId, tsTokenId, tsChain.network);
|
|
462
464
|
const spokeChain = getSpokeChain(tsChain.tsChainId, tsChain.network);
|
|
@@ -469,7 +471,7 @@ export const prepare = {
|
|
|
469
471
|
assertAdapterSupportsCrossChainToken(
|
|
470
472
|
tsChain.tsChainId,
|
|
471
473
|
spokeTokenData.token,
|
|
472
|
-
adapters.adapterId
|
|
474
|
+
adapters.adapterId,
|
|
473
475
|
);
|
|
474
476
|
else
|
|
475
477
|
assertAdapterSupportsDataMessage(tsChain.tsChainId, adapters.adapterId);
|
|
@@ -508,14 +510,14 @@ export const prepare = {
|
|
|
508
510
|
TSCore.getHubProvider(),
|
|
509
511
|
tsChain.network,
|
|
510
512
|
MessageDirection.SpokeToHub,
|
|
511
|
-
messageBuilderParams
|
|
513
|
+
messageBuilderParams,
|
|
512
514
|
);
|
|
513
515
|
feeParams.returnGasLimit = SEND_TOKEN_ACTION_RETURN_GAS_LIMIT;
|
|
514
516
|
|
|
515
517
|
const messageToSend = buildMessageToSend(
|
|
516
518
|
tsChain.chainType,
|
|
517
519
|
messageBuilderParams,
|
|
518
|
-
feeParams
|
|
520
|
+
feeParams,
|
|
519
521
|
);
|
|
520
522
|
|
|
521
523
|
switch (tsChain.chainType) {
|
|
@@ -528,7 +530,7 @@ export const prepare = {
|
|
|
528
530
|
loanId,
|
|
529
531
|
amount,
|
|
530
532
|
spokeChain,
|
|
531
|
-
spokeTokenData
|
|
533
|
+
spokeTokenData,
|
|
532
534
|
);
|
|
533
535
|
default:
|
|
534
536
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -542,7 +544,7 @@ export const prepare = {
|
|
|
542
544
|
amount: bigint,
|
|
543
545
|
isTAmount: boolean,
|
|
544
546
|
receiverTsChainId: TSChainId,
|
|
545
|
-
adapters: MessageAdapters
|
|
547
|
+
adapters: MessageAdapters,
|
|
546
548
|
) {
|
|
547
549
|
const tsChain = TSCore.getSelectedTsChain();
|
|
548
550
|
const network = tsChain.network;
|
|
@@ -552,7 +554,7 @@ export const prepare = {
|
|
|
552
554
|
const receiverSpokeChain = getSpokeChain(receiverTsChainId, network);
|
|
553
555
|
const receiverSpokeTokenData = getSpokeTokenData(
|
|
554
556
|
receiverSpokeChain,
|
|
555
|
-
tsTokenId
|
|
557
|
+
tsTokenId,
|
|
556
558
|
);
|
|
557
559
|
|
|
558
560
|
assertAdapterSupportsDataMessage(tsChain.tsChainId, adapters.adapterId);
|
|
@@ -560,12 +562,12 @@ export const prepare = {
|
|
|
560
562
|
assertAdapterSupportsCrossChainToken(
|
|
561
563
|
receiverTsChainId,
|
|
562
564
|
receiverSpokeTokenData.token,
|
|
563
|
-
adapters.returnAdapterId
|
|
565
|
+
adapters.returnAdapterId,
|
|
564
566
|
);
|
|
565
567
|
else
|
|
566
568
|
assertAdapterSupportsDataMessage(
|
|
567
569
|
receiverTsChainId,
|
|
568
|
-
adapters.returnAdapterId
|
|
570
|
+
adapters.returnAdapterId,
|
|
569
571
|
);
|
|
570
572
|
|
|
571
573
|
assertSpokeChainSupportTsToken(receiverTsChainId, tsTokenId, network);
|
|
@@ -613,7 +615,7 @@ export const prepare = {
|
|
|
613
615
|
TSCore.getEVMProvider(receiverTsChain.tsChainId),
|
|
614
616
|
tsChain.network,
|
|
615
617
|
MessageDirection.HubToSpoke,
|
|
616
|
-
returnMessageBuilderParams
|
|
618
|
+
returnMessageBuilderParams,
|
|
617
619
|
);
|
|
618
620
|
|
|
619
621
|
const data: WithdrawMessageData = {
|
|
@@ -642,7 +644,7 @@ export const prepare = {
|
|
|
642
644
|
amount,
|
|
643
645
|
receiverTsChainId,
|
|
644
646
|
adapters,
|
|
645
|
-
feeParams
|
|
647
|
+
feeParams,
|
|
646
648
|
);
|
|
647
649
|
feeParams.gasLimit = await estimateAdapterReceiveGasLimit(
|
|
648
650
|
tsChain.tsChainId,
|
|
@@ -651,13 +653,13 @@ export const prepare = {
|
|
|
651
653
|
tsChain.network,
|
|
652
654
|
MessageDirection.SpokeToHub,
|
|
653
655
|
messageBuilderParams,
|
|
654
|
-
feeParams.receiverValue
|
|
656
|
+
feeParams.receiverValue,
|
|
655
657
|
);
|
|
656
658
|
|
|
657
659
|
const messageToSend = buildMessageToSend(
|
|
658
660
|
tsChain.chainType,
|
|
659
661
|
messageBuilderParams,
|
|
660
|
-
feeParams
|
|
662
|
+
feeParams,
|
|
661
663
|
);
|
|
662
664
|
|
|
663
665
|
switch (tsChain.chainType) {
|
|
@@ -673,7 +675,7 @@ export const prepare = {
|
|
|
673
675
|
amount,
|
|
674
676
|
isTAmount,
|
|
675
677
|
receiverTsChainId,
|
|
676
|
-
spokeChain
|
|
678
|
+
spokeChain,
|
|
677
679
|
);
|
|
678
680
|
default:
|
|
679
681
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -687,7 +689,7 @@ export const prepare = {
|
|
|
687
689
|
amount: bigint,
|
|
688
690
|
maxStableRate: bigint,
|
|
689
691
|
receiverTsChainId: TSChainId,
|
|
690
|
-
adapters: MessageAdapters
|
|
692
|
+
adapters: MessageAdapters,
|
|
691
693
|
) {
|
|
692
694
|
const tsChain = TSCore.getSelectedTsChain();
|
|
693
695
|
const network = tsChain.network;
|
|
@@ -697,7 +699,7 @@ export const prepare = {
|
|
|
697
699
|
const receiverSpokeChain = getSpokeChain(receiverTsChainId, network);
|
|
698
700
|
const receiverSpokeTokenData = getSpokeTokenData(
|
|
699
701
|
receiverSpokeChain,
|
|
700
|
-
tsTokenId
|
|
702
|
+
tsTokenId,
|
|
701
703
|
);
|
|
702
704
|
|
|
703
705
|
assertAdapterSupportsDataMessage(tsChain.tsChainId, adapters.adapterId);
|
|
@@ -705,12 +707,12 @@ export const prepare = {
|
|
|
705
707
|
assertAdapterSupportsCrossChainToken(
|
|
706
708
|
receiverTsChainId,
|
|
707
709
|
receiverSpokeTokenData.token,
|
|
708
|
-
adapters.returnAdapterId
|
|
710
|
+
adapters.returnAdapterId,
|
|
709
711
|
);
|
|
710
712
|
else
|
|
711
713
|
assertAdapterSupportsDataMessage(
|
|
712
714
|
receiverTsChainId,
|
|
713
|
-
adapters.returnAdapterId
|
|
715
|
+
adapters.returnAdapterId,
|
|
714
716
|
);
|
|
715
717
|
assertSpokeChainSupportTsToken(receiverTsChainId, tsTokenId, network);
|
|
716
718
|
|
|
@@ -757,7 +759,7 @@ export const prepare = {
|
|
|
757
759
|
TSCore.getEVMProvider(receiverTsChain.tsChainId),
|
|
758
760
|
tsChain.network,
|
|
759
761
|
MessageDirection.HubToSpoke,
|
|
760
|
-
returnMessageBuilderParams
|
|
762
|
+
returnMessageBuilderParams,
|
|
761
763
|
);
|
|
762
764
|
|
|
763
765
|
const data: BorrowMessageData = {
|
|
@@ -786,7 +788,7 @@ export const prepare = {
|
|
|
786
788
|
amount,
|
|
787
789
|
receiverTsChainId,
|
|
788
790
|
adapters,
|
|
789
|
-
feeParams
|
|
791
|
+
feeParams,
|
|
790
792
|
);
|
|
791
793
|
feeParams.gasLimit = await estimateAdapterReceiveGasLimit(
|
|
792
794
|
tsChain.tsChainId,
|
|
@@ -795,13 +797,13 @@ export const prepare = {
|
|
|
795
797
|
tsChain.network,
|
|
796
798
|
MessageDirection.SpokeToHub,
|
|
797
799
|
messageBuilderParams,
|
|
798
|
-
feeParams.receiverValue
|
|
800
|
+
feeParams.receiverValue,
|
|
799
801
|
);
|
|
800
802
|
|
|
801
803
|
const messageToSend = buildMessageToSend(
|
|
802
804
|
tsChain.chainType,
|
|
803
805
|
messageBuilderParams,
|
|
804
|
-
feeParams
|
|
806
|
+
feeParams,
|
|
805
807
|
);
|
|
806
808
|
|
|
807
809
|
switch (tsChain.chainType) {
|
|
@@ -817,7 +819,7 @@ export const prepare = {
|
|
|
817
819
|
amount,
|
|
818
820
|
maxStableRate,
|
|
819
821
|
receiverTsChainId,
|
|
820
|
-
spokeChain
|
|
822
|
+
spokeChain,
|
|
821
823
|
);
|
|
822
824
|
default:
|
|
823
825
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -831,14 +833,14 @@ export const prepare = {
|
|
|
831
833
|
tsTokenId: TSTokenId,
|
|
832
834
|
amount: bigint,
|
|
833
835
|
maxOverRepayment: bigint,
|
|
834
|
-
adapters: MessageAdapters
|
|
836
|
+
adapters: MessageAdapters,
|
|
835
837
|
): Promise<PrepareRepayCall> {
|
|
836
838
|
const tsChain = TSCore.getSelectedTsChain();
|
|
837
839
|
|
|
838
840
|
assertSpokeChainSupportTsToken(
|
|
839
841
|
tsChain.tsChainId,
|
|
840
842
|
tsTokenId,
|
|
841
|
-
tsChain.network
|
|
843
|
+
tsChain.network,
|
|
842
844
|
);
|
|
843
845
|
assertLoanTypeSupported(loanTypeId, tsTokenId, tsChain.network);
|
|
844
846
|
const spokeChain = getSpokeChain(tsChain.tsChainId, tsChain.network);
|
|
@@ -851,7 +853,7 @@ export const prepare = {
|
|
|
851
853
|
assertAdapterSupportsCrossChainToken(
|
|
852
854
|
tsChain.tsChainId,
|
|
853
855
|
spokeTokenData.token,
|
|
854
|
-
adapters.adapterId
|
|
856
|
+
adapters.adapterId,
|
|
855
857
|
);
|
|
856
858
|
else
|
|
857
859
|
assertAdapterSupportsDataMessage(tsChain.tsChainId, adapters.adapterId);
|
|
@@ -891,14 +893,14 @@ export const prepare = {
|
|
|
891
893
|
TSCore.getHubProvider(),
|
|
892
894
|
tsChain.network,
|
|
893
895
|
MessageDirection.SpokeToHub,
|
|
894
|
-
messageBuilderParams
|
|
896
|
+
messageBuilderParams,
|
|
895
897
|
);
|
|
896
898
|
feeParams.returnGasLimit = SEND_TOKEN_ACTION_RETURN_GAS_LIMIT;
|
|
897
899
|
|
|
898
900
|
const messageToSend = buildMessageToSend(
|
|
899
901
|
tsChain.chainType,
|
|
900
902
|
messageBuilderParams,
|
|
901
|
-
feeParams
|
|
903
|
+
feeParams,
|
|
902
904
|
);
|
|
903
905
|
|
|
904
906
|
switch (tsChain.chainType) {
|
|
@@ -912,7 +914,7 @@ export const prepare = {
|
|
|
912
914
|
amount,
|
|
913
915
|
maxOverRepayment,
|
|
914
916
|
spokeChain,
|
|
915
|
-
spokeTokenData
|
|
917
|
+
spokeTokenData,
|
|
916
918
|
);
|
|
917
919
|
default:
|
|
918
920
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -926,7 +928,7 @@ export const write = {
|
|
|
926
928
|
nonce: Nonce,
|
|
927
929
|
loanTypeId: LoanTypeId,
|
|
928
930
|
loanName: LoanName,
|
|
929
|
-
prepareCall: PrepareCreateLoanCall
|
|
931
|
+
prepareCall: PrepareCreateLoanCall,
|
|
930
932
|
) {
|
|
931
933
|
const tsChain = TSCore.getSelectedTsChain();
|
|
932
934
|
|
|
@@ -941,7 +943,7 @@ export const write = {
|
|
|
941
943
|
nonce,
|
|
942
944
|
loanTypeId,
|
|
943
945
|
loanName,
|
|
944
|
-
prepareCall
|
|
946
|
+
prepareCall,
|
|
945
947
|
);
|
|
946
948
|
default:
|
|
947
949
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -951,7 +953,7 @@ export const write = {
|
|
|
951
953
|
async deleteLoan(
|
|
952
954
|
accountId: AccountId,
|
|
953
955
|
loanId: LoanId,
|
|
954
|
-
prepareCall: PrepareCreateLoanCall
|
|
956
|
+
prepareCall: PrepareCreateLoanCall,
|
|
955
957
|
) {
|
|
956
958
|
const tsChain = TSCore.getSelectedTsChain();
|
|
957
959
|
|
|
@@ -964,21 +966,21 @@ export const write = {
|
|
|
964
966
|
TSCore.getSigner<ChainType.EVM>(),
|
|
965
967
|
accountId,
|
|
966
968
|
loanId,
|
|
967
|
-
prepareCall
|
|
969
|
+
prepareCall,
|
|
968
970
|
);
|
|
969
971
|
default:
|
|
970
972
|
return exhaustiveCheck(tsChain.chainType);
|
|
971
973
|
}
|
|
972
974
|
},
|
|
973
975
|
|
|
974
|
-
async
|
|
976
|
+
async initiateLoanAccountWithDeposit(
|
|
975
977
|
accountId: AccountId,
|
|
976
978
|
nonce: Nonce,
|
|
977
979
|
loanTypeId: LoanTypeId,
|
|
978
980
|
loanName: LoanName,
|
|
979
981
|
amount: bigint,
|
|
980
982
|
includeApproval: boolean,
|
|
981
|
-
prepareCall: PrepareCreateLoanAndDepositCall
|
|
983
|
+
prepareCall: PrepareCreateLoanAndDepositCall,
|
|
982
984
|
) {
|
|
983
985
|
const tsChain = TSCore.getSelectedTsChain();
|
|
984
986
|
|
|
@@ -995,7 +997,7 @@ export const write = {
|
|
|
995
997
|
loanName,
|
|
996
998
|
amount,
|
|
997
999
|
includeApproval,
|
|
998
|
-
prepareCall
|
|
1000
|
+
prepareCall,
|
|
999
1001
|
);
|
|
1000
1002
|
default:
|
|
1001
1003
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1007,7 +1009,7 @@ export const write = {
|
|
|
1007
1009
|
loanId: LoanId,
|
|
1008
1010
|
amount: bigint,
|
|
1009
1011
|
includeApproval: boolean,
|
|
1010
|
-
prepareCall: PrepareDepositCall
|
|
1012
|
+
prepareCall: PrepareDepositCall,
|
|
1011
1013
|
) {
|
|
1012
1014
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1013
1015
|
|
|
@@ -1022,7 +1024,7 @@ export const write = {
|
|
|
1022
1024
|
loanId,
|
|
1023
1025
|
amount,
|
|
1024
1026
|
includeApproval,
|
|
1025
|
-
prepareCall
|
|
1027
|
+
prepareCall,
|
|
1026
1028
|
);
|
|
1027
1029
|
default:
|
|
1028
1030
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1036,7 +1038,7 @@ export const write = {
|
|
|
1036
1038
|
amount: bigint,
|
|
1037
1039
|
isTAmount: boolean,
|
|
1038
1040
|
receiverTsChainId: TSChainId,
|
|
1039
|
-
prepareCall: PrepareWithdrawCall
|
|
1041
|
+
prepareCall: PrepareWithdrawCall,
|
|
1040
1042
|
) {
|
|
1041
1043
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1042
1044
|
|
|
@@ -1053,7 +1055,7 @@ export const write = {
|
|
|
1053
1055
|
amount,
|
|
1054
1056
|
isTAmount,
|
|
1055
1057
|
receiverTsChainId,
|
|
1056
|
-
prepareCall
|
|
1058
|
+
prepareCall,
|
|
1057
1059
|
);
|
|
1058
1060
|
default:
|
|
1059
1061
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1067,7 +1069,7 @@ export const write = {
|
|
|
1067
1069
|
amount: bigint,
|
|
1068
1070
|
maxStableRate: bigint,
|
|
1069
1071
|
receiverTsChainId: TSChainId,
|
|
1070
|
-
prepareCall: PrepareBorrowCall
|
|
1072
|
+
prepareCall: PrepareBorrowCall,
|
|
1071
1073
|
) {
|
|
1072
1074
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1073
1075
|
|
|
@@ -1084,7 +1086,7 @@ export const write = {
|
|
|
1084
1086
|
amount,
|
|
1085
1087
|
maxStableRate,
|
|
1086
1088
|
receiverTsChainId,
|
|
1087
|
-
prepareCall
|
|
1089
|
+
prepareCall,
|
|
1088
1090
|
);
|
|
1089
1091
|
default:
|
|
1090
1092
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1097,7 +1099,7 @@ export const write = {
|
|
|
1097
1099
|
amount: bigint,
|
|
1098
1100
|
maxOverRepayment: bigint,
|
|
1099
1101
|
includeApproval: boolean,
|
|
1100
|
-
prepareCall: PrepareRepayCall
|
|
1102
|
+
prepareCall: PrepareRepayCall,
|
|
1101
1103
|
) {
|
|
1102
1104
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1103
1105
|
|
|
@@ -1113,7 +1115,7 @@ export const write = {
|
|
|
1113
1115
|
amount,
|
|
1114
1116
|
maxOverRepayment,
|
|
1115
1117
|
includeApproval,
|
|
1116
|
-
prepareCall
|
|
1118
|
+
prepareCall,
|
|
1117
1119
|
);
|
|
1118
1120
|
default:
|
|
1119
1121
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1128,7 +1130,7 @@ export const write = {
|
|
|
1128
1130
|
TSCore.getProvider<ChainType.EVM>(tsChain.tsChainId),
|
|
1129
1131
|
TSCore.getSigner<ChainType.EVM>(),
|
|
1130
1132
|
accountId,
|
|
1131
|
-
prepareCall
|
|
1133
|
+
prepareCall,
|
|
1132
1134
|
);
|
|
1133
1135
|
},
|
|
1134
1136
|
async repayWithCollateral(
|
|
@@ -1136,7 +1138,7 @@ export const write = {
|
|
|
1136
1138
|
loanId: LoanId,
|
|
1137
1139
|
tsTokenId: TSTokenId,
|
|
1138
1140
|
amount: bigint,
|
|
1139
|
-
prepareCall: PrepareRepayWithCollateralCall
|
|
1141
|
+
prepareCall: PrepareRepayWithCollateralCall,
|
|
1140
1142
|
) {
|
|
1141
1143
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1142
1144
|
|
|
@@ -1151,7 +1153,7 @@ export const write = {
|
|
|
1151
1153
|
loanId,
|
|
1152
1154
|
poolId,
|
|
1153
1155
|
amount,
|
|
1154
|
-
prepareCall
|
|
1156
|
+
prepareCall,
|
|
1155
1157
|
);
|
|
1156
1158
|
default:
|
|
1157
1159
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1162,7 +1164,7 @@ export const write = {
|
|
|
1162
1164
|
export const read = {
|
|
1163
1165
|
async rateLimit(
|
|
1164
1166
|
tsTokenId: TSTokenId,
|
|
1165
|
-
tsChainId: TSChainId
|
|
1167
|
+
tsChainId: TSChainId,
|
|
1166
1168
|
): Promise<TokenRateLimit> {
|
|
1167
1169
|
const network = TSCore.getSelectedNetwork();
|
|
1168
1170
|
const tsChain = getTsChain(tsChainId, network);
|
|
@@ -1170,7 +1172,7 @@ export const read = {
|
|
|
1170
1172
|
assertSpokeChainSupportTsToken(
|
|
1171
1173
|
tsChain.tsChainId,
|
|
1172
1174
|
tsTokenId,
|
|
1173
|
-
tsChain.network
|
|
1175
|
+
tsChain.network,
|
|
1174
1176
|
);
|
|
1175
1177
|
const spokeChain = getSpokeChain(tsChain.tsChainId, tsChain.network);
|
|
1176
1178
|
const spokeTokenData = getSpokeTokenData(spokeChain, tsTokenId);
|
|
@@ -1179,7 +1181,7 @@ export const read = {
|
|
|
1179
1181
|
case ChainType.EVM:
|
|
1180
1182
|
return await TSEvmLoan.read.rateLimitInfo(
|
|
1181
1183
|
TSCore.getProvider<ChainType.EVM>(tsChain.tsChainId),
|
|
1182
|
-
spokeTokenData
|
|
1184
|
+
spokeTokenData,
|
|
1183
1185
|
);
|
|
1184
1186
|
default:
|
|
1185
1187
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1191,45 +1193,45 @@ export const read = {
|
|
|
1191
1193
|
|
|
1192
1194
|
// filter for all tokens supported in loan type
|
|
1193
1195
|
const tokensData = Object.values(getHubTokensData(network)).filter(
|
|
1194
|
-
(tokenData) => tokenData.supportedLoanTypes.has(loanTypeId)
|
|
1196
|
+
(tokenData) => tokenData.supportedLoanTypes.has(loanTypeId),
|
|
1195
1197
|
);
|
|
1196
1198
|
|
|
1197
1199
|
return await TsHubLoan.getLoanTypeInfo(
|
|
1198
1200
|
TSCore.getHubProvider(),
|
|
1199
1201
|
network,
|
|
1200
1202
|
loanTypeId,
|
|
1201
|
-
tokensData
|
|
1203
|
+
tokensData,
|
|
1202
1204
|
);
|
|
1203
1205
|
},
|
|
1204
1206
|
|
|
1205
1207
|
async userLoansIds(
|
|
1206
1208
|
accountId: AccountId,
|
|
1207
|
-
loanTypeIdsFilter?: Array<LoanTypeId
|
|
1209
|
+
loanTypeIdsFilter?: Array<LoanTypeId>,
|
|
1208
1210
|
): Promise<Map<LoanTypeId, Array<LoanId>>> {
|
|
1209
1211
|
const network = TSCore.getSelectedNetwork();
|
|
1210
1212
|
return await TsHubLoan.getUserLoanIds(
|
|
1211
1213
|
TSCore.getHubProvider(),
|
|
1212
1214
|
network,
|
|
1213
1215
|
accountId,
|
|
1214
|
-
loanTypeIdsFilter
|
|
1216
|
+
loanTypeIdsFilter,
|
|
1215
1217
|
);
|
|
1216
1218
|
},
|
|
1217
1219
|
|
|
1218
1220
|
async userLoans(
|
|
1219
1221
|
loanIds: Array<LoanId>,
|
|
1220
|
-
throwErrorOnInactiveLoan = true
|
|
1222
|
+
throwErrorOnInactiveLoan = true,
|
|
1221
1223
|
): Promise<Map<LoanId, LoanControllerUserLoan>> {
|
|
1222
1224
|
const network = TSCore.getSelectedNetwork();
|
|
1223
1225
|
return await TsHubLoan.getUserLoans(
|
|
1224
1226
|
TSCore.getHubProvider(),
|
|
1225
1227
|
network,
|
|
1226
1228
|
loanIds,
|
|
1227
|
-
throwErrorOnInactiveLoan
|
|
1229
|
+
throwErrorOnInactiveLoan,
|
|
1228
1230
|
);
|
|
1229
1231
|
},
|
|
1230
1232
|
async getLoanIds(
|
|
1231
1233
|
accountId: AccountId,
|
|
1232
|
-
graphqlEndpoint: string
|
|
1234
|
+
graphqlEndpoint: string,
|
|
1233
1235
|
): Promise<GetUserAccountIdToLoanIdResponse> {
|
|
1234
1236
|
return getUserLoanIds(accountId, graphqlEndpoint);
|
|
1235
1237
|
},
|
|
@@ -1241,7 +1243,7 @@ export const util = {
|
|
|
1241
1243
|
poolsInfo: Partial<Record<TSTokenId, PoolInfo>>,
|
|
1242
1244
|
loanTypesInfo: Partial<Record<LoanTypeId, LoanTypeInfo>>,
|
|
1243
1245
|
oraclePrices: OraclePrices,
|
|
1244
|
-
additionalInterests?: AssetsAdditionalInterest
|
|
1246
|
+
additionalInterests?: AssetsAdditionalInterest,
|
|
1245
1247
|
): Record<LoanId, UserLoanInfo> {
|
|
1246
1248
|
// get info of each user loan
|
|
1247
1249
|
return TsHubLoan.getUserLoansInfo(
|
|
@@ -1249,13 +1251,13 @@ export const util = {
|
|
|
1249
1251
|
poolsInfo,
|
|
1250
1252
|
loanTypesInfo,
|
|
1251
1253
|
oraclePrices,
|
|
1252
|
-
additionalInterests
|
|
1254
|
+
additionalInterests,
|
|
1253
1255
|
);
|
|
1254
1256
|
},
|
|
1255
1257
|
|
|
1256
1258
|
emptyLoanForSimulate(
|
|
1257
1259
|
accountId: AccountId,
|
|
1258
|
-
loanTypeId: LoanTypeId
|
|
1260
|
+
loanTypeId: LoanTypeId,
|
|
1259
1261
|
): LoanControllerUserLoan {
|
|
1260
1262
|
return {
|
|
1261
1263
|
accountId,
|
|
@@ -1269,7 +1271,7 @@ export const util = {
|
|
|
1269
1271
|
|
|
1270
1272
|
simulateLoanChanges(
|
|
1271
1273
|
loan: LoanControllerUserLoan,
|
|
1272
|
-
changes: Array<LoanChange
|
|
1274
|
+
changes: Array<LoanChange>,
|
|
1273
1275
|
): LoanControllerUserLoan {
|
|
1274
1276
|
return TsHubLoan.simulateLoanChanges(loan, changes);
|
|
1275
1277
|
},
|