hedge-web3 0.1.37 → 0.1.38
Sign up to get free protection for your applications and to get access to all the features.
@@ -28,7 +28,6 @@ function claimLiquidationPoolPosition(program, provider, poolPosition, payer, co
|
|
28
28
|
exports.claimLiquidationPoolPosition = claimLiquidationPoolPosition;
|
29
29
|
function claimLiquidationPoolPositionInstruction(program, vaultTypeAccount, collateralMint, poolPosition, payer, payerAssociatedTokenAccount, overrideStartTime) {
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
31
|
-
console.log("inside function");
|
32
31
|
const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
33
32
|
const poolStatePublicKey = yield (0, Constants_1.getLiquidationPoolStatePublicKey)();
|
34
33
|
const poolAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolStatePublicKey, collateralMint);
|
@@ -70,10 +70,10 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
70
70
|
oldSmallerPublicKey = vaults[indexBefore - 1].publicKey;
|
71
71
|
}
|
72
72
|
// Pretty print all the vaults before the operation
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
console.log('Sorted open vaults before');
|
74
|
+
vaults.forEach((vault) => {
|
75
|
+
console.log(vault.toString(vaultPublicKey));
|
76
|
+
});
|
77
77
|
// If it wasn't in the list, add it now
|
78
78
|
if (indexBefore < 0) {
|
79
79
|
vaults.push(thisVault);
|
@@ -98,10 +98,10 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
98
98
|
// Sort it again since we've changed one vault
|
99
99
|
vaults = vaults.sort(sortVaults);
|
100
100
|
// Pretty print the list again
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
console.log('Sorted open vaults with new debt added');
|
102
|
+
vaults.forEach((vault) => {
|
103
|
+
console.log(vault.toString(vaultPublicKey));
|
104
|
+
});
|
105
105
|
// Search for the vaults new position
|
106
106
|
let indexAfter = -1;
|
107
107
|
vaults.forEach((vault, index) => {
|
@@ -110,8 +110,8 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
110
110
|
}
|
111
111
|
});
|
112
112
|
// Print where it moved from / to
|
113
|
-
|
114
|
-
|
113
|
+
console.log('Index Before', indexBefore);
|
114
|
+
console.log('Index After', indexAfter);
|
115
115
|
// Save references to the new left and right
|
116
116
|
if (indexAfter > 0) {
|
117
117
|
newSmallerPublicKey = vaults[indexAfter - 1].publicKey;
|
@@ -120,9 +120,9 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
120
120
|
newLargerPublicKey = vaults[indexAfter + 1].publicKey;
|
121
121
|
}
|
122
122
|
// Print out the new left/right
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
console.log('oldSmallerPublicKey', oldSmallerPublicKey.toString());
|
124
|
+
console.log('newSmallerPublicKey', newSmallerPublicKey.toString());
|
125
|
+
console.log('newLargerPublicKey', newLargerPublicKey.toString());
|
126
126
|
return [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaults];
|
127
127
|
});
|
128
128
|
}
|
package/package.json
CHANGED
@@ -62,7 +62,6 @@ export async function claimLiquidationPoolPositionInstruction(
|
|
62
62
|
overrideStartTime?: number
|
63
63
|
): Promise<TransactionInstruction> {
|
64
64
|
|
65
|
-
console.log("inside function")
|
66
65
|
const vaultSystemState = await getVaultSystemStatePublicKey()
|
67
66
|
const poolStatePublicKey = await getLiquidationPoolStatePublicKey()
|
68
67
|
const poolAssociatedTokenAccount = await findAssociatedTokenAddress(poolStatePublicKey, collateralMint)
|
@@ -78,10 +78,10 @@ export async function getLinkedListAccounts(
|
|
78
78
|
}
|
79
79
|
|
80
80
|
// Pretty print all the vaults before the operation
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
console.log('Sorted open vaults before')
|
82
|
+
vaults.forEach((vault) => {
|
83
|
+
console.log(vault.toString(vaultPublicKey))
|
84
|
+
})
|
85
85
|
|
86
86
|
// If it wasn't in the list, add it now
|
87
87
|
if (indexBefore < 0) {
|
@@ -112,10 +112,10 @@ export async function getLinkedListAccounts(
|
|
112
112
|
vaults = vaults.sort(sortVaults)
|
113
113
|
|
114
114
|
// Pretty print the list again
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
console.log('Sorted open vaults with new debt added')
|
116
|
+
vaults.forEach((vault) => {
|
117
|
+
console.log(vault.toString(vaultPublicKey))
|
118
|
+
})
|
119
119
|
|
120
120
|
// Search for the vaults new position
|
121
121
|
let indexAfter = -1
|
@@ -126,8 +126,8 @@ export async function getLinkedListAccounts(
|
|
126
126
|
})
|
127
127
|
|
128
128
|
// Print where it moved from / to
|
129
|
-
|
130
|
-
|
129
|
+
console.log('Index Before', indexBefore)
|
130
|
+
console.log('Index After', indexAfter)
|
131
131
|
|
132
132
|
// Save references to the new left and right
|
133
133
|
if (indexAfter > 0) {
|
@@ -138,9 +138,9 @@ export async function getLinkedListAccounts(
|
|
138
138
|
}
|
139
139
|
|
140
140
|
// Print out the new left/right
|
141
|
-
|
142
|
-
|
143
|
-
|
141
|
+
console.log('oldSmallerPublicKey', oldSmallerPublicKey.toString())
|
142
|
+
console.log('newSmallerPublicKey', newSmallerPublicKey.toString())
|
143
|
+
console.log('newLargerPublicKey', newLargerPublicKey.toString())
|
144
144
|
|
145
145
|
return [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaults]
|
146
146
|
}
|