@haven-fi/solauto-sdk 1.0.283 → 1.0.285
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +0 -3
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +3 -10
- package/dist/utils/solauto/rebalanceUtils.js +1 -1
- package/package.json +2 -2
- package/src/transactions/transactionsManager.ts +0 -3
- package/src/utils/solanaUtils.ts +3 -10
- package/src/utils/solauto/rebalanceUtils.ts +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AAmFD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAVpB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,MAAM,CAAC,EAAE,kBAAkB,YAAA,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAUpC,OAAO,CAAC,mBAAmB;YAMb,SAAS;IAgBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA+DzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA+BxB,qBAAqB;YAuDrB,cAAc;YAqCd,eAAe;CAmD9B"}
|
@@ -105,10 +105,7 @@ class TransactionSet {
|
|
105
105
|
const transactions = this.items
|
106
106
|
.filter((x) => x.tx && x.tx.getInstructions().length > 0)
|
107
107
|
.map((x) => x.tx);
|
108
|
-
const txSpecificLuts = this.lutAddresses();
|
109
|
-
this.txHandler.log("Tx-specific LUTs: ", txSpecificLuts.map(x => x.toString()));
|
110
108
|
const lutInputs = await this.lookupTables.getLutInputs(this.lutAddresses());
|
111
|
-
this.txHandler.log("Lut inputs:", lutInputs);
|
112
109
|
return (0, umi_1.transactionBuilder)()
|
113
110
|
.add(transactions)
|
114
111
|
.setAddressLookupTables(lutInputs);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAKL,UAAU,EACV,SAAS,EAKT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAIlE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,UAErD;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,UAE3D;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAgC,GAC1C,CAAC,UAAU,EAAE,GAAG,CAAC,CAQnB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,kBAAkB,CAOpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,kBAAkB,CAOpB;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,GACd,kBAAkB,CAUpB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,EACtB,QAAQ,EAAE,MAAM,GACf,kBAAkB,CASpB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,EACvB,SAA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,MAAM,CAAC,EAAE,kBAAkB,EAC3B,eAAe,GAAE,kBAA2C,EAC5D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA0DjC"}
|
@@ -92,14 +92,13 @@ async function getAddressLookupInputs(umi, lookupTableAddresses) {
|
|
92
92
|
}, new Array());
|
93
93
|
}
|
94
94
|
function addTxOptimizations(signer, transaction, computeUnitPrice, computeUnitLimit) {
|
95
|
-
return
|
95
|
+
return transaction
|
96
96
|
.prepend(computeUnitPrice !== undefined
|
97
97
|
? setComputeUnitPriceUmiIx(signer, computeUnitPrice)
|
98
98
|
: (0, umi_1.transactionBuilder)())
|
99
99
|
.prepend(computeUnitLimit
|
100
100
|
? setComputeUnitLimitUmiIx(signer, computeUnitLimit)
|
101
|
-
: (0, umi_1.transactionBuilder)())
|
102
|
-
.add(transaction);
|
101
|
+
: (0, umi_1.transactionBuilder)());
|
103
102
|
}
|
104
103
|
function assembleFinalTransaction(signer, transaction, computeUnitPrice, computeUnitLimit) {
|
105
104
|
const tx = addTxOptimizations(signer, transaction, computeUnitPrice, computeUnitLimit);
|
@@ -139,13 +138,7 @@ function assembleFinalTransaction(signer, transaction, computeUnitPrice, compute
|
|
139
138
|
return tx;
|
140
139
|
}
|
141
140
|
async function simulateTransaction(umi, connection, transaction) {
|
142
|
-
(0,
|
143
|
-
(0, generalUtils_1.consoleLog)("TRANSACTION SIZE", transaction.useV0().getTransactionSize(umi));
|
144
|
-
const tx = (0, umi_web3js_adapters_1.toWeb3JsTransaction)(transaction.build(umi));
|
145
|
-
(0, generalUtils_1.consoleLog)("TRANSACTIONS REQUIRED", transaction.minimumTransactionsRequired(umi));
|
146
|
-
(0, generalUtils_1.consoleLog)("TRANSACTION SIZE", transaction.getTransactionSize(umi));
|
147
|
-
(0, generalUtils_1.consoleLog)("FITS IN ONE TX", transaction.fitsInOneTransaction(umi));
|
148
|
-
const simulationResult = await connection.simulateTransaction(tx, {
|
141
|
+
const simulationResult = await connection.simulateTransaction((0, umi_web3js_adapters_1.toWeb3JsTransaction)(transaction.build(umi)), {
|
149
142
|
sigVerify: false,
|
150
143
|
commitment: "processed",
|
151
144
|
});
|
@@ -83,7 +83,7 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
|
|
83
83
|
const { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, targetLiqUtilizationRateBps);
|
84
84
|
const amountUsdToDcaIn = (0, numberUtils_1.fromBaseUnit)(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
|
85
85
|
(dca?.tokenType === generated_1.TokenType.Debt ? debtPrice : supplyPrice);
|
86
|
-
const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps
|
86
|
+
const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps <= targetRateBps ? generated_1.RebalanceDirection.Boost : generated_1.RebalanceDirection.Repay;
|
87
87
|
const adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, targetLiqUtilizationRateBps, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS), rebalanceDirection).total;
|
88
88
|
const supplyUsd = (0, numberUtils_1.fromBaseUnit)(state.supply.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS) +
|
89
89
|
amountUsdToDcaIn;
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "@haven-fi/solauto-sdk",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.285",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"types": "dist/index.d.ts",
|
6
6
|
"description": "Typescript SDK for the Solauto program on the Solana blockchain",
|
7
7
|
"author": "Chelioso",
|
8
8
|
"license": "MIT",
|
9
9
|
"scripts": {
|
10
|
-
"build": "rm -
|
10
|
+
"build": "rm -rf dist && npx tsc",
|
11
11
|
"test:txs": "ts-mocha -p ./tsconfig.json -t 1000000 tests/transactions/**/*.ts",
|
12
12
|
"test:unit": "ts-mocha -p ./tsconfig.json -t 1000000 tests/unit/**/*.ts",
|
13
13
|
"test:all": "pnpm test:unit && pnpm test:txs",
|
@@ -161,10 +161,7 @@ class TransactionSet {
|
|
161
161
|
.filter((x) => x.tx && x.tx.getInstructions().length > 0)
|
162
162
|
.map((x) => x.tx!);
|
163
163
|
|
164
|
-
const txSpecificLuts = this.lutAddresses();
|
165
|
-
this.txHandler.log("Tx-specific LUTs: ", txSpecificLuts.map(x => x.toString()));
|
166
164
|
const lutInputs = await this.lookupTables.getLutInputs(this.lutAddresses());
|
167
|
-
this.txHandler.log("Lut inputs:", lutInputs);
|
168
165
|
return transactionBuilder()
|
169
166
|
.add(transactions)
|
170
167
|
.setAddressLookupTables(lutInputs);
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -187,7 +187,7 @@ export function addTxOptimizations(
|
|
187
187
|
computeUnitPrice?: number,
|
188
188
|
computeUnitLimit?: number
|
189
189
|
) {
|
190
|
-
return
|
190
|
+
return transaction
|
191
191
|
.prepend(
|
192
192
|
computeUnitPrice !== undefined
|
193
193
|
? setComputeUnitPriceUmiIx(signer, computeUnitPrice)
|
@@ -197,8 +197,7 @@ export function addTxOptimizations(
|
|
197
197
|
computeUnitLimit
|
198
198
|
? setComputeUnitLimitUmiIx(signer, computeUnitLimit)
|
199
199
|
: transactionBuilder()
|
200
|
-
)
|
201
|
-
.add(transaction);
|
200
|
+
);
|
202
201
|
}
|
203
202
|
|
204
203
|
export function assembleFinalTransaction(
|
@@ -271,14 +270,8 @@ async function simulateTransaction(
|
|
271
270
|
connection: Connection,
|
272
271
|
transaction: TransactionBuilder
|
273
272
|
): Promise<RpcResponseAndContext<SimulatedTransactionResponse>> {
|
274
|
-
consoleLog("TRANSACTION SIZE", transaction.getTransactionSize(umi));
|
275
|
-
consoleLog("TRANSACTION SIZE", transaction.useV0().getTransactionSize(umi));
|
276
|
-
const tx = toWeb3JsTransaction(transaction.build(umi));
|
277
|
-
consoleLog("TRANSACTIONS REQUIRED", transaction.minimumTransactionsRequired(umi));
|
278
|
-
consoleLog("TRANSACTION SIZE", transaction.getTransactionSize(umi));
|
279
|
-
consoleLog("FITS IN ONE TX", transaction.fitsInOneTransaction(umi));
|
280
273
|
const simulationResult = await connection.simulateTransaction(
|
281
|
-
|
274
|
+
toWeb3JsTransaction(transaction.build(umi)),
|
282
275
|
{
|
283
276
|
sigVerify: false,
|
284
277
|
commitment: "processed",
|
@@ -190,7 +190,7 @@ export function getRebalanceValues(
|
|
190
190
|
fromBaseUnit(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
|
191
191
|
(dca?.tokenType === TokenType.Debt ? debtPrice : supplyPrice);
|
192
192
|
|
193
|
-
const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps
|
193
|
+
const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps <= targetRateBps ? RebalanceDirection.Boost : RebalanceDirection.Repay;
|
194
194
|
const adjustmentFeeBps = getSolautoFeesBps(
|
195
195
|
false,
|
196
196
|
targetLiqUtilizationRateBps,
|