@scallop-io/sui-scallop-sdk 0.47.2 → 0.47.4
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/builders/oracle.d.ts +4 -1
- package/dist/index.js +52 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -30
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallop.d.ts +5 -5
- package/dist/models/scallopQuery.d.ts +4 -1
- package/dist/queries/vescaQuery.d.ts +1 -1
- package/dist/types/model.d.ts +4 -3
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +3 -8
- package/src/builders/oracle.ts +8 -2
- package/src/models/scallop.ts +39 -16
- package/src/models/scallopClient.ts +3 -1
- package/src/models/scallopQuery.ts +8 -2
- package/src/queries/vescaQuery.ts +8 -2
- package/src/types/model.ts +7 -3
package/dist/index.mjs
CHANGED
|
@@ -4081,7 +4081,7 @@ var getVescaKeys = async (utils, ownerAddress) => {
|
|
|
4081
4081
|
};
|
|
4082
4082
|
var getVeScas = async ({
|
|
4083
4083
|
utils
|
|
4084
|
-
}, ownerAddress) => {
|
|
4084
|
+
}, ownerAddress, excludeEmpty) => {
|
|
4085
4085
|
const keyObjectDatas = await getVescaKeys(utils, ownerAddress);
|
|
4086
4086
|
const veScas = Array(keyObjectDatas.length).fill(null);
|
|
4087
4087
|
const tasks = keyObjectDatas.map(async (veScaKey, idx) => {
|
|
@@ -4091,7 +4091,11 @@ var getVeScas = async ({
|
|
|
4091
4091
|
}
|
|
4092
4092
|
});
|
|
4093
4093
|
await Promise.allSettled(tasks);
|
|
4094
|
-
|
|
4094
|
+
const result = veScas.filter(Boolean).sort((a, b) => b.currentVeScaBalance - a.currentVeScaBalance);
|
|
4095
|
+
if (excludeEmpty) {
|
|
4096
|
+
return result.filter((v) => v.lockedScaAmount !== "0");
|
|
4097
|
+
}
|
|
4098
|
+
return result;
|
|
4095
4099
|
};
|
|
4096
4100
|
var SuiObjectRefZod = zod2.object({
|
|
4097
4101
|
objectId: zod2.string(),
|
|
@@ -4734,12 +4738,13 @@ import {
|
|
|
4734
4738
|
SuiPythClient,
|
|
4735
4739
|
SuiPriceServiceConnection as SuiPriceServiceConnection2
|
|
4736
4740
|
} from "@pythnetwork/pyth-sui-js";
|
|
4737
|
-
var updateOracles = async (builder, txBlock, assetCoinNames) => {
|
|
4741
|
+
var updateOracles = async (builder, txBlock, assetCoinNames, options = { usePythPullModel: true }) => {
|
|
4742
|
+
const usePythPullModel = builder.params.usePythPullModel ?? options.usePythPullModel;
|
|
4738
4743
|
assetCoinNames = assetCoinNames ?? [
|
|
4739
4744
|
.../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
|
|
4740
4745
|
];
|
|
4741
4746
|
const rules = builder.isTestnet ? ["pyth"] : ["pyth"];
|
|
4742
|
-
if (rules.includes("pyth")) {
|
|
4747
|
+
if (usePythPullModel && rules.includes("pyth")) {
|
|
4743
4748
|
const pythClient = new SuiPythClient(
|
|
4744
4749
|
builder.suiKit.client(),
|
|
4745
4750
|
builder.address.get("core.oracles.pyth.state"),
|
|
@@ -5646,19 +5651,14 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
5646
5651
|
);
|
|
5647
5652
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
5648
5653
|
const bindedVeScaKey = await builder.query.getBindedVeScaKey(obligationArg);
|
|
5649
|
-
if (veScaKey && veScaKey !== bindedVeScaKey) {
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
);
|
|
5653
|
-
}
|
|
5654
|
-
if (bindedVeScaKey) {
|
|
5654
|
+
if (veScaKey && veScaKey !== bindedVeScaKey || !bindedVeScaKey) {
|
|
5655
|
+
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
5656
|
+
} else {
|
|
5655
5657
|
txBlock.stakeObligationWithVesca(
|
|
5656
5658
|
obligationArg,
|
|
5657
5659
|
obligationKeyArg,
|
|
5658
5660
|
bindedVeScaKey
|
|
5659
5661
|
);
|
|
5660
|
-
} else {
|
|
5661
|
-
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
5662
5662
|
}
|
|
5663
5663
|
}
|
|
5664
5664
|
},
|
|
@@ -6989,8 +6989,11 @@ var ScallopQuery = class {
|
|
|
6989
6989
|
* @param walletAddress
|
|
6990
6990
|
* @returns array of veSca
|
|
6991
6991
|
*/
|
|
6992
|
-
async getVeScas(
|
|
6993
|
-
|
|
6992
|
+
async getVeScas({
|
|
6993
|
+
walletAddress = this.walletAddress,
|
|
6994
|
+
excludeEmpty = false
|
|
6995
|
+
} = {}) {
|
|
6996
|
+
return await getVeScas(this, walletAddress, excludeEmpty);
|
|
6994
6997
|
}
|
|
6995
6998
|
/**
|
|
6996
6999
|
* Get total vesca treasury with movecall
|
|
@@ -7838,7 +7841,9 @@ var ScallopClient = class {
|
|
|
7838
7841
|
}
|
|
7839
7842
|
}
|
|
7840
7843
|
async claimAllUnlockedSca(sign = true) {
|
|
7841
|
-
const veScaKeys = (await this.query.getVeScas(
|
|
7844
|
+
const veScaKeys = (await this.query.getVeScas({
|
|
7845
|
+
walletAddress: this.walletAddress
|
|
7846
|
+
}) ?? []).map(({ keyObject }) => keyObject);
|
|
7842
7847
|
if (veScaKeys.length === 0) {
|
|
7843
7848
|
throw new Error("No veSCA found in the wallet");
|
|
7844
7849
|
}
|
|
@@ -7935,11 +7940,15 @@ var Scallop = class {
|
|
|
7935
7940
|
*
|
|
7936
7941
|
* @return Scallop Builder.
|
|
7937
7942
|
*/
|
|
7938
|
-
async createScallopBuilder() {
|
|
7943
|
+
async createScallopBuilder(params) {
|
|
7939
7944
|
if (!this.address.getAddresses())
|
|
7940
7945
|
await this.address.read();
|
|
7941
|
-
const
|
|
7942
|
-
|
|
7946
|
+
const builderParams = {
|
|
7947
|
+
...this.params,
|
|
7948
|
+
...params
|
|
7949
|
+
};
|
|
7950
|
+
const scallopBuilder = new ScallopBuilder(builderParams, {
|
|
7951
|
+
query: await this.createScallopQuery(builderParams)
|
|
7943
7952
|
});
|
|
7944
7953
|
return scallopBuilder;
|
|
7945
7954
|
}
|
|
@@ -7949,13 +7958,16 @@ var Scallop = class {
|
|
|
7949
7958
|
* @param walletAddress - When user cannot provide a secret key or mnemonic, the scallop client cannot directly derive the address of the transaction the user wants to sign. This argument specifies the wallet address for signing the transaction.
|
|
7950
7959
|
* @return Scallop Client.
|
|
7951
7960
|
*/
|
|
7952
|
-
async createScallopClient(
|
|
7961
|
+
async createScallopClient(params) {
|
|
7953
7962
|
if (!this.address.getAddresses())
|
|
7954
7963
|
await this.address.read();
|
|
7955
|
-
const
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7964
|
+
const clientParams = {
|
|
7965
|
+
...this.params,
|
|
7966
|
+
...params
|
|
7967
|
+
};
|
|
7968
|
+
const scallopClient = new ScallopClient(clientParams, {
|
|
7969
|
+
builder: await this.createScallopBuilder(clientParams)
|
|
7970
|
+
});
|
|
7959
7971
|
return scallopClient;
|
|
7960
7972
|
}
|
|
7961
7973
|
/**
|
|
@@ -7963,11 +7975,15 @@ var Scallop = class {
|
|
|
7963
7975
|
*
|
|
7964
7976
|
* @return Scallop Query.
|
|
7965
7977
|
*/
|
|
7966
|
-
async createScallopQuery() {
|
|
7978
|
+
async createScallopQuery(params) {
|
|
7967
7979
|
if (!this.address.getAddresses())
|
|
7968
7980
|
await this.address.read();
|
|
7969
|
-
const
|
|
7970
|
-
|
|
7981
|
+
const queryParams = {
|
|
7982
|
+
...this.params,
|
|
7983
|
+
...params
|
|
7984
|
+
};
|
|
7985
|
+
const scallopQuery = new ScallopQuery(queryParams, {
|
|
7986
|
+
utils: await this.createScallopUtils(queryParams)
|
|
7971
7987
|
});
|
|
7972
7988
|
return scallopQuery;
|
|
7973
7989
|
}
|
|
@@ -7987,12 +8003,18 @@ var Scallop = class {
|
|
|
7987
8003
|
*
|
|
7988
8004
|
* @return Scallop Utils.
|
|
7989
8005
|
*/
|
|
7990
|
-
async createScallopUtils() {
|
|
8006
|
+
async createScallopUtils(params) {
|
|
7991
8007
|
if (!this.address.getAddresses())
|
|
7992
8008
|
await this.address.read();
|
|
7993
|
-
const scallopUtils = new ScallopUtils(
|
|
7994
|
-
|
|
7995
|
-
|
|
8009
|
+
const scallopUtils = new ScallopUtils(
|
|
8010
|
+
{
|
|
8011
|
+
...this.params,
|
|
8012
|
+
...params
|
|
8013
|
+
},
|
|
8014
|
+
{
|
|
8015
|
+
address: this.address
|
|
8016
|
+
}
|
|
8017
|
+
);
|
|
7996
8018
|
return scallopUtils;
|
|
7997
8019
|
}
|
|
7998
8020
|
};
|