@jup-ag/lend 0.0.14 → 0.0.16
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 +54 -24
- package/dist/borrow/index.d.ts +54 -24
- package/dist/borrow/index.mjs +42 -28
- package/dist/index.mjs +1 -1
- package/dist/shared/{lend.gEWT9qRO.mjs → lend.DfnSwnoV.mjs} +57 -27
- package/package.json +1 -1
package/dist/borrow/index.d.mts
CHANGED
|
@@ -695,9 +695,6 @@ type Vaults = {
|
|
|
695
695
|
};
|
|
696
696
|
};
|
|
697
697
|
},
|
|
698
|
-
{
|
|
699
|
-
name: "vaultAdmin";
|
|
700
|
-
},
|
|
701
698
|
{
|
|
702
699
|
name: "vaultConfig";
|
|
703
700
|
docs: [
|
|
@@ -721,10 +718,6 @@ type Vaults = {
|
|
|
721
718
|
{
|
|
722
719
|
name: "oracle";
|
|
723
720
|
},
|
|
724
|
-
{
|
|
725
|
-
name: "topTick";
|
|
726
|
-
writable: true;
|
|
727
|
-
},
|
|
728
721
|
{
|
|
729
722
|
name: "newBranch";
|
|
730
723
|
writable: true;
|
|
@@ -756,6 +749,7 @@ type Vaults = {
|
|
|
756
749
|
{
|
|
757
750
|
name: "supplyTokenClaimAccount";
|
|
758
751
|
writable: true;
|
|
752
|
+
optional: true;
|
|
759
753
|
},
|
|
760
754
|
{
|
|
761
755
|
name: "liquidity";
|
|
@@ -804,6 +798,16 @@ type Vaults = {
|
|
|
804
798
|
name: "absorb";
|
|
805
799
|
type: "bool";
|
|
806
800
|
},
|
|
801
|
+
{
|
|
802
|
+
name: "transferType";
|
|
803
|
+
type: {
|
|
804
|
+
option: {
|
|
805
|
+
defined: {
|
|
806
|
+
name: "transferType";
|
|
807
|
+
};
|
|
808
|
+
};
|
|
809
|
+
};
|
|
810
|
+
},
|
|
807
811
|
{
|
|
808
812
|
name: "remainingAccountsIndices";
|
|
809
813
|
type: "bytes";
|
|
@@ -1135,10 +1139,12 @@ type Vaults = {
|
|
|
1135
1139
|
{
|
|
1136
1140
|
name: "supplyTokenClaimAccount";
|
|
1137
1141
|
writable: true;
|
|
1142
|
+
optional: true;
|
|
1138
1143
|
},
|
|
1139
1144
|
{
|
|
1140
1145
|
name: "borrowTokenClaimAccount";
|
|
1141
1146
|
writable: true;
|
|
1147
|
+
optional: true;
|
|
1142
1148
|
},
|
|
1143
1149
|
{
|
|
1144
1150
|
name: "liquidity";
|
|
@@ -1175,6 +1181,16 @@ type Vaults = {
|
|
|
1175
1181
|
name: "newDebt";
|
|
1176
1182
|
type: "i128";
|
|
1177
1183
|
},
|
|
1184
|
+
{
|
|
1185
|
+
name: "transferType";
|
|
1186
|
+
type: {
|
|
1187
|
+
option: {
|
|
1188
|
+
defined: {
|
|
1189
|
+
name: "transferType";
|
|
1190
|
+
};
|
|
1191
|
+
};
|
|
1192
|
+
};
|
|
1193
|
+
},
|
|
1178
1194
|
{
|
|
1179
1195
|
name: "remainingAccountsIndices";
|
|
1180
1196
|
type: "bytes";
|
|
@@ -2270,51 +2286,56 @@ type Vaults = {
|
|
|
2270
2286
|
},
|
|
2271
2287
|
{
|
|
2272
2288
|
code: 6056;
|
|
2289
|
+
name: "vaultClaimAccountRequired";
|
|
2290
|
+
msg: "vaultClaimAccountRequired";
|
|
2291
|
+
},
|
|
2292
|
+
{
|
|
2293
|
+
code: 6057;
|
|
2273
2294
|
name: "vaultAdminValueAboveLimit";
|
|
2274
2295
|
msg: "vaultAdminValueAboveLimit";
|
|
2275
2296
|
},
|
|
2276
2297
|
{
|
|
2277
|
-
code:
|
|
2298
|
+
code: 6058;
|
|
2278
2299
|
name: "vaultAdminOnlyAuths";
|
|
2279
2300
|
msg: "vaultAdminOnlyAuthAccounts";
|
|
2280
2301
|
},
|
|
2281
2302
|
{
|
|
2282
|
-
code:
|
|
2303
|
+
code: 6059;
|
|
2283
2304
|
name: "vaultAdminAddressZeroNotAllowed";
|
|
2284
2305
|
msg: "vaultAdminAddressZeroNotAllowed";
|
|
2285
2306
|
},
|
|
2286
2307
|
{
|
|
2287
|
-
code:
|
|
2308
|
+
code: 6060;
|
|
2288
2309
|
name: "vaultAdminVaultIdMismatch";
|
|
2289
2310
|
msg: "vaultAdminVaultIdMismatch";
|
|
2290
2311
|
},
|
|
2291
2312
|
{
|
|
2292
|
-
code:
|
|
2313
|
+
code: 6061;
|
|
2293
2314
|
name: "vaultAdminTotalIdsMismatch";
|
|
2294
2315
|
msg: "vaultAdminTotalIdsMismatch";
|
|
2295
2316
|
},
|
|
2296
2317
|
{
|
|
2297
|
-
code:
|
|
2318
|
+
code: 6062;
|
|
2298
2319
|
name: "vaultAdminTickMismatch";
|
|
2299
2320
|
msg: "vaultAdminTickMismatch";
|
|
2300
2321
|
},
|
|
2301
2322
|
{
|
|
2302
|
-
code:
|
|
2323
|
+
code: 6063;
|
|
2303
2324
|
name: "vaultAdminLiquidityProgramMismatch";
|
|
2304
2325
|
msg: "vaultAdminLiquidityProgramMismatch";
|
|
2305
2326
|
},
|
|
2306
2327
|
{
|
|
2307
|
-
code:
|
|
2328
|
+
code: 6064;
|
|
2308
2329
|
name: "vaultAdminMaxAuthCountReached";
|
|
2309
2330
|
msg: "vaultAdminMaxAuthCountReached";
|
|
2310
2331
|
},
|
|
2311
2332
|
{
|
|
2312
|
-
code:
|
|
2333
|
+
code: 6065;
|
|
2313
2334
|
name: "vaultAdminInvalidParams";
|
|
2314
2335
|
msg: "vaultAdminInvalidParams";
|
|
2315
2336
|
},
|
|
2316
2337
|
{
|
|
2317
|
-
code:
|
|
2338
|
+
code: 6066;
|
|
2318
2339
|
name: "vaultAdminOnlyAuthority";
|
|
2319
2340
|
msg: "vaultAdminOnlyAuthority";
|
|
2320
2341
|
}
|
|
@@ -2884,10 +2905,6 @@ type Vaults = {
|
|
|
2884
2905
|
{
|
|
2885
2906
|
name: "dustDebtAmount";
|
|
2886
2907
|
type: "u64";
|
|
2887
|
-
},
|
|
2888
|
-
{
|
|
2889
|
-
name: "bump";
|
|
2890
|
-
type: "u8";
|
|
2891
2908
|
}
|
|
2892
2909
|
];
|
|
2893
2910
|
};
|
|
@@ -2977,10 +2994,6 @@ type Vaults = {
|
|
|
2977
2994
|
{
|
|
2978
2995
|
name: "debtFactor";
|
|
2979
2996
|
type: "u64";
|
|
2980
|
-
},
|
|
2981
|
-
{
|
|
2982
|
-
name: "bump";
|
|
2983
|
-
type: "u8";
|
|
2984
2997
|
}
|
|
2985
2998
|
];
|
|
2986
2999
|
};
|
|
@@ -3192,6 +3205,23 @@ type Vaults = {
|
|
|
3192
3205
|
];
|
|
3193
3206
|
};
|
|
3194
3207
|
},
|
|
3208
|
+
{
|
|
3209
|
+
name: "transferType";
|
|
3210
|
+
type: {
|
|
3211
|
+
kind: "enum";
|
|
3212
|
+
variants: [
|
|
3213
|
+
{
|
|
3214
|
+
name: "skip";
|
|
3215
|
+
},
|
|
3216
|
+
{
|
|
3217
|
+
name: "direct";
|
|
3218
|
+
},
|
|
3219
|
+
{
|
|
3220
|
+
name: "claim";
|
|
3221
|
+
}
|
|
3222
|
+
];
|
|
3223
|
+
};
|
|
3224
|
+
},
|
|
3195
3225
|
{
|
|
3196
3226
|
name: "updateCoreSettingsParams";
|
|
3197
3227
|
type: {
|
package/dist/borrow/index.d.ts
CHANGED
|
@@ -695,9 +695,6 @@ type Vaults = {
|
|
|
695
695
|
};
|
|
696
696
|
};
|
|
697
697
|
},
|
|
698
|
-
{
|
|
699
|
-
name: "vaultAdmin";
|
|
700
|
-
},
|
|
701
698
|
{
|
|
702
699
|
name: "vaultConfig";
|
|
703
700
|
docs: [
|
|
@@ -721,10 +718,6 @@ type Vaults = {
|
|
|
721
718
|
{
|
|
722
719
|
name: "oracle";
|
|
723
720
|
},
|
|
724
|
-
{
|
|
725
|
-
name: "topTick";
|
|
726
|
-
writable: true;
|
|
727
|
-
},
|
|
728
721
|
{
|
|
729
722
|
name: "newBranch";
|
|
730
723
|
writable: true;
|
|
@@ -756,6 +749,7 @@ type Vaults = {
|
|
|
756
749
|
{
|
|
757
750
|
name: "supplyTokenClaimAccount";
|
|
758
751
|
writable: true;
|
|
752
|
+
optional: true;
|
|
759
753
|
},
|
|
760
754
|
{
|
|
761
755
|
name: "liquidity";
|
|
@@ -804,6 +798,16 @@ type Vaults = {
|
|
|
804
798
|
name: "absorb";
|
|
805
799
|
type: "bool";
|
|
806
800
|
},
|
|
801
|
+
{
|
|
802
|
+
name: "transferType";
|
|
803
|
+
type: {
|
|
804
|
+
option: {
|
|
805
|
+
defined: {
|
|
806
|
+
name: "transferType";
|
|
807
|
+
};
|
|
808
|
+
};
|
|
809
|
+
};
|
|
810
|
+
},
|
|
807
811
|
{
|
|
808
812
|
name: "remainingAccountsIndices";
|
|
809
813
|
type: "bytes";
|
|
@@ -1135,10 +1139,12 @@ type Vaults = {
|
|
|
1135
1139
|
{
|
|
1136
1140
|
name: "supplyTokenClaimAccount";
|
|
1137
1141
|
writable: true;
|
|
1142
|
+
optional: true;
|
|
1138
1143
|
},
|
|
1139
1144
|
{
|
|
1140
1145
|
name: "borrowTokenClaimAccount";
|
|
1141
1146
|
writable: true;
|
|
1147
|
+
optional: true;
|
|
1142
1148
|
},
|
|
1143
1149
|
{
|
|
1144
1150
|
name: "liquidity";
|
|
@@ -1175,6 +1181,16 @@ type Vaults = {
|
|
|
1175
1181
|
name: "newDebt";
|
|
1176
1182
|
type: "i128";
|
|
1177
1183
|
},
|
|
1184
|
+
{
|
|
1185
|
+
name: "transferType";
|
|
1186
|
+
type: {
|
|
1187
|
+
option: {
|
|
1188
|
+
defined: {
|
|
1189
|
+
name: "transferType";
|
|
1190
|
+
};
|
|
1191
|
+
};
|
|
1192
|
+
};
|
|
1193
|
+
},
|
|
1178
1194
|
{
|
|
1179
1195
|
name: "remainingAccountsIndices";
|
|
1180
1196
|
type: "bytes";
|
|
@@ -2270,51 +2286,56 @@ type Vaults = {
|
|
|
2270
2286
|
},
|
|
2271
2287
|
{
|
|
2272
2288
|
code: 6056;
|
|
2289
|
+
name: "vaultClaimAccountRequired";
|
|
2290
|
+
msg: "vaultClaimAccountRequired";
|
|
2291
|
+
},
|
|
2292
|
+
{
|
|
2293
|
+
code: 6057;
|
|
2273
2294
|
name: "vaultAdminValueAboveLimit";
|
|
2274
2295
|
msg: "vaultAdminValueAboveLimit";
|
|
2275
2296
|
},
|
|
2276
2297
|
{
|
|
2277
|
-
code:
|
|
2298
|
+
code: 6058;
|
|
2278
2299
|
name: "vaultAdminOnlyAuths";
|
|
2279
2300
|
msg: "vaultAdminOnlyAuthAccounts";
|
|
2280
2301
|
},
|
|
2281
2302
|
{
|
|
2282
|
-
code:
|
|
2303
|
+
code: 6059;
|
|
2283
2304
|
name: "vaultAdminAddressZeroNotAllowed";
|
|
2284
2305
|
msg: "vaultAdminAddressZeroNotAllowed";
|
|
2285
2306
|
},
|
|
2286
2307
|
{
|
|
2287
|
-
code:
|
|
2308
|
+
code: 6060;
|
|
2288
2309
|
name: "vaultAdminVaultIdMismatch";
|
|
2289
2310
|
msg: "vaultAdminVaultIdMismatch";
|
|
2290
2311
|
},
|
|
2291
2312
|
{
|
|
2292
|
-
code:
|
|
2313
|
+
code: 6061;
|
|
2293
2314
|
name: "vaultAdminTotalIdsMismatch";
|
|
2294
2315
|
msg: "vaultAdminTotalIdsMismatch";
|
|
2295
2316
|
},
|
|
2296
2317
|
{
|
|
2297
|
-
code:
|
|
2318
|
+
code: 6062;
|
|
2298
2319
|
name: "vaultAdminTickMismatch";
|
|
2299
2320
|
msg: "vaultAdminTickMismatch";
|
|
2300
2321
|
},
|
|
2301
2322
|
{
|
|
2302
|
-
code:
|
|
2323
|
+
code: 6063;
|
|
2303
2324
|
name: "vaultAdminLiquidityProgramMismatch";
|
|
2304
2325
|
msg: "vaultAdminLiquidityProgramMismatch";
|
|
2305
2326
|
},
|
|
2306
2327
|
{
|
|
2307
|
-
code:
|
|
2328
|
+
code: 6064;
|
|
2308
2329
|
name: "vaultAdminMaxAuthCountReached";
|
|
2309
2330
|
msg: "vaultAdminMaxAuthCountReached";
|
|
2310
2331
|
},
|
|
2311
2332
|
{
|
|
2312
|
-
code:
|
|
2333
|
+
code: 6065;
|
|
2313
2334
|
name: "vaultAdminInvalidParams";
|
|
2314
2335
|
msg: "vaultAdminInvalidParams";
|
|
2315
2336
|
},
|
|
2316
2337
|
{
|
|
2317
|
-
code:
|
|
2338
|
+
code: 6066;
|
|
2318
2339
|
name: "vaultAdminOnlyAuthority";
|
|
2319
2340
|
msg: "vaultAdminOnlyAuthority";
|
|
2320
2341
|
}
|
|
@@ -2884,10 +2905,6 @@ type Vaults = {
|
|
|
2884
2905
|
{
|
|
2885
2906
|
name: "dustDebtAmount";
|
|
2886
2907
|
type: "u64";
|
|
2887
|
-
},
|
|
2888
|
-
{
|
|
2889
|
-
name: "bump";
|
|
2890
|
-
type: "u8";
|
|
2891
2908
|
}
|
|
2892
2909
|
];
|
|
2893
2910
|
};
|
|
@@ -2977,10 +2994,6 @@ type Vaults = {
|
|
|
2977
2994
|
{
|
|
2978
2995
|
name: "debtFactor";
|
|
2979
2996
|
type: "u64";
|
|
2980
|
-
},
|
|
2981
|
-
{
|
|
2982
|
-
name: "bump";
|
|
2983
|
-
type: "u8";
|
|
2984
2997
|
}
|
|
2985
2998
|
];
|
|
2986
2999
|
};
|
|
@@ -3192,6 +3205,23 @@ type Vaults = {
|
|
|
3192
3205
|
];
|
|
3193
3206
|
};
|
|
3194
3207
|
},
|
|
3208
|
+
{
|
|
3209
|
+
name: "transferType";
|
|
3210
|
+
type: {
|
|
3211
|
+
kind: "enum";
|
|
3212
|
+
variants: [
|
|
3213
|
+
{
|
|
3214
|
+
name: "skip";
|
|
3215
|
+
},
|
|
3216
|
+
{
|
|
3217
|
+
name: "direct";
|
|
3218
|
+
},
|
|
3219
|
+
{
|
|
3220
|
+
name: "claim";
|
|
3221
|
+
}
|
|
3222
|
+
];
|
|
3223
|
+
};
|
|
3224
|
+
},
|
|
3195
3225
|
{
|
|
3196
3226
|
name: "updateCoreSettingsParams";
|
|
3197
3227
|
type: {
|
package/dist/borrow/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PublicKey, SystemProgram } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
3
|
import { Program } from '@coral-xyz/anchor';
|
|
4
|
-
import { g as getTick, a as getTickIdLiquidation, c as getVaultState, d as getVaultConfig, e as getBranch, f as getTickHasDebt, h as getVaultMetadata, i as getPosition, j as getLiquidity, k as getClaimAccount, l as getRateModel, m as getUserBorrowPosition, n as getUserSupplyPosition, o as getLiquidityReserve, p as getPositionTokenAccount, q as getPositionMint, r as getVaultAdmin, v as vaults } from '../shared/lend.
|
|
4
|
+
import { g as getTick, a as getTickIdLiquidation, c as getVaultState, d as getVaultConfig, e as getBranch, f as getTickHasDebt, h as getVaultMetadata, i as getPosition, j as getLiquidity, k as getClaimAccount, l as getRateModel, m as getUserBorrowPosition, n as getUserSupplyPosition, o as getLiquidityReserve, p as getPositionTokenAccount, q as getPositionMint, r as getVaultAdmin, v as vaults } from '../shared/lend.DfnSwnoV.mjs';
|
|
5
5
|
import { l as liquidity } from '../shared/lend.D5fnz2Fg.mjs';
|
|
6
6
|
import { getMint, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
7
7
|
|
|
@@ -475,12 +475,12 @@ const oracle = {
|
|
|
475
475
|
types: types
|
|
476
476
|
};
|
|
477
477
|
|
|
478
|
-
const MIN_TICK$
|
|
478
|
+
const MIN_TICK$1 = -16383;
|
|
479
479
|
const MAX_TICK$1 = 16383;
|
|
480
480
|
const ZERO_TICK_SCALED_RATIO$1 = new BN(281474976710656);
|
|
481
481
|
function getRatioAtTick(tick) {
|
|
482
|
-
if (tick < MIN_TICK$
|
|
483
|
-
throw new Error(`Tick ${tick} out of range [${MIN_TICK$
|
|
482
|
+
if (tick < MIN_TICK$1 || tick > MAX_TICK$1) {
|
|
483
|
+
throw new Error(`Tick ${tick} out of range [${MIN_TICK$1}, ${MAX_TICK$1}]`);
|
|
484
484
|
}
|
|
485
485
|
const FACTOR00 = new BN("18446744073709551616");
|
|
486
486
|
const FACTOR01 = new BN("18419115400608638658");
|
|
@@ -669,7 +669,7 @@ function mulBigNumber(bigNumber1, bigNumber2) {
|
|
|
669
669
|
}
|
|
670
670
|
|
|
671
671
|
const INIT_TICK = -2147483648;
|
|
672
|
-
const MIN_TICK
|
|
672
|
+
const MIN_TICK = -16383;
|
|
673
673
|
const MAX_TICK = 16383;
|
|
674
674
|
const MAX_MASK_DEBT_FACTOR = new BN("1125899906842623");
|
|
675
675
|
const EXCHANGE_PRICES_PRECISION = new BN(10).pow(new BN(12));
|
|
@@ -684,11 +684,11 @@ const getCurrentPositionState = async ({
|
|
|
684
684
|
}) => {
|
|
685
685
|
let positionTick = position.tick;
|
|
686
686
|
if (positionTick === INIT_TICK) {
|
|
687
|
-
positionTick = MIN_TICK
|
|
687
|
+
positionTick = MIN_TICK;
|
|
688
688
|
}
|
|
689
689
|
if (position.isSupplyOnlyPosition) {
|
|
690
690
|
return {
|
|
691
|
-
tick: MIN_TICK
|
|
691
|
+
tick: MIN_TICK,
|
|
692
692
|
tickId: 0,
|
|
693
693
|
colRaw: new BN(position.supplyAmount.toString()),
|
|
694
694
|
finalAmount: new BN(position.supplyAmount.toString()),
|
|
@@ -700,14 +700,14 @@ const getCurrentPositionState = async ({
|
|
|
700
700
|
let colRaw = new BN(position.supplyAmount.toString());
|
|
701
701
|
let dustDebtRaw = new BN(position.dustDebtAmount.toString());
|
|
702
702
|
let debtRaw = new BN(0);
|
|
703
|
-
if (positionTick > MIN_TICK
|
|
703
|
+
if (positionTick > MIN_TICK) {
|
|
704
704
|
const collateralForDebtCalc = colRaw.add(new BN(1));
|
|
705
705
|
const ratio = getRatioAtTick(positionTick);
|
|
706
706
|
debtRaw = ratio.mul(collateralForDebtCalc).shrn(48).add(new BN(1));
|
|
707
707
|
} else {
|
|
708
708
|
debtRaw = new BN(0);
|
|
709
709
|
}
|
|
710
|
-
if (positionTick > MIN_TICK
|
|
710
|
+
if (positionTick > MIN_TICK) {
|
|
711
711
|
const tickData = await program.account.tick.fetch(
|
|
712
712
|
getTick(vaultId, positionTick)
|
|
713
713
|
);
|
|
@@ -719,7 +719,7 @@ const getCurrentPositionState = async ({
|
|
|
719
719
|
const { isFullyLiquidated, branchId, connectionFactor } = getLiquidationStatus(position.tickId, tickData, tickIdData);
|
|
720
720
|
if (isFullyLiquidated) {
|
|
721
721
|
return {
|
|
722
|
-
tick: MIN_TICK
|
|
722
|
+
tick: MIN_TICK,
|
|
723
723
|
tickId: 0,
|
|
724
724
|
colRaw: new BN(0),
|
|
725
725
|
debtRaw: new BN(0),
|
|
@@ -742,7 +742,7 @@ const getCurrentPositionState = async ({
|
|
|
742
742
|
debtRaw: finalDebtRaw,
|
|
743
743
|
dustDebtRaw,
|
|
744
744
|
finalAmount: netDebtRaw2.gt(new BN(0)) ? finalColRaw : new BN(0),
|
|
745
|
-
isSupplyOnlyPosition: finalTick === MIN_TICK
|
|
745
|
+
isSupplyOnlyPosition: finalTick === MIN_TICK
|
|
746
746
|
};
|
|
747
747
|
}
|
|
748
748
|
}
|
|
@@ -754,7 +754,7 @@ const getCurrentPositionState = async ({
|
|
|
754
754
|
debtRaw,
|
|
755
755
|
dustDebtRaw,
|
|
756
756
|
finalAmount: netDebtRaw.gt(new BN(0)) ? colRaw : new BN(0),
|
|
757
|
-
isSupplyOnlyPosition: positionTick === MIN_TICK
|
|
757
|
+
isSupplyOnlyPosition: positionTick === MIN_TICK
|
|
758
758
|
};
|
|
759
759
|
};
|
|
760
760
|
async function getAllBranches({
|
|
@@ -841,7 +841,7 @@ async function processLiquidatedPosition({
|
|
|
841
841
|
let positionDebtRaw = new BN(0);
|
|
842
842
|
if (currentBranch.status === 3 || currentConnectionFactor.eq(MAX_MASK_DEBT_FACTOR)) {
|
|
843
843
|
positionDebtRaw = new BN(0);
|
|
844
|
-
finalTick = MIN_TICK
|
|
844
|
+
finalTick = MIN_TICK;
|
|
845
845
|
} else {
|
|
846
846
|
positionDebtRaw = mulDivNormal(
|
|
847
847
|
initialDebtRaw,
|
|
@@ -862,7 +862,7 @@ async function processLiquidatedPosition({
|
|
|
862
862
|
ratioLength.mul(new BN(currentBranch.minimaTickPartials)).div(X30)
|
|
863
863
|
);
|
|
864
864
|
finalColRaw = positionDebtRaw.mul(ZERO_TICK_SCALED_RATIO).div(finalRatio);
|
|
865
|
-
} else finalTick = MIN_TICK
|
|
865
|
+
} else finalTick = MIN_TICK;
|
|
866
866
|
}
|
|
867
867
|
return {
|
|
868
868
|
finalTick,
|
|
@@ -920,7 +920,7 @@ const calculateFinalPosition = async ({
|
|
|
920
920
|
let finalTick;
|
|
921
921
|
let isSupplyOnlyPosition;
|
|
922
922
|
if (netDebtRaw.eq(new BN(0)) || colRaw.eq(new BN(0))) {
|
|
923
|
-
finalTick = MIN_TICK
|
|
923
|
+
finalTick = MIN_TICK;
|
|
924
924
|
isSupplyOnlyPosition = true;
|
|
925
925
|
} else {
|
|
926
926
|
const marginAdjustedDebt = netDebtRaw.mul(new BN(1000000001)).div(new BN(1e9)).add(new BN(1));
|
|
@@ -930,8 +930,8 @@ const calculateFinalPosition = async ({
|
|
|
930
930
|
finalTick = baseTickAtRatio + 1;
|
|
931
931
|
const ratioNew = ratioAtTick.mul(TICK_SPACING).div(new BN(1e4));
|
|
932
932
|
ratioNew.mul(colRaw).shrn(48);
|
|
933
|
-
if (finalTick < MIN_TICK
|
|
934
|
-
finalTick = MIN_TICK
|
|
933
|
+
if (finalTick < MIN_TICK) {
|
|
934
|
+
finalTick = MIN_TICK;
|
|
935
935
|
} else if (finalTick > MAX_TICK) {
|
|
936
936
|
finalTick = MAX_TICK;
|
|
937
937
|
}
|
|
@@ -1007,7 +1007,7 @@ async function loadRelevantBranches(vaultId, vaultState, program) {
|
|
|
1007
1007
|
branches.push({
|
|
1008
1008
|
branchId: 1,
|
|
1009
1009
|
status: 0,
|
|
1010
|
-
minimaTick: MIN_TICK
|
|
1010
|
+
minimaTick: MIN_TICK,
|
|
1011
1011
|
minimaTickPartials: 0,
|
|
1012
1012
|
debtLiquidity: 0,
|
|
1013
1013
|
debtFactor: 0,
|
|
@@ -1030,15 +1030,13 @@ async function loadRelevantTicksHasDebtArrays(vaultId, program) {
|
|
|
1030
1030
|
}
|
|
1031
1031
|
|
|
1032
1032
|
const MIN_I128 = new BN("170141183460469231731687303715884105728").neg();
|
|
1033
|
-
const MIN_TICK = -16383;
|
|
1034
1033
|
async function getOtherInstructionsOperate(vaultId, vaultState, currentPosition, finalPosition, currentTick, program, signer) {
|
|
1035
1034
|
const otherIxs = [];
|
|
1036
1035
|
const tickToRead = [currentTick];
|
|
1037
1036
|
let currentTickData;
|
|
1038
1037
|
let finalTickData;
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
tickToRead.push(finalPosition.tick);
|
|
1038
|
+
tickToRead.push(currentPosition.tick);
|
|
1039
|
+
tickToRead.push(finalPosition.tick);
|
|
1042
1040
|
if (tickToRead.length > 0) {
|
|
1043
1041
|
const tickData = await program.account.tick.fetchMultiple(
|
|
1044
1042
|
tickToRead.map((tick) => getTick(vaultId, tick))
|
|
@@ -1082,11 +1080,22 @@ async function getOtherInstructionsOperate(vaultId, vaultState, currentPosition,
|
|
|
1082
1080
|
finalPosition.tick,
|
|
1083
1081
|
finalTickData ? finalTickData.totalIds : 0
|
|
1084
1082
|
);
|
|
1085
|
-
if (finalPosition.tick !== currentTick
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1083
|
+
if (finalPosition.tick !== currentTick)
|
|
1084
|
+
if (finalTickData) {
|
|
1085
|
+
tickIdsToRead.push({
|
|
1086
|
+
tick: finalPosition.tick,
|
|
1087
|
+
totalIds: finalTickData.totalIds
|
|
1088
|
+
});
|
|
1089
|
+
} else {
|
|
1090
|
+
const context = await getInitTickIdLiquidationContext(
|
|
1091
|
+
vaultId,
|
|
1092
|
+
finalPosition.tick,
|
|
1093
|
+
signer,
|
|
1094
|
+
program
|
|
1095
|
+
);
|
|
1096
|
+
const ix = await program.methods.initTickIdLiquidation(vaultId, finalPosition.tick, 0).accounts(context).instruction();
|
|
1097
|
+
otherIxs.push(ix);
|
|
1098
|
+
}
|
|
1090
1099
|
const tickIdData = await program.account.tickIdLiquidation.fetchMultiple(
|
|
1091
1100
|
tickIdsToRead.map(
|
|
1092
1101
|
({ tick, totalIds }) => getTickIdLiquidation(vaultId, tick, totalIds)
|
|
@@ -1373,7 +1382,12 @@ const getOperateIx = async ({
|
|
|
1373
1382
|
program
|
|
1374
1383
|
});
|
|
1375
1384
|
const [operateIx, addressLookupTable] = await Promise.all([
|
|
1376
|
-
program.methods.operate(
|
|
1385
|
+
program.methods.operate(
|
|
1386
|
+
colAmount,
|
|
1387
|
+
debtAmount,
|
|
1388
|
+
{ direct: {} },
|
|
1389
|
+
Buffer.from(remainingAccountsIndices)
|
|
1390
|
+
).accounts(accounts).remainingAccounts(remainingAccounts).instruction(),
|
|
1377
1391
|
connection.getAddressLookupTable(lookupTable)
|
|
1378
1392
|
]);
|
|
1379
1393
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { l as lendingPda, b as lendingRewardRateModelPda, a as liquidityPda } from './shared/lend.Cbyx-MDB.mjs';
|
|
2
|
-
export { b as borrowPda } from './shared/lend.
|
|
2
|
+
export { b as borrowPda } from './shared/lend.DfnSwnoV.mjs';
|
|
3
3
|
import '@solana/web3.js';
|
|
4
4
|
import './shared/lend.D5fnz2Fg.mjs';
|
|
5
5
|
import '@solana/spl-token';
|
|
@@ -827,9 +827,6 @@ const instructions = [
|
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
829
|
},
|
|
830
|
-
{
|
|
831
|
-
name: "vault_admin"
|
|
832
|
-
},
|
|
833
830
|
{
|
|
834
831
|
name: "vault_config",
|
|
835
832
|
docs: [
|
|
@@ -853,10 +850,6 @@ const instructions = [
|
|
|
853
850
|
{
|
|
854
851
|
name: "oracle"
|
|
855
852
|
},
|
|
856
|
-
{
|
|
857
|
-
name: "top_tick",
|
|
858
|
-
writable: true
|
|
859
|
-
},
|
|
860
853
|
{
|
|
861
854
|
name: "new_branch",
|
|
862
855
|
writable: true
|
|
@@ -887,7 +880,8 @@ const instructions = [
|
|
|
887
880
|
},
|
|
888
881
|
{
|
|
889
882
|
name: "supply_token_claim_account",
|
|
890
|
-
writable: true
|
|
883
|
+
writable: true,
|
|
884
|
+
optional: true
|
|
891
885
|
},
|
|
892
886
|
{
|
|
893
887
|
name: "liquidity",
|
|
@@ -936,6 +930,16 @@ const instructions = [
|
|
|
936
930
|
name: "absorb",
|
|
937
931
|
type: "bool"
|
|
938
932
|
},
|
|
933
|
+
{
|
|
934
|
+
name: "transfer_type",
|
|
935
|
+
type: {
|
|
936
|
+
option: {
|
|
937
|
+
defined: {
|
|
938
|
+
name: "TransferType"
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
},
|
|
939
943
|
{
|
|
940
944
|
name: "remaining_accounts_indices",
|
|
941
945
|
type: "bytes"
|
|
@@ -1279,11 +1283,13 @@ const instructions = [
|
|
|
1279
1283
|
},
|
|
1280
1284
|
{
|
|
1281
1285
|
name: "supply_token_claim_account",
|
|
1282
|
-
writable: true
|
|
1286
|
+
writable: true,
|
|
1287
|
+
optional: true
|
|
1283
1288
|
},
|
|
1284
1289
|
{
|
|
1285
1290
|
name: "borrow_token_claim_account",
|
|
1286
|
-
writable: true
|
|
1291
|
+
writable: true,
|
|
1292
|
+
optional: true
|
|
1287
1293
|
},
|
|
1288
1294
|
{
|
|
1289
1295
|
name: "liquidity",
|
|
@@ -1320,6 +1326,16 @@ const instructions = [
|
|
|
1320
1326
|
name: "new_debt",
|
|
1321
1327
|
type: "i128"
|
|
1322
1328
|
},
|
|
1329
|
+
{
|
|
1330
|
+
name: "transfer_type",
|
|
1331
|
+
type: {
|
|
1332
|
+
option: {
|
|
1333
|
+
defined: {
|
|
1334
|
+
name: "TransferType"
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
},
|
|
1323
1339
|
{
|
|
1324
1340
|
name: "remaining_accounts_indices",
|
|
1325
1341
|
type: "bytes"
|
|
@@ -2944,51 +2960,56 @@ const errors = [
|
|
|
2944
2960
|
},
|
|
2945
2961
|
{
|
|
2946
2962
|
code: 6056,
|
|
2963
|
+
name: "VaultClaimAccountRequired",
|
|
2964
|
+
msg: "VAULT_CLAIM_ACCOUNT_REQUIRED"
|
|
2965
|
+
},
|
|
2966
|
+
{
|
|
2967
|
+
code: 6057,
|
|
2947
2968
|
name: "VaultAdminValueAboveLimit",
|
|
2948
2969
|
msg: "VAULT_ADMIN_VALUE_ABOVE_LIMIT"
|
|
2949
2970
|
},
|
|
2950
2971
|
{
|
|
2951
|
-
code:
|
|
2972
|
+
code: 6058,
|
|
2952
2973
|
name: "VaultAdminOnlyAuths",
|
|
2953
2974
|
msg: "VAULT_ADMIN_ONLY_AUTH_ACCOUNTS"
|
|
2954
2975
|
},
|
|
2955
2976
|
{
|
|
2956
|
-
code:
|
|
2977
|
+
code: 6059,
|
|
2957
2978
|
name: "VaultAdminAddressZeroNotAllowed",
|
|
2958
2979
|
msg: "VAULT_ADMIN_ADDRESS_ZERO_NOT_ALLOWED"
|
|
2959
2980
|
},
|
|
2960
2981
|
{
|
|
2961
|
-
code:
|
|
2982
|
+
code: 6060,
|
|
2962
2983
|
name: "VaultAdminVaultIdMismatch",
|
|
2963
2984
|
msg: "VAULT_ADMIN_VAULT_ID_MISMATCH"
|
|
2964
2985
|
},
|
|
2965
2986
|
{
|
|
2966
|
-
code:
|
|
2987
|
+
code: 6061,
|
|
2967
2988
|
name: "VaultAdminTotalIdsMismatch",
|
|
2968
2989
|
msg: "VAULT_ADMIN_TOTAL_IDS_MISMATCH"
|
|
2969
2990
|
},
|
|
2970
2991
|
{
|
|
2971
|
-
code:
|
|
2992
|
+
code: 6062,
|
|
2972
2993
|
name: "VaultAdminTickMismatch",
|
|
2973
2994
|
msg: "VAULT_ADMIN_TICK_MISMATCH"
|
|
2974
2995
|
},
|
|
2975
2996
|
{
|
|
2976
|
-
code:
|
|
2997
|
+
code: 6063,
|
|
2977
2998
|
name: "VaultAdminLiquidityProgramMismatch",
|
|
2978
2999
|
msg: "VAULT_ADMIN_LIQUIDITY_PROGRAM_MISMATCH"
|
|
2979
3000
|
},
|
|
2980
3001
|
{
|
|
2981
|
-
code:
|
|
3002
|
+
code: 6064,
|
|
2982
3003
|
name: "VaultAdminMaxAuthCountReached",
|
|
2983
3004
|
msg: "VAULT_ADMIN_MAX_AUTH_COUNT_REACHED"
|
|
2984
3005
|
},
|
|
2985
3006
|
{
|
|
2986
|
-
code:
|
|
3007
|
+
code: 6065,
|
|
2987
3008
|
name: "VaultAdminInvalidParams",
|
|
2988
3009
|
msg: "VAULT_ADMIN_INVALID_PARAMS"
|
|
2989
3010
|
},
|
|
2990
3011
|
{
|
|
2991
|
-
code:
|
|
3012
|
+
code: 6066,
|
|
2992
3013
|
name: "VaultAdminOnlyAuthority",
|
|
2993
3014
|
msg: "VAULT_ADMIN_ONLY_AUTHORITY"
|
|
2994
3015
|
}
|
|
@@ -3562,10 +3583,6 @@ const types = [
|
|
|
3562
3583
|
{
|
|
3563
3584
|
name: "dust_debt_amount",
|
|
3564
3585
|
type: "u64"
|
|
3565
|
-
},
|
|
3566
|
-
{
|
|
3567
|
-
name: "bump",
|
|
3568
|
-
type: "u8"
|
|
3569
3586
|
}
|
|
3570
3587
|
]
|
|
3571
3588
|
}
|
|
@@ -3657,10 +3674,6 @@ const types = [
|
|
|
3657
3674
|
{
|
|
3658
3675
|
name: "debt_factor",
|
|
3659
3676
|
type: "u64"
|
|
3660
|
-
},
|
|
3661
|
-
{
|
|
3662
|
-
name: "bump",
|
|
3663
|
-
type: "u8"
|
|
3664
3677
|
}
|
|
3665
3678
|
]
|
|
3666
3679
|
}
|
|
@@ -3879,6 +3892,23 @@ const types = [
|
|
|
3879
3892
|
]
|
|
3880
3893
|
}
|
|
3881
3894
|
},
|
|
3895
|
+
{
|
|
3896
|
+
name: "TransferType",
|
|
3897
|
+
type: {
|
|
3898
|
+
kind: "enum",
|
|
3899
|
+
variants: [
|
|
3900
|
+
{
|
|
3901
|
+
name: "SKIP"
|
|
3902
|
+
},
|
|
3903
|
+
{
|
|
3904
|
+
name: "DIRECT"
|
|
3905
|
+
},
|
|
3906
|
+
{
|
|
3907
|
+
name: "CLAIM"
|
|
3908
|
+
}
|
|
3909
|
+
]
|
|
3910
|
+
}
|
|
3911
|
+
},
|
|
3882
3912
|
{
|
|
3883
3913
|
name: "UpdateCoreSettingsParams",
|
|
3884
3914
|
type: {
|