@townsq/mm-sdk 2.5.0 → 2.8.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 +4 -4
- package/dist/chains/evm/common/constant/tokens.js.map +1 -1
- package/dist/chains/evm/hub/constants/chain.js +16 -13
- package/dist/chains/evm/hub/constants/chain.js.map +1 -1
- package/dist/chains/evm/spoke/modules/ts-evm-loan.d.ts +1 -1
- package/dist/chains/evm/spoke/modules/ts-evm-loan.js +67 -19
- package/dist/chains/evm/spoke/modules/ts-evm-loan.js.map +1 -1
- package/dist/common/constants/chain.js +16 -10
- package/dist/common/constants/chain.js.map +1 -1
- package/dist/common/constants/pool.d.ts +0 -1
- package/dist/common/constants/pool.js +1 -1
- package/dist/common/constants/pool.js.map +1 -1
- package/dist/common/types/token.d.ts +0 -1
- package/dist/common/types/token.js +1 -1
- package/dist/common/types/token.js.map +1 -1
- package/dist/lifeline/modules/ts-loan.js +0 -1
- package/dist/lifeline/modules/ts-loan.js.map +1 -1
- package/package.json +1 -1
- package/src/chains/evm/common/constant/tokens.ts +4 -4
- package/src/chains/evm/hub/constants/chain.ts +16 -16
- package/src/chains/evm/spoke/modules/ts-evm-loan.ts +83 -21
- package/src/common/constants/chain.ts +16 -16
- package/src/common/constants/pool.ts +1 -1
- package/src/common/types/token.ts +1 -1
- package/src/lifeline/modules/ts-loan.ts +83 -84
|
@@ -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,7 +339,7 @@ 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);
|
|
@@ -353,14 +353,14 @@ export const prepare = {
|
|
|
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);
|
|
@@ -407,7 +407,6 @@ export const prepare = {
|
|
|
407
407
|
extraArgs,
|
|
408
408
|
};
|
|
409
409
|
|
|
410
|
-
console.log(messageBuilderParams);
|
|
411
410
|
const feeParams: OptionalFeeParams = {};
|
|
412
411
|
|
|
413
412
|
feeParams.gasLimit = await estimateAdapterReceiveGasLimit(
|
|
@@ -416,14 +415,14 @@ export const prepare = {
|
|
|
416
415
|
TSCore.getHubProvider(),
|
|
417
416
|
tsChain.network,
|
|
418
417
|
MessageDirection.SpokeToHub,
|
|
419
|
-
messageBuilderParams
|
|
418
|
+
messageBuilderParams
|
|
420
419
|
);
|
|
421
420
|
feeParams.returnGasLimit = SEND_TOKEN_ACTION_RETURN_GAS_LIMIT;
|
|
422
421
|
|
|
423
422
|
const messageToSend = buildMessageToSend(
|
|
424
423
|
tsChain.chainType,
|
|
425
424
|
messageBuilderParams,
|
|
426
|
-
feeParams
|
|
425
|
+
feeParams
|
|
427
426
|
);
|
|
428
427
|
|
|
429
428
|
switch (tsChain.chainType) {
|
|
@@ -438,7 +437,7 @@ export const prepare = {
|
|
|
438
437
|
loanName,
|
|
439
438
|
amount,
|
|
440
439
|
spokeChain,
|
|
441
|
-
spokeTokenData
|
|
440
|
+
spokeTokenData
|
|
442
441
|
);
|
|
443
442
|
default:
|
|
444
443
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -451,14 +450,14 @@ export const prepare = {
|
|
|
451
450
|
loanTypeId: LoanTypeId,
|
|
452
451
|
tsTokenId: TSTokenId,
|
|
453
452
|
amount: bigint,
|
|
454
|
-
adapters: MessageAdapters
|
|
453
|
+
adapters: MessageAdapters
|
|
455
454
|
) {
|
|
456
455
|
const tsChain = TSCore.getSelectedTsChain();
|
|
457
456
|
|
|
458
457
|
assertSpokeChainSupportTsToken(
|
|
459
458
|
tsChain.tsChainId,
|
|
460
459
|
tsTokenId,
|
|
461
|
-
tsChain.network
|
|
460
|
+
tsChain.network
|
|
462
461
|
);
|
|
463
462
|
assertLoanTypeSupported(loanTypeId, tsTokenId, tsChain.network);
|
|
464
463
|
const spokeChain = getSpokeChain(tsChain.tsChainId, tsChain.network);
|
|
@@ -471,7 +470,7 @@ export const prepare = {
|
|
|
471
470
|
assertAdapterSupportsCrossChainToken(
|
|
472
471
|
tsChain.tsChainId,
|
|
473
472
|
spokeTokenData.token,
|
|
474
|
-
adapters.adapterId
|
|
473
|
+
adapters.adapterId
|
|
475
474
|
);
|
|
476
475
|
else
|
|
477
476
|
assertAdapterSupportsDataMessage(tsChain.tsChainId, adapters.adapterId);
|
|
@@ -510,14 +509,14 @@ export const prepare = {
|
|
|
510
509
|
TSCore.getHubProvider(),
|
|
511
510
|
tsChain.network,
|
|
512
511
|
MessageDirection.SpokeToHub,
|
|
513
|
-
messageBuilderParams
|
|
512
|
+
messageBuilderParams
|
|
514
513
|
);
|
|
515
514
|
feeParams.returnGasLimit = SEND_TOKEN_ACTION_RETURN_GAS_LIMIT;
|
|
516
515
|
|
|
517
516
|
const messageToSend = buildMessageToSend(
|
|
518
517
|
tsChain.chainType,
|
|
519
518
|
messageBuilderParams,
|
|
520
|
-
feeParams
|
|
519
|
+
feeParams
|
|
521
520
|
);
|
|
522
521
|
|
|
523
522
|
switch (tsChain.chainType) {
|
|
@@ -530,7 +529,7 @@ export const prepare = {
|
|
|
530
529
|
loanId,
|
|
531
530
|
amount,
|
|
532
531
|
spokeChain,
|
|
533
|
-
spokeTokenData
|
|
532
|
+
spokeTokenData
|
|
534
533
|
);
|
|
535
534
|
default:
|
|
536
535
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -544,7 +543,7 @@ export const prepare = {
|
|
|
544
543
|
amount: bigint,
|
|
545
544
|
isTAmount: boolean,
|
|
546
545
|
receiverTsChainId: TSChainId,
|
|
547
|
-
adapters: MessageAdapters
|
|
546
|
+
adapters: MessageAdapters
|
|
548
547
|
) {
|
|
549
548
|
const tsChain = TSCore.getSelectedTsChain();
|
|
550
549
|
const network = tsChain.network;
|
|
@@ -554,7 +553,7 @@ export const prepare = {
|
|
|
554
553
|
const receiverSpokeChain = getSpokeChain(receiverTsChainId, network);
|
|
555
554
|
const receiverSpokeTokenData = getSpokeTokenData(
|
|
556
555
|
receiverSpokeChain,
|
|
557
|
-
tsTokenId
|
|
556
|
+
tsTokenId
|
|
558
557
|
);
|
|
559
558
|
|
|
560
559
|
assertAdapterSupportsDataMessage(tsChain.tsChainId, adapters.adapterId);
|
|
@@ -562,12 +561,12 @@ export const prepare = {
|
|
|
562
561
|
assertAdapterSupportsCrossChainToken(
|
|
563
562
|
receiverTsChainId,
|
|
564
563
|
receiverSpokeTokenData.token,
|
|
565
|
-
adapters.returnAdapterId
|
|
564
|
+
adapters.returnAdapterId
|
|
566
565
|
);
|
|
567
566
|
else
|
|
568
567
|
assertAdapterSupportsDataMessage(
|
|
569
568
|
receiverTsChainId,
|
|
570
|
-
adapters.returnAdapterId
|
|
569
|
+
adapters.returnAdapterId
|
|
571
570
|
);
|
|
572
571
|
|
|
573
572
|
assertSpokeChainSupportTsToken(receiverTsChainId, tsTokenId, network);
|
|
@@ -615,7 +614,7 @@ export const prepare = {
|
|
|
615
614
|
TSCore.getEVMProvider(receiverTsChain.tsChainId),
|
|
616
615
|
tsChain.network,
|
|
617
616
|
MessageDirection.HubToSpoke,
|
|
618
|
-
returnMessageBuilderParams
|
|
617
|
+
returnMessageBuilderParams
|
|
619
618
|
);
|
|
620
619
|
|
|
621
620
|
const data: WithdrawMessageData = {
|
|
@@ -644,7 +643,7 @@ export const prepare = {
|
|
|
644
643
|
amount,
|
|
645
644
|
receiverTsChainId,
|
|
646
645
|
adapters,
|
|
647
|
-
feeParams
|
|
646
|
+
feeParams
|
|
648
647
|
);
|
|
649
648
|
feeParams.gasLimit = await estimateAdapterReceiveGasLimit(
|
|
650
649
|
tsChain.tsChainId,
|
|
@@ -653,13 +652,13 @@ export const prepare = {
|
|
|
653
652
|
tsChain.network,
|
|
654
653
|
MessageDirection.SpokeToHub,
|
|
655
654
|
messageBuilderParams,
|
|
656
|
-
feeParams.receiverValue
|
|
655
|
+
feeParams.receiverValue
|
|
657
656
|
);
|
|
658
657
|
|
|
659
658
|
const messageToSend = buildMessageToSend(
|
|
660
659
|
tsChain.chainType,
|
|
661
660
|
messageBuilderParams,
|
|
662
|
-
feeParams
|
|
661
|
+
feeParams
|
|
663
662
|
);
|
|
664
663
|
|
|
665
664
|
switch (tsChain.chainType) {
|
|
@@ -675,7 +674,7 @@ export const prepare = {
|
|
|
675
674
|
amount,
|
|
676
675
|
isTAmount,
|
|
677
676
|
receiverTsChainId,
|
|
678
|
-
spokeChain
|
|
677
|
+
spokeChain
|
|
679
678
|
);
|
|
680
679
|
default:
|
|
681
680
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -689,7 +688,7 @@ export const prepare = {
|
|
|
689
688
|
amount: bigint,
|
|
690
689
|
maxStableRate: bigint,
|
|
691
690
|
receiverTsChainId: TSChainId,
|
|
692
|
-
adapters: MessageAdapters
|
|
691
|
+
adapters: MessageAdapters
|
|
693
692
|
) {
|
|
694
693
|
const tsChain = TSCore.getSelectedTsChain();
|
|
695
694
|
const network = tsChain.network;
|
|
@@ -699,7 +698,7 @@ export const prepare = {
|
|
|
699
698
|
const receiverSpokeChain = getSpokeChain(receiverTsChainId, network);
|
|
700
699
|
const receiverSpokeTokenData = getSpokeTokenData(
|
|
701
700
|
receiverSpokeChain,
|
|
702
|
-
tsTokenId
|
|
701
|
+
tsTokenId
|
|
703
702
|
);
|
|
704
703
|
|
|
705
704
|
assertAdapterSupportsDataMessage(tsChain.tsChainId, adapters.adapterId);
|
|
@@ -707,12 +706,12 @@ export const prepare = {
|
|
|
707
706
|
assertAdapterSupportsCrossChainToken(
|
|
708
707
|
receiverTsChainId,
|
|
709
708
|
receiverSpokeTokenData.token,
|
|
710
|
-
adapters.returnAdapterId
|
|
709
|
+
adapters.returnAdapterId
|
|
711
710
|
);
|
|
712
711
|
else
|
|
713
712
|
assertAdapterSupportsDataMessage(
|
|
714
713
|
receiverTsChainId,
|
|
715
|
-
adapters.returnAdapterId
|
|
714
|
+
adapters.returnAdapterId
|
|
716
715
|
);
|
|
717
716
|
assertSpokeChainSupportTsToken(receiverTsChainId, tsTokenId, network);
|
|
718
717
|
|
|
@@ -759,7 +758,7 @@ export const prepare = {
|
|
|
759
758
|
TSCore.getEVMProvider(receiverTsChain.tsChainId),
|
|
760
759
|
tsChain.network,
|
|
761
760
|
MessageDirection.HubToSpoke,
|
|
762
|
-
returnMessageBuilderParams
|
|
761
|
+
returnMessageBuilderParams
|
|
763
762
|
);
|
|
764
763
|
|
|
765
764
|
const data: BorrowMessageData = {
|
|
@@ -788,7 +787,7 @@ export const prepare = {
|
|
|
788
787
|
amount,
|
|
789
788
|
receiverTsChainId,
|
|
790
789
|
adapters,
|
|
791
|
-
feeParams
|
|
790
|
+
feeParams
|
|
792
791
|
);
|
|
793
792
|
feeParams.gasLimit = await estimateAdapterReceiveGasLimit(
|
|
794
793
|
tsChain.tsChainId,
|
|
@@ -797,13 +796,13 @@ export const prepare = {
|
|
|
797
796
|
tsChain.network,
|
|
798
797
|
MessageDirection.SpokeToHub,
|
|
799
798
|
messageBuilderParams,
|
|
800
|
-
feeParams.receiverValue
|
|
799
|
+
feeParams.receiverValue
|
|
801
800
|
);
|
|
802
801
|
|
|
803
802
|
const messageToSend = buildMessageToSend(
|
|
804
803
|
tsChain.chainType,
|
|
805
804
|
messageBuilderParams,
|
|
806
|
-
feeParams
|
|
805
|
+
feeParams
|
|
807
806
|
);
|
|
808
807
|
|
|
809
808
|
switch (tsChain.chainType) {
|
|
@@ -819,7 +818,7 @@ export const prepare = {
|
|
|
819
818
|
amount,
|
|
820
819
|
maxStableRate,
|
|
821
820
|
receiverTsChainId,
|
|
822
|
-
spokeChain
|
|
821
|
+
spokeChain
|
|
823
822
|
);
|
|
824
823
|
default:
|
|
825
824
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -833,14 +832,14 @@ export const prepare = {
|
|
|
833
832
|
tsTokenId: TSTokenId,
|
|
834
833
|
amount: bigint,
|
|
835
834
|
maxOverRepayment: bigint,
|
|
836
|
-
adapters: MessageAdapters
|
|
835
|
+
adapters: MessageAdapters
|
|
837
836
|
): Promise<PrepareRepayCall> {
|
|
838
837
|
const tsChain = TSCore.getSelectedTsChain();
|
|
839
838
|
|
|
840
839
|
assertSpokeChainSupportTsToken(
|
|
841
840
|
tsChain.tsChainId,
|
|
842
841
|
tsTokenId,
|
|
843
|
-
tsChain.network
|
|
842
|
+
tsChain.network
|
|
844
843
|
);
|
|
845
844
|
assertLoanTypeSupported(loanTypeId, tsTokenId, tsChain.network);
|
|
846
845
|
const spokeChain = getSpokeChain(tsChain.tsChainId, tsChain.network);
|
|
@@ -853,7 +852,7 @@ export const prepare = {
|
|
|
853
852
|
assertAdapterSupportsCrossChainToken(
|
|
854
853
|
tsChain.tsChainId,
|
|
855
854
|
spokeTokenData.token,
|
|
856
|
-
adapters.adapterId
|
|
855
|
+
adapters.adapterId
|
|
857
856
|
);
|
|
858
857
|
else
|
|
859
858
|
assertAdapterSupportsDataMessage(tsChain.tsChainId, adapters.adapterId);
|
|
@@ -893,14 +892,14 @@ export const prepare = {
|
|
|
893
892
|
TSCore.getHubProvider(),
|
|
894
893
|
tsChain.network,
|
|
895
894
|
MessageDirection.SpokeToHub,
|
|
896
|
-
messageBuilderParams
|
|
895
|
+
messageBuilderParams
|
|
897
896
|
);
|
|
898
897
|
feeParams.returnGasLimit = SEND_TOKEN_ACTION_RETURN_GAS_LIMIT;
|
|
899
898
|
|
|
900
899
|
const messageToSend = buildMessageToSend(
|
|
901
900
|
tsChain.chainType,
|
|
902
901
|
messageBuilderParams,
|
|
903
|
-
feeParams
|
|
902
|
+
feeParams
|
|
904
903
|
);
|
|
905
904
|
|
|
906
905
|
switch (tsChain.chainType) {
|
|
@@ -914,7 +913,7 @@ export const prepare = {
|
|
|
914
913
|
amount,
|
|
915
914
|
maxOverRepayment,
|
|
916
915
|
spokeChain,
|
|
917
|
-
spokeTokenData
|
|
916
|
+
spokeTokenData
|
|
918
917
|
);
|
|
919
918
|
default:
|
|
920
919
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -928,7 +927,7 @@ export const write = {
|
|
|
928
927
|
nonce: Nonce,
|
|
929
928
|
loanTypeId: LoanTypeId,
|
|
930
929
|
loanName: LoanName,
|
|
931
|
-
prepareCall: PrepareCreateLoanCall
|
|
930
|
+
prepareCall: PrepareCreateLoanCall
|
|
932
931
|
) {
|
|
933
932
|
const tsChain = TSCore.getSelectedTsChain();
|
|
934
933
|
|
|
@@ -943,7 +942,7 @@ export const write = {
|
|
|
943
942
|
nonce,
|
|
944
943
|
loanTypeId,
|
|
945
944
|
loanName,
|
|
946
|
-
prepareCall
|
|
945
|
+
prepareCall
|
|
947
946
|
);
|
|
948
947
|
default:
|
|
949
948
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -953,7 +952,7 @@ export const write = {
|
|
|
953
952
|
async deleteLoan(
|
|
954
953
|
accountId: AccountId,
|
|
955
954
|
loanId: LoanId,
|
|
956
|
-
prepareCall: PrepareCreateLoanCall
|
|
955
|
+
prepareCall: PrepareCreateLoanCall
|
|
957
956
|
) {
|
|
958
957
|
const tsChain = TSCore.getSelectedTsChain();
|
|
959
958
|
|
|
@@ -966,7 +965,7 @@ export const write = {
|
|
|
966
965
|
TSCore.getSigner<ChainType.EVM>(),
|
|
967
966
|
accountId,
|
|
968
967
|
loanId,
|
|
969
|
-
prepareCall
|
|
968
|
+
prepareCall
|
|
970
969
|
);
|
|
971
970
|
default:
|
|
972
971
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -980,7 +979,7 @@ export const write = {
|
|
|
980
979
|
loanName: LoanName,
|
|
981
980
|
amount: bigint,
|
|
982
981
|
includeApproval: boolean,
|
|
983
|
-
prepareCall: PrepareCreateLoanAndDepositCall
|
|
982
|
+
prepareCall: PrepareCreateLoanAndDepositCall
|
|
984
983
|
) {
|
|
985
984
|
const tsChain = TSCore.getSelectedTsChain();
|
|
986
985
|
|
|
@@ -997,7 +996,7 @@ export const write = {
|
|
|
997
996
|
loanName,
|
|
998
997
|
amount,
|
|
999
998
|
includeApproval,
|
|
1000
|
-
prepareCall
|
|
999
|
+
prepareCall
|
|
1001
1000
|
);
|
|
1002
1001
|
default:
|
|
1003
1002
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1009,7 +1008,7 @@ export const write = {
|
|
|
1009
1008
|
loanId: LoanId,
|
|
1010
1009
|
amount: bigint,
|
|
1011
1010
|
includeApproval: boolean,
|
|
1012
|
-
prepareCall: PrepareDepositCall
|
|
1011
|
+
prepareCall: PrepareDepositCall
|
|
1013
1012
|
) {
|
|
1014
1013
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1015
1014
|
|
|
@@ -1024,7 +1023,7 @@ export const write = {
|
|
|
1024
1023
|
loanId,
|
|
1025
1024
|
amount,
|
|
1026
1025
|
includeApproval,
|
|
1027
|
-
prepareCall
|
|
1026
|
+
prepareCall
|
|
1028
1027
|
);
|
|
1029
1028
|
default:
|
|
1030
1029
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1038,7 +1037,7 @@ export const write = {
|
|
|
1038
1037
|
amount: bigint,
|
|
1039
1038
|
isTAmount: boolean,
|
|
1040
1039
|
receiverTsChainId: TSChainId,
|
|
1041
|
-
prepareCall: PrepareWithdrawCall
|
|
1040
|
+
prepareCall: PrepareWithdrawCall
|
|
1042
1041
|
) {
|
|
1043
1042
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1044
1043
|
|
|
@@ -1055,7 +1054,7 @@ export const write = {
|
|
|
1055
1054
|
amount,
|
|
1056
1055
|
isTAmount,
|
|
1057
1056
|
receiverTsChainId,
|
|
1058
|
-
prepareCall
|
|
1057
|
+
prepareCall
|
|
1059
1058
|
);
|
|
1060
1059
|
default:
|
|
1061
1060
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1069,7 +1068,7 @@ export const write = {
|
|
|
1069
1068
|
amount: bigint,
|
|
1070
1069
|
maxStableRate: bigint,
|
|
1071
1070
|
receiverTsChainId: TSChainId,
|
|
1072
|
-
prepareCall: PrepareBorrowCall
|
|
1071
|
+
prepareCall: PrepareBorrowCall
|
|
1073
1072
|
) {
|
|
1074
1073
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1075
1074
|
|
|
@@ -1086,7 +1085,7 @@ export const write = {
|
|
|
1086
1085
|
amount,
|
|
1087
1086
|
maxStableRate,
|
|
1088
1087
|
receiverTsChainId,
|
|
1089
|
-
prepareCall
|
|
1088
|
+
prepareCall
|
|
1090
1089
|
);
|
|
1091
1090
|
default:
|
|
1092
1091
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1099,7 +1098,7 @@ export const write = {
|
|
|
1099
1098
|
amount: bigint,
|
|
1100
1099
|
maxOverRepayment: bigint,
|
|
1101
1100
|
includeApproval: boolean,
|
|
1102
|
-
prepareCall: PrepareRepayCall
|
|
1101
|
+
prepareCall: PrepareRepayCall
|
|
1103
1102
|
) {
|
|
1104
1103
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1105
1104
|
|
|
@@ -1115,7 +1114,7 @@ export const write = {
|
|
|
1115
1114
|
amount,
|
|
1116
1115
|
maxOverRepayment,
|
|
1117
1116
|
includeApproval,
|
|
1118
|
-
prepareCall
|
|
1117
|
+
prepareCall
|
|
1119
1118
|
);
|
|
1120
1119
|
default:
|
|
1121
1120
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1130,7 +1129,7 @@ export const write = {
|
|
|
1130
1129
|
TSCore.getProvider<ChainType.EVM>(tsChain.tsChainId),
|
|
1131
1130
|
TSCore.getSigner<ChainType.EVM>(),
|
|
1132
1131
|
accountId,
|
|
1133
|
-
prepareCall
|
|
1132
|
+
prepareCall
|
|
1134
1133
|
);
|
|
1135
1134
|
},
|
|
1136
1135
|
async repayWithCollateral(
|
|
@@ -1138,7 +1137,7 @@ export const write = {
|
|
|
1138
1137
|
loanId: LoanId,
|
|
1139
1138
|
tsTokenId: TSTokenId,
|
|
1140
1139
|
amount: bigint,
|
|
1141
|
-
prepareCall: PrepareRepayWithCollateralCall
|
|
1140
|
+
prepareCall: PrepareRepayWithCollateralCall
|
|
1142
1141
|
) {
|
|
1143
1142
|
const tsChain = TSCore.getSelectedTsChain();
|
|
1144
1143
|
|
|
@@ -1153,7 +1152,7 @@ export const write = {
|
|
|
1153
1152
|
loanId,
|
|
1154
1153
|
poolId,
|
|
1155
1154
|
amount,
|
|
1156
|
-
prepareCall
|
|
1155
|
+
prepareCall
|
|
1157
1156
|
);
|
|
1158
1157
|
default:
|
|
1159
1158
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1164,7 +1163,7 @@ export const write = {
|
|
|
1164
1163
|
export const read = {
|
|
1165
1164
|
async rateLimit(
|
|
1166
1165
|
tsTokenId: TSTokenId,
|
|
1167
|
-
tsChainId: TSChainId
|
|
1166
|
+
tsChainId: TSChainId
|
|
1168
1167
|
): Promise<TokenRateLimit> {
|
|
1169
1168
|
const network = TSCore.getSelectedNetwork();
|
|
1170
1169
|
const tsChain = getTsChain(tsChainId, network);
|
|
@@ -1172,7 +1171,7 @@ export const read = {
|
|
|
1172
1171
|
assertSpokeChainSupportTsToken(
|
|
1173
1172
|
tsChain.tsChainId,
|
|
1174
1173
|
tsTokenId,
|
|
1175
|
-
tsChain.network
|
|
1174
|
+
tsChain.network
|
|
1176
1175
|
);
|
|
1177
1176
|
const spokeChain = getSpokeChain(tsChain.tsChainId, tsChain.network);
|
|
1178
1177
|
const spokeTokenData = getSpokeTokenData(spokeChain, tsTokenId);
|
|
@@ -1181,7 +1180,7 @@ export const read = {
|
|
|
1181
1180
|
case ChainType.EVM:
|
|
1182
1181
|
return await TSEvmLoan.read.rateLimitInfo(
|
|
1183
1182
|
TSCore.getProvider<ChainType.EVM>(tsChain.tsChainId),
|
|
1184
|
-
spokeTokenData
|
|
1183
|
+
spokeTokenData
|
|
1185
1184
|
);
|
|
1186
1185
|
default:
|
|
1187
1186
|
return exhaustiveCheck(tsChain.chainType);
|
|
@@ -1193,45 +1192,45 @@ export const read = {
|
|
|
1193
1192
|
|
|
1194
1193
|
// filter for all tokens supported in loan type
|
|
1195
1194
|
const tokensData = Object.values(getHubTokensData(network)).filter(
|
|
1196
|
-
(tokenData) => tokenData.supportedLoanTypes.has(loanTypeId)
|
|
1195
|
+
(tokenData) => tokenData.supportedLoanTypes.has(loanTypeId)
|
|
1197
1196
|
);
|
|
1198
1197
|
|
|
1199
1198
|
return await TsHubLoan.getLoanTypeInfo(
|
|
1200
1199
|
TSCore.getHubProvider(),
|
|
1201
1200
|
network,
|
|
1202
1201
|
loanTypeId,
|
|
1203
|
-
tokensData
|
|
1202
|
+
tokensData
|
|
1204
1203
|
);
|
|
1205
1204
|
},
|
|
1206
1205
|
|
|
1207
1206
|
async userLoansIds(
|
|
1208
1207
|
accountId: AccountId,
|
|
1209
|
-
loanTypeIdsFilter?: Array<LoanTypeId
|
|
1208
|
+
loanTypeIdsFilter?: Array<LoanTypeId>
|
|
1210
1209
|
): Promise<Map<LoanTypeId, Array<LoanId>>> {
|
|
1211
1210
|
const network = TSCore.getSelectedNetwork();
|
|
1212
1211
|
return await TsHubLoan.getUserLoanIds(
|
|
1213
1212
|
TSCore.getHubProvider(),
|
|
1214
1213
|
network,
|
|
1215
1214
|
accountId,
|
|
1216
|
-
loanTypeIdsFilter
|
|
1215
|
+
loanTypeIdsFilter
|
|
1217
1216
|
);
|
|
1218
1217
|
},
|
|
1219
1218
|
|
|
1220
1219
|
async userLoans(
|
|
1221
1220
|
loanIds: Array<LoanId>,
|
|
1222
|
-
throwErrorOnInactiveLoan = true
|
|
1221
|
+
throwErrorOnInactiveLoan = true
|
|
1223
1222
|
): Promise<Map<LoanId, LoanControllerUserLoan>> {
|
|
1224
1223
|
const network = TSCore.getSelectedNetwork();
|
|
1225
1224
|
return await TsHubLoan.getUserLoans(
|
|
1226
1225
|
TSCore.getHubProvider(),
|
|
1227
1226
|
network,
|
|
1228
1227
|
loanIds,
|
|
1229
|
-
throwErrorOnInactiveLoan
|
|
1228
|
+
throwErrorOnInactiveLoan
|
|
1230
1229
|
);
|
|
1231
1230
|
},
|
|
1232
1231
|
async getLoanIds(
|
|
1233
1232
|
accountId: AccountId,
|
|
1234
|
-
graphqlEndpoint: string
|
|
1233
|
+
graphqlEndpoint: string
|
|
1235
1234
|
): Promise<GetUserAccountIdToLoanIdResponse> {
|
|
1236
1235
|
return getUserLoanIds(accountId, graphqlEndpoint);
|
|
1237
1236
|
},
|
|
@@ -1243,7 +1242,7 @@ export const util = {
|
|
|
1243
1242
|
poolsInfo: Partial<Record<TSTokenId, PoolInfo>>,
|
|
1244
1243
|
loanTypesInfo: Partial<Record<LoanTypeId, LoanTypeInfo>>,
|
|
1245
1244
|
oraclePrices: OraclePrices,
|
|
1246
|
-
additionalInterests?: AssetsAdditionalInterest
|
|
1245
|
+
additionalInterests?: AssetsAdditionalInterest
|
|
1247
1246
|
): Record<LoanId, UserLoanInfo> {
|
|
1248
1247
|
// get info of each user loan
|
|
1249
1248
|
return TsHubLoan.getUserLoansInfo(
|
|
@@ -1251,13 +1250,13 @@ export const util = {
|
|
|
1251
1250
|
poolsInfo,
|
|
1252
1251
|
loanTypesInfo,
|
|
1253
1252
|
oraclePrices,
|
|
1254
|
-
additionalInterests
|
|
1253
|
+
additionalInterests
|
|
1255
1254
|
);
|
|
1256
1255
|
},
|
|
1257
1256
|
|
|
1258
1257
|
emptyLoanForSimulate(
|
|
1259
1258
|
accountId: AccountId,
|
|
1260
|
-
loanTypeId: LoanTypeId
|
|
1259
|
+
loanTypeId: LoanTypeId
|
|
1261
1260
|
): LoanControllerUserLoan {
|
|
1262
1261
|
return {
|
|
1263
1262
|
accountId,
|
|
@@ -1271,7 +1270,7 @@ export const util = {
|
|
|
1271
1270
|
|
|
1272
1271
|
simulateLoanChanges(
|
|
1273
1272
|
loan: LoanControllerUserLoan,
|
|
1274
|
-
changes: Array<LoanChange
|
|
1273
|
+
changes: Array<LoanChange>
|
|
1275
1274
|
): LoanControllerUserLoan {
|
|
1276
1275
|
return TsHubLoan.simulateLoanChanges(loan, changes);
|
|
1277
1276
|
},
|