@kasufinance/kasu-sdk 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +46 -27
- package/dist/bundle.esm.js +46 -27
- package/dist/facade/deposits.d.ts +2 -2
- package/dist/facade/deposits.js +3 -3
- package/dist/facade/deposits.js.map +1 -1
- package/dist/facade/types.d.ts +8 -8
- package/dist/sdk-config.d.ts +6 -0
- package/dist/sdk-config.js +2 -1
- package/dist/sdk-config.js.map +1 -1
- package/dist/services/DataService/data-service.js +1 -1
- package/dist/services/DataService/data-service.js.map +1 -1
- package/dist/services/Locking/locking.d.ts +5 -1
- package/dist/services/Locking/locking.js +25 -13
- package/dist/services/Locking/locking.js.map +1 -1
- package/dist/services/Locking/types.d.ts +1 -1
- package/dist/services/Portfolio/portfolio.d.ts +2 -2
- package/dist/services/Portfolio/portfolio.js +6 -6
- package/dist/services/Portfolio/portfolio.js.map +1 -1
- package/dist/services/Portfolio/types.d.ts +2 -2
- package/dist/services/UserLending/user-lending.d.ts +3 -1
- package/dist/services/UserLending/user-lending.js +9 -3
- package/dist/services/UserLending/user-lending.js.map +1 -1
- package/package.json +1 -1
- package/src/facade/deposits.ts +3 -3
- package/src/facade/types.ts +8 -8
- package/src/sdk-config.ts +7 -0
- package/src/services/DataService/data-service.ts +1 -1
- package/src/services/Locking/locking.ts +28 -13
- package/src/services/Locking/types.ts +1 -1
- package/src/services/Portfolio/portfolio.ts +6 -6
- package/src/services/Portfolio/types.ts +2 -2
- package/src/services/UserLending/user-lending.ts +13 -4
- package/.claude/settings.local.json +0 -15
package/dist/bundle.cjs.js
CHANGED
|
@@ -15845,7 +15845,7 @@ class DataService {
|
|
|
15845
15845
|
];
|
|
15846
15846
|
})));
|
|
15847
15847
|
for (const [id, tvl] of results) {
|
|
15848
|
-
tvlMap.set(id, utils$2.formatUnits(tvl,
|
|
15848
|
+
tvlMap.set(id, utils$2.formatUnits(tvl, this._kasuConfig.stableAssetDecimals));
|
|
15849
15849
|
}
|
|
15850
15850
|
}
|
|
15851
15851
|
catch (error) {
|
|
@@ -16512,13 +16512,13 @@ class KSULocking {
|
|
|
16512
16512
|
});
|
|
16513
16513
|
const resultPromises = result.userLocks.map((userLock) => __awaiter(this, void 0, void 0, function* () {
|
|
16514
16514
|
const [, id] = userLock.id.split('-');
|
|
16515
|
-
const
|
|
16516
|
-
const loyaltyStatus = this.getLoyaltyLevelAndApyBonusFromRatio(
|
|
16515
|
+
const rKSUtoStableRatio = yield this.getRKSUvsStableRatio(userLock.rKSUAmount, userAddress);
|
|
16516
|
+
const loyaltyStatus = this.getLoyaltyLevelAndApyBonusFromRatio(rKSUtoStableRatio);
|
|
16517
16517
|
return {
|
|
16518
16518
|
id: ethers.BigNumber.from(id),
|
|
16519
16519
|
lockedAmount: userLock.ksuAmount,
|
|
16520
16520
|
rKSUAmount: userLock.rKSUAmount,
|
|
16521
|
-
|
|
16521
|
+
rKSUtoStableRatio: rKSUtoStableRatio,
|
|
16522
16522
|
apyBonus: loyaltyStatus.apyBonus,
|
|
16523
16523
|
loyaltyLevel: loyaltyStatus.loyaltyLevel,
|
|
16524
16524
|
startTime: parseFloat(userLock.startTimestamp),
|
|
@@ -16571,20 +16571,20 @@ class KSULocking {
|
|
|
16571
16571
|
};
|
|
16572
16572
|
});
|
|
16573
16573
|
}
|
|
16574
|
-
getLoyaltyLevelAndApyBonusFromRatio(
|
|
16574
|
+
getLoyaltyLevelAndApyBonusFromRatio(rKSUtoStableRatio) {
|
|
16575
16575
|
// On Lite deployments, always return level 0 with no bonus
|
|
16576
16576
|
if (this._isLiteDeployment) {
|
|
16577
16577
|
return { loyaltyLevel: 0, apyBonus: 0 };
|
|
16578
16578
|
}
|
|
16579
|
-
if (
|
|
16579
|
+
if (rKSUtoStableRatio < 0.01) {
|
|
16580
16580
|
return { loyaltyLevel: 0, apyBonus: this.apyBonuses[0] };
|
|
16581
16581
|
}
|
|
16582
|
-
else if (
|
|
16582
|
+
else if (rKSUtoStableRatio < 0.05) {
|
|
16583
16583
|
return { loyaltyLevel: 1, apyBonus: this.apyBonuses[1] };
|
|
16584
16584
|
}
|
|
16585
16585
|
return { loyaltyLevel: 2, apyBonus: this.apyBonuses[2] };
|
|
16586
16586
|
}
|
|
16587
|
-
|
|
16587
|
+
getRKSUvsStableRatio(rKSUAmount, userAddress) {
|
|
16588
16588
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16589
16589
|
if (this._isLiteDeployment) {
|
|
16590
16590
|
return 0;
|
|
@@ -16592,12 +16592,20 @@ class KSULocking {
|
|
|
16592
16592
|
const [depositedAmount, pendingAmount] = yield this._userManagerAbi.userTotalPendingAndActiveDepositedAmountForCurrentEpoch(userAddress);
|
|
16593
16593
|
const ksuPrice = yield this._systemVariablesAbi.ksuEpochTokenPrice();
|
|
16594
16594
|
const rKSUAmountBignumber = ethers.ethers.utils.parseUnits(rKSUAmount, 18);
|
|
16595
|
-
const
|
|
16596
|
-
|
|
16595
|
+
const totalUserStableAmount = depositedAmount.toNumber() + pendingAmount.toNumber();
|
|
16596
|
+
// Convert rKSU value to stable asset units: rKSU * ksuPrice / 1e18 / 1e(18 - stableDecimals)
|
|
16597
|
+
const decimalDiff = 18 - this._kasuConfig.stableAssetDecimals;
|
|
16598
|
+
const rKSUInStable = rKSUAmountBignumber
|
|
16597
16599
|
.mul(ksuPrice)
|
|
16598
16600
|
.div(ethers.ethers.utils.parseUnits('1', 18))
|
|
16599
|
-
.div(ethers.ethers.utils.parseUnits('1',
|
|
16600
|
-
return
|
|
16601
|
+
.div(ethers.ethers.utils.parseUnits('1', decimalDiff));
|
|
16602
|
+
return rKSUInStable.toNumber() / totalUserStableAmount;
|
|
16603
|
+
});
|
|
16604
|
+
}
|
|
16605
|
+
/** @deprecated Use `getRKSUvsStableRatio` instead. */
|
|
16606
|
+
getRKSUvsUSDCRatio(rKSUAmount, userAddress) {
|
|
16607
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16608
|
+
return this.getRKSUvsStableRatio(rKSUAmount, userAddress);
|
|
16601
16609
|
});
|
|
16602
16610
|
}
|
|
16603
16611
|
getClaimableRewards(userAddress) {
|
|
@@ -16707,7 +16715,7 @@ class KSULocking {
|
|
|
16707
16715
|
lifeTimeRewards: '0',
|
|
16708
16716
|
};
|
|
16709
16717
|
}
|
|
16710
|
-
const rewardDecimals =
|
|
16718
|
+
const rewardDecimals = this._kasuConfig.stableAssetDecimals;
|
|
16711
16719
|
const claimableRewards = yield this.getClaimableRewards(userAddress);
|
|
16712
16720
|
const lifeTimeRewards = yield this.getLifetimeRewards(userAddress, rewardDecimals, claimableRewards);
|
|
16713
16721
|
return {
|
|
@@ -16771,9 +16779,13 @@ class KSULocking {
|
|
|
16771
16779
|
getProjectedApy() {
|
|
16772
16780
|
return '10.00';
|
|
16773
16781
|
}
|
|
16774
|
-
|
|
16782
|
+
getProjectedStableAmount() {
|
|
16775
16783
|
return '20.00';
|
|
16776
16784
|
}
|
|
16785
|
+
/** @deprecated Use `getProjectedStableAmount` instead. */
|
|
16786
|
+
getProjectedUSDC() {
|
|
16787
|
+
return this.getProjectedStableAmount();
|
|
16788
|
+
}
|
|
16777
16789
|
}
|
|
16778
16790
|
|
|
16779
16791
|
/**
|
|
@@ -17076,13 +17088,19 @@ class UserLending {
|
|
|
17076
17088
|
return yield this._lendingPoolManagerAbi.requestWithdrawal(lendingPool, tranche, amount);
|
|
17077
17089
|
});
|
|
17078
17090
|
}
|
|
17079
|
-
|
|
17091
|
+
requestWithdrawalInAsset(lendingPool, tranche, assetAmount) {
|
|
17080
17092
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17081
17093
|
const trancheContract = ILendingPoolTrancheAbi__factory.connect(tranche, this._signerOrProvider);
|
|
17082
|
-
const shareAmount = yield trancheContract.convertToShares(
|
|
17094
|
+
const shareAmount = yield trancheContract.convertToShares(assetAmount);
|
|
17083
17095
|
return yield this._lendingPoolManagerAbi.requestWithdrawal(lendingPool, tranche, shareAmount);
|
|
17084
17096
|
});
|
|
17085
17097
|
}
|
|
17098
|
+
/** @deprecated Use `requestWithdrawalInAsset` instead. */
|
|
17099
|
+
requestWithdrawalInUSDC(lendingPool, tranche, amount) {
|
|
17100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17101
|
+
return this.requestWithdrawalInAsset(lendingPool, tranche, amount);
|
|
17102
|
+
});
|
|
17103
|
+
}
|
|
17086
17104
|
requestWithdrawalMax(lendingPool, tranche, user) {
|
|
17087
17105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17088
17106
|
const trancheContract = ILendingPoolTrancheAbi__factory.connect(tranche, this._signerOrProvider);
|
|
@@ -17364,7 +17382,7 @@ class UserLending {
|
|
|
17364
17382
|
lendingPool.id.toLowerCase())) === null || _a === void 0 ? void 0 : _a.balance) !== null && _b !== void 0 ? _b : ethers.BigNumber.from(0);
|
|
17365
17383
|
return {
|
|
17366
17384
|
poolId: lendingPool.id,
|
|
17367
|
-
yieldEarned: parseFloat(ethers.ethers.utils.formatUnits(balance,
|
|
17385
|
+
yieldEarned: parseFloat(ethers.ethers.utils.formatUnits(balance, this._kasuConfig.stableAssetDecimals)) -
|
|
17368
17386
|
parseFloat(totalAcceptedDeposits) -
|
|
17369
17387
|
-parseFloat(totalAcceptedWithdrawnAmount),
|
|
17370
17388
|
balance,
|
|
@@ -17685,8 +17703,8 @@ class Portfolio {
|
|
|
17685
17703
|
return this.computeYieldMetrics(portfolioLendingPools);
|
|
17686
17704
|
}
|
|
17687
17705
|
/**
|
|
17688
|
-
* Calculate the user's weekly protocol fee share (
|
|
17689
|
-
* system variables and locking summary. All inputs are expected to be pre-fetched.
|
|
17706
|
+
* Calculate the user's weekly protocol fee share (in stable asset units) given tranche
|
|
17707
|
+
* balances/configs, system variables and locking summary. All inputs are expected to be pre-fetched.
|
|
17690
17708
|
*/
|
|
17691
17709
|
calculateWeeklyProtocolFees(params) {
|
|
17692
17710
|
var _a, _b;
|
|
@@ -17728,8 +17746,8 @@ class Portfolio {
|
|
|
17728
17746
|
const totalUserDeposits = userDepositAmounts[0].add(userDepositAmounts[1]);
|
|
17729
17747
|
if (totalUserDeposits.isZero())
|
|
17730
17748
|
return 0;
|
|
17731
|
-
const
|
|
17732
|
-
const { loyaltyLevel } = this._lockingService.getLoyaltyLevelAndApyBonusFromRatio(
|
|
17749
|
+
const rKSUtoStableRatio = yield this._lockingService.getRKSUvsStableRatio(userRksuAmount, userAddress);
|
|
17750
|
+
const { loyaltyLevel } = this._lockingService.getLoyaltyLevelAndApyBonusFromRatio(rKSUtoStableRatio);
|
|
17733
17751
|
const loyaltyRewardRate = yield this._userLoyaltyRewardsAbi.loyaltyEpochRewardRates(loyaltyLevel);
|
|
17734
17752
|
if (loyaltyRewardRate.isZero() || ksuEpochPrice.price.isZero()) {
|
|
17735
17753
|
return 0;
|
|
@@ -17757,9 +17775,9 @@ class Portfolio {
|
|
|
17757
17775
|
},
|
|
17758
17776
|
protocolFees: {
|
|
17759
17777
|
claimableBalance: {
|
|
17760
|
-
|
|
17778
|
+
stableAmount: lockingRewards.claimableRewards,
|
|
17761
17779
|
},
|
|
17762
|
-
lifeTime: {
|
|
17780
|
+
lifeTime: { stableAmount: lockingRewards.lifeTimeRewards },
|
|
17763
17781
|
},
|
|
17764
17782
|
ksuLaunchBonus: { lifeTime: { ksuAmount: ksuLaunchBonus } },
|
|
17765
17783
|
};
|
|
@@ -21873,13 +21891,14 @@ class KasuSdk {
|
|
|
21873
21891
|
|
|
21874
21892
|
class SdkConfig {
|
|
21875
21893
|
constructor(options) {
|
|
21876
|
-
var _a, _b, _c;
|
|
21894
|
+
var _a, _b, _c, _d;
|
|
21877
21895
|
this.subgraphUrl = options.subgraphUrl;
|
|
21878
21896
|
this.contracts = options.contracts;
|
|
21879
21897
|
this.directusUrl = (_a = options.directusUrl) !== null && _a !== void 0 ? _a : '';
|
|
21880
21898
|
this.UNUSED_LENDING_POOL_IDS = options.UNUSED_LENDING_POOL_IDS;
|
|
21881
21899
|
this.isLiteDeployment = (_b = options.isLiteDeployment) !== null && _b !== void 0 ? _b : false;
|
|
21882
21900
|
this.poolMetadataMapping = (_c = options.poolMetadataMapping) !== null && _c !== void 0 ? _c : {};
|
|
21901
|
+
this.stableAssetDecimals = (_d = options.stableAssetDecimals) !== null && _d !== void 0 ? _d : 6;
|
|
21883
21902
|
}
|
|
21884
21903
|
}
|
|
21885
21904
|
|
|
@@ -21990,7 +22009,7 @@ class DepositsFacade {
|
|
|
21990
22009
|
* const tx = await kasu.deposits.deposit({
|
|
21991
22010
|
* poolId: '0x...',
|
|
21992
22011
|
* trancheId: '0x...',
|
|
21993
|
-
* amount: parseUnits('1000', 6),
|
|
22012
|
+
* amount: parseUnits('1000', 6), // 6 decimals for USDC/AUDD; use token's actual decimals
|
|
21994
22013
|
* kycSignature: { blockExpiration, signature },
|
|
21995
22014
|
* });
|
|
21996
22015
|
* ```
|
|
@@ -22002,11 +22021,11 @@ class DepositsFacade {
|
|
|
22002
22021
|
});
|
|
22003
22022
|
}
|
|
22004
22023
|
/**
|
|
22005
|
-
* Submit a withdrawal request for a specific
|
|
22024
|
+
* Submit a withdrawal request for a specific stable asset amount.
|
|
22006
22025
|
*/
|
|
22007
22026
|
withdraw(params) {
|
|
22008
22027
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22009
|
-
return yield this._userLending.
|
|
22028
|
+
return yield this._userLending.requestWithdrawalInAsset(params.poolId, params.trancheId, params.amount);
|
|
22010
22029
|
});
|
|
22011
22030
|
}
|
|
22012
22031
|
/**
|
package/dist/bundle.esm.js
CHANGED
|
@@ -15843,7 +15843,7 @@ class DataService {
|
|
|
15843
15843
|
];
|
|
15844
15844
|
})));
|
|
15845
15845
|
for (const [id, tvl] of results) {
|
|
15846
|
-
tvlMap.set(id, formatUnits(tvl,
|
|
15846
|
+
tvlMap.set(id, formatUnits(tvl, this._kasuConfig.stableAssetDecimals));
|
|
15847
15847
|
}
|
|
15848
15848
|
}
|
|
15849
15849
|
catch (error) {
|
|
@@ -16510,13 +16510,13 @@ class KSULocking {
|
|
|
16510
16510
|
});
|
|
16511
16511
|
const resultPromises = result.userLocks.map((userLock) => __awaiter(this, void 0, void 0, function* () {
|
|
16512
16512
|
const [, id] = userLock.id.split('-');
|
|
16513
|
-
const
|
|
16514
|
-
const loyaltyStatus = this.getLoyaltyLevelAndApyBonusFromRatio(
|
|
16513
|
+
const rKSUtoStableRatio = yield this.getRKSUvsStableRatio(userLock.rKSUAmount, userAddress);
|
|
16514
|
+
const loyaltyStatus = this.getLoyaltyLevelAndApyBonusFromRatio(rKSUtoStableRatio);
|
|
16515
16515
|
return {
|
|
16516
16516
|
id: BigNumber.from(id),
|
|
16517
16517
|
lockedAmount: userLock.ksuAmount,
|
|
16518
16518
|
rKSUAmount: userLock.rKSUAmount,
|
|
16519
|
-
|
|
16519
|
+
rKSUtoStableRatio: rKSUtoStableRatio,
|
|
16520
16520
|
apyBonus: loyaltyStatus.apyBonus,
|
|
16521
16521
|
loyaltyLevel: loyaltyStatus.loyaltyLevel,
|
|
16522
16522
|
startTime: parseFloat(userLock.startTimestamp),
|
|
@@ -16569,20 +16569,20 @@ class KSULocking {
|
|
|
16569
16569
|
};
|
|
16570
16570
|
});
|
|
16571
16571
|
}
|
|
16572
|
-
getLoyaltyLevelAndApyBonusFromRatio(
|
|
16572
|
+
getLoyaltyLevelAndApyBonusFromRatio(rKSUtoStableRatio) {
|
|
16573
16573
|
// On Lite deployments, always return level 0 with no bonus
|
|
16574
16574
|
if (this._isLiteDeployment) {
|
|
16575
16575
|
return { loyaltyLevel: 0, apyBonus: 0 };
|
|
16576
16576
|
}
|
|
16577
|
-
if (
|
|
16577
|
+
if (rKSUtoStableRatio < 0.01) {
|
|
16578
16578
|
return { loyaltyLevel: 0, apyBonus: this.apyBonuses[0] };
|
|
16579
16579
|
}
|
|
16580
|
-
else if (
|
|
16580
|
+
else if (rKSUtoStableRatio < 0.05) {
|
|
16581
16581
|
return { loyaltyLevel: 1, apyBonus: this.apyBonuses[1] };
|
|
16582
16582
|
}
|
|
16583
16583
|
return { loyaltyLevel: 2, apyBonus: this.apyBonuses[2] };
|
|
16584
16584
|
}
|
|
16585
|
-
|
|
16585
|
+
getRKSUvsStableRatio(rKSUAmount, userAddress) {
|
|
16586
16586
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16587
16587
|
if (this._isLiteDeployment) {
|
|
16588
16588
|
return 0;
|
|
@@ -16590,12 +16590,20 @@ class KSULocking {
|
|
|
16590
16590
|
const [depositedAmount, pendingAmount] = yield this._userManagerAbi.userTotalPendingAndActiveDepositedAmountForCurrentEpoch(userAddress);
|
|
16591
16591
|
const ksuPrice = yield this._systemVariablesAbi.ksuEpochTokenPrice();
|
|
16592
16592
|
const rKSUAmountBignumber = ethers.utils.parseUnits(rKSUAmount, 18);
|
|
16593
|
-
const
|
|
16594
|
-
|
|
16593
|
+
const totalUserStableAmount = depositedAmount.toNumber() + pendingAmount.toNumber();
|
|
16594
|
+
// Convert rKSU value to stable asset units: rKSU * ksuPrice / 1e18 / 1e(18 - stableDecimals)
|
|
16595
|
+
const decimalDiff = 18 - this._kasuConfig.stableAssetDecimals;
|
|
16596
|
+
const rKSUInStable = rKSUAmountBignumber
|
|
16595
16597
|
.mul(ksuPrice)
|
|
16596
16598
|
.div(ethers.utils.parseUnits('1', 18))
|
|
16597
|
-
.div(ethers.utils.parseUnits('1',
|
|
16598
|
-
return
|
|
16599
|
+
.div(ethers.utils.parseUnits('1', decimalDiff));
|
|
16600
|
+
return rKSUInStable.toNumber() / totalUserStableAmount;
|
|
16601
|
+
});
|
|
16602
|
+
}
|
|
16603
|
+
/** @deprecated Use `getRKSUvsStableRatio` instead. */
|
|
16604
|
+
getRKSUvsUSDCRatio(rKSUAmount, userAddress) {
|
|
16605
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16606
|
+
return this.getRKSUvsStableRatio(rKSUAmount, userAddress);
|
|
16599
16607
|
});
|
|
16600
16608
|
}
|
|
16601
16609
|
getClaimableRewards(userAddress) {
|
|
@@ -16705,7 +16713,7 @@ class KSULocking {
|
|
|
16705
16713
|
lifeTimeRewards: '0',
|
|
16706
16714
|
};
|
|
16707
16715
|
}
|
|
16708
|
-
const rewardDecimals =
|
|
16716
|
+
const rewardDecimals = this._kasuConfig.stableAssetDecimals;
|
|
16709
16717
|
const claimableRewards = yield this.getClaimableRewards(userAddress);
|
|
16710
16718
|
const lifeTimeRewards = yield this.getLifetimeRewards(userAddress, rewardDecimals, claimableRewards);
|
|
16711
16719
|
return {
|
|
@@ -16769,9 +16777,13 @@ class KSULocking {
|
|
|
16769
16777
|
getProjectedApy() {
|
|
16770
16778
|
return '10.00';
|
|
16771
16779
|
}
|
|
16772
|
-
|
|
16780
|
+
getProjectedStableAmount() {
|
|
16773
16781
|
return '20.00';
|
|
16774
16782
|
}
|
|
16783
|
+
/** @deprecated Use `getProjectedStableAmount` instead. */
|
|
16784
|
+
getProjectedUSDC() {
|
|
16785
|
+
return this.getProjectedStableAmount();
|
|
16786
|
+
}
|
|
16775
16787
|
}
|
|
16776
16788
|
|
|
16777
16789
|
/**
|
|
@@ -17074,13 +17086,19 @@ class UserLending {
|
|
|
17074
17086
|
return yield this._lendingPoolManagerAbi.requestWithdrawal(lendingPool, tranche, amount);
|
|
17075
17087
|
});
|
|
17076
17088
|
}
|
|
17077
|
-
|
|
17089
|
+
requestWithdrawalInAsset(lendingPool, tranche, assetAmount) {
|
|
17078
17090
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17079
17091
|
const trancheContract = ILendingPoolTrancheAbi__factory.connect(tranche, this._signerOrProvider);
|
|
17080
|
-
const shareAmount = yield trancheContract.convertToShares(
|
|
17092
|
+
const shareAmount = yield trancheContract.convertToShares(assetAmount);
|
|
17081
17093
|
return yield this._lendingPoolManagerAbi.requestWithdrawal(lendingPool, tranche, shareAmount);
|
|
17082
17094
|
});
|
|
17083
17095
|
}
|
|
17096
|
+
/** @deprecated Use `requestWithdrawalInAsset` instead. */
|
|
17097
|
+
requestWithdrawalInUSDC(lendingPool, tranche, amount) {
|
|
17098
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17099
|
+
return this.requestWithdrawalInAsset(lendingPool, tranche, amount);
|
|
17100
|
+
});
|
|
17101
|
+
}
|
|
17084
17102
|
requestWithdrawalMax(lendingPool, tranche, user) {
|
|
17085
17103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17086
17104
|
const trancheContract = ILendingPoolTrancheAbi__factory.connect(tranche, this._signerOrProvider);
|
|
@@ -17362,7 +17380,7 @@ class UserLending {
|
|
|
17362
17380
|
lendingPool.id.toLowerCase())) === null || _a === void 0 ? void 0 : _a.balance) !== null && _b !== void 0 ? _b : BigNumber.from(0);
|
|
17363
17381
|
return {
|
|
17364
17382
|
poolId: lendingPool.id,
|
|
17365
|
-
yieldEarned: parseFloat(ethers.utils.formatUnits(balance,
|
|
17383
|
+
yieldEarned: parseFloat(ethers.utils.formatUnits(balance, this._kasuConfig.stableAssetDecimals)) -
|
|
17366
17384
|
parseFloat(totalAcceptedDeposits) -
|
|
17367
17385
|
-parseFloat(totalAcceptedWithdrawnAmount),
|
|
17368
17386
|
balance,
|
|
@@ -17683,8 +17701,8 @@ class Portfolio {
|
|
|
17683
17701
|
return this.computeYieldMetrics(portfolioLendingPools);
|
|
17684
17702
|
}
|
|
17685
17703
|
/**
|
|
17686
|
-
* Calculate the user's weekly protocol fee share (
|
|
17687
|
-
* system variables and locking summary. All inputs are expected to be pre-fetched.
|
|
17704
|
+
* Calculate the user's weekly protocol fee share (in stable asset units) given tranche
|
|
17705
|
+
* balances/configs, system variables and locking summary. All inputs are expected to be pre-fetched.
|
|
17688
17706
|
*/
|
|
17689
17707
|
calculateWeeklyProtocolFees(params) {
|
|
17690
17708
|
var _a, _b;
|
|
@@ -17726,8 +17744,8 @@ class Portfolio {
|
|
|
17726
17744
|
const totalUserDeposits = userDepositAmounts[0].add(userDepositAmounts[1]);
|
|
17727
17745
|
if (totalUserDeposits.isZero())
|
|
17728
17746
|
return 0;
|
|
17729
|
-
const
|
|
17730
|
-
const { loyaltyLevel } = this._lockingService.getLoyaltyLevelAndApyBonusFromRatio(
|
|
17747
|
+
const rKSUtoStableRatio = yield this._lockingService.getRKSUvsStableRatio(userRksuAmount, userAddress);
|
|
17748
|
+
const { loyaltyLevel } = this._lockingService.getLoyaltyLevelAndApyBonusFromRatio(rKSUtoStableRatio);
|
|
17731
17749
|
const loyaltyRewardRate = yield this._userLoyaltyRewardsAbi.loyaltyEpochRewardRates(loyaltyLevel);
|
|
17732
17750
|
if (loyaltyRewardRate.isZero() || ksuEpochPrice.price.isZero()) {
|
|
17733
17751
|
return 0;
|
|
@@ -17755,9 +17773,9 @@ class Portfolio {
|
|
|
17755
17773
|
},
|
|
17756
17774
|
protocolFees: {
|
|
17757
17775
|
claimableBalance: {
|
|
17758
|
-
|
|
17776
|
+
stableAmount: lockingRewards.claimableRewards,
|
|
17759
17777
|
},
|
|
17760
|
-
lifeTime: {
|
|
17778
|
+
lifeTime: { stableAmount: lockingRewards.lifeTimeRewards },
|
|
17761
17779
|
},
|
|
17762
17780
|
ksuLaunchBonus: { lifeTime: { ksuAmount: ksuLaunchBonus } },
|
|
17763
17781
|
};
|
|
@@ -21871,13 +21889,14 @@ class KasuSdk {
|
|
|
21871
21889
|
|
|
21872
21890
|
class SdkConfig {
|
|
21873
21891
|
constructor(options) {
|
|
21874
|
-
var _a, _b, _c;
|
|
21892
|
+
var _a, _b, _c, _d;
|
|
21875
21893
|
this.subgraphUrl = options.subgraphUrl;
|
|
21876
21894
|
this.contracts = options.contracts;
|
|
21877
21895
|
this.directusUrl = (_a = options.directusUrl) !== null && _a !== void 0 ? _a : '';
|
|
21878
21896
|
this.UNUSED_LENDING_POOL_IDS = options.UNUSED_LENDING_POOL_IDS;
|
|
21879
21897
|
this.isLiteDeployment = (_b = options.isLiteDeployment) !== null && _b !== void 0 ? _b : false;
|
|
21880
21898
|
this.poolMetadataMapping = (_c = options.poolMetadataMapping) !== null && _c !== void 0 ? _c : {};
|
|
21899
|
+
this.stableAssetDecimals = (_d = options.stableAssetDecimals) !== null && _d !== void 0 ? _d : 6;
|
|
21881
21900
|
}
|
|
21882
21901
|
}
|
|
21883
21902
|
|
|
@@ -21988,7 +22007,7 @@ class DepositsFacade {
|
|
|
21988
22007
|
* const tx = await kasu.deposits.deposit({
|
|
21989
22008
|
* poolId: '0x...',
|
|
21990
22009
|
* trancheId: '0x...',
|
|
21991
|
-
* amount: parseUnits('1000', 6),
|
|
22010
|
+
* amount: parseUnits('1000', 6), // 6 decimals for USDC/AUDD; use token's actual decimals
|
|
21992
22011
|
* kycSignature: { blockExpiration, signature },
|
|
21993
22012
|
* });
|
|
21994
22013
|
* ```
|
|
@@ -22000,11 +22019,11 @@ class DepositsFacade {
|
|
|
22000
22019
|
});
|
|
22001
22020
|
}
|
|
22002
22021
|
/**
|
|
22003
|
-
* Submit a withdrawal request for a specific
|
|
22022
|
+
* Submit a withdrawal request for a specific stable asset amount.
|
|
22004
22023
|
*/
|
|
22005
22024
|
withdraw(params) {
|
|
22006
22025
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22007
|
-
return yield this._userLending.
|
|
22026
|
+
return yield this._userLending.requestWithdrawalInAsset(params.poolId, params.trancheId, params.amount);
|
|
22008
22027
|
});
|
|
22009
22028
|
}
|
|
22010
22029
|
/**
|
|
@@ -23,14 +23,14 @@ export declare class DepositsFacade {
|
|
|
23
23
|
* const tx = await kasu.deposits.deposit({
|
|
24
24
|
* poolId: '0x...',
|
|
25
25
|
* trancheId: '0x...',
|
|
26
|
-
* amount: parseUnits('1000', 6),
|
|
26
|
+
* amount: parseUnits('1000', 6), // 6 decimals for USDC/AUDD; use token's actual decimals
|
|
27
27
|
* kycSignature: { blockExpiration, signature },
|
|
28
28
|
* });
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
deposit(params: DepositParams): Promise<ContractTransaction>;
|
|
32
32
|
/**
|
|
33
|
-
* Submit a withdrawal request for a specific
|
|
33
|
+
* Submit a withdrawal request for a specific stable asset amount.
|
|
34
34
|
*/
|
|
35
35
|
withdraw(params: WithdrawParams): Promise<ContractTransaction>;
|
|
36
36
|
/**
|
package/dist/facade/deposits.js
CHANGED
|
@@ -30,7 +30,7 @@ export class DepositsFacade {
|
|
|
30
30
|
* const tx = await kasu.deposits.deposit({
|
|
31
31
|
* poolId: '0x...',
|
|
32
32
|
* trancheId: '0x...',
|
|
33
|
-
* amount: parseUnits('1000', 6),
|
|
33
|
+
* amount: parseUnits('1000', 6), // 6 decimals for USDC/AUDD; use token's actual decimals
|
|
34
34
|
* kycSignature: { blockExpiration, signature },
|
|
35
35
|
* });
|
|
36
36
|
* ```
|
|
@@ -42,11 +42,11 @@ export class DepositsFacade {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Submit a withdrawal request for a specific
|
|
45
|
+
* Submit a withdrawal request for a specific stable asset amount.
|
|
46
46
|
*/
|
|
47
47
|
withdraw(params) {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
return yield this._userLending.
|
|
49
|
+
return yield this._userLending.requestWithdrawalInAsset(params.poolId, params.trancheId, params.amount);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deposits.js","sourceRoot":"","sources":["../../src/facade/deposits.ts"],"names":[],"mappings":";;;;;;;;;AAMA;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACvB,YACY,YAAyB,EACzB,QAAgB;QADhB,iBAAY,GAAZ,YAAY,CAAa;QACzB,aAAQ,GAAR,QAAQ,CAAQ;IACzB,CAAC;IAEJ;;;;;;;;;;;;;;;;OAgBG;IACG,OAAO,CAAC,MAAqB;;;YAC/B,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,qBAAqB,CAChD,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,MAAM,EACb,MAAA,MAAM,CAAC,QAAQ,mCAAI,IAAI,EACvB,MAAA,MAAM,CAAC,iBAAiB,mCAAI,CAAC,EAC7B,MAAA,MAAM,CAAC,WAAW,mCAAI,IAAI,EAC1B,MAAM,CAAC,YAAY,EACnB,MAAA,MAAM,CAAC,QAAQ,mCAAI,GAAG,CACzB,CAAC;QACN,CAAC;KAAA;IAED;;OAEG;IACG,QAAQ,CAAC,MAAsB;;YACjC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"deposits.js","sourceRoot":"","sources":["../../src/facade/deposits.ts"],"names":[],"mappings":";;;;;;;;;AAMA;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACvB,YACY,YAAyB,EACzB,QAAgB;QADhB,iBAAY,GAAZ,YAAY,CAAa;QACzB,aAAQ,GAAR,QAAQ,CAAQ;IACzB,CAAC;IAEJ;;;;;;;;;;;;;;;;OAgBG;IACG,OAAO,CAAC,MAAqB;;;YAC/B,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,qBAAqB,CAChD,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,MAAM,EACb,MAAA,MAAM,CAAC,QAAQ,mCAAI,IAAI,EACvB,MAAA,MAAM,CAAC,iBAAiB,mCAAI,CAAC,EAC7B,MAAA,MAAM,CAAC,WAAW,mCAAI,IAAI,EAC1B,MAAM,CAAC,YAAY,EACnB,MAAA,MAAM,CAAC,QAAQ,mCAAI,GAAG,CACzB,CAAC;QACN,CAAC;KAAA;IAED;;OAEG;IACG,QAAQ,CAAC,MAAsB;;YACjC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,wBAAwB,CACnD,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,MAAM,CAChB,CAAC;QACN,CAAC;KAAA;IAED;;OAEG;IACG,WAAW,CACb,MAAc,EACd,SAAiB,EACjB,WAAmB;;YAEnB,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAC/C,MAAM,EACN,SAAS,EACT,WAAW,CACd,CAAC;QACN,CAAC;KAAA;IAED;;;;;OAKG;IACH,cAAc,CAAC,WAA0B;QACrC,OAAO,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAC5C,WAAW,EACX,IAAI,CAAC,QAAQ,CAChB,CAAC;IACN,CAAC;IAED;;;OAGG;IACG,iBAAiB,CAAC,MAAc;;YAClC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC;KAAA;IAED;;OAEG;IACG,eAAe;;YACjB,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC;QACrD,CAAC;KAAA;CACJ"}
|
package/dist/facade/types.d.ts
CHANGED
|
@@ -57,9 +57,9 @@ export interface StrategyTranche {
|
|
|
57
57
|
apy: number;
|
|
58
58
|
minApy: number;
|
|
59
59
|
maxApy: number;
|
|
60
|
-
/** Minimum deposit in
|
|
60
|
+
/** Minimum deposit in stable asset units (ether-formatted string). */
|
|
61
61
|
minimumDeposit: string;
|
|
62
|
-
/** Maximum deposit in
|
|
62
|
+
/** Maximum deposit in stable asset units (ether-formatted string). */
|
|
63
63
|
maximumDeposit: string;
|
|
64
64
|
/** Remaining tranche capacity (ether-formatted string). */
|
|
65
65
|
availableCapacity: string;
|
|
@@ -78,7 +78,7 @@ export interface FixedTermOption {
|
|
|
78
78
|
export interface DepositParams {
|
|
79
79
|
poolId: string;
|
|
80
80
|
trancheId: string;
|
|
81
|
-
/** Amount in
|
|
81
|
+
/** Amount in stable asset base units (BigNumberish). */
|
|
82
82
|
amount: BigNumberish;
|
|
83
83
|
/** KYC signature obtained from the Nexera flow. */
|
|
84
84
|
kycSignature: {
|
|
@@ -89,7 +89,7 @@ export interface DepositParams {
|
|
|
89
89
|
depositData?: BytesLike;
|
|
90
90
|
/** Fixed-term config ID. Pass `0` for variable deposits. */
|
|
91
91
|
fixedTermConfigId?: BigNumberish;
|
|
92
|
-
/** Swap calldata. Pass `'0x'` when depositing
|
|
92
|
+
/** Swap calldata. Pass `'0x'` when depositing the stable asset directly. */
|
|
93
93
|
swapData?: BytesLike;
|
|
94
94
|
/** Native token value to send (e.g. for gas on some chains). Defaults to `'0'`. */
|
|
95
95
|
ethValue?: string;
|
|
@@ -97,17 +97,17 @@ export interface DepositParams {
|
|
|
97
97
|
export interface WithdrawParams {
|
|
98
98
|
poolId: string;
|
|
99
99
|
trancheId: string;
|
|
100
|
-
/**
|
|
100
|
+
/** Stable asset amount to withdraw, or `'max'` to withdraw entire balance. */
|
|
101
101
|
amount: BigNumberish;
|
|
102
102
|
/** Required when `amount` is `'max'`. */
|
|
103
103
|
userAddress?: string;
|
|
104
104
|
}
|
|
105
105
|
export interface DepositLimits {
|
|
106
|
-
/** Minimum deposit (ether-formatted
|
|
106
|
+
/** Minimum deposit (ether-formatted stable asset amount). */
|
|
107
107
|
min: string;
|
|
108
|
-
/** Maximum deposit (ether-formatted
|
|
108
|
+
/** Maximum deposit (ether-formatted stable asset amount). */
|
|
109
109
|
max: string;
|
|
110
|
-
/** Remaining tranche capacity (ether-formatted
|
|
110
|
+
/** Remaining tranche capacity (ether-formatted stable asset amount). */
|
|
111
111
|
availableCapacity: string;
|
|
112
112
|
}
|
|
113
113
|
export interface KycParams {
|
package/dist/sdk-config.d.ts
CHANGED
|
@@ -33,6 +33,11 @@ export interface SdkConfigOptions {
|
|
|
33
33
|
* Value: pool address in Directus / Base pool (lowercase)
|
|
34
34
|
*/
|
|
35
35
|
poolMetadataMapping?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* Decimals of the stable asset used by lending pools (e.g. 6 for USDC/AUDD).
|
|
38
|
+
* @default 6
|
|
39
|
+
*/
|
|
40
|
+
stableAssetDecimals?: number;
|
|
36
41
|
}
|
|
37
42
|
export declare class SdkConfig {
|
|
38
43
|
subgraphUrl: string;
|
|
@@ -42,5 +47,6 @@ export declare class SdkConfig {
|
|
|
42
47
|
UNUSED_LENDING_POOL_IDS: string[];
|
|
43
48
|
isLiteDeployment: boolean;
|
|
44
49
|
poolMetadataMapping: Record<string, string>;
|
|
50
|
+
stableAssetDecimals: number;
|
|
45
51
|
constructor(options: SdkConfigOptions);
|
|
46
52
|
}
|
package/dist/sdk-config.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export class SdkConfig {
|
|
2
2
|
constructor(options) {
|
|
3
|
-
var _a, _b, _c;
|
|
3
|
+
var _a, _b, _c, _d;
|
|
4
4
|
this.subgraphUrl = options.subgraphUrl;
|
|
5
5
|
this.contracts = options.contracts;
|
|
6
6
|
this.directusUrl = (_a = options.directusUrl) !== null && _a !== void 0 ? _a : '';
|
|
7
7
|
this.UNUSED_LENDING_POOL_IDS = options.UNUSED_LENDING_POOL_IDS;
|
|
8
8
|
this.isLiteDeployment = (_b = options.isLiteDeployment) !== null && _b !== void 0 ? _b : false;
|
|
9
9
|
this.poolMetadataMapping = (_c = options.poolMetadataMapping) !== null && _c !== void 0 ? _c : {};
|
|
10
|
+
this.stableAssetDecimals = (_d = options.stableAssetDecimals) !== null && _d !== void 0 ? _d : 6;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=sdk-config.js.map
|
package/dist/sdk-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-config.js","sourceRoot":"","sources":["../src/sdk-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk-config.js","sourceRoot":"","sources":["../src/sdk-config.ts"],"names":[],"mappings":"AA2CA,MAAM,OAAO,SAAS;IAUlB,YAAY,OAAyB;;QACjC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,MAAA,OAAO,CAAC,WAAW,mCAAI,EAAE,CAAC;QAC7C,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;QAC/D,IAAI,CAAC,gBAAgB,GAAG,MAAA,OAAO,CAAC,gBAAgB,mCAAI,KAAK,CAAC;QAC1D,IAAI,CAAC,mBAAmB,GAAG,MAAA,OAAO,CAAC,mBAAmB,mCAAI,EAAE,CAAC;QAC7D,IAAI,CAAC,mBAAmB,GAAG,MAAA,OAAO,CAAC,mBAAmB,mCAAI,CAAC,CAAC;IAChE,CAAC;CACJ"}
|