@jup-ag/lend 0.2.0-beta.2 → 0.2.0-beta.3
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/borrow/index.d.mts +91 -24
- package/dist/borrow/index.d.ts +91 -24
- package/dist/borrow/index.mjs +5 -4
- package/dist/dex/index.mjs +1 -1
- package/dist/earn/index.d.mts +23 -14
- package/dist/earn/index.d.ts +23 -14
- package/dist/earn/index.mjs +48 -2215
- package/dist/flashloan/index.d.mts +0 -1
- package/dist/flashloan/index.d.ts +0 -1
- package/dist/flashloan/index.mjs +6 -111
- package/dist/index.mjs +1 -1
- package/dist/refinance/index.d.mts +1 -2
- package/dist/refinance/index.d.ts +1 -2
- package/dist/refinance/index.mjs +3 -2
- package/dist/shared/lend.B80NmXTG.mjs +2184 -0
- package/dist/shared/{lend.siYu8A-9.mjs → lend.CS-bkwRq.mjs} +30 -8
- package/dist/shared/{lend.DcHJFKzT.mjs → lend.CVtn-ehf.mjs} +235 -449
- package/dist/shared/{lend.BT41yQVJ.d.mts → lend.CdoFqRFx.d.mts} +168 -474
- package/dist/shared/{lend.BT41yQVJ.d.ts → lend.CdoFqRFx.d.ts} +168 -474
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Program, AnchorProvider } from '@coral-xyz/anchor';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
|
-
import { p as getTickHasDebt, e as getPosition, q as getTick, s as getTickIdLiquidation, h as getVaultConfig, r as getBranch, f as getVaultState } from './lend.a53XYkl5.mjs';
|
|
3
|
+
import { p as getTickHasDebt, e as getPosition, q as getTick, s as getTickIdLiquidation, i as getVaultMetadata, h as getVaultConfig, r as getBranch, f as getVaultState } from './lend.a53XYkl5.mjs';
|
|
4
4
|
import { PublicKey, Transaction } from '@solana/web3.js';
|
|
5
5
|
import { e as getReserve } from './lend.C3XdrR6R.mjs';
|
|
6
6
|
|
|
@@ -894,6 +894,26 @@ const errors$1 = [
|
|
|
894
894
|
code: 6044,
|
|
895
895
|
name: "ChainlinkDataStreamsNoFeedKeepers",
|
|
896
896
|
msg: "CHAINLINK_DATA_STREAMS_NO_FEED_KEEPERS"
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
code: 6045,
|
|
900
|
+
name: "PstPoolInvalidState",
|
|
901
|
+
msg: "PST_POOL_INVALID_STATE"
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
code: 6046,
|
|
905
|
+
name: "PstPoolModeStatesEmpty",
|
|
906
|
+
msg: "PST_POOL_MODE_STATES_EMPTY"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
code: 6047,
|
|
910
|
+
name: "PstPoolMintMismatch",
|
|
911
|
+
msg: "PST_POOL_MINT_MISMATCH"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
code: 6048,
|
|
915
|
+
name: "PstPoolMintSupplyZero",
|
|
916
|
+
msg: "PST_POOL_MINT_SUPPLY_ZERO"
|
|
897
917
|
}
|
|
898
918
|
];
|
|
899
919
|
const types$1 = [
|
|
@@ -1287,6 +1307,9 @@ const types$1 = [
|
|
|
1287
1307
|
},
|
|
1288
1308
|
{
|
|
1289
1309
|
name: "ChainlinkDataStreams"
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
name: "PstPool"
|
|
1290
1313
|
}
|
|
1291
1314
|
]
|
|
1292
1315
|
}
|
|
@@ -1431,7 +1454,7 @@ function mulShift64(n0, n1) {
|
|
|
1431
1454
|
}
|
|
1432
1455
|
function getTickAtRatio(ratioX48) {
|
|
1433
1456
|
const MIN_RATIOX48 = new BN(6093);
|
|
1434
|
-
const MAX_RATIOX48 = new BN("
|
|
1457
|
+
const MAX_RATIOX48 = new BN("13002088162051014298412982");
|
|
1435
1458
|
const _1E13 = new BN("10000000000000");
|
|
1436
1459
|
if (ratioX48.lt(MIN_RATIOX48) || ratioX48.gt(MAX_RATIOX48)) {
|
|
1437
1460
|
throw new Error(`Ratio ${ratioX48.toString()} out of bounds`);
|
|
@@ -2554,120 +2577,14 @@ const instructions = [
|
|
|
2554
2577
|
},
|
|
2555
2578
|
{
|
|
2556
2579
|
name: "signer_token_account",
|
|
2557
|
-
writable: true
|
|
2558
|
-
pda: {
|
|
2559
|
-
seeds: [
|
|
2560
|
-
{
|
|
2561
|
-
kind: "account",
|
|
2562
|
-
path: "signer"
|
|
2563
|
-
},
|
|
2564
|
-
{
|
|
2565
|
-
kind: "account",
|
|
2566
|
-
path: "borrow_token_program"
|
|
2567
|
-
},
|
|
2568
|
-
{
|
|
2569
|
-
kind: "account",
|
|
2570
|
-
path: "borrow_token"
|
|
2571
|
-
}
|
|
2572
|
-
],
|
|
2573
|
-
program: {
|
|
2574
|
-
kind: "const",
|
|
2575
|
-
value: [
|
|
2576
|
-
140,
|
|
2577
|
-
151,
|
|
2578
|
-
37,
|
|
2579
|
-
143,
|
|
2580
|
-
78,
|
|
2581
|
-
36,
|
|
2582
|
-
137,
|
|
2583
|
-
241,
|
|
2584
|
-
187,
|
|
2585
|
-
61,
|
|
2586
|
-
16,
|
|
2587
|
-
41,
|
|
2588
|
-
20,
|
|
2589
|
-
142,
|
|
2590
|
-
13,
|
|
2591
|
-
131,
|
|
2592
|
-
11,
|
|
2593
|
-
90,
|
|
2594
|
-
19,
|
|
2595
|
-
153,
|
|
2596
|
-
218,
|
|
2597
|
-
255,
|
|
2598
|
-
16,
|
|
2599
|
-
132,
|
|
2600
|
-
4,
|
|
2601
|
-
142,
|
|
2602
|
-
123,
|
|
2603
|
-
216,
|
|
2604
|
-
219,
|
|
2605
|
-
233,
|
|
2606
|
-
248,
|
|
2607
|
-
89
|
|
2608
|
-
]
|
|
2609
|
-
}
|
|
2610
|
-
}
|
|
2580
|
+
writable: true
|
|
2611
2581
|
},
|
|
2612
2582
|
{
|
|
2613
2583
|
name: "to"
|
|
2614
2584
|
},
|
|
2615
2585
|
{
|
|
2616
2586
|
name: "to_token_account",
|
|
2617
|
-
writable: true
|
|
2618
|
-
pda: {
|
|
2619
|
-
seeds: [
|
|
2620
|
-
{
|
|
2621
|
-
kind: "account",
|
|
2622
|
-
path: "to"
|
|
2623
|
-
},
|
|
2624
|
-
{
|
|
2625
|
-
kind: "account",
|
|
2626
|
-
path: "supply_token_program"
|
|
2627
|
-
},
|
|
2628
|
-
{
|
|
2629
|
-
kind: "account",
|
|
2630
|
-
path: "supply_token"
|
|
2631
|
-
}
|
|
2632
|
-
],
|
|
2633
|
-
program: {
|
|
2634
|
-
kind: "const",
|
|
2635
|
-
value: [
|
|
2636
|
-
140,
|
|
2637
|
-
151,
|
|
2638
|
-
37,
|
|
2639
|
-
143,
|
|
2640
|
-
78,
|
|
2641
|
-
36,
|
|
2642
|
-
137,
|
|
2643
|
-
241,
|
|
2644
|
-
187,
|
|
2645
|
-
61,
|
|
2646
|
-
16,
|
|
2647
|
-
41,
|
|
2648
|
-
20,
|
|
2649
|
-
142,
|
|
2650
|
-
13,
|
|
2651
|
-
131,
|
|
2652
|
-
11,
|
|
2653
|
-
90,
|
|
2654
|
-
19,
|
|
2655
|
-
153,
|
|
2656
|
-
218,
|
|
2657
|
-
255,
|
|
2658
|
-
16,
|
|
2659
|
-
132,
|
|
2660
|
-
4,
|
|
2661
|
-
142,
|
|
2662
|
-
123,
|
|
2663
|
-
216,
|
|
2664
|
-
219,
|
|
2665
|
-
233,
|
|
2666
|
-
248,
|
|
2667
|
-
89
|
|
2668
|
-
]
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2587
|
+
writable: true
|
|
2671
2588
|
},
|
|
2672
2589
|
{
|
|
2673
2590
|
name: "vault_config",
|
|
@@ -2746,6 +2663,7 @@ const instructions = [
|
|
|
2746
2663
|
},
|
|
2747
2664
|
{
|
|
2748
2665
|
name: "associated_token_program",
|
|
2666
|
+
optional: true,
|
|
2749
2667
|
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
2750
2668
|
},
|
|
2751
2669
|
{
|
|
@@ -2801,117 +2719,11 @@ const instructions = [
|
|
|
2801
2719
|
},
|
|
2802
2720
|
{
|
|
2803
2721
|
name: "signer_supply_token_account",
|
|
2804
|
-
writable: true
|
|
2805
|
-
pda: {
|
|
2806
|
-
seeds: [
|
|
2807
|
-
{
|
|
2808
|
-
kind: "account",
|
|
2809
|
-
path: "signer"
|
|
2810
|
-
},
|
|
2811
|
-
{
|
|
2812
|
-
kind: "account",
|
|
2813
|
-
path: "supply_token_program"
|
|
2814
|
-
},
|
|
2815
|
-
{
|
|
2816
|
-
kind: "account",
|
|
2817
|
-
path: "supply_token"
|
|
2818
|
-
}
|
|
2819
|
-
],
|
|
2820
|
-
program: {
|
|
2821
|
-
kind: "const",
|
|
2822
|
-
value: [
|
|
2823
|
-
140,
|
|
2824
|
-
151,
|
|
2825
|
-
37,
|
|
2826
|
-
143,
|
|
2827
|
-
78,
|
|
2828
|
-
36,
|
|
2829
|
-
137,
|
|
2830
|
-
241,
|
|
2831
|
-
187,
|
|
2832
|
-
61,
|
|
2833
|
-
16,
|
|
2834
|
-
41,
|
|
2835
|
-
20,
|
|
2836
|
-
142,
|
|
2837
|
-
13,
|
|
2838
|
-
131,
|
|
2839
|
-
11,
|
|
2840
|
-
90,
|
|
2841
|
-
19,
|
|
2842
|
-
153,
|
|
2843
|
-
218,
|
|
2844
|
-
255,
|
|
2845
|
-
16,
|
|
2846
|
-
132,
|
|
2847
|
-
4,
|
|
2848
|
-
142,
|
|
2849
|
-
123,
|
|
2850
|
-
216,
|
|
2851
|
-
219,
|
|
2852
|
-
233,
|
|
2853
|
-
248,
|
|
2854
|
-
89
|
|
2855
|
-
]
|
|
2856
|
-
}
|
|
2857
|
-
}
|
|
2722
|
+
writable: true
|
|
2858
2723
|
},
|
|
2859
2724
|
{
|
|
2860
2725
|
name: "signer_borrow_token_account",
|
|
2861
|
-
writable: true
|
|
2862
|
-
pda: {
|
|
2863
|
-
seeds: [
|
|
2864
|
-
{
|
|
2865
|
-
kind: "account",
|
|
2866
|
-
path: "signer"
|
|
2867
|
-
},
|
|
2868
|
-
{
|
|
2869
|
-
kind: "account",
|
|
2870
|
-
path: "borrow_token_program"
|
|
2871
|
-
},
|
|
2872
|
-
{
|
|
2873
|
-
kind: "account",
|
|
2874
|
-
path: "borrow_token"
|
|
2875
|
-
}
|
|
2876
|
-
],
|
|
2877
|
-
program: {
|
|
2878
|
-
kind: "const",
|
|
2879
|
-
value: [
|
|
2880
|
-
140,
|
|
2881
|
-
151,
|
|
2882
|
-
37,
|
|
2883
|
-
143,
|
|
2884
|
-
78,
|
|
2885
|
-
36,
|
|
2886
|
-
137,
|
|
2887
|
-
241,
|
|
2888
|
-
187,
|
|
2889
|
-
61,
|
|
2890
|
-
16,
|
|
2891
|
-
41,
|
|
2892
|
-
20,
|
|
2893
|
-
142,
|
|
2894
|
-
13,
|
|
2895
|
-
131,
|
|
2896
|
-
11,
|
|
2897
|
-
90,
|
|
2898
|
-
19,
|
|
2899
|
-
153,
|
|
2900
|
-
218,
|
|
2901
|
-
255,
|
|
2902
|
-
16,
|
|
2903
|
-
132,
|
|
2904
|
-
4,
|
|
2905
|
-
142,
|
|
2906
|
-
123,
|
|
2907
|
-
216,
|
|
2908
|
-
219,
|
|
2909
|
-
233,
|
|
2910
|
-
248,
|
|
2911
|
-
89
|
|
2912
|
-
]
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2726
|
+
writable: true
|
|
2915
2727
|
},
|
|
2916
2728
|
{
|
|
2917
2729
|
name: "recipient",
|
|
@@ -2920,118 +2732,12 @@ const instructions = [
|
|
|
2920
2732
|
{
|
|
2921
2733
|
name: "recipient_borrow_token_account",
|
|
2922
2734
|
writable: true,
|
|
2923
|
-
optional: true
|
|
2924
|
-
pda: {
|
|
2925
|
-
seeds: [
|
|
2926
|
-
{
|
|
2927
|
-
kind: "account",
|
|
2928
|
-
path: "recipient"
|
|
2929
|
-
},
|
|
2930
|
-
{
|
|
2931
|
-
kind: "account",
|
|
2932
|
-
path: "borrow_token_program"
|
|
2933
|
-
},
|
|
2934
|
-
{
|
|
2935
|
-
kind: "account",
|
|
2936
|
-
path: "borrow_token"
|
|
2937
|
-
}
|
|
2938
|
-
],
|
|
2939
|
-
program: {
|
|
2940
|
-
kind: "const",
|
|
2941
|
-
value: [
|
|
2942
|
-
140,
|
|
2943
|
-
151,
|
|
2944
|
-
37,
|
|
2945
|
-
143,
|
|
2946
|
-
78,
|
|
2947
|
-
36,
|
|
2948
|
-
137,
|
|
2949
|
-
241,
|
|
2950
|
-
187,
|
|
2951
|
-
61,
|
|
2952
|
-
16,
|
|
2953
|
-
41,
|
|
2954
|
-
20,
|
|
2955
|
-
142,
|
|
2956
|
-
13,
|
|
2957
|
-
131,
|
|
2958
|
-
11,
|
|
2959
|
-
90,
|
|
2960
|
-
19,
|
|
2961
|
-
153,
|
|
2962
|
-
218,
|
|
2963
|
-
255,
|
|
2964
|
-
16,
|
|
2965
|
-
132,
|
|
2966
|
-
4,
|
|
2967
|
-
142,
|
|
2968
|
-
123,
|
|
2969
|
-
216,
|
|
2970
|
-
219,
|
|
2971
|
-
233,
|
|
2972
|
-
248,
|
|
2973
|
-
89
|
|
2974
|
-
]
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2735
|
+
optional: true
|
|
2977
2736
|
},
|
|
2978
|
-
{
|
|
2979
|
-
name: "recipient_supply_token_account",
|
|
2980
|
-
writable: true,
|
|
2981
|
-
optional: true
|
|
2982
|
-
pda: {
|
|
2983
|
-
seeds: [
|
|
2984
|
-
{
|
|
2985
|
-
kind: "account",
|
|
2986
|
-
path: "recipient"
|
|
2987
|
-
},
|
|
2988
|
-
{
|
|
2989
|
-
kind: "account",
|
|
2990
|
-
path: "supply_token_program"
|
|
2991
|
-
},
|
|
2992
|
-
{
|
|
2993
|
-
kind: "account",
|
|
2994
|
-
path: "supply_token"
|
|
2995
|
-
}
|
|
2996
|
-
],
|
|
2997
|
-
program: {
|
|
2998
|
-
kind: "const",
|
|
2999
|
-
value: [
|
|
3000
|
-
140,
|
|
3001
|
-
151,
|
|
3002
|
-
37,
|
|
3003
|
-
143,
|
|
3004
|
-
78,
|
|
3005
|
-
36,
|
|
3006
|
-
137,
|
|
3007
|
-
241,
|
|
3008
|
-
187,
|
|
3009
|
-
61,
|
|
3010
|
-
16,
|
|
3011
|
-
41,
|
|
3012
|
-
20,
|
|
3013
|
-
142,
|
|
3014
|
-
13,
|
|
3015
|
-
131,
|
|
3016
|
-
11,
|
|
3017
|
-
90,
|
|
3018
|
-
19,
|
|
3019
|
-
153,
|
|
3020
|
-
218,
|
|
3021
|
-
255,
|
|
3022
|
-
16,
|
|
3023
|
-
132,
|
|
3024
|
-
4,
|
|
3025
|
-
142,
|
|
3026
|
-
123,
|
|
3027
|
-
216,
|
|
3028
|
-
219,
|
|
3029
|
-
233,
|
|
3030
|
-
248,
|
|
3031
|
-
89
|
|
3032
|
-
]
|
|
3033
|
-
}
|
|
3034
|
-
}
|
|
2737
|
+
{
|
|
2738
|
+
name: "recipient_supply_token_account",
|
|
2739
|
+
writable: true,
|
|
2740
|
+
optional: true
|
|
3035
2741
|
},
|
|
3036
2742
|
{
|
|
3037
2743
|
name: "vault_config",
|
|
@@ -3142,6 +2848,7 @@ const instructions = [
|
|
|
3142
2848
|
},
|
|
3143
2849
|
{
|
|
3144
2850
|
name: "associated_token_program",
|
|
2851
|
+
optional: true,
|
|
3145
2852
|
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
3146
2853
|
},
|
|
3147
2854
|
{
|
|
@@ -3197,117 +2904,122 @@ const instructions = [
|
|
|
3197
2904
|
},
|
|
3198
2905
|
{
|
|
3199
2906
|
name: "rebalancer_supply_token_account",
|
|
3200
|
-
writable: true
|
|
3201
|
-
pda: {
|
|
3202
|
-
seeds: [
|
|
3203
|
-
{
|
|
3204
|
-
kind: "account",
|
|
3205
|
-
path: "rebalancer"
|
|
3206
|
-
},
|
|
3207
|
-
{
|
|
3208
|
-
kind: "account",
|
|
3209
|
-
path: "supply_token_program"
|
|
3210
|
-
},
|
|
3211
|
-
{
|
|
3212
|
-
kind: "account",
|
|
3213
|
-
path: "supply_token"
|
|
3214
|
-
}
|
|
3215
|
-
],
|
|
3216
|
-
program: {
|
|
3217
|
-
kind: "const",
|
|
3218
|
-
value: [
|
|
3219
|
-
140,
|
|
3220
|
-
151,
|
|
3221
|
-
37,
|
|
3222
|
-
143,
|
|
3223
|
-
78,
|
|
3224
|
-
36,
|
|
3225
|
-
137,
|
|
3226
|
-
241,
|
|
3227
|
-
187,
|
|
3228
|
-
61,
|
|
3229
|
-
16,
|
|
3230
|
-
41,
|
|
3231
|
-
20,
|
|
3232
|
-
142,
|
|
3233
|
-
13,
|
|
3234
|
-
131,
|
|
3235
|
-
11,
|
|
3236
|
-
90,
|
|
3237
|
-
19,
|
|
3238
|
-
153,
|
|
3239
|
-
218,
|
|
3240
|
-
255,
|
|
3241
|
-
16,
|
|
3242
|
-
132,
|
|
3243
|
-
4,
|
|
3244
|
-
142,
|
|
3245
|
-
123,
|
|
3246
|
-
216,
|
|
3247
|
-
219,
|
|
3248
|
-
233,
|
|
3249
|
-
248,
|
|
3250
|
-
89
|
|
3251
|
-
]
|
|
3252
|
-
}
|
|
3253
|
-
}
|
|
2907
|
+
writable: true
|
|
3254
2908
|
},
|
|
3255
2909
|
{
|
|
3256
2910
|
name: "rebalancer_borrow_token_account",
|
|
2911
|
+
writable: true
|
|
2912
|
+
},
|
|
2913
|
+
{
|
|
2914
|
+
name: "vault_config",
|
|
2915
|
+
docs: [
|
|
2916
|
+
"@dev mut because this PDA signs the CPI to liquidity program",
|
|
2917
|
+
"@dev verification inside instruction logic"
|
|
2918
|
+
],
|
|
2919
|
+
writable: true
|
|
2920
|
+
},
|
|
2921
|
+
{
|
|
2922
|
+
name: "vault_state",
|
|
2923
|
+
docs: [
|
|
2924
|
+
"@dev verification inside instruction logic"
|
|
2925
|
+
],
|
|
2926
|
+
writable: true
|
|
2927
|
+
},
|
|
2928
|
+
{
|
|
2929
|
+
name: "supply_token",
|
|
2930
|
+
relations: [
|
|
2931
|
+
"vault_config"
|
|
2932
|
+
]
|
|
2933
|
+
},
|
|
2934
|
+
{
|
|
2935
|
+
name: "borrow_token",
|
|
2936
|
+
relations: [
|
|
2937
|
+
"vault_config"
|
|
2938
|
+
]
|
|
2939
|
+
},
|
|
2940
|
+
{
|
|
2941
|
+
name: "supply_token_reserves_liquidity",
|
|
2942
|
+
writable: true
|
|
2943
|
+
},
|
|
2944
|
+
{
|
|
2945
|
+
name: "borrow_token_reserves_liquidity",
|
|
2946
|
+
writable: true
|
|
2947
|
+
},
|
|
2948
|
+
{
|
|
2949
|
+
name: "vault_supply_position_on_liquidity",
|
|
2950
|
+
writable: true
|
|
2951
|
+
},
|
|
2952
|
+
{
|
|
2953
|
+
name: "vault_borrow_position_on_liquidity",
|
|
2954
|
+
writable: true
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
name: "supply_rate_model"
|
|
2958
|
+
},
|
|
2959
|
+
{
|
|
2960
|
+
name: "borrow_rate_model"
|
|
2961
|
+
},
|
|
2962
|
+
{
|
|
2963
|
+
name: "liquidity"
|
|
2964
|
+
},
|
|
2965
|
+
{
|
|
2966
|
+
name: "liquidity_program"
|
|
2967
|
+
},
|
|
2968
|
+
{
|
|
2969
|
+
name: "vault_supply_token_account",
|
|
2970
|
+
writable: true
|
|
2971
|
+
},
|
|
2972
|
+
{
|
|
2973
|
+
name: "vault_borrow_token_account",
|
|
2974
|
+
writable: true
|
|
2975
|
+
},
|
|
2976
|
+
{
|
|
2977
|
+
name: "system_program",
|
|
2978
|
+
address: "11111111111111111111111111111111"
|
|
2979
|
+
},
|
|
2980
|
+
{
|
|
2981
|
+
name: "supply_token_program"
|
|
2982
|
+
},
|
|
2983
|
+
{
|
|
2984
|
+
name: "borrow_token_program"
|
|
2985
|
+
},
|
|
2986
|
+
{
|
|
2987
|
+
name: "associated_token_program",
|
|
2988
|
+
optional: true,
|
|
2989
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
2990
|
+
}
|
|
2991
|
+
],
|
|
2992
|
+
args: [
|
|
2993
|
+
]
|
|
2994
|
+
},
|
|
2995
|
+
{
|
|
2996
|
+
name: "rebalance_with_amounts",
|
|
2997
|
+
discriminator: [
|
|
2998
|
+
190,
|
|
2999
|
+
33,
|
|
3000
|
+
144,
|
|
3001
|
+
182,
|
|
3002
|
+
86,
|
|
3003
|
+
4,
|
|
3004
|
+
141,
|
|
3005
|
+
73
|
|
3006
|
+
],
|
|
3007
|
+
accounts: [
|
|
3008
|
+
{
|
|
3009
|
+
name: "rebalancer",
|
|
3257
3010
|
writable: true,
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
path: "borrow_token"
|
|
3271
|
-
}
|
|
3272
|
-
],
|
|
3273
|
-
program: {
|
|
3274
|
-
kind: "const",
|
|
3275
|
-
value: [
|
|
3276
|
-
140,
|
|
3277
|
-
151,
|
|
3278
|
-
37,
|
|
3279
|
-
143,
|
|
3280
|
-
78,
|
|
3281
|
-
36,
|
|
3282
|
-
137,
|
|
3283
|
-
241,
|
|
3284
|
-
187,
|
|
3285
|
-
61,
|
|
3286
|
-
16,
|
|
3287
|
-
41,
|
|
3288
|
-
20,
|
|
3289
|
-
142,
|
|
3290
|
-
13,
|
|
3291
|
-
131,
|
|
3292
|
-
11,
|
|
3293
|
-
90,
|
|
3294
|
-
19,
|
|
3295
|
-
153,
|
|
3296
|
-
218,
|
|
3297
|
-
255,
|
|
3298
|
-
16,
|
|
3299
|
-
132,
|
|
3300
|
-
4,
|
|
3301
|
-
142,
|
|
3302
|
-
123,
|
|
3303
|
-
216,
|
|
3304
|
-
219,
|
|
3305
|
-
233,
|
|
3306
|
-
248,
|
|
3307
|
-
89
|
|
3308
|
-
]
|
|
3309
|
-
}
|
|
3310
|
-
}
|
|
3011
|
+
signer: true,
|
|
3012
|
+
relations: [
|
|
3013
|
+
"vault_config"
|
|
3014
|
+
]
|
|
3015
|
+
},
|
|
3016
|
+
{
|
|
3017
|
+
name: "rebalancer_supply_token_account",
|
|
3018
|
+
writable: true
|
|
3019
|
+
},
|
|
3020
|
+
{
|
|
3021
|
+
name: "rebalancer_borrow_token_account",
|
|
3022
|
+
writable: true
|
|
3311
3023
|
},
|
|
3312
3024
|
{
|
|
3313
3025
|
name: "vault_config",
|
|
@@ -3384,10 +3096,23 @@ const instructions = [
|
|
|
3384
3096
|
},
|
|
3385
3097
|
{
|
|
3386
3098
|
name: "associated_token_program",
|
|
3099
|
+
optional: true,
|
|
3387
3100
|
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
3388
3101
|
}
|
|
3389
3102
|
],
|
|
3390
3103
|
args: [
|
|
3104
|
+
{
|
|
3105
|
+
name: "supply_amount",
|
|
3106
|
+
type: {
|
|
3107
|
+
option: "u128"
|
|
3108
|
+
}
|
|
3109
|
+
},
|
|
3110
|
+
{
|
|
3111
|
+
name: "borrow_amount",
|
|
3112
|
+
type: {
|
|
3113
|
+
option: "u128"
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3391
3116
|
]
|
|
3392
3117
|
},
|
|
3393
3118
|
{
|
|
@@ -5820,6 +5545,9 @@ const types = [
|
|
|
5820
5545
|
},
|
|
5821
5546
|
{
|
|
5822
5547
|
name: "ChainlinkDataStreams"
|
|
5548
|
+
},
|
|
5549
|
+
{
|
|
5550
|
+
name: "PstPool"
|
|
5823
5551
|
}
|
|
5824
5552
|
]
|
|
5825
5553
|
}
|
|
@@ -6266,7 +5994,11 @@ const types = [
|
|
|
6266
5994
|
},
|
|
6267
5995
|
{
|
|
6268
5996
|
name: "withdrawal_limit",
|
|
6269
|
-
type: "
|
|
5997
|
+
type: "u64"
|
|
5998
|
+
},
|
|
5999
|
+
{
|
|
6000
|
+
name: "decay_amount",
|
|
6001
|
+
type: "u64"
|
|
6270
6002
|
},
|
|
6271
6003
|
{
|
|
6272
6004
|
name: "last_update",
|
|
@@ -6278,7 +6010,11 @@ const types = [
|
|
|
6278
6010
|
},
|
|
6279
6011
|
{
|
|
6280
6012
|
name: "expand_duration",
|
|
6281
|
-
type: "
|
|
6013
|
+
type: "u32"
|
|
6014
|
+
},
|
|
6015
|
+
{
|
|
6016
|
+
name: "decay_duration",
|
|
6017
|
+
type: "u32"
|
|
6282
6018
|
},
|
|
6283
6019
|
{
|
|
6284
6020
|
name: "base_withdrawal_limit",
|
|
@@ -6538,6 +6274,45 @@ const X30 = new BN(1073741823);
|
|
|
6538
6274
|
const MIN_I128 = new BN("170141183460469231731687303715884105728").neg();
|
|
6539
6275
|
const MAX_REPAY_AMOUNT = MIN_I128;
|
|
6540
6276
|
const MAX_WITHDRAW_AMOUNT = MIN_I128;
|
|
6277
|
+
const MAX_TOKEN_DECIMALS = 9;
|
|
6278
|
+
const LOWER_DECIMALS_OPERATE = 4;
|
|
6279
|
+
const MIN_DEBT = new BN(1e3);
|
|
6280
|
+
const MIN_DEBT_LOWER_DECIMALS = new BN(10);
|
|
6281
|
+
const LIQUIDATED_POSITION_DEBT_MULTIPLIER = new BN(2);
|
|
6282
|
+
function getMinimumDebt(decimals) {
|
|
6283
|
+
if (decimals > MAX_TOKEN_DECIMALS) {
|
|
6284
|
+
throw new Error(`Unsupported token decimals: ${decimals}`);
|
|
6285
|
+
}
|
|
6286
|
+
const base = decimals >= LOWER_DECIMALS_OPERATE ? MIN_DEBT : MIN_DEBT_LOWER_DECIMALS;
|
|
6287
|
+
return base.mul(new BN(10).pow(new BN(MAX_TOKEN_DECIMALS - decimals)));
|
|
6288
|
+
}
|
|
6289
|
+
function reconcileLiquidatedDust({
|
|
6290
|
+
finalTick,
|
|
6291
|
+
finalColRaw,
|
|
6292
|
+
finalDebtRaw,
|
|
6293
|
+
dustDebtRaw,
|
|
6294
|
+
borrowMintDecimals
|
|
6295
|
+
}) {
|
|
6296
|
+
const absorbThreshold = getMinimumDebt(borrowMintDecimals).mul(
|
|
6297
|
+
LIQUIDATED_POSITION_DEBT_MULTIPLIER
|
|
6298
|
+
);
|
|
6299
|
+
if (finalDebtRaw.lt(dustDebtRaw) || finalDebtRaw.lt(absorbThreshold)) {
|
|
6300
|
+
return {
|
|
6301
|
+
tick: MIN_TICK,
|
|
6302
|
+
colRaw: new BN(0),
|
|
6303
|
+
debtRaw: new BN(0),
|
|
6304
|
+
dustDebtRaw: new BN(0),
|
|
6305
|
+
isWiped: true
|
|
6306
|
+
};
|
|
6307
|
+
}
|
|
6308
|
+
return {
|
|
6309
|
+
tick: finalTick,
|
|
6310
|
+
colRaw: finalColRaw,
|
|
6311
|
+
debtRaw: finalDebtRaw,
|
|
6312
|
+
dustDebtRaw,
|
|
6313
|
+
isWiped: false
|
|
6314
|
+
};
|
|
6315
|
+
}
|
|
6541
6316
|
const getAccountOwner = async (account, connection) => {
|
|
6542
6317
|
const info = await connection.getAccountInfo(account);
|
|
6543
6318
|
if (!info)
|
|
@@ -6565,7 +6340,8 @@ const getCurrentPositionState = async ({
|
|
|
6565
6340
|
vaultId,
|
|
6566
6341
|
position,
|
|
6567
6342
|
program,
|
|
6568
|
-
market
|
|
6343
|
+
market,
|
|
6344
|
+
borrowMintDecimals
|
|
6569
6345
|
}) => {
|
|
6570
6346
|
let positionTick = position.tick;
|
|
6571
6347
|
if (positionTick === INIT_TICK) {
|
|
@@ -6650,17 +6426,27 @@ const getCurrentPositionState = async ({
|
|
|
6650
6426
|
initialConnectionFactor: connectionFactor,
|
|
6651
6427
|
initialDebtRaw: debtRaw
|
|
6652
6428
|
});
|
|
6653
|
-
const
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6429
|
+
const borrowDecimals = borrowMintDecimals ?? (await program.account.vaultMetadata.fetch(
|
|
6430
|
+
getVaultMetadata(vaultId, market)
|
|
6431
|
+
)).borrowMintDecimals;
|
|
6432
|
+
const reconciled = reconcileLiquidatedDust({
|
|
6433
|
+
finalTick,
|
|
6434
|
+
finalColRaw,
|
|
6435
|
+
finalDebtRaw,
|
|
6659
6436
|
dustDebtRaw,
|
|
6660
|
-
|
|
6661
|
-
|
|
6437
|
+
borrowMintDecimals: borrowDecimals
|
|
6438
|
+
});
|
|
6439
|
+
const netDebtRaw2 = reconciled.debtRaw.gt(reconciled.dustDebtRaw) ? reconciled.debtRaw.sub(reconciled.dustDebtRaw) : new BN(0);
|
|
6440
|
+
return {
|
|
6441
|
+
tick: reconciled.tick,
|
|
6442
|
+
tickId: reconciled.isWiped ? 0 : position.tickId,
|
|
6443
|
+
colRaw: reconciled.colRaw,
|
|
6444
|
+
debtRaw: reconciled.debtRaw,
|
|
6445
|
+
dustDebtRaw: reconciled.dustDebtRaw,
|
|
6446
|
+
finalAmount: netDebtRaw2.gt(new BN(0)) ? reconciled.colRaw : new BN(0),
|
|
6447
|
+
isSupplyOnlyPosition: reconciled.tick === MIN_TICK,
|
|
6662
6448
|
userLiquidationStatus,
|
|
6663
|
-
postLiquidationBranchId
|
|
6449
|
+
postLiquidationBranchId: reconciled.isWiped ? 0 : postLiquidationBranchId
|
|
6664
6450
|
};
|
|
6665
6451
|
}
|
|
6666
6452
|
}
|
|
@@ -7114,4 +6900,4 @@ const getLiquidityProgramId = (market) => {
|
|
|
7114
6900
|
return market === "ethena" ? new PublicKey("jup6QF1sNDGpkkcu6F4qaFHcRBmnSS1VgyB4uFbBvNS") : new PublicKey("jupeiUmn818Jg1ekPURTpr4mFo29p46vygyykFJ3wZC");
|
|
7115
6901
|
};
|
|
7116
6902
|
|
|
7117
|
-
export {
|
|
6903
|
+
export { readTickHasDebtArray as A, reconcileLiquidatedDust as B, vaultsIdl as C, oracle as D, INIT_TICK as I, MAX_REPAY_AMOUNT as M, TICKS_PER_TICK_HAS_DEBT as T, ZERO_TICK_SCALED_RATIO$1 as Z, MAX_TICK$1 as a, MAX_WITHDRAW_AMOUNT as b, MIN_I128 as c, MIN_TICK$1 as d, TICK_HAS_DEBT_ARRAY_SIZE as e, TICK_HAS_DEBT_CHILDREN_SIZE as f, getVaultsProgram as g, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS as h, TOTAL_INDICES_NEEDED as i, findNextTickWithDebt as j, getAccountOwner as k, getCurrentPosition as l, getCurrentPositionState as m, getFinalPosition as n, getFirstTickForIndex as o, getLiquidityProgramId as p, getMinimumDebt as q, getOracleSources as r, getRatioAtTick as s, getTickAtRatio as t, getTickIndices as u, loadRelevantBranches as v, loadRelevantBranchesForLiquidate as w, loadRelevantTicksHasDebtArrays as x, loadRelevantTicksHasDebtArraysLiquidate as y, readOraclePrice as z };
|