@sodax/sdk 0.0.1-rc.23 → 0.0.1-rc.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +64 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +64 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7190,7 +7190,7 @@ var getAllLegacybnUSDTokens = () => {
|
|
|
7190
7190
|
var hubAssets = {
|
|
7191
7191
|
[types.SONIC_MAINNET_CHAIN_ID]: {
|
|
7192
7192
|
[spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].nativeToken]: {
|
|
7193
|
-
asset: spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.
|
|
7193
|
+
asset: spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.S.address,
|
|
7194
7194
|
decimal: 18,
|
|
7195
7195
|
symbol: "S",
|
|
7196
7196
|
name: "Sonic",
|
|
@@ -10072,7 +10072,7 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10072
10072
|
params.data
|
|
10073
10073
|
)[0]
|
|
10074
10074
|
);
|
|
10075
|
-
if (params.token === spokeProvider.chainConfig.nativeToken) {
|
|
10075
|
+
if (params.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
|
|
10076
10076
|
const wrapCall = {
|
|
10077
10077
|
address: spokeProvider.chainConfig.addresses.wrappedSonic,
|
|
10078
10078
|
value: params.amount,
|
|
@@ -10106,7 +10106,7 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10106
10106
|
from: params.from,
|
|
10107
10107
|
to: spokeProvider.chainConfig.addresses.walletRouter,
|
|
10108
10108
|
data: txData,
|
|
10109
|
-
value: params.token === spokeProvider.chainConfig.nativeToken ? params.amount : 0n
|
|
10109
|
+
value: params.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase() ? params.amount : 0n
|
|
10110
10110
|
};
|
|
10111
10111
|
if (raw) {
|
|
10112
10112
|
return rawTx;
|
|
@@ -10321,12 +10321,16 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10321
10321
|
}
|
|
10322
10322
|
return spokeProvider.walletProvider.sendTransaction(rawTx);
|
|
10323
10323
|
}
|
|
10324
|
-
static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService) {
|
|
10325
|
-
const userRouter = await _SonicSpokeService.getUserRouter(from, spokeProvider);
|
|
10324
|
+
static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService, userRouterAddress) {
|
|
10325
|
+
const userRouter = userRouterAddress ?? await _SonicSpokeService.getUserRouter(from, spokeProvider);
|
|
10326
|
+
let token = withdrawInfo.token;
|
|
10327
|
+
if (withdrawInfo.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
|
|
10328
|
+
token = spokeProvider.chainConfig.addresses.wrappedSonic;
|
|
10329
|
+
}
|
|
10326
10330
|
const withdrawCall = moneyMarketService.buildWithdrawData(
|
|
10327
10331
|
userRouter,
|
|
10328
10332
|
from,
|
|
10329
|
-
|
|
10333
|
+
token,
|
|
10330
10334
|
amount,
|
|
10331
10335
|
spokeProvider.chainConfig.chain.id
|
|
10332
10336
|
);
|
|
@@ -10344,17 +10348,6 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10344
10348
|
],
|
|
10345
10349
|
withdrawCall
|
|
10346
10350
|
)[0];
|
|
10347
|
-
const transferFromCall = Erc20Service.encodeTransferFrom(
|
|
10348
|
-
withdrawInfo.aTokenAddress,
|
|
10349
|
-
from,
|
|
10350
|
-
userRouter,
|
|
10351
|
-
withdrawInfo.aTokenAmount
|
|
10352
|
-
);
|
|
10353
|
-
calls.unshift({
|
|
10354
|
-
address: transferFromCall.address,
|
|
10355
|
-
value: transferFromCall.value,
|
|
10356
|
-
data: transferFromCall.data
|
|
10357
|
-
});
|
|
10358
10351
|
return encodeContractCalls(calls);
|
|
10359
10352
|
}
|
|
10360
10353
|
};
|
|
@@ -13860,7 +13853,7 @@ function calculateAllUserIncentives({
|
|
|
13860
13853
|
(reserve2) => reserve2.underlyingAsset === userIncentive.underlyingAsset
|
|
13861
13854
|
);
|
|
13862
13855
|
const userReserve = userReserves.find(
|
|
13863
|
-
(userReserve2) => userReserve2.reserve.underlyingAsset === userIncentive.underlyingAsset
|
|
13856
|
+
(userReserve2) => userReserve2.reserve.underlyingAsset.toLowerCase() === userIncentive.underlyingAsset.toLowerCase()
|
|
13864
13857
|
);
|
|
13865
13858
|
if (reserve) {
|
|
13866
13859
|
const reserveRewards = calculateUserReserveIncentives({
|
|
@@ -14875,7 +14868,11 @@ var MoneyMarketDataService = class {
|
|
|
14875
14868
|
*/
|
|
14876
14869
|
async getUserReservesData(spokeProvider) {
|
|
14877
14870
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
14878
|
-
const hubWalletAddress =
|
|
14871
|
+
const hubWalletAddress = await WalletAbstractionService.getUserHubWalletAddress(
|
|
14872
|
+
walletAddress,
|
|
14873
|
+
spokeProvider,
|
|
14874
|
+
this.hubProvider
|
|
14875
|
+
);
|
|
14879
14876
|
return this.uiPoolDataProviderService.getUserReservesData(hubWalletAddress);
|
|
14880
14877
|
}
|
|
14881
14878
|
/**
|
|
@@ -14906,7 +14903,11 @@ var MoneyMarketDataService = class {
|
|
|
14906
14903
|
*/
|
|
14907
14904
|
async getUserReservesHumanized(spokeProvider) {
|
|
14908
14905
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
14909
|
-
const hubWalletAddress =
|
|
14906
|
+
const hubWalletAddress = await WalletAbstractionService.getUserHubWalletAddress(
|
|
14907
|
+
walletAddress,
|
|
14908
|
+
spokeProvider,
|
|
14909
|
+
this.hubProvider
|
|
14910
|
+
);
|
|
14910
14911
|
return this.uiPoolDataProviderService.getUserReservesHumanized(hubWalletAddress);
|
|
14911
14912
|
}
|
|
14912
14913
|
/**
|
|
@@ -15644,13 +15645,31 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15644
15645
|
spokeProvider,
|
|
15645
15646
|
this.hubProvider
|
|
15646
15647
|
);
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
15651
|
-
|
|
15652
|
-
|
|
15653
|
-
|
|
15648
|
+
let data;
|
|
15649
|
+
if (spokeProvider instanceof SonicSpokeProvider) {
|
|
15650
|
+
const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
|
|
15651
|
+
params.token,
|
|
15652
|
+
params.amount,
|
|
15653
|
+
spokeProvider,
|
|
15654
|
+
this.data
|
|
15655
|
+
);
|
|
15656
|
+
data = await SonicSpokeService.buildWithdrawData(
|
|
15657
|
+
walletAddress,
|
|
15658
|
+
withdrawInfo,
|
|
15659
|
+
params.amount,
|
|
15660
|
+
spokeProvider,
|
|
15661
|
+
this,
|
|
15662
|
+
hubWallet
|
|
15663
|
+
);
|
|
15664
|
+
} else {
|
|
15665
|
+
data = this.buildWithdrawData(
|
|
15666
|
+
hubWallet,
|
|
15667
|
+
encodedAddress,
|
|
15668
|
+
params.token,
|
|
15669
|
+
params.amount,
|
|
15670
|
+
spokeProvider.chainConfig.chain.id
|
|
15671
|
+
);
|
|
15672
|
+
}
|
|
15654
15673
|
const txResult = await SpokeService.callWallet(hubWallet, data, spokeProvider, this.hubProvider, raw);
|
|
15655
15674
|
return {
|
|
15656
15675
|
ok: true,
|
|
@@ -15814,9 +15833,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15814
15833
|
const calls = [];
|
|
15815
15834
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
15816
15835
|
invariant10__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
|
|
15817
|
-
|
|
15836
|
+
let assetAddress = assetConfig.asset;
|
|
15818
15837
|
const vaultAddress = assetConfig.vault;
|
|
15819
15838
|
const lendingPool = this.config.lendingPool;
|
|
15839
|
+
if (spokeChainId === this.hubProvider.chainConfig.chain.id) {
|
|
15840
|
+
if (token.toLowerCase() === spokeChainConfig[this.hubProvider.chainConfig.chain.id].nativeToken.toLowerCase()) {
|
|
15841
|
+
assetAddress = spokeChainConfig[this.hubProvider.chainConfig.chain.id].supportedTokens.wS.address;
|
|
15842
|
+
}
|
|
15843
|
+
}
|
|
15820
15844
|
calls.push(Erc20Service.encodeApprove(assetAddress, vaultAddress, amount));
|
|
15821
15845
|
calls.push(EvmVaultTokenService.encodeDeposit(vaultAddress, assetAddress, amount));
|
|
15822
15846
|
const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(assetConfig.decimal, amount);
|
|
@@ -15846,10 +15870,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15846
15870
|
);
|
|
15847
15871
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
15848
15872
|
invariant10__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
|
|
15849
|
-
|
|
15873
|
+
let assetAddress = assetConfig.asset;
|
|
15850
15874
|
const vaultAddress = assetConfig.vault;
|
|
15851
15875
|
const bnUSDVault = this.config.bnUSDVault;
|
|
15852
15876
|
const bnUSD = this.config.bnUSD;
|
|
15877
|
+
if (spokeChainId === this.hubProvider.chainConfig.chain.id) {
|
|
15878
|
+
if (token.toLowerCase() === spokeChainConfig[this.hubProvider.chainConfig.chain.id].nativeToken.toLowerCase()) {
|
|
15879
|
+
assetAddress = spokeChainConfig[this.hubProvider.chainConfig.chain.id].supportedTokens.wS.address;
|
|
15880
|
+
}
|
|
15881
|
+
}
|
|
15853
15882
|
const feeAmount = calculateFeeAmount(amount, this.config.partnerFee);
|
|
15854
15883
|
const calls = [];
|
|
15855
15884
|
if (bnUSDVault && bnUSD && bnUSDVault.toLowerCase() === vaultAddress.toLowerCase()) {
|
|
@@ -15970,10 +15999,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15970
15999
|
if (!assetConfig) {
|
|
15971
16000
|
throw new Error("[buildRepayData] Hub asset not found");
|
|
15972
16001
|
}
|
|
15973
|
-
|
|
16002
|
+
let assetAddress = assetConfig.asset;
|
|
15974
16003
|
const vaultAddress = assetConfig.vault;
|
|
15975
16004
|
const bnUSDVault = this.config.bnUSDVault;
|
|
15976
16005
|
const bnUSD = this.config.bnUSD;
|
|
16006
|
+
if (spokeChainId === this.hubProvider.chainConfig.chain.id) {
|
|
16007
|
+
if (token.toLowerCase() === spokeChainConfig[this.hubProvider.chainConfig.chain.id].nativeToken.toLowerCase()) {
|
|
16008
|
+
assetAddress = spokeChainConfig[this.hubProvider.chainConfig.chain.id].supportedTokens.wS.address;
|
|
16009
|
+
}
|
|
16010
|
+
}
|
|
15977
16011
|
calls.push(Erc20Service.encodeApprove(assetAddress, vaultAddress, amount));
|
|
15978
16012
|
calls.push(EvmVaultTokenService.encodeDeposit(vaultAddress, assetAddress, amount));
|
|
15979
16013
|
const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(assetConfig.decimal, amount);
|