@sodax/sdk 1.0.0-rc.6 → 1.0.0-rc.7
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 +46 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -13
- package/dist/index.d.ts +53 -13
- package/dist/index.mjs +46 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -6881,7 +6881,6 @@ var ConfigService = class {
|
|
|
6881
6881
|
supportedSodaVaultAssetsSet;
|
|
6882
6882
|
intentRelayChainIdToSpokeChainIdMap;
|
|
6883
6883
|
supportedTokensPerChain;
|
|
6884
|
-
hubVaultsAddressSet;
|
|
6885
6884
|
moneyMarketReserveAssetsSet;
|
|
6886
6885
|
spokeChainIdsSet;
|
|
6887
6886
|
constructor({ backendApiService, config }) {
|
|
@@ -6928,9 +6927,6 @@ var ConfigService = class {
|
|
|
6928
6927
|
getHubAssets() {
|
|
6929
6928
|
return this.sodaxConfig.supportedHubAssets;
|
|
6930
6929
|
}
|
|
6931
|
-
getHubVaults() {
|
|
6932
|
-
return this.sodaxConfig.supportedHubVaults;
|
|
6933
|
-
}
|
|
6934
6930
|
getRelayChainIdMap() {
|
|
6935
6931
|
return this.sodaxConfig.relayChainIdMap;
|
|
6936
6932
|
}
|
|
@@ -7034,12 +7030,8 @@ var ConfigService = class {
|
|
|
7034
7030
|
isMoneyMarketReserveHubAsset(hubAsset) {
|
|
7035
7031
|
return this.moneyMarketReserveAssetsSet.has(hubAsset.toLowerCase());
|
|
7036
7032
|
}
|
|
7037
|
-
getHubVaultsAddressSet() {
|
|
7038
|
-
return this.hubVaultsAddressSet;
|
|
7039
|
-
}
|
|
7040
7033
|
loadSodaxConfigDataStructures(sodaxConfig) {
|
|
7041
7034
|
this.loadHubAssetDataStructures(sodaxConfig.supportedHubAssets);
|
|
7042
|
-
this.loadHubVaultsDataStructures(sodaxConfig.supportedHubVaults);
|
|
7043
7035
|
this.loadSpokeChainDataStructures(sodaxConfig.supportedChains);
|
|
7044
7036
|
this.loadRelayChainIdMapDataStructures(sodaxConfig.relayChainIdMap);
|
|
7045
7037
|
this.loadSpokeChainConfigDataStructures(sodaxConfig.spokeChainConfig);
|
|
@@ -7075,9 +7067,6 @@ var ConfigService = class {
|
|
|
7075
7067
|
)
|
|
7076
7068
|
);
|
|
7077
7069
|
}
|
|
7078
|
-
loadHubVaultsDataStructures(hubVaults) {
|
|
7079
|
-
this.hubVaultsAddressSet = new Set(Object.values(hubVaults).map((vault) => vault.address.toLowerCase()));
|
|
7080
|
-
}
|
|
7081
7070
|
loadSpokeChainDataStructures(chains) {
|
|
7082
7071
|
this.spokeChainIdsSet = new Set(chains);
|
|
7083
7072
|
}
|
|
@@ -10151,7 +10140,8 @@ var UiPoolDataProviderService = class {
|
|
|
10151
10140
|
availableLiquidity: cap - currentBorrowed,
|
|
10152
10141
|
totalScaledVariableDebt: bnUSDReserve.totalScaledVariableDebt + bnUSDVaultReserve.totalScaledVariableDebt,
|
|
10153
10142
|
virtualUnderlyingBalance: bnUSDReserve.virtualUnderlyingBalance + bnUSDVaultReserve.virtualUnderlyingBalance,
|
|
10154
|
-
accruedToTreasury: bnUSDReserve.accruedToTreasury + bnUSDVaultReserve.accruedToTreasury
|
|
10143
|
+
accruedToTreasury: bnUSDReserve.accruedToTreasury + bnUSDVaultReserve.accruedToTreasury,
|
|
10144
|
+
variableBorrowRate: bnUSDReserve.variableBorrowRate
|
|
10155
10145
|
};
|
|
10156
10146
|
return [
|
|
10157
10147
|
[
|
|
@@ -10680,6 +10670,7 @@ var StellarSpokeService = class _StellarSpokeService {
|
|
|
10680
10670
|
}
|
|
10681
10671
|
};
|
|
10682
10672
|
var IntentCreatedEventAbi = viem.getAbiItem({ abi: IntentsAbi, name: "IntentCreated" });
|
|
10673
|
+
var IntentFilledEventAbi = viem.getAbiItem({ abi: IntentsAbi, name: "IntentFilled" });
|
|
10683
10674
|
var EvmSolverService = class _EvmSolverService {
|
|
10684
10675
|
constructor() {
|
|
10685
10676
|
}
|
|
@@ -10806,6 +10797,36 @@ var EvmSolverService = class _EvmSolverService {
|
|
|
10806
10797
|
}
|
|
10807
10798
|
throw new Error(`No intent found for ${txHash}`);
|
|
10808
10799
|
}
|
|
10800
|
+
/**
|
|
10801
|
+
* Gets a filled intent from a transaction hash
|
|
10802
|
+
* @param {Hash} txHash - The transaction hash
|
|
10803
|
+
* @param {SolverConfig} solverConfig - The solver configuration
|
|
10804
|
+
* @param {EvmHubProvider} hubProvider - The EVM hub provider
|
|
10805
|
+
* @returns {Promise<IntentState>} The intent state
|
|
10806
|
+
*/
|
|
10807
|
+
static async getFilledIntent(txHash, solverConfig, hubProvider) {
|
|
10808
|
+
const receipt = await hubProvider.publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
10809
|
+
const logs = viem.parseEventLogs({
|
|
10810
|
+
abi: IntentsAbi,
|
|
10811
|
+
eventName: "IntentFilled",
|
|
10812
|
+
logs: receipt.logs,
|
|
10813
|
+
strict: true
|
|
10814
|
+
});
|
|
10815
|
+
for (const log of logs) {
|
|
10816
|
+
if (log.address.toLowerCase() === solverConfig.intentsContract.toLowerCase()) {
|
|
10817
|
+
if (!log.args.intentHash || !log.args.intentState) {
|
|
10818
|
+
continue;
|
|
10819
|
+
}
|
|
10820
|
+
return {
|
|
10821
|
+
exists: log.args.intentState.exists,
|
|
10822
|
+
remainingInput: log.args.intentState.remainingInput,
|
|
10823
|
+
receivedOutput: log.args.intentState.receivedOutput,
|
|
10824
|
+
pendingPayment: log.args.intentState.pendingPayment
|
|
10825
|
+
};
|
|
10826
|
+
}
|
|
10827
|
+
}
|
|
10828
|
+
throw new Error(`No filled intent found for ${txHash}`);
|
|
10829
|
+
}
|
|
10809
10830
|
/**
|
|
10810
10831
|
* Gets the keccak256 hash of an intent. Hash serves as the intent id on Hub chain.
|
|
10811
10832
|
* @param {Intent} intent - The intent
|
|
@@ -11851,6 +11872,14 @@ var SwapService = class {
|
|
|
11851
11872
|
getIntent(txHash) {
|
|
11852
11873
|
return EvmSolverService.getIntent(txHash, this.config, this.hubProvider);
|
|
11853
11874
|
}
|
|
11875
|
+
/**
|
|
11876
|
+
* Gets the intent state from a transaction hash (on Hub chain)
|
|
11877
|
+
* @param {Hash} txHash - The transaction hash on Hub chain
|
|
11878
|
+
* @returns {Promise<IntentState>} The intent state
|
|
11879
|
+
*/
|
|
11880
|
+
getFilledIntent(txHash) {
|
|
11881
|
+
return EvmSolverService.getFilledIntent(txHash, this.config, this.hubProvider);
|
|
11882
|
+
}
|
|
11854
11883
|
/**
|
|
11855
11884
|
* Gets the keccak256 hash of an intent. Hash serves as the intent id on Hub chain.
|
|
11856
11885
|
* @param {Intent} intent - The intent
|
|
@@ -13651,18 +13680,7 @@ var Sodax = class {
|
|
|
13651
13680
|
* @param sodax - The Sodax instance to initialize.
|
|
13652
13681
|
*/
|
|
13653
13682
|
async initialize() {
|
|
13654
|
-
|
|
13655
|
-
await this.config.initialize();
|
|
13656
|
-
return {
|
|
13657
|
-
ok: true,
|
|
13658
|
-
value: void 0
|
|
13659
|
-
};
|
|
13660
|
-
} catch (error) {
|
|
13661
|
-
return {
|
|
13662
|
-
ok: false,
|
|
13663
|
-
error
|
|
13664
|
-
};
|
|
13665
|
-
}
|
|
13683
|
+
return this.config.initialize();
|
|
13666
13684
|
}
|
|
13667
13685
|
};
|
|
13668
13686
|
|
|
@@ -15342,8 +15360,9 @@ var BackendApiService = class {
|
|
|
15342
15360
|
}
|
|
15343
15361
|
// Intent endpoints
|
|
15344
15362
|
/**
|
|
15345
|
-
* Get intent details by transaction hash
|
|
15346
|
-
*
|
|
15363
|
+
* Get intent details by intent created transaction hash from the hub chain.
|
|
15364
|
+
* Intents are only created on the hub chain, so the transaction hash must be from the hub chain.
|
|
15365
|
+
* @param txHash - The intent created transaction hash from the hub chain
|
|
15347
15366
|
* @returns Promise<IntentResponse>
|
|
15348
15367
|
*/
|
|
15349
15368
|
async getIntentByTxHash(txHash) {
|
|
@@ -15498,13 +15517,6 @@ var BackendApiService = class {
|
|
|
15498
15517
|
async getHubAssets() {
|
|
15499
15518
|
return this.makeRequest("/config/hub/assets", { method: "GET" });
|
|
15500
15519
|
}
|
|
15501
|
-
/**
|
|
15502
|
-
* Get all supported Soda hub vaults
|
|
15503
|
-
* @returns Promise<GetHubVaultsApiResponse>
|
|
15504
|
-
*/
|
|
15505
|
-
async getHubVaults() {
|
|
15506
|
-
return this.makeRequest("/config/hub/vaults", { method: "GET" });
|
|
15507
|
-
}
|
|
15508
15520
|
/**
|
|
15509
15521
|
* Get supported hub assets (assets representing spoke token deposit) for a specific spoke chain
|
|
15510
15522
|
* @param chainId - Spoke chain id
|
|
@@ -19460,6 +19472,7 @@ exports.InjectiveSpokeProvider = InjectiveSpokeProvider;
|
|
|
19460
19472
|
exports.InjectiveSpokeService = InjectiveSpokeService;
|
|
19461
19473
|
exports.IntentCreatedEventAbi = IntentCreatedEventAbi;
|
|
19462
19474
|
exports.IntentDataType = IntentDataType;
|
|
19475
|
+
exports.IntentFilledEventAbi = IntentFilledEventAbi;
|
|
19463
19476
|
exports.IntentsAbi = IntentsAbi;
|
|
19464
19477
|
exports.LTV_PRECISION = LTV_PRECISION;
|
|
19465
19478
|
exports.LendingPoolService = LendingPoolService;
|