@defisaver/positions-sdk 1.0.14 → 1.0.16
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/cjs/liquityV2/index.js
CHANGED
|
@@ -121,10 +121,9 @@ const getTransferredTroves = (web3, network, troveNFTAddress, limitBlocksForEven
|
|
|
121
121
|
const nftContractCreationBlock = nftContractCreationBlockMapping[market];
|
|
122
122
|
const currentBlock = yield web3.eth.getBlockNumber();
|
|
123
123
|
const events = yield nftContract.getPastEvents(TransferEventSig, {
|
|
124
|
-
filter: { to: account },
|
|
125
124
|
fromBlock: limitBlocksForEventFetching ? (currentBlock - 1000) : nftContractCreationBlock,
|
|
126
125
|
});
|
|
127
|
-
const userTransferredTroves = events.filter((event) =>
|
|
126
|
+
const userTransferredTroves = events.filter((event) => (0, utils_1.compareAddresses)(event.returnValues.to, account));
|
|
128
127
|
// check if the last know transfer address is the user
|
|
129
128
|
userTransferredTroves.forEach((event, index) => {
|
|
130
129
|
const otherTransfers = events.filter((e) => event.blockNumber < e.blockNumber && e.returnValues.tokenId === event.returnValues.tokenId);
|
|
@@ -142,7 +141,11 @@ const getLiquityV2UserTroveIds = (web3, network, selectedMarket, troveNFTAddress
|
|
|
142
141
|
]);
|
|
143
142
|
const troves = [...userTroves.map(({ troveId }) => ({ troveId })), ...userTransferredTroves];
|
|
144
143
|
const filteredTroves = troves.filter((value, index, self) => index === self.findIndex((t) => (t.troveId === value.troveId)));
|
|
145
|
-
|
|
144
|
+
const troveIds = filteredTroves.map((trove) => trove.troveId);
|
|
145
|
+
const troveIdsSet = new Set(troveIds);
|
|
146
|
+
const troveIdsArray = Array.from(troveIdsSet);
|
|
147
|
+
const trovesNoDuplicates = troveIdsArray.map((troveId) => troves.find((trove) => trove.troveId === troveId));
|
|
148
|
+
return { troves: trovesNoDuplicates, nextFreeTroveIndex };
|
|
146
149
|
});
|
|
147
150
|
exports.getLiquityV2UserTroveIds = getLiquityV2UserTroveIds;
|
|
148
151
|
const _getDebtInFrontForSingleMarket = (viewContract, marketAddress, troveId, accumulatedSum = '0', iterations = 2000) => __awaiter(void 0, void 0, void 0, function* () { return viewContract.methods.getDebtInFront(marketAddress, troveId, accumulatedSum, iterations).call(); });
|
package/esm/liquityV2/index.js
CHANGED
|
@@ -114,10 +114,9 @@ const getTransferredTroves = (web3, network, troveNFTAddress, limitBlocksForEven
|
|
|
114
114
|
const nftContractCreationBlock = nftContractCreationBlockMapping[market];
|
|
115
115
|
const currentBlock = yield web3.eth.getBlockNumber();
|
|
116
116
|
const events = yield nftContract.getPastEvents(TransferEventSig, {
|
|
117
|
-
filter: { to: account },
|
|
118
117
|
fromBlock: limitBlocksForEventFetching ? (currentBlock - 1000) : nftContractCreationBlock,
|
|
119
118
|
});
|
|
120
|
-
const userTransferredTroves = events.filter((event) =>
|
|
119
|
+
const userTransferredTroves = events.filter((event) => compareAddresses(event.returnValues.to, account));
|
|
121
120
|
// check if the last know transfer address is the user
|
|
122
121
|
userTransferredTroves.forEach((event, index) => {
|
|
123
122
|
const otherTransfers = events.filter((e) => event.blockNumber < e.blockNumber && e.returnValues.tokenId === event.returnValues.tokenId);
|
|
@@ -135,7 +134,11 @@ export const getLiquityV2UserTroveIds = (web3, network, selectedMarket, troveNFT
|
|
|
135
134
|
]);
|
|
136
135
|
const troves = [...userTroves.map(({ troveId }) => ({ troveId })), ...userTransferredTroves];
|
|
137
136
|
const filteredTroves = troves.filter((value, index, self) => index === self.findIndex((t) => (t.troveId === value.troveId)));
|
|
138
|
-
|
|
137
|
+
const troveIds = filteredTroves.map((trove) => trove.troveId);
|
|
138
|
+
const troveIdsSet = new Set(troveIds);
|
|
139
|
+
const troveIdsArray = Array.from(troveIdsSet);
|
|
140
|
+
const trovesNoDuplicates = troveIdsArray.map((troveId) => troves.find((trove) => trove.troveId === troveId));
|
|
141
|
+
return { troves: trovesNoDuplicates, nextFreeTroveIndex };
|
|
139
142
|
});
|
|
140
143
|
const _getDebtInFrontForSingleMarket = (viewContract, marketAddress, troveId, accumulatedSum = '0', iterations = 2000) => __awaiter(void 0, void 0, void 0, function* () { return viewContract.methods.getDebtInFront(marketAddress, troveId, accumulatedSum, iterations).call(); });
|
|
141
144
|
export const getDebtInFrontForSingleMarketLiquityV2 = (viewContract, marketAddress, troveId, accumulatedSum = '0', iterations = 2000) => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
package/src/liquityV2/index.ts
CHANGED
|
@@ -128,11 +128,10 @@ const getTransferredTroves = async (web3: Web3, network: NetworkNumber, troveNFT
|
|
|
128
128
|
const events = await nftContract.getPastEvents(
|
|
129
129
|
TransferEventSig,
|
|
130
130
|
{
|
|
131
|
-
filter: { to: account },
|
|
132
131
|
fromBlock: limitBlocksForEventFetching ? (currentBlock - 1000) : nftContractCreationBlock,
|
|
133
132
|
},
|
|
134
133
|
);
|
|
135
|
-
const userTransferredTroves = events.filter((event) =>
|
|
134
|
+
const userTransferredTroves = events.filter((event) => compareAddresses(event.returnValues.to, account));
|
|
136
135
|
|
|
137
136
|
// check if the last know transfer address is the user
|
|
138
137
|
userTransferredTroves.forEach((event, index) => {
|
|
@@ -155,7 +154,11 @@ export const getLiquityV2UserTroveIds = async (web3: Web3, network: NetworkNumbe
|
|
|
155
154
|
t.troveId === value.troveId
|
|
156
155
|
)),
|
|
157
156
|
);
|
|
158
|
-
|
|
157
|
+
const troveIds = filteredTroves.map((trove) => trove.troveId);
|
|
158
|
+
const troveIdsSet = new Set(troveIds);
|
|
159
|
+
const troveIdsArray = Array.from(troveIdsSet);
|
|
160
|
+
const trovesNoDuplicates = troveIdsArray.map((troveId) => troves.find((trove) => trove.troveId === troveId)) as { troveId: string }[];
|
|
161
|
+
return { troves: trovesNoDuplicates, nextFreeTroveIndex };
|
|
159
162
|
};
|
|
160
163
|
|
|
161
164
|
const _getDebtInFrontForSingleMarket = async (viewContract: any, marketAddress: EthAddress, troveId: string, accumulatedSum = '0', iterations = 2000) => viewContract.methods.getDebtInFront(marketAddress, troveId, accumulatedSum, iterations).call();
|