@0dotxyz/p0-ts-sdk 3.0.0-next.0 → 3.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +64 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -3
- package/dist/index.d.ts +52 -3
- package/dist/index.js +62 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -95,6 +95,7 @@ var FLASHLOAN_ENABLED_FLAG = 1 << 2;
|
|
|
95
95
|
var TRANSFER_ACCOUNT_AUTHORITY_FLAG = 1 << 3;
|
|
96
96
|
var STAKED_ORACLE_DISABLED_FLAG = 1 << 9;
|
|
97
97
|
var STAKED_ORACLE_USES_ONRAMP_FLAG = 1 << 10;
|
|
98
|
+
var CIRCUIT_BREAKER_ENABLED_FLAG = 1 << 11;
|
|
98
99
|
var PREMIUM_ACTIVE_FLAG = 1 << 13;
|
|
99
100
|
var KAMINO_MARKET_EMERGENCY_FLAG = 1 << 14;
|
|
100
101
|
var MAX_COSTLY_POSITIONS = 4;
|
|
@@ -11062,6 +11063,11 @@ function toBankDto(bank) {
|
|
|
11062
11063
|
premiumActive: bank.premiumActive,
|
|
11063
11064
|
premiumActivatedAt: bank.premiumActivatedAt,
|
|
11064
11065
|
kaminoEmergency: bank.kaminoEmergency,
|
|
11066
|
+
liquidationLiquidatorFee: bank.liquidationLiquidatorFee,
|
|
11067
|
+
liquidationInsuranceFee: bank.liquidationInsuranceFee,
|
|
11068
|
+
isCircuitBreakerEnabled: bank.isCircuitBreakerEnabled,
|
|
11069
|
+
cbTier: bank.cbTier,
|
|
11070
|
+
cbHaltEndedAt: bank.cbHaltEndedAt,
|
|
11065
11071
|
rateLimiter: bank.rateLimiter ? toBankRateLimiterDto(bank.rateLimiter) : void 0,
|
|
11066
11072
|
tokenSymbol: bank.tokenSymbol,
|
|
11067
11073
|
feesDestinationAccount: bank.feesDestinationAccount,
|
|
@@ -11123,7 +11129,10 @@ function toBankConfigDto(bankConfig) {
|
|
|
11123
11129
|
configFlags: bankConfig.configFlags,
|
|
11124
11130
|
oracleMaxConfidence: bankConfig.oracleMaxConfidence,
|
|
11125
11131
|
fixedPrice: bankConfig.fixedPrice.toString(),
|
|
11126
|
-
scopeEntryIndex: bankConfig.scopeEntryIndex
|
|
11132
|
+
scopeEntryIndex: bankConfig.scopeEntryIndex,
|
|
11133
|
+
cbWindowMaxUpBps: bankConfig.cbWindowMaxUpBps,
|
|
11134
|
+
cbWindowMaxDownBps: bankConfig.cbWindowMaxDownBps,
|
|
11135
|
+
cbWindowSeconds: bankConfig.cbWindowSeconds
|
|
11127
11136
|
};
|
|
11128
11137
|
}
|
|
11129
11138
|
function toInterestRateConfigDto(interestRateConfig) {
|
|
@@ -11397,6 +11406,11 @@ function parseBankRaw(address23, accountParsed, bankMetadata) {
|
|
|
11397
11406
|
premiumActive,
|
|
11398
11407
|
premiumActivatedAt: Number(accountParsed.premiumActivatedAt),
|
|
11399
11408
|
kaminoEmergency: (flags & KAMINO_MARKET_EMERGENCY_FLAG) > 0,
|
|
11409
|
+
liquidationLiquidatorFee: accountParsed.liquidationLiquidatorFee,
|
|
11410
|
+
liquidationInsuranceFee: accountParsed.liquidationInsuranceFee,
|
|
11411
|
+
isCircuitBreakerEnabled: (flags & CIRCUIT_BREAKER_ENABLED_FLAG) > 0,
|
|
11412
|
+
cbTier: accountParsed.cbTier,
|
|
11413
|
+
cbHaltEndedAt: Number(accountParsed.cbHaltEndedAt),
|
|
11400
11414
|
rateLimiter,
|
|
11401
11415
|
tokenSymbol,
|
|
11402
11416
|
kaminoIntegrationAccounts,
|
|
@@ -11443,6 +11457,11 @@ function dtoToBank(bankDto) {
|
|
|
11443
11457
|
premiumActive: bankDto.premiumActive ?? false,
|
|
11444
11458
|
premiumActivatedAt: bankDto.premiumActivatedAt ?? 0,
|
|
11445
11459
|
kaminoEmergency: bankDto.kaminoEmergency ?? false,
|
|
11460
|
+
liquidationLiquidatorFee: bankDto.liquidationLiquidatorFee ?? 0,
|
|
11461
|
+
liquidationInsuranceFee: bankDto.liquidationInsuranceFee ?? 0,
|
|
11462
|
+
isCircuitBreakerEnabled: bankDto.isCircuitBreakerEnabled ?? false,
|
|
11463
|
+
cbTier: bankDto.cbTier ?? 0,
|
|
11464
|
+
cbHaltEndedAt: bankDto.cbHaltEndedAt ?? 0,
|
|
11446
11465
|
rateLimiter: bankDto.rateLimiter ? dtoToBankRateLimiter(bankDto.rateLimiter) : void 0,
|
|
11447
11466
|
tokenSymbol: bankDto.tokenSymbol,
|
|
11448
11467
|
feesDestinationAccount: bankDto.feesDestinationAccount ? kit.address(bankDto.feesDestinationAccount) : void 0,
|
|
@@ -11520,7 +11539,10 @@ function dtoToBankConfig(bankConfigDto) {
|
|
|
11520
11539
|
interestRateConfig: dtoToInterestRateConfig(bankConfigDto.interestRateConfig),
|
|
11521
11540
|
oracleMaxConfidence: bankConfigDto.oracleMaxConfidence,
|
|
11522
11541
|
fixedPrice: new bignumber_js.BigNumber(bankConfigDto.fixedPrice),
|
|
11523
|
-
scopeEntryIndex: bankConfigDto.scopeEntryIndex
|
|
11542
|
+
scopeEntryIndex: bankConfigDto.scopeEntryIndex,
|
|
11543
|
+
cbWindowMaxUpBps: bankConfigDto.cbWindowMaxUpBps ?? 0,
|
|
11544
|
+
cbWindowMaxDownBps: bankConfigDto.cbWindowMaxDownBps ?? 0,
|
|
11545
|
+
cbWindowSeconds: bankConfigDto.cbWindowSeconds ?? 0
|
|
11524
11546
|
};
|
|
11525
11547
|
}
|
|
11526
11548
|
function dtoToInterestRateConfig(interestRateConfigDto) {
|
|
@@ -11602,7 +11624,10 @@ function parseBankConfigRaw(bankConfigRaw) {
|
|
|
11602
11624
|
interestRateConfig,
|
|
11603
11625
|
oracleMaxConfidence,
|
|
11604
11626
|
fixedPrice,
|
|
11605
|
-
scopeEntryIndex
|
|
11627
|
+
scopeEntryIndex,
|
|
11628
|
+
cbWindowMaxUpBps: bankConfigRaw.cbWindowMaxUpBps,
|
|
11629
|
+
cbWindowMaxDownBps: bankConfigRaw.cbWindowMaxDownBps,
|
|
11630
|
+
cbWindowSeconds: bankConfigRaw.cbWindowSeconds
|
|
11606
11631
|
};
|
|
11607
11632
|
}
|
|
11608
11633
|
function parseRiskTier(riskTierRaw) {
|
|
@@ -15461,6 +15486,15 @@ function getLiabilityWeight(config, marginRequirementType) {
|
|
|
15461
15486
|
throw new Error("Invalid margin requirement type");
|
|
15462
15487
|
}
|
|
15463
15488
|
}
|
|
15489
|
+
var DEFAULT_LIQUIDATION_FEE = new bignumber_js.BigNumber(0.025);
|
|
15490
|
+
var U32_MAX2 = 4294967295;
|
|
15491
|
+
function getBankLiquidationFees(bank) {
|
|
15492
|
+
const toFraction = (fee) => fee === 0 ? DEFAULT_LIQUIDATION_FEE : new bignumber_js.BigNumber(fee).div(U32_MAX2);
|
|
15493
|
+
return {
|
|
15494
|
+
liquidatorFee: toFraction(bank.liquidationLiquidatorFee),
|
|
15495
|
+
insuranceFee: toFraction(bank.liquidationInsuranceFee)
|
|
15496
|
+
};
|
|
15497
|
+
}
|
|
15464
15498
|
function computeUsdValue(params) {
|
|
15465
15499
|
const {
|
|
15466
15500
|
bank,
|
|
@@ -15585,9 +15619,9 @@ function computeInterestRates(bank) {
|
|
|
15585
15619
|
const borrowingRate = baseInterestRate.times(new bignumber_js.BigNumber(1).plus(rateFee)).plus(fixedFee);
|
|
15586
15620
|
return { lendingRate, borrowingRate };
|
|
15587
15621
|
}
|
|
15588
|
-
var
|
|
15622
|
+
var U32_MAX3 = 4294967295;
|
|
15589
15623
|
function rateFromU32(rate) {
|
|
15590
|
-
const ratio = new bignumber_js.BigNumber(rate).div(
|
|
15624
|
+
const ratio = new bignumber_js.BigNumber(rate).div(U32_MAX3);
|
|
15591
15625
|
return ratio.times(10);
|
|
15592
15626
|
}
|
|
15593
15627
|
function calculateRateBetweenPoints(startX, startY, endX, endY, targetX) {
|
|
@@ -15618,7 +15652,7 @@ function computeMultipointCurve(utilizationRate, zeroUtilRate, hundredUtilRate,
|
|
|
15618
15652
|
let prevUtil = new bignumber_js.BigNumber(0);
|
|
15619
15653
|
let prevRate = zeroRate;
|
|
15620
15654
|
for (const point of nonPaddingPoints) {
|
|
15621
|
-
const pointUtil = new bignumber_js.BigNumber(point.util).div(
|
|
15655
|
+
const pointUtil = new bignumber_js.BigNumber(point.util).div(U32_MAX3);
|
|
15622
15656
|
const pointRate = rateFromU32(point.rate);
|
|
15623
15657
|
if (clampedUtilizationRate.lte(pointUtil)) {
|
|
15624
15658
|
return calculateRateBetweenPoints(
|
|
@@ -15688,6 +15722,9 @@ function isStandardDepositable(bank) {
|
|
|
15688
15722
|
const { assetTag, operationalState } = bank.config;
|
|
15689
15723
|
return (assetTag === 0 /* DEFAULT */ || assetTag === 1 /* SOL */) && operationalState === "Operational" /* Operational */;
|
|
15690
15724
|
}
|
|
15725
|
+
function isBankCircuitBreakerHalted(bank, nowSeconds) {
|
|
15726
|
+
return bank.isCircuitBreakerEnabled && bank.cbTier > 0 && nowSeconds < bank.cbHaltEndedAt;
|
|
15727
|
+
}
|
|
15691
15728
|
var SECONDS_PER_DAY = 24 * 60 * 60;
|
|
15692
15729
|
var SECONDS_PER_YEAR = SECONDS_PER_DAY * 365;
|
|
15693
15730
|
var EXECUTION_HEADROOM_SECONDS = 120;
|
|
@@ -23826,7 +23863,7 @@ async function makeVaultCompleteWithdrawalTx(params) {
|
|
|
23826
23863
|
|
|
23827
23864
|
// src/models/bank.ts
|
|
23828
23865
|
var Bank = class _Bank {
|
|
23829
|
-
constructor(address23, mint, mintDecimals, group, assetShareValue, liabilityShareValue, liquidityVault, liquidityVaultBump, liquidityVaultAuthorityBump, insuranceVault, insuranceVaultBump, insuranceVaultAuthorityBump, collectedInsuranceFeesOutstanding, feeVault, feeVaultBump, feeVaultAuthorityBump, collectedGroupFeesOutstanding, lastUpdate, config, totalAssetShares, totalLiabilityShares, emissionsActiveBorrowing, emissionsActiveLending, emissionsRate, emissionsMint, emissionsRemaining, collectedProgramFeesOutstanding, oracleKey, emode, premiumTag, premiumActive, premiumActivatedAt, kaminoEmergency, stakedOracleDisabled, stakedOracleUsesOnramp, rateLimiter, kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts, jupLendIntegrationAccounts, stakedIntegrationAccounts, feesDestinationAccount, lendingPositionCount, borrowingPositionCount, tokenSymbol) {
|
|
23866
|
+
constructor(address23, mint, mintDecimals, group, assetShareValue, liabilityShareValue, liquidityVault, liquidityVaultBump, liquidityVaultAuthorityBump, insuranceVault, insuranceVaultBump, insuranceVaultAuthorityBump, collectedInsuranceFeesOutstanding, feeVault, feeVaultBump, feeVaultAuthorityBump, collectedGroupFeesOutstanding, lastUpdate, config, totalAssetShares, totalLiabilityShares, emissionsActiveBorrowing, emissionsActiveLending, emissionsRate, emissionsMint, emissionsRemaining, collectedProgramFeesOutstanding, oracleKey, emode, premiumTag, premiumActive, premiumActivatedAt, kaminoEmergency, liquidationLiquidatorFee, liquidationInsuranceFee, isCircuitBreakerEnabled, cbTier, cbHaltEndedAt, stakedOracleDisabled, stakedOracleUsesOnramp, rateLimiter, kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts, jupLendIntegrationAccounts, stakedIntegrationAccounts, feesDestinationAccount, lendingPositionCount, borrowingPositionCount, tokenSymbol) {
|
|
23830
23867
|
this.address = address23;
|
|
23831
23868
|
this.mint = mint;
|
|
23832
23869
|
this.mintDecimals = mintDecimals;
|
|
@@ -23860,6 +23897,11 @@ var Bank = class _Bank {
|
|
|
23860
23897
|
this.premiumActive = premiumActive;
|
|
23861
23898
|
this.premiumActivatedAt = premiumActivatedAt;
|
|
23862
23899
|
this.kaminoEmergency = kaminoEmergency;
|
|
23900
|
+
this.liquidationLiquidatorFee = liquidationLiquidatorFee;
|
|
23901
|
+
this.liquidationInsuranceFee = liquidationInsuranceFee;
|
|
23902
|
+
this.isCircuitBreakerEnabled = isCircuitBreakerEnabled;
|
|
23903
|
+
this.cbTier = cbTier;
|
|
23904
|
+
this.cbHaltEndedAt = cbHaltEndedAt;
|
|
23863
23905
|
this.stakedOracleDisabled = stakedOracleDisabled;
|
|
23864
23906
|
this.stakedOracleUsesOnramp = stakedOracleUsesOnramp;
|
|
23865
23907
|
this.rateLimiter = rateLimiter;
|
|
@@ -23907,6 +23949,9 @@ var Bank = class _Bank {
|
|
|
23907
23949
|
bankType.config.operationalState,
|
|
23908
23950
|
bankType.config.oracleMaxConfidence,
|
|
23909
23951
|
bankType.config.fixedPrice,
|
|
23952
|
+
bankType.config.cbWindowMaxUpBps,
|
|
23953
|
+
bankType.config.cbWindowMaxDownBps,
|
|
23954
|
+
bankType.config.cbWindowSeconds,
|
|
23910
23955
|
bankType.config.configFlags,
|
|
23911
23956
|
bankType.config.scopeEntryIndex
|
|
23912
23957
|
);
|
|
@@ -23944,6 +23989,11 @@ var Bank = class _Bank {
|
|
|
23944
23989
|
bankType.premiumActive,
|
|
23945
23990
|
bankType.premiumActivatedAt,
|
|
23946
23991
|
bankType.kaminoEmergency,
|
|
23992
|
+
bankType.liquidationLiquidatorFee,
|
|
23993
|
+
bankType.liquidationInsuranceFee,
|
|
23994
|
+
bankType.isCircuitBreakerEnabled,
|
|
23995
|
+
bankType.cbTier,
|
|
23996
|
+
bankType.cbHaltEndedAt,
|
|
23947
23997
|
bankType.stakedOracleDisabled,
|
|
23948
23998
|
bankType.stakedOracleUsesOnramp,
|
|
23949
23999
|
bankType.rateLimiter,
|
|
@@ -24088,7 +24138,7 @@ var Bank = class _Bank {
|
|
|
24088
24138
|
}
|
|
24089
24139
|
};
|
|
24090
24140
|
var BankConfig = class {
|
|
24091
|
-
constructor(assetWeightInit, assetWeightMaint, liabilityWeightInit, liabilityWeightMaint, depositLimit, borrowLimit, riskTier, totalAssetValueInitLimit, assetTag, oracleSetup, oracleKeys, oracleMaxAge, interestRateConfig, operationalState, oracleMaxConfidence, fixedPrice, configFlags, scopeEntryIndex) {
|
|
24141
|
+
constructor(assetWeightInit, assetWeightMaint, liabilityWeightInit, liabilityWeightMaint, depositLimit, borrowLimit, riskTier, totalAssetValueInitLimit, assetTag, oracleSetup, oracleKeys, oracleMaxAge, interestRateConfig, operationalState, oracleMaxConfidence, fixedPrice, cbWindowMaxUpBps, cbWindowMaxDownBps, cbWindowSeconds, configFlags, scopeEntryIndex) {
|
|
24092
24142
|
this.assetWeightInit = assetWeightInit;
|
|
24093
24143
|
this.assetWeightMaint = assetWeightMaint;
|
|
24094
24144
|
this.liabilityWeightInit = liabilityWeightInit;
|
|
@@ -24105,6 +24155,9 @@ var BankConfig = class {
|
|
|
24105
24155
|
this.operationalState = operationalState;
|
|
24106
24156
|
this.oracleMaxConfidence = oracleMaxConfidence;
|
|
24107
24157
|
this.fixedPrice = fixedPrice;
|
|
24158
|
+
this.cbWindowMaxUpBps = cbWindowMaxUpBps;
|
|
24159
|
+
this.cbWindowMaxDownBps = cbWindowMaxDownBps;
|
|
24160
|
+
this.cbWindowSeconds = cbWindowSeconds;
|
|
24108
24161
|
this.configFlags = configFlags;
|
|
24109
24162
|
this.scopeEntryIndex = scopeEntryIndex;
|
|
24110
24163
|
}
|
|
@@ -25308,6 +25361,7 @@ exports.Balance = Balance;
|
|
|
25308
25361
|
exports.Bank = Bank;
|
|
25309
25362
|
exports.BankConfig = BankConfig;
|
|
25310
25363
|
exports.BankConfigFlag = BankConfigFlag;
|
|
25364
|
+
exports.CIRCUIT_BREAKER_ENABLED_FLAG = CIRCUIT_BREAKER_ENABLED_FLAG;
|
|
25311
25365
|
exports.DEFAULT_ADDRESS = DEFAULT_ADDRESS;
|
|
25312
25366
|
exports.DEFAULT_BRIDGE_MINTS = DEFAULT_BRIDGE_MINTS;
|
|
25313
25367
|
exports.DEFAULT_ORACLE_MAX_AGE = DEFAULT_ORACLE_MAX_AGE;
|
|
@@ -25552,6 +25606,7 @@ exports.getAssetShares = getAssetShares;
|
|
|
25552
25606
|
exports.getAssetWeight = getAssetWeight;
|
|
25553
25607
|
exports.getBalance = getBalance;
|
|
25554
25608
|
exports.getBalanceUsdValueWithPriceBias = getBalanceUsdValueWithPriceBias;
|
|
25609
|
+
exports.getBankLiquidationFees = getBankLiquidationFees;
|
|
25555
25610
|
exports.getConfig = getConfig;
|
|
25556
25611
|
exports.getEffectiveDepositLimit = getEffectiveDepositLimit;
|
|
25557
25612
|
exports.getEmodePairs = getEmodePairs;
|
|
@@ -25580,6 +25635,7 @@ exports.hasEmodeEntryFlag = hasEmodeEntryFlag;
|
|
|
25580
25635
|
exports.hasEmodeFlag = hasEmodeFlag;
|
|
25581
25636
|
exports.hasHealthCacheFlag = hasHealthCacheFlag;
|
|
25582
25637
|
exports.healthCacheToDto = healthCacheToDto;
|
|
25638
|
+
exports.isBankCircuitBreakerHalted = isBankCircuitBreakerHalted;
|
|
25583
25639
|
exports.isBorrowLimitActive = isBorrowLimitActive;
|
|
25584
25640
|
exports.isBridgeConflictError = isBridgeConflictError;
|
|
25585
25641
|
exports.isCostlyBank = isCostlyBank;
|