@0dotxyz/p0-ts-sdk 2.0.0 → 2.0.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 +294 -259
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +293 -258
- package/dist/index.js.map +1 -1
- package/dist/vendor.cjs +27 -27
- package/dist/vendor.cjs.map +1 -1
- package/dist/vendor.d.cts +20 -20
- package/dist/vendor.d.ts +20 -20
- package/dist/vendor.js +32 -32
- package/dist/vendor.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var web3_js = require('@solana/web3.js');
|
|
4
4
|
var superstruct = require('superstruct');
|
|
5
|
-
var
|
|
5
|
+
var BigNumber3 = require('bignumber.js');
|
|
6
6
|
var BN11 = require('bn.js');
|
|
7
7
|
var Decimal3 = require('decimal.js');
|
|
8
8
|
var anchor = require('@coral-xyz/anchor');
|
|
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
35
35
|
return Object.freeze(n);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var BigNumber3__default = /*#__PURE__*/_interopDefault(BigNumber3);
|
|
39
39
|
var BN11__default = /*#__PURE__*/_interopDefault(BN11);
|
|
40
40
|
var Decimal3__default = /*#__PURE__*/_interopDefault(Decimal3);
|
|
41
41
|
var borsh__namespace = /*#__PURE__*/_interopNamespace(borsh);
|
|
@@ -268,9 +268,9 @@ var PYTH_SPONSORED_SHARD_ID = 0;
|
|
|
268
268
|
var MARGINFI_SPONSORED_SHARD_ID = 3301;
|
|
269
269
|
var DEFAULT_ORACLE_MAX_AGE = 60;
|
|
270
270
|
var ZERO_ORACLE_KEY = "DMhGWtLAKE5d56WdyHQxqeFncwUeqMEnuC2RvvZfbuur";
|
|
271
|
-
var PYTH_PRICE_CONF_INTERVALS = new
|
|
272
|
-
var SWB_PRICE_CONF_INTERVALS = new
|
|
273
|
-
var MAX_CONFIDENCE_INTERVAL_RATIO = new
|
|
271
|
+
var PYTH_PRICE_CONF_INTERVALS = new BigNumber3__default.default(2.12);
|
|
272
|
+
var SWB_PRICE_CONF_INTERVALS = new BigNumber3__default.default(1.96);
|
|
273
|
+
var MAX_CONFIDENCE_INTERVAL_RATIO = new BigNumber3__default.default(0.05);
|
|
274
274
|
var DISABLED_FLAG = 1 << 0;
|
|
275
275
|
var FLASHLOAN_ENABLED_FLAG = 1 << 2;
|
|
276
276
|
var TRANSFER_ACCOUNT_AUTHORITY_FLAG = 1 << 3;
|
|
@@ -363,7 +363,7 @@ function wrappedI80F48toBigNumber(wrapped) {
|
|
|
363
363
|
}
|
|
364
364
|
let hex = signChar + "0x" + bytesBE.map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
365
365
|
let decoded = new Decimal3.Decimal(hex).dividedBy(I80F48_DIVISOR);
|
|
366
|
-
return new
|
|
366
|
+
return new BigNumber3__default.default(decoded.toString());
|
|
367
367
|
}
|
|
368
368
|
function bigNumberToWrappedI80F48(value) {
|
|
369
369
|
let decimalValue = new Decimal3.Decimal(value.toString());
|
|
@@ -394,16 +394,16 @@ function toNumber(amount) {
|
|
|
394
394
|
}
|
|
395
395
|
function toBigNumber(amount) {
|
|
396
396
|
let amt;
|
|
397
|
-
if (amount instanceof
|
|
397
|
+
if (amount instanceof BigNumber3__default.default) {
|
|
398
398
|
amt = amount;
|
|
399
399
|
} else {
|
|
400
|
-
amt = new
|
|
400
|
+
amt = new BigNumber3__default.default(amount.toString());
|
|
401
401
|
}
|
|
402
402
|
return amt;
|
|
403
403
|
}
|
|
404
404
|
function uiToNative(amount, decimals) {
|
|
405
405
|
let amt = toBigNumber(amount);
|
|
406
|
-
return new BN11__default.default(amt.times(10 ** decimals).toFixed(0,
|
|
406
|
+
return new BN11__default.default(amt.times(10 ** decimals).toFixed(0, BigNumber3__default.default.ROUND_FLOOR));
|
|
407
407
|
}
|
|
408
408
|
function uiToNativeBigNumber(amount, decimals) {
|
|
409
409
|
let amt = toBigNumber(amount);
|
|
@@ -13786,13 +13786,13 @@ function parseBankRaw(address, accountParsed, bankMetadata, mintData) {
|
|
|
13786
13786
|
const emissionsActiveLending = (flags & 2) > 0;
|
|
13787
13787
|
const emissionsRate = accountParsed.emissionsRate.toNumber();
|
|
13788
13788
|
const emissionsMint = accountParsed.emissionsMint;
|
|
13789
|
-
const emissionsRemaining = accountParsed.emissionsRemaining ? wrappedI80F48toBigNumber(accountParsed.emissionsRemaining) : new
|
|
13789
|
+
const emissionsRemaining = accountParsed.emissionsRemaining ? wrappedI80F48toBigNumber(accountParsed.emissionsRemaining) : new BigNumber3__default.default(0);
|
|
13790
13790
|
const { oracleKey } = { oracleKey: config.oracleKeys[0] };
|
|
13791
13791
|
const emode = parseEmodeSettingsRaw(accountParsed.emode);
|
|
13792
13792
|
const tokenSymbol = bankMetadata?.tokenSymbol;
|
|
13793
13793
|
const feesDestinationAccount = accountParsed.feesDestinationAccount;
|
|
13794
|
-
const lendingPositionCount = accountParsed.lendingPositionCount ? new
|
|
13795
|
-
const borrowingPositionCount = accountParsed.borrowingPositionCount ? new
|
|
13794
|
+
const lendingPositionCount = accountParsed.lendingPositionCount ? new BigNumber3__default.default(accountParsed.lendingPositionCount.toString()) : new BigNumber3__default.default(0);
|
|
13795
|
+
const borrowingPositionCount = accountParsed.borrowingPositionCount ? new BigNumber3__default.default(accountParsed.borrowingPositionCount.toString()) : new BigNumber3__default.default(0);
|
|
13796
13796
|
let kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts = void 0;
|
|
13797
13797
|
switch (config.assetTag) {
|
|
13798
13798
|
case 3 /* KAMINO */:
|
|
@@ -13861,34 +13861,34 @@ function dtoToBank(bankDto) {
|
|
|
13861
13861
|
group: new web3_js.PublicKey(bankDto.group),
|
|
13862
13862
|
mint: new web3_js.PublicKey(bankDto.mint),
|
|
13863
13863
|
mintDecimals: bankDto.mintDecimals,
|
|
13864
|
-
assetShareValue: new
|
|
13865
|
-
liabilityShareValue: new
|
|
13864
|
+
assetShareValue: new BigNumber3__default.default(bankDto.assetShareValue),
|
|
13865
|
+
liabilityShareValue: new BigNumber3__default.default(bankDto.liabilityShareValue),
|
|
13866
13866
|
liquidityVault: new web3_js.PublicKey(bankDto.liquidityVault),
|
|
13867
13867
|
liquidityVaultBump: bankDto.liquidityVaultBump,
|
|
13868
13868
|
liquidityVaultAuthorityBump: bankDto.liquidityVaultAuthorityBump,
|
|
13869
13869
|
insuranceVault: new web3_js.PublicKey(bankDto.insuranceVault),
|
|
13870
13870
|
insuranceVaultBump: bankDto.insuranceVaultBump,
|
|
13871
13871
|
insuranceVaultAuthorityBump: bankDto.insuranceVaultAuthorityBump,
|
|
13872
|
-
collectedInsuranceFeesOutstanding: new
|
|
13872
|
+
collectedInsuranceFeesOutstanding: new BigNumber3__default.default(bankDto.collectedInsuranceFeesOutstanding),
|
|
13873
13873
|
feeVault: new web3_js.PublicKey(bankDto.feeVault),
|
|
13874
13874
|
feeVaultBump: bankDto.feeVaultBump,
|
|
13875
13875
|
feeVaultAuthorityBump: bankDto.feeVaultAuthorityBump,
|
|
13876
|
-
collectedGroupFeesOutstanding: new
|
|
13876
|
+
collectedGroupFeesOutstanding: new BigNumber3__default.default(bankDto.collectedGroupFeesOutstanding),
|
|
13877
13877
|
lastUpdate: bankDto.lastUpdate,
|
|
13878
13878
|
config: dtoToBankConfig(bankDto.config),
|
|
13879
|
-
totalAssetShares: new
|
|
13880
|
-
totalLiabilityShares: new
|
|
13879
|
+
totalAssetShares: new BigNumber3__default.default(bankDto.totalAssetShares),
|
|
13880
|
+
totalLiabilityShares: new BigNumber3__default.default(bankDto.totalLiabilityShares),
|
|
13881
13881
|
emissionsActiveBorrowing: bankDto.emissionsActiveBorrowing,
|
|
13882
13882
|
emissionsActiveLending: bankDto.emissionsActiveLending,
|
|
13883
13883
|
emissionsRate: bankDto.emissionsRate,
|
|
13884
13884
|
emissionsMint: new web3_js.PublicKey(bankDto.emissionsMint),
|
|
13885
|
-
emissionsRemaining: new
|
|
13885
|
+
emissionsRemaining: new BigNumber3__default.default(bankDto.emissionsRemaining),
|
|
13886
13886
|
oracleKey: new web3_js.PublicKey(bankDto.oracleKey),
|
|
13887
13887
|
emode: dtoToEmodeSettings(bankDto.emode),
|
|
13888
13888
|
tokenSymbol: bankDto.tokenSymbol,
|
|
13889
13889
|
feesDestinationAccount: bankDto.feesDestinationAccount ? new web3_js.PublicKey(bankDto.feesDestinationAccount) : void 0,
|
|
13890
|
-
lendingPositionCount: bankDto.lendingPositionCount ? new
|
|
13891
|
-
borrowingPositionCount: bankDto.borrowingPositionCount ? new
|
|
13890
|
+
lendingPositionCount: bankDto.lendingPositionCount ? new BigNumber3__default.default(bankDto.lendingPositionCount) : void 0,
|
|
13891
|
+
borrowingPositionCount: bankDto.borrowingPositionCount ? new BigNumber3__default.default(bankDto.borrowingPositionCount) : void 0,
|
|
13892
13892
|
mintRate: null,
|
|
13893
13893
|
// TODO: move these out
|
|
13894
13894
|
mintPrice: 0,
|
|
@@ -13916,23 +13916,23 @@ function dtoToEmodeSettings(emodeSettingsDto) {
|
|
|
13916
13916
|
return {
|
|
13917
13917
|
collateralBankEmodeTag: entry.collateralBankEmodeTag,
|
|
13918
13918
|
flags: entry.flags,
|
|
13919
|
-
assetWeightInit: new
|
|
13920
|
-
assetWeightMaint: new
|
|
13919
|
+
assetWeightInit: new BigNumber3__default.default(entry.assetWeightInit),
|
|
13920
|
+
assetWeightMaint: new BigNumber3__default.default(entry.assetWeightMaint)
|
|
13921
13921
|
};
|
|
13922
13922
|
})
|
|
13923
13923
|
};
|
|
13924
13924
|
}
|
|
13925
13925
|
function dtoToBankConfig(bankConfigDto) {
|
|
13926
13926
|
return {
|
|
13927
|
-
assetWeightInit: new
|
|
13928
|
-
assetWeightMaint: new
|
|
13929
|
-
liabilityWeightInit: new
|
|
13930
|
-
liabilityWeightMaint: new
|
|
13931
|
-
depositLimit: new
|
|
13932
|
-
borrowLimit: new
|
|
13927
|
+
assetWeightInit: new BigNumber3__default.default(bankConfigDto.assetWeightInit),
|
|
13928
|
+
assetWeightMaint: new BigNumber3__default.default(bankConfigDto.assetWeightMaint),
|
|
13929
|
+
liabilityWeightInit: new BigNumber3__default.default(bankConfigDto.liabilityWeightInit),
|
|
13930
|
+
liabilityWeightMaint: new BigNumber3__default.default(bankConfigDto.liabilityWeightMaint),
|
|
13931
|
+
depositLimit: new BigNumber3__default.default(bankConfigDto.depositLimit),
|
|
13932
|
+
borrowLimit: new BigNumber3__default.default(bankConfigDto.borrowLimit),
|
|
13933
13933
|
riskTier: bankConfigDto.riskTier,
|
|
13934
13934
|
operationalState: bankConfigDto.operationalState,
|
|
13935
|
-
totalAssetValueInitLimit: new
|
|
13935
|
+
totalAssetValueInitLimit: new BigNumber3__default.default(bankConfigDto.totalAssetValueInitLimit),
|
|
13936
13936
|
assetTag: bankConfigDto.assetTag,
|
|
13937
13937
|
configFlags: bankConfigDto.configFlags,
|
|
13938
13938
|
oracleSetup: bankConfigDto.oracleSetup,
|
|
@@ -13940,19 +13940,19 @@ function dtoToBankConfig(bankConfigDto) {
|
|
|
13940
13940
|
oracleMaxAge: bankConfigDto.oracleMaxAge,
|
|
13941
13941
|
interestRateConfig: dtoToInterestRateConfig(bankConfigDto.interestRateConfig),
|
|
13942
13942
|
oracleMaxConfidence: bankConfigDto.oracleMaxConfidence,
|
|
13943
|
-
fixedPrice: new
|
|
13943
|
+
fixedPrice: new BigNumber3__default.default(bankConfigDto.fixedPrice)
|
|
13944
13944
|
};
|
|
13945
13945
|
}
|
|
13946
13946
|
function dtoToInterestRateConfig(interestRateConfigDto) {
|
|
13947
13947
|
return {
|
|
13948
|
-
optimalUtilizationRate: new
|
|
13949
|
-
plateauInterestRate: new
|
|
13950
|
-
maxInterestRate: new
|
|
13951
|
-
insuranceFeeFixedApr: new
|
|
13952
|
-
insuranceIrFee: new
|
|
13953
|
-
protocolFixedFeeApr: new
|
|
13954
|
-
protocolIrFee: new
|
|
13955
|
-
protocolOriginationFee: new
|
|
13948
|
+
optimalUtilizationRate: new BigNumber3__default.default(interestRateConfigDto.optimalUtilizationRate),
|
|
13949
|
+
plateauInterestRate: new BigNumber3__default.default(interestRateConfigDto.plateauInterestRate),
|
|
13950
|
+
maxInterestRate: new BigNumber3__default.default(interestRateConfigDto.maxInterestRate),
|
|
13951
|
+
insuranceFeeFixedApr: new BigNumber3__default.default(interestRateConfigDto.insuranceFeeFixedApr),
|
|
13952
|
+
insuranceIrFee: new BigNumber3__default.default(interestRateConfigDto.insuranceIrFee),
|
|
13953
|
+
protocolFixedFeeApr: new BigNumber3__default.default(interestRateConfigDto.protocolFixedFeeApr),
|
|
13954
|
+
protocolIrFee: new BigNumber3__default.default(interestRateConfigDto.protocolIrFee),
|
|
13955
|
+
protocolOriginationFee: new BigNumber3__default.default(interestRateConfigDto.protocolOriginationFee),
|
|
13956
13956
|
zeroUtilRate: interestRateConfigDto.zeroUtilRate,
|
|
13957
13957
|
hundredUtilRate: interestRateConfigDto.hundredUtilRate,
|
|
13958
13958
|
points: interestRateConfigDto.points,
|
|
@@ -14037,11 +14037,11 @@ function parseBankConfigRaw(bankConfigRaw) {
|
|
|
14037
14037
|
const assetWeightMaint = wrappedI80F48toBigNumber(bankConfigRaw.assetWeightMaint);
|
|
14038
14038
|
const liabilityWeightInit = wrappedI80F48toBigNumber(bankConfigRaw.liabilityWeightInit);
|
|
14039
14039
|
const liabilityWeightMaint = wrappedI80F48toBigNumber(bankConfigRaw.liabilityWeightMaint);
|
|
14040
|
-
const depositLimit =
|
|
14041
|
-
const borrowLimit =
|
|
14040
|
+
const depositLimit = BigNumber3__default.default(bankConfigRaw.depositLimit.toString());
|
|
14041
|
+
const borrowLimit = BigNumber3__default.default(bankConfigRaw.borrowLimit.toString());
|
|
14042
14042
|
const riskTier = parseRiskTier(bankConfigRaw.riskTier);
|
|
14043
14043
|
const operationalState = parseOperationalState(bankConfigRaw.operationalState);
|
|
14044
|
-
const totalAssetValueInitLimit =
|
|
14044
|
+
const totalAssetValueInitLimit = BigNumber3__default.default(bankConfigRaw.totalAssetValueInitLimit.toString());
|
|
14045
14045
|
const assetTag = bankConfigRaw.assetTag;
|
|
14046
14046
|
const configFlags = bankConfigRaw.configFlags;
|
|
14047
14047
|
const oracleSetup = parseOracleSetup(bankConfigRaw.oracleSetup);
|
|
@@ -14213,13 +14213,13 @@ function getLiabilityQuantity(bank, liabilityShares) {
|
|
|
14213
14213
|
}
|
|
14214
14214
|
function getAssetShares(bank, assetQuantity) {
|
|
14215
14215
|
if (bank.assetShareValue.isZero()) {
|
|
14216
|
-
return new
|
|
14216
|
+
return new BigNumber3__default.default(0);
|
|
14217
14217
|
}
|
|
14218
14218
|
return assetQuantity.div(bank.assetShareValue);
|
|
14219
14219
|
}
|
|
14220
14220
|
function getLiabilityShares(bank, liabilityQuantity) {
|
|
14221
14221
|
if (bank.liabilityShareValue.isZero()) {
|
|
14222
|
-
return new
|
|
14222
|
+
return new BigNumber3__default.default(0);
|
|
14223
14223
|
}
|
|
14224
14224
|
return liabilityQuantity.div(bank.liabilityShareValue);
|
|
14225
14225
|
}
|
|
@@ -17187,8 +17187,8 @@ var mapBrokenFeedsToOraclePrices = (banks, swbOracleAiDataByKey, birdeyeResponse
|
|
|
17187
17187
|
return bankOraclePriceMap;
|
|
17188
17188
|
};
|
|
17189
17189
|
function parseSwbOraclePriceData(price, stdDev, timestamp, oracleData) {
|
|
17190
|
-
const swbPrice = Array.isArray(price) ? new
|
|
17191
|
-
const swbConfidence = new
|
|
17190
|
+
const swbPrice = Array.isArray(price) ? new BigNumber3__default.default(median(price)) : new BigNumber3__default.default(price.toString()).div(10 ** SWITCHBOARD_ONDEMANDE_PRICE_PRECISION);
|
|
17191
|
+
const swbConfidence = new BigNumber3__default.default(stdDev.toString()).times(SWB_PRICE_CONF_INTERVALS);
|
|
17192
17192
|
const swbConfidenceCapped = capConfidenceInterval(
|
|
17193
17193
|
swbPrice,
|
|
17194
17194
|
swbConfidence,
|
|
@@ -17209,7 +17209,7 @@ function parseSwbOraclePriceData(price, stdDev, timestamp, oracleData) {
|
|
|
17209
17209
|
lowestPrice: swbLowestPrice,
|
|
17210
17210
|
highestPrice: swbHighestPrice
|
|
17211
17211
|
},
|
|
17212
|
-
timestamp: new
|
|
17212
|
+
timestamp: new BigNumber3__default.default(timestamp),
|
|
17213
17213
|
switchboardData: oracleData
|
|
17214
17214
|
};
|
|
17215
17215
|
}
|
|
@@ -17324,13 +17324,13 @@ var adjustPriceComponent = (priceComponent, priceCoeff) => ({
|
|
|
17324
17324
|
function parseRpcPythPriceData(rawData) {
|
|
17325
17325
|
function capConfidenceInterval2(price, confidence, maxConfidence) {
|
|
17326
17326
|
const maxConfidenceInterval = price.times(maxConfidence);
|
|
17327
|
-
return
|
|
17327
|
+
return BigNumber3__default.default.min(confidence, maxConfidenceInterval);
|
|
17328
17328
|
}
|
|
17329
17329
|
const bytesWithoutDiscriminator = rawData.slice(8);
|
|
17330
17330
|
const data = parsePriceInfo(bytesWithoutDiscriminator);
|
|
17331
|
-
const exponent = new
|
|
17332
|
-
const priceRealTime = new
|
|
17333
|
-
const confidenceRealTime = new
|
|
17331
|
+
const exponent = new BigNumber3__default.default(10 ** data.priceMessage.exponent);
|
|
17332
|
+
const priceRealTime = new BigNumber3__default.default(Number(data.priceMessage.price)).times(exponent);
|
|
17333
|
+
const confidenceRealTime = new BigNumber3__default.default(Number(data.priceMessage.conf)).times(exponent).times(PYTH_PRICE_CONF_INTERVALS);
|
|
17334
17334
|
const cappedConfidenceRealTime = capConfidenceInterval2(
|
|
17335
17335
|
priceRealTime,
|
|
17336
17336
|
confidenceRealTime,
|
|
@@ -17338,8 +17338,8 @@ function parseRpcPythPriceData(rawData) {
|
|
|
17338
17338
|
);
|
|
17339
17339
|
const lowestPriceRealTime = priceRealTime.minus(cappedConfidenceRealTime);
|
|
17340
17340
|
const highestPriceRealTime = priceRealTime.plus(cappedConfidenceRealTime);
|
|
17341
|
-
const priceTimeWeighted = new
|
|
17342
|
-
const confidenceTimeWeighted = new
|
|
17341
|
+
const priceTimeWeighted = new BigNumber3__default.default(Number(data.priceMessage.emaPrice)).times(exponent);
|
|
17342
|
+
const confidenceTimeWeighted = new BigNumber3__default.default(Number(data.priceMessage.emaConf)).times(exponent).times(PYTH_PRICE_CONF_INTERVALS);
|
|
17343
17343
|
const cappedConfidenceWeighted = capConfidenceInterval2(
|
|
17344
17344
|
priceTimeWeighted,
|
|
17345
17345
|
confidenceTimeWeighted,
|
|
@@ -17360,7 +17360,7 @@ function parseRpcPythPriceData(rawData) {
|
|
|
17360
17360
|
lowestPrice: lowestPriceWeighted,
|
|
17361
17361
|
highestPrice: highestPriceWeighted
|
|
17362
17362
|
},
|
|
17363
|
-
timestamp: new
|
|
17363
|
+
timestamp: new BigNumber3__default.default(Number(data.priceMessage.publishTime))
|
|
17364
17364
|
};
|
|
17365
17365
|
}
|
|
17366
17366
|
|
|
@@ -17381,7 +17381,7 @@ function getPrice(oraclePrice, priceBias = 1 /* None */, weightedPrice = false)
|
|
|
17381
17381
|
}
|
|
17382
17382
|
function capConfidenceInterval(price, confidence, maxConfidence) {
|
|
17383
17383
|
let maxConfidenceInterval = price.times(maxConfidence);
|
|
17384
|
-
return
|
|
17384
|
+
return BigNumber3__default.default.min(confidence, maxConfidenceInterval);
|
|
17385
17385
|
}
|
|
17386
17386
|
function parseOraclePriceData(oracleSetup, rawData) {
|
|
17387
17387
|
switch (oracleSetup) {
|
|
@@ -17397,18 +17397,18 @@ function parseOraclePriceData(oracleSetup, rawData) {
|
|
|
17397
17397
|
case "SwitchboardV2" /* SwitchboardV2 */: {
|
|
17398
17398
|
return {
|
|
17399
17399
|
priceRealtime: {
|
|
17400
|
-
price: new
|
|
17401
|
-
confidence: new
|
|
17402
|
-
lowestPrice: new
|
|
17403
|
-
highestPrice: new
|
|
17400
|
+
price: new BigNumber3__default.default(0),
|
|
17401
|
+
confidence: new BigNumber3__default.default(0),
|
|
17402
|
+
lowestPrice: new BigNumber3__default.default(0),
|
|
17403
|
+
highestPrice: new BigNumber3__default.default(0)
|
|
17404
17404
|
},
|
|
17405
17405
|
priceWeighted: {
|
|
17406
|
-
price: new
|
|
17407
|
-
confidence: new
|
|
17408
|
-
lowestPrice: new
|
|
17409
|
-
highestPrice: new
|
|
17406
|
+
price: new BigNumber3__default.default(0),
|
|
17407
|
+
confidence: new BigNumber3__default.default(0),
|
|
17408
|
+
lowestPrice: new BigNumber3__default.default(0),
|
|
17409
|
+
highestPrice: new BigNumber3__default.default(0)
|
|
17410
17410
|
},
|
|
17411
|
-
timestamp: new
|
|
17411
|
+
timestamp: new BigNumber3__default.default(0)
|
|
17412
17412
|
};
|
|
17413
17413
|
}
|
|
17414
17414
|
case "SwitchboardPull" /* SwitchboardPull */:
|
|
@@ -17458,18 +17458,18 @@ function oraclePriceToDto(oraclePrice) {
|
|
|
17458
17458
|
function dtoToOraclePrice(dto) {
|
|
17459
17459
|
return {
|
|
17460
17460
|
priceRealtime: {
|
|
17461
|
-
price: new
|
|
17462
|
-
confidence: new
|
|
17463
|
-
lowestPrice: new
|
|
17464
|
-
highestPrice: new
|
|
17461
|
+
price: new BigNumber3__default.default(dto.priceRealtime.price),
|
|
17462
|
+
confidence: new BigNumber3__default.default(dto.priceRealtime.confidence),
|
|
17463
|
+
lowestPrice: new BigNumber3__default.default(dto.priceRealtime.lowestPrice),
|
|
17464
|
+
highestPrice: new BigNumber3__default.default(dto.priceRealtime.highestPrice)
|
|
17465
17465
|
},
|
|
17466
17466
|
priceWeighted: {
|
|
17467
|
-
price: new
|
|
17468
|
-
confidence: new
|
|
17469
|
-
lowestPrice: new
|
|
17470
|
-
highestPrice: new
|
|
17467
|
+
price: new BigNumber3__default.default(dto.priceWeighted.price),
|
|
17468
|
+
confidence: new BigNumber3__default.default(dto.priceWeighted.confidence),
|
|
17469
|
+
lowestPrice: new BigNumber3__default.default(dto.priceWeighted.lowestPrice),
|
|
17470
|
+
highestPrice: new BigNumber3__default.default(dto.priceWeighted.highestPrice)
|
|
17471
17471
|
},
|
|
17472
|
-
timestamp: new
|
|
17472
|
+
timestamp: new BigNumber3__default.default(dto.timestamp),
|
|
17473
17473
|
switchboardData: dto.switchboardData
|
|
17474
17474
|
};
|
|
17475
17475
|
}
|
|
@@ -17740,10 +17740,10 @@ var EMPTY_HEALTH_CACHE = {
|
|
|
17740
17740
|
timestamp: new BN11__default.default(0),
|
|
17741
17741
|
flags: 0,
|
|
17742
17742
|
prices: [],
|
|
17743
|
-
assetValueMaint: bigNumberToWrappedI80F48(new
|
|
17744
|
-
liabilityValueMaint: bigNumberToWrappedI80F48(new
|
|
17745
|
-
assetValueEquity: bigNumberToWrappedI80F48(new
|
|
17746
|
-
liabilityValueEquity: bigNumberToWrappedI80F48(new
|
|
17743
|
+
assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
17744
|
+
liabilityValueMaint: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
17745
|
+
assetValueEquity: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
17746
|
+
liabilityValueEquity: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
17747
17747
|
errIndex: 0,
|
|
17748
17748
|
internalErr: 0,
|
|
17749
17749
|
internalBankruptcyErr: 0,
|
|
@@ -17873,21 +17873,21 @@ function dtoToBalance(balanceDto) {
|
|
|
17873
17873
|
return {
|
|
17874
17874
|
active: balanceDto.active,
|
|
17875
17875
|
bankPk: new web3_js.PublicKey(balanceDto.bankPk),
|
|
17876
|
-
assetShares: new
|
|
17877
|
-
liabilityShares: new
|
|
17878
|
-
emissionsOutstanding: new
|
|
17876
|
+
assetShares: new BigNumber3__default.default(balanceDto.assetShares),
|
|
17877
|
+
liabilityShares: new BigNumber3__default.default(balanceDto.liabilityShares),
|
|
17878
|
+
emissionsOutstanding: new BigNumber3__default.default(balanceDto.emissionsOutstanding),
|
|
17879
17879
|
lastUpdate: balanceDto.lastUpdate
|
|
17880
17880
|
};
|
|
17881
17881
|
}
|
|
17882
17882
|
function dtoToHealthCache(healthCacheDto) {
|
|
17883
17883
|
return {
|
|
17884
|
-
assetValue: new
|
|
17885
|
-
liabilityValue: new
|
|
17886
|
-
assetValueMaint: new
|
|
17887
|
-
liabilityValueMaint: new
|
|
17888
|
-
assetValueEquity: new
|
|
17889
|
-
liabilityValueEquity: new
|
|
17890
|
-
timestamp: new
|
|
17884
|
+
assetValue: new BigNumber3__default.default(healthCacheDto.assetValue),
|
|
17885
|
+
liabilityValue: new BigNumber3__default.default(healthCacheDto.liabilityValue),
|
|
17886
|
+
assetValueMaint: new BigNumber3__default.default(healthCacheDto.assetValueMaint),
|
|
17887
|
+
liabilityValueMaint: new BigNumber3__default.default(healthCacheDto.liabilityValueMaint),
|
|
17888
|
+
assetValueEquity: new BigNumber3__default.default(healthCacheDto.assetValueEquity),
|
|
17889
|
+
liabilityValueEquity: new BigNumber3__default.default(healthCacheDto.liabilityValueEquity),
|
|
17890
|
+
timestamp: new BigNumber3__default.default(healthCacheDto.timestamp),
|
|
17891
17891
|
flags: healthCacheDto.flags,
|
|
17892
17892
|
prices: healthCacheDto.prices,
|
|
17893
17893
|
simulationStatus: healthCacheDto.simulationStatus
|
|
@@ -17964,8 +17964,8 @@ function computeLowestEmodeWeights(emodePairs) {
|
|
|
17964
17964
|
});
|
|
17965
17965
|
} else {
|
|
17966
17966
|
result.set(bankPkStr, {
|
|
17967
|
-
assetWeightInit:
|
|
17968
|
-
assetWeightMaint:
|
|
17967
|
+
assetWeightInit: BigNumber3__default.default.min(existing.assetWeightInit, emodePair.assetWeightInit),
|
|
17968
|
+
assetWeightMaint: BigNumber3__default.default.min(existing.assetWeightMaint, emodePair.assetWeightMaint)
|
|
17969
17969
|
});
|
|
17970
17970
|
}
|
|
17971
17971
|
});
|
|
@@ -18204,8 +18204,8 @@ function computeQuantity(balance, bank) {
|
|
|
18204
18204
|
function computeQuantityUi(balance, bank, assetShareValueMultiplier) {
|
|
18205
18205
|
const { assets, liabilities } = computeQuantity(balance, bank);
|
|
18206
18206
|
const adjustedAssets = assetShareValueMultiplier ? assets.multipliedBy(assetShareValueMultiplier) : assets;
|
|
18207
|
-
const assetsQuantity = new
|
|
18208
|
-
const liabilitiesQuantity = new
|
|
18207
|
+
const assetsQuantity = new BigNumber3__default.default(nativeToUi(adjustedAssets, bank.mintDecimals));
|
|
18208
|
+
const liabilitiesQuantity = new BigNumber3__default.default(nativeToUi(liabilities, bank.mintDecimals));
|
|
18209
18209
|
return { assets: assetsQuantity, liabilities: liabilitiesQuantity };
|
|
18210
18210
|
}
|
|
18211
18211
|
|
|
@@ -18217,7 +18217,7 @@ function computeFreeCollateralFromCache(marginfiAccount, opts) {
|
|
|
18217
18217
|
0 /* Initial */
|
|
18218
18218
|
);
|
|
18219
18219
|
const signedFreeCollateral = assets.minus(liabilities);
|
|
18220
|
-
return _clamped ?
|
|
18220
|
+
return _clamped ? BigNumber3__default.default.max(0, signedFreeCollateral) : signedFreeCollateral;
|
|
18221
18221
|
}
|
|
18222
18222
|
function computeFreeCollateralFromBalances(params) {
|
|
18223
18223
|
const {
|
|
@@ -18237,7 +18237,7 @@ function computeFreeCollateralFromBalances(params) {
|
|
|
18237
18237
|
marginRequirement: 0 /* Initial */
|
|
18238
18238
|
});
|
|
18239
18239
|
const signedFreeCollateral = assets.minus(liabilities);
|
|
18240
|
-
return clamped ?
|
|
18240
|
+
return clamped ? BigNumber3__default.default.max(0, signedFreeCollateral) : signedFreeCollateral;
|
|
18241
18241
|
}
|
|
18242
18242
|
function computeHealthComponentsFromCache(marginfiAccount, marginRequirement) {
|
|
18243
18243
|
if (marginfiAccount.healthCache.simulationStatus === 0 /* UNSET */) {
|
|
@@ -18276,8 +18276,8 @@ function computeHealthComponentsFromBalances(params) {
|
|
|
18276
18276
|
const filteredBalances = activeBalances.filter(
|
|
18277
18277
|
(accountBalance) => !(excludedBanks ?? []).find((b) => b.equals(accountBalance.bankPk))
|
|
18278
18278
|
);
|
|
18279
|
-
let totalAssets = new
|
|
18280
|
-
let totalLiabilities = new
|
|
18279
|
+
let totalAssets = new BigNumber3__default.default(0);
|
|
18280
|
+
let totalLiabilities = new BigNumber3__default.default(0);
|
|
18281
18281
|
for (const accountBalance of filteredBalances) {
|
|
18282
18282
|
const bankKey = accountBalance.bankPk.toBase58();
|
|
18283
18283
|
const bank = banksMap.get(bankKey);
|
|
@@ -18297,11 +18297,11 @@ function computeHealthComponentsFromBalances(params) {
|
|
|
18297
18297
|
const emodeWeight = activeEmodeWeightsByBank?.get(bankKey);
|
|
18298
18298
|
const assetShareValueMultiplier = assetShareValueMultiplierByBank?.get(bankKey);
|
|
18299
18299
|
const activeEmodeWeights = emodeWeight ? {
|
|
18300
|
-
assetWeightInit:
|
|
18300
|
+
assetWeightInit: BigNumber3__default.default.max(
|
|
18301
18301
|
bank.config.assetWeightInit,
|
|
18302
18302
|
emodeWeight.assetWeightInit ?? bank.config.assetWeightInit
|
|
18303
18303
|
),
|
|
18304
|
-
assetWeightMaint:
|
|
18304
|
+
assetWeightMaint: BigNumber3__default.default.max(
|
|
18305
18305
|
bank.config.assetWeightMaint,
|
|
18306
18306
|
emodeWeight.assetWeightMaint ?? bank.config.assetWeightMaint
|
|
18307
18307
|
)
|
|
@@ -18332,8 +18332,8 @@ function computeHealthComponentsWithoutBiasFromBalances(params) {
|
|
|
18332
18332
|
const filteredBalances = activeBalances.filter(
|
|
18333
18333
|
(accountBalance) => !(excludedBanks ?? []).find((b) => b.equals(accountBalance.bankPk))
|
|
18334
18334
|
);
|
|
18335
|
-
let totalAssets = new
|
|
18336
|
-
let totalLiabilities = new
|
|
18335
|
+
let totalAssets = new BigNumber3__default.default(0);
|
|
18336
|
+
let totalLiabilities = new BigNumber3__default.default(0);
|
|
18337
18337
|
for (const accountBalance of filteredBalances) {
|
|
18338
18338
|
const bankKey = accountBalance.bankPk.toBase58();
|
|
18339
18339
|
const bank = banksMap.get(bankKey);
|
|
@@ -18353,11 +18353,11 @@ function computeHealthComponentsWithoutBiasFromBalances(params) {
|
|
|
18353
18353
|
const emodeWeight = activeEmodeWeightsByBank?.get(bankKey);
|
|
18354
18354
|
const assetShareValueMultiplier = assetShareValueMultiplierByBank?.get(bankKey);
|
|
18355
18355
|
const activeEmodeWeights = emodeWeight ? {
|
|
18356
|
-
assetWeightInit:
|
|
18356
|
+
assetWeightInit: BigNumber3__default.default.max(
|
|
18357
18357
|
bank.config.assetWeightInit,
|
|
18358
18358
|
emodeWeight.assetWeightInit ?? bank.config.assetWeightInit
|
|
18359
18359
|
),
|
|
18360
|
-
assetWeightMaint:
|
|
18360
|
+
assetWeightMaint: BigNumber3__default.default.max(
|
|
18361
18361
|
bank.config.assetWeightMaint,
|
|
18362
18362
|
emodeWeight.assetWeightMaint ?? bank.config.assetWeightMaint
|
|
18363
18363
|
)
|
|
@@ -18414,7 +18414,7 @@ function computeHealthCacheStatus(params) {
|
|
|
18414
18414
|
liabilityValueMaint,
|
|
18415
18415
|
assetValueEquity,
|
|
18416
18416
|
liabilityValueEquity,
|
|
18417
|
-
timestamp: new
|
|
18417
|
+
timestamp: new BigNumber3__default.default(0),
|
|
18418
18418
|
flags: [],
|
|
18419
18419
|
prices: [],
|
|
18420
18420
|
simulationStatus: 2 /* COMPUTED */
|
|
@@ -18461,9 +18461,9 @@ function createEmptyBalance(bankPk) {
|
|
|
18461
18461
|
const balance = {
|
|
18462
18462
|
active: false,
|
|
18463
18463
|
bankPk,
|
|
18464
|
-
assetShares: new
|
|
18465
|
-
liabilityShares: new
|
|
18466
|
-
emissionsOutstanding: new
|
|
18464
|
+
assetShares: new BigNumber3__default.default(0),
|
|
18465
|
+
liabilityShares: new BigNumber3__default.default(0),
|
|
18466
|
+
emissionsOutstanding: new BigNumber3__default.default(0),
|
|
18467
18467
|
lastUpdate: 0
|
|
18468
18468
|
};
|
|
18469
18469
|
return balance;
|
|
@@ -18534,7 +18534,7 @@ function computeNetApy(params) {
|
|
|
18534
18534
|
}).assets
|
|
18535
18535
|
).div(totalUsdValue.isEqualTo(0) ? 1 : totalUsdValue)
|
|
18536
18536
|
);
|
|
18537
|
-
}, new
|
|
18537
|
+
}, new BigNumber3__default.default(0)).toNumber();
|
|
18538
18538
|
return aprToApy(apr);
|
|
18539
18539
|
}
|
|
18540
18540
|
function computeLiquidationPriceForBank(params) {
|
|
@@ -18594,13 +18594,13 @@ function computeClaimedEmissions(balance, bank, currentTimestamp) {
|
|
|
18594
18594
|
}
|
|
18595
18595
|
if (balanceAmount) {
|
|
18596
18596
|
const lastUpdate = balance.lastUpdate;
|
|
18597
|
-
const period = new
|
|
18598
|
-
const emissionsRate = new
|
|
18597
|
+
const period = new BigNumber3__default.default(currentTimestamp - lastUpdate);
|
|
18598
|
+
const emissionsRate = new BigNumber3__default.default(bank.emissionsRate);
|
|
18599
18599
|
const emissions = period.times(balanceAmount).times(emissionsRate).div(31536e3 * Math.pow(10, bank.mintDecimals));
|
|
18600
|
-
const emissionsReal =
|
|
18600
|
+
const emissionsReal = BigNumber3__default.default.min(emissions, new BigNumber3__default.default(bank.emissionsRemaining));
|
|
18601
18601
|
return emissionsReal;
|
|
18602
18602
|
}
|
|
18603
|
-
return new
|
|
18603
|
+
return new BigNumber3__default.default(0);
|
|
18604
18604
|
}
|
|
18605
18605
|
function computeTotalOutstandingEmissions(balance, bank) {
|
|
18606
18606
|
const claimedEmissions = balance.emissionsOutstanding;
|
|
@@ -18722,9 +18722,9 @@ function computeProjectedActiveBalancesNoCpi(balances, instructions2, program, b
|
|
|
18722
18722
|
let projectedBalances = balances.map((b) => ({
|
|
18723
18723
|
active: b.active,
|
|
18724
18724
|
bankPk: b.bankPk,
|
|
18725
|
-
assetShares: new
|
|
18726
|
-
liabilityShares: new
|
|
18727
|
-
emissionsOutstanding: new
|
|
18725
|
+
assetShares: new BigNumber3__default.default(b.assetShares),
|
|
18726
|
+
liabilityShares: new BigNumber3__default.default(b.liabilityShares),
|
|
18727
|
+
emissionsOutstanding: new BigNumber3__default.default(b.emissionsOutstanding),
|
|
18728
18728
|
lastUpdate: b.lastUpdate
|
|
18729
18729
|
}));
|
|
18730
18730
|
const impactedAssetsBanks = /* @__PURE__ */ new Set();
|
|
@@ -18753,15 +18753,15 @@ function computeProjectedActiveBalancesNoCpi(balances, instructions2, program, b
|
|
|
18753
18753
|
targetBalance = projectedBalances[firstInactiveBalanceIndex];
|
|
18754
18754
|
targetBalance.active = true;
|
|
18755
18755
|
targetBalance.bankPk = targetBank;
|
|
18756
|
-
targetBalance.assetShares = new
|
|
18757
|
-
targetBalance.liabilityShares = new
|
|
18756
|
+
targetBalance.assetShares = new BigNumber3__default.default(0);
|
|
18757
|
+
targetBalance.liabilityShares = new BigNumber3__default.default(0);
|
|
18758
18758
|
}
|
|
18759
|
-
const depositTokenAmount = new
|
|
18759
|
+
const depositTokenAmount = new BigNumber3__default.default(ixArgs.amount?.toString() || "0");
|
|
18760
18760
|
const bank = banksMap.get(targetBank.toBase58());
|
|
18761
18761
|
if (!bank) {
|
|
18762
18762
|
throw Error(`Bank ${targetBank.toBase58()} not found in bankMap`);
|
|
18763
18763
|
}
|
|
18764
|
-
const assetShareValueMultiplier = assetShareValueMultiplierByBank.get(targetBank.toBase58()) ??
|
|
18764
|
+
const assetShareValueMultiplier = assetShareValueMultiplierByBank.get(targetBank.toBase58()) ?? BigNumber3__default.default(1);
|
|
18765
18765
|
const cTokenAmount = depositTokenAmount.div(assetShareValueMultiplier);
|
|
18766
18766
|
const depositShares = getAssetShares(bank, cTokenAmount);
|
|
18767
18767
|
targetBalance.assetShares = targetBalance.assetShares.plus(depositShares);
|
|
@@ -18779,10 +18779,10 @@ function computeProjectedActiveBalancesNoCpi(balances, instructions2, program, b
|
|
|
18779
18779
|
targetBalance = projectedBalances[firstInactiveBalanceIndex];
|
|
18780
18780
|
targetBalance.active = true;
|
|
18781
18781
|
targetBalance.bankPk = targetBank;
|
|
18782
|
-
targetBalance.assetShares = new
|
|
18783
|
-
targetBalance.liabilityShares = new
|
|
18782
|
+
targetBalance.assetShares = new BigNumber3__default.default(0);
|
|
18783
|
+
targetBalance.liabilityShares = new BigNumber3__default.default(0);
|
|
18784
18784
|
}
|
|
18785
|
-
const borrowTokenAmount = new
|
|
18785
|
+
const borrowTokenAmount = new BigNumber3__default.default(ixArgs.amount?.toString() || "0");
|
|
18786
18786
|
const bank = banksMap.get(targetBank.toBase58());
|
|
18787
18787
|
if (!bank) {
|
|
18788
18788
|
throw Error(`Bank ${targetBank.toBase58()} not found in bankMap`);
|
|
@@ -18802,19 +18802,19 @@ function computeProjectedActiveBalancesNoCpi(balances, instructions2, program, b
|
|
|
18802
18802
|
);
|
|
18803
18803
|
}
|
|
18804
18804
|
if (ixArgs.repayAll) {
|
|
18805
|
-
targetBalance.liabilityShares = new
|
|
18805
|
+
targetBalance.liabilityShares = new BigNumber3__default.default(0);
|
|
18806
18806
|
if (targetBalance.assetShares.eq(0)) {
|
|
18807
18807
|
targetBalance.active = false;
|
|
18808
18808
|
targetBalance.bankPk = web3_js.PublicKey.default;
|
|
18809
18809
|
}
|
|
18810
18810
|
} else {
|
|
18811
|
-
const repayTokenAmount = new
|
|
18811
|
+
const repayTokenAmount = new BigNumber3__default.default(ixArgs.amount?.toString() || "0");
|
|
18812
18812
|
const bank = banksMap.get(targetBank.toBase58());
|
|
18813
18813
|
if (!bank) {
|
|
18814
18814
|
throw Error(`Bank ${targetBank.toBase58()} not found in bankMap`);
|
|
18815
18815
|
}
|
|
18816
18816
|
const repayShares = getLiabilityShares(bank, repayTokenAmount);
|
|
18817
|
-
targetBalance.liabilityShares =
|
|
18817
|
+
targetBalance.liabilityShares = BigNumber3__default.default.max(
|
|
18818
18818
|
0,
|
|
18819
18819
|
targetBalance.liabilityShares.minus(repayShares)
|
|
18820
18820
|
);
|
|
@@ -18838,19 +18838,19 @@ function computeProjectedActiveBalancesNoCpi(balances, instructions2, program, b
|
|
|
18838
18838
|
);
|
|
18839
18839
|
}
|
|
18840
18840
|
if (ixArgs.withdrawAll) {
|
|
18841
|
-
targetBalance.assetShares = new
|
|
18841
|
+
targetBalance.assetShares = new BigNumber3__default.default(0);
|
|
18842
18842
|
if (targetBalance.liabilityShares.eq(0)) {
|
|
18843
18843
|
targetBalance.active = false;
|
|
18844
18844
|
targetBalance.bankPk = web3_js.PublicKey.default;
|
|
18845
18845
|
}
|
|
18846
18846
|
} else {
|
|
18847
|
-
const withdrawTokenAmount = new
|
|
18847
|
+
const withdrawTokenAmount = new BigNumber3__default.default(ixArgs.amount?.toString() || "0");
|
|
18848
18848
|
const bank = banksMap.get(targetBank.toBase58());
|
|
18849
18849
|
if (!bank) {
|
|
18850
18850
|
throw Error(`Bank ${targetBank.toBase58()} not found in bankMap`);
|
|
18851
18851
|
}
|
|
18852
18852
|
const withdrawShares = getAssetShares(bank, withdrawTokenAmount);
|
|
18853
|
-
targetBalance.assetShares =
|
|
18853
|
+
targetBalance.assetShares = BigNumber3__default.default.max(
|
|
18854
18854
|
0,
|
|
18855
18855
|
targetBalance.assetShares.minus(withdrawShares)
|
|
18856
18856
|
);
|
|
@@ -33711,7 +33711,7 @@ async function makePulseHealthIx2(program, marginfiAccountPk, banks, balances, m
|
|
|
33711
33711
|
return { instructions: [ix], keys: [] };
|
|
33712
33712
|
}
|
|
33713
33713
|
function generateDummyAccount(group, authority, accountKey) {
|
|
33714
|
-
const dummyWrappedI80F48 = bigNumberToWrappedI80F48(new
|
|
33714
|
+
const dummyWrappedI80F48 = bigNumberToWrappedI80F48(new BigNumber3__default.default(0));
|
|
33715
33715
|
const dummyBalances = Array(15).fill({
|
|
33716
33716
|
active: false,
|
|
33717
33717
|
bankPk: new web3_js.PublicKey("11111111111111111111111111111111"),
|
|
@@ -33734,10 +33734,10 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
33734
33734
|
timestamp: new BN11__default.default(0),
|
|
33735
33735
|
flags: 0,
|
|
33736
33736
|
prices: [],
|
|
33737
|
-
assetValueMaint: bigNumberToWrappedI80F48(new
|
|
33738
|
-
liabilityValueMaint: bigNumberToWrappedI80F48(new
|
|
33739
|
-
assetValueEquity: bigNumberToWrappedI80F48(new
|
|
33740
|
-
liabilityValueEquity: bigNumberToWrappedI80F48(new
|
|
33737
|
+
assetValueMaint: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
33738
|
+
liabilityValueMaint: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
33739
|
+
assetValueEquity: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
33740
|
+
liabilityValueEquity: bigNumberToWrappedI80F48(new BigNumber3__default.default(0)),
|
|
33741
33741
|
errIndex: 0,
|
|
33742
33742
|
internalErr: 0,
|
|
33743
33743
|
internalBankruptcyErr: 0,
|
|
@@ -42352,8 +42352,8 @@ async function makeKaminoWithdrawTx(params) {
|
|
|
42352
42352
|
throw new Error("Bank has no kamino integration accounts");
|
|
42353
42353
|
}
|
|
42354
42354
|
const { value: amountValue, type: amountType } = resolveAmount(amount);
|
|
42355
|
-
const multiplier = assetShareValueMultiplierByBank.get(withdrawIxParams.bank.address.toBase58()) ?? new
|
|
42356
|
-
const adjustedAmount = amountType === "cToken" ? new
|
|
42355
|
+
const multiplier = assetShareValueMultiplierByBank.get(withdrawIxParams.bank.address.toBase58()) ?? new BigNumber3.BigNumber(1);
|
|
42356
|
+
const adjustedAmount = amountType === "cToken" ? new BigNumber3.BigNumber(amountValue).toNumber() : new BigNumber3.BigNumber(amountValue).div(multiplier).toNumber();
|
|
42357
42357
|
const refreshIxs = makeRefreshKaminoBanksIxs(
|
|
42358
42358
|
params.marginfiAccount,
|
|
42359
42359
|
params.bankMap,
|
|
@@ -42595,7 +42595,7 @@ async function makeDriftDepositIx3({
|
|
|
42595
42595
|
const depositIxs = [];
|
|
42596
42596
|
const userTokenAtaPk = getAssociatedTokenAddressSync(bank.mint, authority, true, tokenProgram);
|
|
42597
42597
|
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
42598
|
-
depositIxs.push(...makeWrapSolIxs(authority, new
|
|
42598
|
+
depositIxs.push(...makeWrapSolIxs(authority, new BigNumber3__default.default(amount).minus(wSolBalanceUi)));
|
|
42599
42599
|
}
|
|
42600
42600
|
const driftState = deriveDriftState()[0];
|
|
42601
42601
|
const driftSpotMarketVault = deriveDriftSpotMarketVault(driftMarketIndex)[0];
|
|
@@ -42705,7 +42705,7 @@ async function makeKaminoDepositIx3({
|
|
|
42705
42705
|
const reserveDestinationDepositCollateral = reserve.collateral.supplyVault;
|
|
42706
42706
|
const { lendingMarketAuthority } = getAllDerivedKaminoAccounts(reserve.lendingMarket, bank.mint);
|
|
42707
42707
|
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
42708
|
-
depositIxs.push(...makeWrapSolIxs(authority, new
|
|
42708
|
+
depositIxs.push(...makeWrapSolIxs(authority, new BigNumber3__default.default(amount).minus(wSolBalanceUi)));
|
|
42709
42709
|
}
|
|
42710
42710
|
const reserveFarm = !reserve.farmCollateral.equals(
|
|
42711
42711
|
new web3_js.PublicKey("11111111111111111111111111111111")
|
|
@@ -42834,7 +42834,7 @@ async function makeDepositIx3({
|
|
|
42834
42834
|
const remainingAccounts = tokenProgram.equals(TOKEN_2022_PROGRAM_ID) ? [{ pubkey: bank.mint, isSigner: false, isWritable: false }] : [];
|
|
42835
42835
|
const depositIxs = [];
|
|
42836
42836
|
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
42837
|
-
depositIxs.push(...makeWrapSolIxs(authority, new
|
|
42837
|
+
depositIxs.push(...makeWrapSolIxs(authority, new BigNumber3__default.default(amount).minus(wSolBalanceUi)));
|
|
42838
42838
|
}
|
|
42839
42839
|
const depositIx = isSync ? sync_instructions_default.makeDepositIx(
|
|
42840
42840
|
program.programId,
|
|
@@ -43049,7 +43049,7 @@ async function makeLoopTx(params) {
|
|
|
43049
43049
|
let additionalTxs = [];
|
|
43050
43050
|
if (depositOpts.depositBank.mint.equals(NATIVE_MINT) && depositOpts.inputDepositAmount) {
|
|
43051
43051
|
setupIxs.push(
|
|
43052
|
-
...makeWrapSolIxs(marginfiAccount.authority, new
|
|
43052
|
+
...makeWrapSolIxs(marginfiAccount.authority, new BigNumber3.BigNumber(depositOpts.inputDepositAmount))
|
|
43053
43053
|
);
|
|
43054
43054
|
}
|
|
43055
43055
|
if (setupIxs.length > 0 || additionalIxs.length > 0 || kaminoRefreshIxs.instructions.length > 0 || updateDriftMarketIxs.instructions.length > 0) {
|
|
@@ -43307,7 +43307,7 @@ async function makeRepayIx3({
|
|
|
43307
43307
|
const userAta = getAssociatedTokenAddressSync(bank.mint, authority, true, tokenProgram);
|
|
43308
43308
|
const remainingAccounts = tokenProgram.equals(TOKEN_2022_PROGRAM_ID) ? [{ pubkey: bank.mint, isSigner: false, isWritable: false }] : [];
|
|
43309
43309
|
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
43310
|
-
repayIxs.push(...makeWrapSolIxs(authority, new
|
|
43310
|
+
repayIxs.push(...makeWrapSolIxs(authority, new BigNumber3.BigNumber(amount).minus(wSolBalanceUi)));
|
|
43311
43311
|
}
|
|
43312
43312
|
const repayIx = !isSync || !opts.overrideInferAccounts?.group ? await instructions_default.makeRepayIx(
|
|
43313
43313
|
program,
|
|
@@ -43537,8 +43537,8 @@ async function buildRepayWithCollatFlashloanTx({
|
|
|
43537
43537
|
withdrawOpts.withdrawBank.tokenSymbol
|
|
43538
43538
|
);
|
|
43539
43539
|
}
|
|
43540
|
-
const multiplier = assetShareValueMultiplierByBank.get(withdrawOpts.withdrawBank.address.toBase58()) ?? new
|
|
43541
|
-
const adjustedAmount = new
|
|
43540
|
+
const multiplier = assetShareValueMultiplierByBank.get(withdrawOpts.withdrawBank.address.toBase58()) ?? new BigNumber3.BigNumber(1);
|
|
43541
|
+
const adjustedAmount = new BigNumber3.BigNumber(withdrawOpts.withdrawAmount).div(multiplier).times(1.0001).toNumber();
|
|
43542
43542
|
withdrawIxs = await makeKaminoWithdrawIx3({
|
|
43543
43543
|
program,
|
|
43544
43544
|
bank: withdrawOpts.withdrawBank,
|
|
@@ -43875,8 +43875,8 @@ async function buildSwapCollateralFlashloanTx({
|
|
|
43875
43875
|
withdrawOpts.withdrawBank.tokenSymbol
|
|
43876
43876
|
);
|
|
43877
43877
|
}
|
|
43878
|
-
const multiplier = assetShareValueMultiplierByBank.get(withdrawOpts.withdrawBank.address.toBase58()) ?? new
|
|
43879
|
-
const adjustedAmount = new
|
|
43878
|
+
const multiplier = assetShareValueMultiplierByBank.get(withdrawOpts.withdrawBank.address.toBase58()) ?? new BigNumber3.BigNumber(1);
|
|
43879
|
+
const adjustedAmount = new BigNumber3.BigNumber(actualWithdrawAmount).div(multiplier).times(1.0001).toNumber();
|
|
43880
43880
|
withdrawIxs = await makeKaminoWithdrawIx3({
|
|
43881
43881
|
program,
|
|
43882
43882
|
bank: withdrawBank,
|
|
@@ -44445,7 +44445,7 @@ async function simulateAccountHealthCacheWithFallback(params) {
|
|
|
44445
44445
|
liabilityValueMaint,
|
|
44446
44446
|
assetValueEquity,
|
|
44447
44447
|
liabilityValueEquity,
|
|
44448
|
-
timestamp: new
|
|
44448
|
+
timestamp: new BigNumber3__default.default(0),
|
|
44449
44449
|
flags: [],
|
|
44450
44450
|
prices: [],
|
|
44451
44451
|
simulationStatus: 2 /* COMPUTED */
|
|
@@ -44859,7 +44859,7 @@ function computeMaxBorrowForBank(params) {
|
|
|
44859
44859
|
(b) => b.config.riskTier === "Isolated" /* Isolated */ && !b.address.equals(bankAddress)
|
|
44860
44860
|
);
|
|
44861
44861
|
if (attemptingToBorrowIsolatedAssetWithActiveDebt || attemptingToBorrowNewAssetWithExistingIsolatedDebt) {
|
|
44862
|
-
return new
|
|
44862
|
+
return new BigNumber3__default.default(0);
|
|
44863
44863
|
}
|
|
44864
44864
|
const _volatilityFactor = volatilityFactor ?? 1;
|
|
44865
44865
|
const balance = getBalance(bankAddress, activeBalances);
|
|
@@ -44871,7 +44871,7 @@ function computeMaxBorrowForBank(params) {
|
|
|
44871
44871
|
activeEmodeWeightsByBank,
|
|
44872
44872
|
assetShareValueMultiplierByBank
|
|
44873
44873
|
}).times(_volatilityFactor);
|
|
44874
|
-
const untiedCollateralForBank =
|
|
44874
|
+
const untiedCollateralForBank = BigNumber3__default.default.min(
|
|
44875
44875
|
computeAssetUsdValue({
|
|
44876
44876
|
bank,
|
|
44877
44877
|
oraclePrice,
|
|
@@ -44970,7 +44970,7 @@ function computeMaxWithdrawForBank(params) {
|
|
|
44970
44970
|
);
|
|
44971
44971
|
if (bank.config.riskTier === "Isolated" /* Isolated */ || initAssetWeight.isZero() && maintAssetWeight.isZero()) {
|
|
44972
44972
|
if (freeCollateral.isZero() && !liabilitiesInit.isZero()) {
|
|
44973
|
-
return new
|
|
44973
|
+
return new BigNumber3__default.default(0);
|
|
44974
44974
|
} else {
|
|
44975
44975
|
return entireBalance;
|
|
44976
44976
|
}
|
|
@@ -44979,7 +44979,7 @@ function computeMaxWithdrawForBank(params) {
|
|
|
44979
44979
|
if (liabilitiesInit.eq(0)) {
|
|
44980
44980
|
return entireBalance;
|
|
44981
44981
|
} else if (freeCollateral.isZero()) {
|
|
44982
|
-
return new
|
|
44982
|
+
return new BigNumber3__default.default(0);
|
|
44983
44983
|
} else {
|
|
44984
44984
|
const { liabilities: maintLiabilities, assets: maintAssets } = computeHealthComponentsFromCache(account, 1 /* Maintenance */);
|
|
44985
44985
|
const maintUntiedCollateral = maintAssets.minus(maintLiabilities);
|
|
@@ -45344,9 +45344,7 @@ async function computeSmartCrank({
|
|
|
45344
45344
|
};
|
|
45345
45345
|
}
|
|
45346
45346
|
async function makeSmartCrankSwbFeedIx(params) {
|
|
45347
|
-
console.log("[makeSmartCrankSwbFeedIx] Called");
|
|
45348
45347
|
const crankResult = await computeSmartCrank(params);
|
|
45349
|
-
console.log("[makeSmartCrankSwbFeedIx] Crank result:", crankResult);
|
|
45350
45348
|
if (crankResult.uncrankableLiabilities.length > 0) {
|
|
45351
45349
|
console.log(
|
|
45352
45350
|
"Uncrankable liability details:",
|
|
@@ -45382,7 +45380,6 @@ async function makeSmartCrankSwbFeedIx(params) {
|
|
|
45382
45380
|
);
|
|
45383
45381
|
}
|
|
45384
45382
|
const oraclesToCrank = crankResult.requiredOracles;
|
|
45385
|
-
console.log("[makeSmartCrankSwbFeedIx] Oracles to crank:", oraclesToCrank);
|
|
45386
45383
|
const { instructions: instructions2, luts } = await makeUpdateSwbFeedIx({
|
|
45387
45384
|
swbPullOracles: oraclesToCrank,
|
|
45388
45385
|
feePayer: params.marginfiAccount.authority,
|
|
@@ -45419,9 +45416,6 @@ async function makeCrankSwbFeedIx(marginfiAccount, bankMap, newBanksPk, provider
|
|
|
45419
45416
|
}
|
|
45420
45417
|
}
|
|
45421
45418
|
async function makeUpdateSwbFeedIx(props) {
|
|
45422
|
-
console.log(
|
|
45423
|
-
`[makeUpdateSwbFeedIx] Called with ${props.swbPullOracles.length} oracles, feePayer: ${props.feePayer.toBase58()}`
|
|
45424
|
-
);
|
|
45425
45419
|
const seen = /* @__PURE__ */ new Set();
|
|
45426
45420
|
const uniqueOracles = props.swbPullOracles.filter((oracle) => {
|
|
45427
45421
|
const key = oracle.key.toBase58();
|
|
@@ -45429,21 +45423,12 @@ async function makeUpdateSwbFeedIx(props) {
|
|
|
45429
45423
|
seen.add(key);
|
|
45430
45424
|
return true;
|
|
45431
45425
|
});
|
|
45432
|
-
console.log(
|
|
45433
|
-
`[makeUpdateSwbFeedIx] ${uniqueOracles.length} unique oracles after dedup (removed ${props.swbPullOracles.length - uniqueOracles.length})`
|
|
45434
|
-
);
|
|
45435
|
-
uniqueOracles.forEach(
|
|
45436
|
-
(o) => console.log(
|
|
45437
|
-
`[makeUpdateSwbFeedIx] - ${o.key.toBase58()} (hasSwitchboardData: ${!!o.price?.switchboardData})`
|
|
45438
|
-
)
|
|
45439
|
-
);
|
|
45440
45426
|
const swbProgram = await onDemand.AnchorUtils.loadProgramFromConnection(props.connection);
|
|
45441
45427
|
const pullFeedInstances = uniqueOracles.map((oracle) => {
|
|
45442
45428
|
const pullFeed = new onDemand.PullFeed(swbProgram, oracle.key);
|
|
45443
45429
|
return pullFeed;
|
|
45444
45430
|
});
|
|
45445
45431
|
if (pullFeedInstances.length === 0) {
|
|
45446
|
-
console.log(`[makeUpdateSwbFeedIx] No pull feed instances, returning early`);
|
|
45447
45432
|
return { instructions: [], luts: [] };
|
|
45448
45433
|
}
|
|
45449
45434
|
const crossbarClient = new common.CrossbarClient(
|
|
@@ -45465,7 +45450,6 @@ async function makeUpdateSwbFeedIx(props) {
|
|
|
45465
45450
|
payer: props.feePayer,
|
|
45466
45451
|
crossbarClient
|
|
45467
45452
|
});
|
|
45468
|
-
console.log(`[makeUpdateSwbFeedIx] Got ${pullIx.length} instructions, ${luts.length} LUTs`);
|
|
45469
45453
|
return { instructions: pullIx, luts };
|
|
45470
45454
|
}
|
|
45471
45455
|
|
|
@@ -45807,18 +45791,18 @@ var fetchPythOraclePricesFromAPI = async (pythOracleKeys, apiEndpoint, opts) =>
|
|
|
45807
45791
|
key,
|
|
45808
45792
|
{
|
|
45809
45793
|
priceRealtime: {
|
|
45810
|
-
price:
|
|
45811
|
-
confidence:
|
|
45812
|
-
lowestPrice:
|
|
45813
|
-
highestPrice:
|
|
45794
|
+
price: BigNumber3__default.default(oraclePrice.priceRealtime.price),
|
|
45795
|
+
confidence: BigNumber3__default.default(oraclePrice.priceRealtime.confidence),
|
|
45796
|
+
lowestPrice: BigNumber3__default.default(oraclePrice.priceRealtime.lowestPrice),
|
|
45797
|
+
highestPrice: BigNumber3__default.default(oraclePrice.priceRealtime.highestPrice)
|
|
45814
45798
|
},
|
|
45815
45799
|
priceWeighted: {
|
|
45816
|
-
price:
|
|
45817
|
-
confidence:
|
|
45818
|
-
lowestPrice:
|
|
45819
|
-
highestPrice:
|
|
45800
|
+
price: BigNumber3__default.default(oraclePrice.priceWeighted.price),
|
|
45801
|
+
confidence: BigNumber3__default.default(oraclePrice.priceWeighted.confidence),
|
|
45802
|
+
lowestPrice: BigNumber3__default.default(oraclePrice.priceWeighted.lowestPrice),
|
|
45803
|
+
highestPrice: BigNumber3__default.default(oraclePrice.priceWeighted.highestPrice)
|
|
45820
45804
|
},
|
|
45821
|
-
timestamp: oraclePrice.timestamp ?
|
|
45805
|
+
timestamp: oraclePrice.timestamp ? BigNumber3__default.default(oraclePrice.timestamp) : null
|
|
45822
45806
|
}
|
|
45823
45807
|
])
|
|
45824
45808
|
);
|
|
@@ -45833,22 +45817,22 @@ var fetchPythOraclePricesFromChain = async (requestedPythOracleKeys, connection)
|
|
|
45833
45817
|
const oracleKey = requestedPythOracleKeys[index];
|
|
45834
45818
|
const priceDataRaw = oracleAis[index];
|
|
45835
45819
|
let oraclePrice = priceDataRaw && parseRpcPythPriceData(priceDataRaw.data);
|
|
45836
|
-
if (!oraclePrice || oraclePrice.priceRealtime.price.eq(new
|
|
45820
|
+
if (!oraclePrice || oraclePrice.priceRealtime.price.eq(new BigNumber3__default.default(0))) {
|
|
45837
45821
|
oraclePrice = {
|
|
45838
45822
|
...oraclePrice,
|
|
45839
45823
|
priceRealtime: {
|
|
45840
|
-
price: new
|
|
45841
|
-
confidence: new
|
|
45842
|
-
lowestPrice: new
|
|
45843
|
-
highestPrice: new
|
|
45824
|
+
price: new BigNumber3__default.default(0),
|
|
45825
|
+
confidence: new BigNumber3__default.default(0),
|
|
45826
|
+
lowestPrice: new BigNumber3__default.default(0),
|
|
45827
|
+
highestPrice: new BigNumber3__default.default(0)
|
|
45844
45828
|
},
|
|
45845
45829
|
priceWeighted: {
|
|
45846
|
-
price: new
|
|
45847
|
-
confidence: new
|
|
45848
|
-
lowestPrice: new
|
|
45849
|
-
highestPrice: new
|
|
45830
|
+
price: new BigNumber3__default.default(0),
|
|
45831
|
+
confidence: new BigNumber3__default.default(0),
|
|
45832
|
+
lowestPrice: new BigNumber3__default.default(0),
|
|
45833
|
+
highestPrice: new BigNumber3__default.default(0)
|
|
45850
45834
|
},
|
|
45851
|
-
timestamp: new
|
|
45835
|
+
timestamp: new BigNumber3__default.default(Date.now())
|
|
45852
45836
|
};
|
|
45853
45837
|
}
|
|
45854
45838
|
updatedOraclePriceByKey[oracleKey] = oraclePrice;
|
|
@@ -46125,17 +46109,17 @@ function handleFixedOracleBanks(banks) {
|
|
|
46125
46109
|
const fixedOraclePrice = {
|
|
46126
46110
|
priceRealtime: {
|
|
46127
46111
|
price: fixedPrice,
|
|
46128
|
-
confidence:
|
|
46112
|
+
confidence: BigNumber3__default.default(0),
|
|
46129
46113
|
lowestPrice: fixedPrice,
|
|
46130
46114
|
highestPrice: fixedPrice
|
|
46131
46115
|
},
|
|
46132
46116
|
priceWeighted: {
|
|
46133
46117
|
price: fixedPrice,
|
|
46134
|
-
confidence:
|
|
46118
|
+
confidence: BigNumber3__default.default(0),
|
|
46135
46119
|
lowestPrice: fixedPrice,
|
|
46136
46120
|
highestPrice: fixedPrice
|
|
46137
46121
|
},
|
|
46138
|
-
timestamp:
|
|
46122
|
+
timestamp: BigNumber3__default.default(Date.now())
|
|
46139
46123
|
};
|
|
46140
46124
|
oracleMap.set(bank.address.toBase58(), fixedOraclePrice);
|
|
46141
46125
|
});
|
|
@@ -46146,18 +46130,18 @@ function handleZeroOracleBanks(banks) {
|
|
|
46146
46130
|
banks.forEach((bank) => {
|
|
46147
46131
|
const zeroOraclePrice = {
|
|
46148
46132
|
priceRealtime: {
|
|
46149
|
-
price:
|
|
46150
|
-
confidence:
|
|
46151
|
-
lowestPrice:
|
|
46152
|
-
highestPrice:
|
|
46133
|
+
price: BigNumber3__default.default(0),
|
|
46134
|
+
confidence: BigNumber3__default.default(0),
|
|
46135
|
+
lowestPrice: BigNumber3__default.default(0),
|
|
46136
|
+
highestPrice: BigNumber3__default.default(0)
|
|
46153
46137
|
},
|
|
46154
46138
|
priceWeighted: {
|
|
46155
|
-
price:
|
|
46156
|
-
confidence:
|
|
46157
|
-
lowestPrice:
|
|
46158
|
-
highestPrice:
|
|
46139
|
+
price: BigNumber3__default.default(0),
|
|
46140
|
+
confidence: BigNumber3__default.default(0),
|
|
46141
|
+
lowestPrice: BigNumber3__default.default(0),
|
|
46142
|
+
highestPrice: BigNumber3__default.default(0)
|
|
46159
46143
|
},
|
|
46160
|
-
timestamp:
|
|
46144
|
+
timestamp: BigNumber3__default.default(Date.now())
|
|
46161
46145
|
};
|
|
46162
46146
|
oracleMap.set(bank.address.toBase58(), zeroOraclePrice);
|
|
46163
46147
|
});
|
|
@@ -46169,18 +46153,18 @@ function handleIsolatedAssetBanks(banks, staticPrices) {
|
|
|
46169
46153
|
const price = staticPrices?.[bank.address.toBase58()] ?? 0;
|
|
46170
46154
|
const oraclePrice = {
|
|
46171
46155
|
priceRealtime: {
|
|
46172
|
-
price:
|
|
46173
|
-
confidence:
|
|
46174
|
-
lowestPrice:
|
|
46175
|
-
highestPrice:
|
|
46156
|
+
price: BigNumber3__default.default(price),
|
|
46157
|
+
confidence: BigNumber3__default.default(0),
|
|
46158
|
+
lowestPrice: BigNumber3__default.default(price),
|
|
46159
|
+
highestPrice: BigNumber3__default.default(price)
|
|
46176
46160
|
},
|
|
46177
46161
|
priceWeighted: {
|
|
46178
|
-
price:
|
|
46179
|
-
confidence:
|
|
46180
|
-
lowestPrice:
|
|
46181
|
-
highestPrice:
|
|
46162
|
+
price: BigNumber3__default.default(price),
|
|
46163
|
+
confidence: BigNumber3__default.default(0),
|
|
46164
|
+
lowestPrice: BigNumber3__default.default(price),
|
|
46165
|
+
highestPrice: BigNumber3__default.default(price)
|
|
46182
46166
|
},
|
|
46183
|
-
timestamp:
|
|
46167
|
+
timestamp: BigNumber3__default.default(Date.now())
|
|
46184
46168
|
};
|
|
46185
46169
|
oracleMap.set(bank.address.toBase58(), oraclePrice);
|
|
46186
46170
|
});
|
|
@@ -46207,18 +46191,18 @@ async function handleAssetBanks(banks, opts) {
|
|
|
46207
46191
|
if (!oraclePrice) {
|
|
46208
46192
|
bankOraclePriceMap.set(bankAddress, {
|
|
46209
46193
|
priceRealtime: {
|
|
46210
|
-
price:
|
|
46211
|
-
confidence:
|
|
46212
|
-
lowestPrice:
|
|
46213
|
-
highestPrice:
|
|
46194
|
+
price: BigNumber3__default.default(0),
|
|
46195
|
+
confidence: BigNumber3__default.default(0),
|
|
46196
|
+
lowestPrice: BigNumber3__default.default(0),
|
|
46197
|
+
highestPrice: BigNumber3__default.default(0)
|
|
46214
46198
|
},
|
|
46215
46199
|
priceWeighted: {
|
|
46216
|
-
price:
|
|
46217
|
-
confidence:
|
|
46218
|
-
lowestPrice:
|
|
46219
|
-
highestPrice:
|
|
46200
|
+
price: BigNumber3__default.default(0),
|
|
46201
|
+
confidence: BigNumber3__default.default(0),
|
|
46202
|
+
lowestPrice: BigNumber3__default.default(0),
|
|
46203
|
+
highestPrice: BigNumber3__default.default(0)
|
|
46220
46204
|
},
|
|
46221
|
-
timestamp:
|
|
46205
|
+
timestamp: BigNumber3__default.default(Date.now())
|
|
46222
46206
|
});
|
|
46223
46207
|
}
|
|
46224
46208
|
});
|
|
@@ -46259,12 +46243,12 @@ function getAssetWeight(params) {
|
|
|
46259
46243
|
activeEmodeWeights,
|
|
46260
46244
|
ignoreSoftLimits
|
|
46261
46245
|
} = params;
|
|
46262
|
-
const assetWeightInit =
|
|
46263
|
-
activeEmodeWeights?.assetWeightInit ??
|
|
46246
|
+
const assetWeightInit = BigNumber3__default.default.max(
|
|
46247
|
+
activeEmodeWeights?.assetWeightInit ?? BigNumber3__default.default(0),
|
|
46264
46248
|
bank.config.assetWeightInit
|
|
46265
46249
|
);
|
|
46266
|
-
const assetWeightMaint =
|
|
46267
|
-
activeEmodeWeights?.assetWeightMaint ??
|
|
46250
|
+
const assetWeightMaint = BigNumber3__default.default.max(
|
|
46251
|
+
activeEmodeWeights?.assetWeightMaint ?? BigNumber3__default.default(0),
|
|
46268
46252
|
bank.config.assetWeightMaint
|
|
46269
46253
|
);
|
|
46270
46254
|
switch (marginRequirement) {
|
|
@@ -46288,7 +46272,7 @@ function getAssetWeight(params) {
|
|
|
46288
46272
|
case 1 /* Maintenance */:
|
|
46289
46273
|
return assetWeightMaint;
|
|
46290
46274
|
case 2 /* Equity */:
|
|
46291
|
-
return new
|
|
46275
|
+
return new BigNumber3__default.default(1);
|
|
46292
46276
|
default:
|
|
46293
46277
|
throw new Error("Invalid margin requirement type");
|
|
46294
46278
|
}
|
|
@@ -46300,7 +46284,7 @@ function getLiabilityWeight(config, marginRequirementType) {
|
|
|
46300
46284
|
case 1 /* Maintenance */:
|
|
46301
46285
|
return config.liabilityWeightMaint;
|
|
46302
46286
|
case 2 /* Equity */:
|
|
46303
|
-
return new
|
|
46287
|
+
return new BigNumber3__default.default(1);
|
|
46304
46288
|
default:
|
|
46305
46289
|
throw new Error("Invalid margin requirement type");
|
|
46306
46290
|
}
|
|
@@ -46328,17 +46312,17 @@ function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank
|
|
|
46328
46312
|
);
|
|
46329
46313
|
clampedLeverage = maxLeverage;
|
|
46330
46314
|
}
|
|
46331
|
-
const totalDepositAmount = initialCollateral.times(new
|
|
46315
|
+
const totalDepositAmount = initialCollateral.times(new BigNumber3__default.default(clampedLeverage));
|
|
46332
46316
|
const additionalDepositAmount = totalDepositAmount.minus(initialCollateral);
|
|
46333
46317
|
const totalBorrowAmount = additionalDepositAmount.times(depositOracleInfo.priceWeighted.lowestPrice).div(borrowOracleInfo.priceWeighted.highestPrice);
|
|
46334
46318
|
return {
|
|
46335
46319
|
totalBorrowAmount: totalBorrowAmount.decimalPlaces(
|
|
46336
46320
|
borrowBank.mintDecimals,
|
|
46337
|
-
|
|
46321
|
+
BigNumber3__default.default.ROUND_DOWN
|
|
46338
46322
|
),
|
|
46339
46323
|
totalDepositAmount: totalDepositAmount.decimalPlaces(
|
|
46340
46324
|
depositBank.mintDecimals,
|
|
46341
|
-
|
|
46325
|
+
BigNumber3__default.default.ROUND_DOWN
|
|
46342
46326
|
)
|
|
46343
46327
|
};
|
|
46344
46328
|
}
|
|
@@ -46349,7 +46333,7 @@ function computeUsdValue(params) {
|
|
|
46349
46333
|
quantity,
|
|
46350
46334
|
priceBias,
|
|
46351
46335
|
isWeightedPrice: isWeightedPrice2,
|
|
46352
|
-
weight = new
|
|
46336
|
+
weight = new BigNumber3__default.default(1),
|
|
46353
46337
|
scaleToBase = true,
|
|
46354
46338
|
assetShareValueMultiplier
|
|
46355
46339
|
} = params;
|
|
@@ -46484,16 +46468,16 @@ function computeInterestRates(bank) {
|
|
|
46484
46468
|
const baseInterestRate = computeBaseInterestRate(bank);
|
|
46485
46469
|
const utilizationRate = computeUtilizationRate(bank);
|
|
46486
46470
|
const lendingRate = baseInterestRate.times(utilizationRate);
|
|
46487
|
-
const borrowingRate = baseInterestRate.times(new
|
|
46471
|
+
const borrowingRate = baseInterestRate.times(new BigNumber3__default.default(1).plus(rateFee)).plus(fixedFee);
|
|
46488
46472
|
return { lendingRate, borrowingRate };
|
|
46489
46473
|
}
|
|
46490
46474
|
var U32_MAX = 4294967295;
|
|
46491
46475
|
function rateFromU32(rate) {
|
|
46492
|
-
const ratio = new
|
|
46476
|
+
const ratio = new BigNumber3__default.default(rate).div(U32_MAX);
|
|
46493
46477
|
return ratio.times(10);
|
|
46494
46478
|
}
|
|
46495
46479
|
function utilFromU32(util) {
|
|
46496
|
-
return new
|
|
46480
|
+
return new BigNumber3__default.default(util).div(U32_MAX);
|
|
46497
46481
|
}
|
|
46498
46482
|
function calculateRateBetweenPoints(startX, startY, endX, endY, targetX) {
|
|
46499
46483
|
if (endX.lte(startX)) return startY;
|
|
@@ -46512,15 +46496,15 @@ function computeLegacyCurve(utilizationRate, optimalUtilizationRate, plateauInte
|
|
|
46512
46496
|
if (utilizationRate.lte(optimalUtilizationRate)) {
|
|
46513
46497
|
return utilizationRate.times(plateauInterestRate).div(optimalUtilizationRate);
|
|
46514
46498
|
} else {
|
|
46515
|
-
return utilizationRate.minus(optimalUtilizationRate).div(new
|
|
46499
|
+
return utilizationRate.minus(optimalUtilizationRate).div(new BigNumber3__default.default(1).minus(optimalUtilizationRate)).times(maxInterestRate.minus(plateauInterestRate)).plus(plateauInterestRate);
|
|
46516
46500
|
}
|
|
46517
46501
|
}
|
|
46518
46502
|
function computeMultipointCurve(utilizationRate, zeroUtilRate, hundredUtilRate, points) {
|
|
46519
46503
|
const zeroRate = rateFromU32(zeroUtilRate);
|
|
46520
46504
|
const hundredRate = rateFromU32(hundredUtilRate);
|
|
46521
|
-
const clampedUtilizationRate =
|
|
46505
|
+
const clampedUtilizationRate = BigNumber3__default.default.max(0, BigNumber3__default.default.min(1, utilizationRate));
|
|
46522
46506
|
const nonPaddingPoints = points.filter((point) => point.util !== 0);
|
|
46523
|
-
let prevUtil = new
|
|
46507
|
+
let prevUtil = new BigNumber3__default.default(0);
|
|
46524
46508
|
let prevRate = zeroRate;
|
|
46525
46509
|
for (const point of nonPaddingPoints) {
|
|
46526
46510
|
const pointUtil = utilFromU32(point.util);
|
|
@@ -46540,7 +46524,7 @@ function computeMultipointCurve(utilizationRate, zeroUtilRate, hundredUtilRate,
|
|
|
46540
46524
|
return calculateRateBetweenPoints(
|
|
46541
46525
|
prevUtil,
|
|
46542
46526
|
prevRate,
|
|
46543
|
-
new
|
|
46527
|
+
new BigNumber3__default.default(1),
|
|
46544
46528
|
hundredRate,
|
|
46545
46529
|
clampedUtilizationRate
|
|
46546
46530
|
);
|
|
@@ -46568,16 +46552,16 @@ function computeBaseInterestRate(bank) {
|
|
|
46568
46552
|
function computeUtilizationRate(bank) {
|
|
46569
46553
|
const assets = getTotalAssetQuantity(bank);
|
|
46570
46554
|
const liabilities = getTotalLiabilityQuantity(bank);
|
|
46571
|
-
if (assets.isZero()) return new
|
|
46555
|
+
if (assets.isZero()) return new BigNumber3__default.default(0);
|
|
46572
46556
|
return liabilities.div(assets);
|
|
46573
46557
|
}
|
|
46574
46558
|
var SECONDS_PER_DAY = 24 * 60 * 60;
|
|
46575
46559
|
var SECONDS_PER_YEAR = SECONDS_PER_DAY * 365.25;
|
|
46576
46560
|
function computeRemainingCapacity(bank) {
|
|
46577
46561
|
const totalDeposits = getTotalAssetQuantity(bank);
|
|
46578
|
-
const remainingCapacity =
|
|
46562
|
+
const remainingCapacity = BigNumber3__default.default.max(0, bank.config.depositLimit.minus(totalDeposits));
|
|
46579
46563
|
const totalBorrows = getTotalLiabilityQuantity(bank);
|
|
46580
|
-
const remainingBorrowCapacity =
|
|
46564
|
+
const remainingBorrowCapacity = BigNumber3__default.default.max(0, bank.config.borrowLimit.minus(totalBorrows));
|
|
46581
46565
|
const durationSinceLastAccrual = Date.now() / 1e3 - bank.lastUpdate;
|
|
46582
46566
|
const { lendingRate, borrowingRate } = computeInterestRates(bank);
|
|
46583
46567
|
const outstandingLendingInterest = lendingRate.times(durationSinceLastAccrual).dividedBy(SECONDS_PER_YEAR).times(totalDeposits);
|
|
@@ -47082,7 +47066,7 @@ async function getKaminoStatesDto(connection, kaminoBanks) {
|
|
|
47082
47066
|
}
|
|
47083
47067
|
function getKaminoCTokenMultiplier(reserve) {
|
|
47084
47068
|
const [totalLiquidity, totalCollateral] = scaledSupplies(reserve);
|
|
47085
|
-
return totalCollateral.isZero() ? new
|
|
47069
|
+
return totalCollateral.isZero() ? new BigNumber3__default.default(1) : new BigNumber3__default.default(totalLiquidity.dividedBy(totalCollateral).toString());
|
|
47086
47070
|
}
|
|
47087
47071
|
async function getDriftMetadata(options) {
|
|
47088
47072
|
const driftBanks = options.banks.filter((b) => b.config.assetTag === 4 /* DRIFT */);
|
|
@@ -47111,9 +47095,9 @@ async function getDriftMetadata(options) {
|
|
|
47111
47095
|
for (const [bankAddress, state] of Object.entries(driftStates)) {
|
|
47112
47096
|
driftMetadataMap.set(bankAddress, {
|
|
47113
47097
|
driftStates: {
|
|
47114
|
-
|
|
47115
|
-
|
|
47116
|
-
|
|
47098
|
+
spotMarketState: dtoToDriftSpotMarketRaw(state.driftSpotMarketState),
|
|
47099
|
+
userState: dtoToDriftUserRaw(state.driftUserState),
|
|
47100
|
+
userRewards: state.driftUserRewards.map((r) => dtoToDriftRewardsRaw(r))
|
|
47117
47101
|
}
|
|
47118
47102
|
});
|
|
47119
47103
|
}
|
|
@@ -47175,8 +47159,8 @@ async function getDriftStatesDto(connection, driftBanks) {
|
|
|
47175
47159
|
return driftStatesMap;
|
|
47176
47160
|
}
|
|
47177
47161
|
function getDriftCTokenMultiplier(spotMarket) {
|
|
47178
|
-
const cumulativeDepositInterest = new
|
|
47179
|
-
const SPOT_BALANCE_PRECISION = new
|
|
47162
|
+
const cumulativeDepositInterest = new BigNumber3__default.default(spotMarket.cumulativeDepositInterest.toNumber());
|
|
47163
|
+
const SPOT_BALANCE_PRECISION = new BigNumber3__default.default(10).pow(19 - spotMarket.decimals);
|
|
47180
47164
|
return cumulativeDepositInterest.dividedBy(SPOT_BALANCE_PRECISION);
|
|
47181
47165
|
}
|
|
47182
47166
|
|
|
@@ -47369,11 +47353,11 @@ var Bank = class _Bank {
|
|
|
47369
47353
|
const newBank = Object.create(_Bank.prototype);
|
|
47370
47354
|
Object.assign(newBank, bank);
|
|
47371
47355
|
newBank.config = Object.assign({}, bank.config);
|
|
47372
|
-
newBank.config.assetWeightInit =
|
|
47356
|
+
newBank.config.assetWeightInit = BigNumber3__default.default.max(
|
|
47373
47357
|
bank.config.assetWeightInit,
|
|
47374
47358
|
emodeWeights.assetWeightInit
|
|
47375
47359
|
);
|
|
47376
|
-
newBank.config.assetWeightMaint =
|
|
47360
|
+
newBank.config.assetWeightMaint = BigNumber3__default.default.max(
|
|
47377
47361
|
bank.config.assetWeightMaint,
|
|
47378
47362
|
emodeWeights.assetWeightMaint
|
|
47379
47363
|
);
|
|
@@ -48232,9 +48216,9 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
48232
48216
|
*
|
|
48233
48217
|
* @see {@link makeWrapSolIxs} and {@link makeUnwrapSolIx} for wrap/unwrap implementation
|
|
48234
48218
|
*/
|
|
48235
|
-
wrapInstructionForWSol(ix, amount = new
|
|
48219
|
+
wrapInstructionForWSol(ix, amount = new BigNumber3__default.default(0)) {
|
|
48236
48220
|
return [
|
|
48237
|
-
...makeWrapSolIxs(this.authority, new
|
|
48221
|
+
...makeWrapSolIxs(this.authority, new BigNumber3__default.default(amount)),
|
|
48238
48222
|
ix,
|
|
48239
48223
|
makeUnwrapSolIx(this.authority)
|
|
48240
48224
|
];
|
|
@@ -48270,7 +48254,12 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
48270
48254
|
async makeLoopTx(params) {
|
|
48271
48255
|
return makeLoopTx({
|
|
48272
48256
|
...params,
|
|
48273
|
-
marginfiAccount: this
|
|
48257
|
+
marginfiAccount: this,
|
|
48258
|
+
overrideInferAccounts: {
|
|
48259
|
+
authority: this.authority,
|
|
48260
|
+
group: this.group,
|
|
48261
|
+
...params.overrideInferAccounts
|
|
48262
|
+
}
|
|
48274
48263
|
});
|
|
48275
48264
|
}
|
|
48276
48265
|
/**
|
|
@@ -48304,7 +48293,12 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
48304
48293
|
async makeRepayWithCollatTx(params) {
|
|
48305
48294
|
return makeRepayWithCollatTx({
|
|
48306
48295
|
...params,
|
|
48307
|
-
marginfiAccount: this
|
|
48296
|
+
marginfiAccount: this,
|
|
48297
|
+
overrideInferAccounts: {
|
|
48298
|
+
authority: this.authority,
|
|
48299
|
+
group: this.group,
|
|
48300
|
+
...params.overrideInferAccounts
|
|
48301
|
+
}
|
|
48308
48302
|
});
|
|
48309
48303
|
}
|
|
48310
48304
|
/**
|
|
@@ -48339,7 +48333,12 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
48339
48333
|
async makeSwapCollateralTx(params) {
|
|
48340
48334
|
return makeSwapCollateralTx({
|
|
48341
48335
|
...params,
|
|
48342
|
-
marginfiAccount: this
|
|
48336
|
+
marginfiAccount: this,
|
|
48337
|
+
overrideInferAccounts: {
|
|
48338
|
+
authority: this.authority,
|
|
48339
|
+
group: this.group,
|
|
48340
|
+
...params.overrideInferAccounts
|
|
48341
|
+
}
|
|
48343
48342
|
});
|
|
48344
48343
|
}
|
|
48345
48344
|
/**
|
|
@@ -48373,7 +48372,12 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
48373
48372
|
async makeSwapDebtTx(params) {
|
|
48374
48373
|
return makeSwapDebtTx({
|
|
48375
48374
|
...params,
|
|
48376
|
-
marginfiAccount: this
|
|
48375
|
+
marginfiAccount: this,
|
|
48376
|
+
overrideInferAccounts: {
|
|
48377
|
+
authority: this.authority,
|
|
48378
|
+
group: this.group,
|
|
48379
|
+
...params.overrideInferAccounts
|
|
48380
|
+
}
|
|
48377
48381
|
});
|
|
48378
48382
|
}
|
|
48379
48383
|
/**
|
|
@@ -48435,7 +48439,14 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
48435
48439
|
async makeBorrowTx(params) {
|
|
48436
48440
|
return makeBorrowTx({
|
|
48437
48441
|
...params,
|
|
48438
|
-
marginfiAccount: this
|
|
48442
|
+
marginfiAccount: this,
|
|
48443
|
+
opts: {
|
|
48444
|
+
...params.opts,
|
|
48445
|
+
overrideInferAccounts: {
|
|
48446
|
+
authority: this.authority,
|
|
48447
|
+
...params.opts?.overrideInferAccounts
|
|
48448
|
+
}
|
|
48449
|
+
}
|
|
48439
48450
|
});
|
|
48440
48451
|
}
|
|
48441
48452
|
/**
|
|
@@ -48464,7 +48475,15 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
48464
48475
|
async makeWithdrawTx(params) {
|
|
48465
48476
|
return makeWithdrawTx({
|
|
48466
48477
|
...params,
|
|
48467
|
-
marginfiAccount: this
|
|
48478
|
+
marginfiAccount: this,
|
|
48479
|
+
opts: {
|
|
48480
|
+
...params.opts,
|
|
48481
|
+
overrideInferAccounts: {
|
|
48482
|
+
authority: this.authority,
|
|
48483
|
+
group: this.group,
|
|
48484
|
+
...params.opts?.overrideInferAccounts
|
|
48485
|
+
}
|
|
48486
|
+
}
|
|
48468
48487
|
});
|
|
48469
48488
|
}
|
|
48470
48489
|
/**
|
|
@@ -48478,7 +48497,15 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
48478
48497
|
async makeDriftWithdrawTx(params) {
|
|
48479
48498
|
return makeDriftWithdrawTx({
|
|
48480
48499
|
...params,
|
|
48481
|
-
marginfiAccount: this
|
|
48500
|
+
marginfiAccount: this,
|
|
48501
|
+
opts: {
|
|
48502
|
+
...params.opts,
|
|
48503
|
+
overrideInferAccounts: {
|
|
48504
|
+
authority: this.authority,
|
|
48505
|
+
group: this.group,
|
|
48506
|
+
...params.opts?.overrideInferAccounts
|
|
48507
|
+
}
|
|
48508
|
+
}
|
|
48482
48509
|
});
|
|
48483
48510
|
}
|
|
48484
48511
|
/**
|
|
@@ -48492,7 +48519,15 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
48492
48519
|
async makeKaminoWithdrawTx(params) {
|
|
48493
48520
|
return makeKaminoWithdrawTx({
|
|
48494
48521
|
...params,
|
|
48495
|
-
marginfiAccount: this
|
|
48522
|
+
marginfiAccount: this,
|
|
48523
|
+
opts: {
|
|
48524
|
+
...params.opts,
|
|
48525
|
+
overrideInferAccounts: {
|
|
48526
|
+
authority: this.authority,
|
|
48527
|
+
group: this.group,
|
|
48528
|
+
...params.opts?.overrideInferAccounts
|
|
48529
|
+
}
|
|
48530
|
+
}
|
|
48496
48531
|
});
|
|
48497
48532
|
}
|
|
48498
48533
|
/**
|
|
@@ -48607,7 +48642,7 @@ var MarginfiAccountWrapper = class {
|
|
|
48607
48642
|
* @param opts - Optional configuration for wrapping SOL and overrides
|
|
48608
48643
|
*/
|
|
48609
48644
|
async makeDepositIx(bankAddress, amount, opts = {}) {
|
|
48610
|
-
if (new
|
|
48645
|
+
if (new BigNumber3__default.default(amount).lte(0)) {
|
|
48611
48646
|
throw Error(`Deposit amount must be positive, got ${amount}`);
|
|
48612
48647
|
}
|
|
48613
48648
|
const bank = await this.getBankFromAddress(bankAddress);
|
|
@@ -48631,7 +48666,7 @@ var MarginfiAccountWrapper = class {
|
|
|
48631
48666
|
* @param opts - Optional configuration for wrapping SOL and overrides
|
|
48632
48667
|
*/
|
|
48633
48668
|
async makeRepayIx(bankAddress, amount, repayAll = false, opts = {}) {
|
|
48634
|
-
if (!repayAll && new
|
|
48669
|
+
if (!repayAll && new BigNumber3__default.default(amount).lte(0)) {
|
|
48635
48670
|
throw Error(`Repay amount must be positive, got ${amount}`);
|
|
48636
48671
|
}
|
|
48637
48672
|
const bank = await this.getBankFromAddress(bankAddress);
|
|
@@ -48656,7 +48691,7 @@ var MarginfiAccountWrapper = class {
|
|
|
48656
48691
|
* @param opts - Optional configuration for unwrapping SOL and overrides
|
|
48657
48692
|
*/
|
|
48658
48693
|
async makeWithdrawIx(bankAddress, amount, withdrawAll = false, opts = {}) {
|
|
48659
|
-
if (!withdrawAll && new
|
|
48694
|
+
if (!withdrawAll && new BigNumber3__default.default(amount).lte(0)) {
|
|
48660
48695
|
throw Error(`Withdraw amount must be positive, got ${amount}`);
|
|
48661
48696
|
}
|
|
48662
48697
|
const bank = await this.getBankFromAddress(bankAddress);
|
|
@@ -48682,7 +48717,7 @@ var MarginfiAccountWrapper = class {
|
|
|
48682
48717
|
* @param opts - Optional configuration for unwrapping SOL and overrides
|
|
48683
48718
|
*/
|
|
48684
48719
|
async makeBorrowIx(bankAddress, amount, opts = {}) {
|
|
48685
|
-
if (new
|
|
48720
|
+
if (new BigNumber3__default.default(amount).lte(0)) {
|
|
48686
48721
|
throw Error(`Borrow amount must be positive, got ${amount}`);
|
|
48687
48722
|
}
|
|
48688
48723
|
const bank = await this.getBankFromAddress(bankAddress);
|
|
@@ -49441,7 +49476,7 @@ var Project0Client = class _Project0Client {
|
|
|
49441
49476
|
const reserve = bankIntegrationMap[bank.address.toBase58()]?.kaminoStates?.reserveState;
|
|
49442
49477
|
if (!reserve) {
|
|
49443
49478
|
console.error(`No Kamino reserve found for bank ${bank.address.toBase58()}`);
|
|
49444
|
-
assetShareMultiplierByBank.set(bank.address.toBase58(), new
|
|
49479
|
+
assetShareMultiplierByBank.set(bank.address.toBase58(), new BigNumber3__default.default(1));
|
|
49445
49480
|
break;
|
|
49446
49481
|
}
|
|
49447
49482
|
assetShareMultiplierByBank.set(
|
|
@@ -49453,7 +49488,7 @@ var Project0Client = class _Project0Client {
|
|
|
49453
49488
|
const spotMarket = bankIntegrationMap[bank.address.toBase58()]?.driftStates?.spotMarketState;
|
|
49454
49489
|
if (!spotMarket) {
|
|
49455
49490
|
console.error(`No Drift spot market found for bank ${bank.address.toBase58()}`);
|
|
49456
|
-
assetShareMultiplierByBank.set(bank.address.toBase58(), new
|
|
49491
|
+
assetShareMultiplierByBank.set(bank.address.toBase58(), new BigNumber3__default.default(1));
|
|
49457
49492
|
break;
|
|
49458
49493
|
}
|
|
49459
49494
|
assetShareMultiplierByBank.set(
|
|
@@ -49462,15 +49497,15 @@ var Project0Client = class _Project0Client {
|
|
|
49462
49497
|
);
|
|
49463
49498
|
break;
|
|
49464
49499
|
case 5 /* SOLEND */:
|
|
49465
|
-
assetShareMultiplierByBank.set(bank.address.toBase58(), new
|
|
49500
|
+
assetShareMultiplierByBank.set(bank.address.toBase58(), new BigNumber3__default.default(1));
|
|
49466
49501
|
break;
|
|
49467
49502
|
case 2 /* STAKED */:
|
|
49468
|
-
assetShareMultiplierByBank.set(bank.address.toBase58(), new
|
|
49503
|
+
assetShareMultiplierByBank.set(bank.address.toBase58(), new BigNumber3__default.default(1));
|
|
49469
49504
|
break;
|
|
49470
49505
|
case 0 /* DEFAULT */:
|
|
49471
49506
|
case 1 /* SOL */:
|
|
49472
49507
|
default:
|
|
49473
|
-
assetShareMultiplierByBank.set(bank.address.toBase58(), new
|
|
49508
|
+
assetShareMultiplierByBank.set(bank.address.toBase58(), new BigNumber3__default.default(1));
|
|
49474
49509
|
break;
|
|
49475
49510
|
}
|
|
49476
49511
|
});
|