@gearbox-protocol/sdk 3.0.0-next.109 → 3.0.0-next.110
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/lib/core/endpoint.d.ts +4 -1
- package/lib/core/endpoint.js +8 -3
- package/lib/core/trade.d.ts +2 -5
- package/lib/core/trade.js +3 -5
- package/lib/core/transactions.js +1 -1
- package/package.json +1 -1
package/lib/core/endpoint.d.ts
CHANGED
package/lib/core/endpoint.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChartsApi = exports.
|
|
3
|
+
exports.ChartsApi = exports.TESTNET_CHAINS = void 0;
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
|
-
exports.
|
|
5
|
+
exports.TESTNET_CHAINS = {
|
|
6
|
+
Mainnet: 7878,
|
|
7
|
+
Optimism: 7879,
|
|
8
|
+
};
|
|
6
9
|
const CHARTS_BACKEND_ADDRESSES = {
|
|
7
10
|
[sdk_gov_1.CHAINS.Mainnet]: "https://charts-server.fly.dev",
|
|
8
11
|
[sdk_gov_1.CHAINS.Local]: "https://charts-server.fly.dev",
|
|
9
|
-
[exports.
|
|
12
|
+
[exports.TESTNET_CHAINS.Mainnet]: "https://testnet.gearbox.foundation",
|
|
13
|
+
// !& test server for optimism
|
|
14
|
+
[exports.TESTNET_CHAINS.Optimism]: "https://testnet.gearbox.foundation",
|
|
10
15
|
};
|
|
11
16
|
class ChartsApi {
|
|
12
17
|
static getUrl = (url, chainId, options, priceSource) => [
|
package/lib/core/trade.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { SupportedContract } from "@gearbox-protocol/sdk-gov";
|
|
2
1
|
import { MultiCall, PathFinderResult, SwapOperation } from "../pathfinder/core";
|
|
3
2
|
import { CreditManagerData } from "./creditManager";
|
|
4
3
|
interface Info {
|
|
5
4
|
name: string;
|
|
6
|
-
contractAddress: string;
|
|
7
5
|
creditManager: string;
|
|
8
6
|
creditManagerName: string;
|
|
9
7
|
}
|
|
@@ -14,7 +12,6 @@ export interface GetTradesProps {
|
|
|
14
12
|
amount: bigint;
|
|
15
13
|
results: Array<PathFinderResult>;
|
|
16
14
|
creditManager: CreditManagerData;
|
|
17
|
-
currentContracts: Record<SupportedContract, string>;
|
|
18
15
|
swapOperation: SwapOperation;
|
|
19
16
|
swapName: TradeOperations;
|
|
20
17
|
}
|
|
@@ -32,8 +29,8 @@ export declare class Trade {
|
|
|
32
29
|
private constructor();
|
|
33
30
|
getName(): string;
|
|
34
31
|
toString(): string;
|
|
35
|
-
static getTrades({ tokenIn, tokenOut, amount, results, creditManager,
|
|
36
|
-
static getCallInfo(calls: Array<MultiCall>, creditManager: string,
|
|
32
|
+
static getTrades({ tokenIn, tokenOut, amount, results, creditManager, swapOperation, swapName, }: GetTradesProps): Trade[];
|
|
33
|
+
static getCallInfo(calls: Array<MultiCall>, creditManager: string, creditManagerName: string): Info[];
|
|
37
34
|
private static getContractSymbol;
|
|
38
35
|
static sortTrades(trades: Array<Trade>, swapStrategy: string): Trade[];
|
|
39
36
|
}
|
package/lib/core/trade.js
CHANGED
|
@@ -41,10 +41,10 @@ class Trade {
|
|
|
41
41
|
const decimalsTo = sdk_gov_1.decimals[symbolTo];
|
|
42
42
|
return `${this.operationName} ${(0, sdk_gov_1.formatBN)(this.sourceAmount, decimalsFrom)} ${symbolFrom} ⇒ ${(0, sdk_gov_1.formatBN)(this.minExpectedAmount, decimalsTo)} ${symbolTo} on ${this.helper.name}`;
|
|
43
43
|
}
|
|
44
|
-
static getTrades({ tokenIn, tokenOut, amount, results, creditManager,
|
|
44
|
+
static getTrades({ tokenIn, tokenOut, amount, results, creditManager, swapOperation, swapName, }) {
|
|
45
45
|
const trades = results.reduce((acc, tradePath) => {
|
|
46
46
|
const { calls } = tradePath;
|
|
47
|
-
const callInfo = Trade.getCallInfo(calls, creditManager.address,
|
|
47
|
+
const callInfo = Trade.getCallInfo(calls, creditManager.address, creditManager.name);
|
|
48
48
|
const trade = new Trade({
|
|
49
49
|
tradePath,
|
|
50
50
|
adapter: callInfo[0] || {
|
|
@@ -66,17 +66,15 @@ class Trade {
|
|
|
66
66
|
}, []);
|
|
67
67
|
return trades;
|
|
68
68
|
}
|
|
69
|
-
static getCallInfo(calls, creditManager,
|
|
69
|
+
static getCallInfo(calls, creditManager, creditManagerName) {
|
|
70
70
|
const callAdapters = calls.reduce((acc, call) => {
|
|
71
71
|
const contractSymbol = this.getContractSymbol(call.target.toLowerCase());
|
|
72
72
|
if (!(0, sdk_gov_1.isSupportedContract)(contractSymbol)) {
|
|
73
73
|
return acc;
|
|
74
74
|
}
|
|
75
75
|
const { name } = sdk_gov_1.contractParams[contractSymbol];
|
|
76
|
-
const contractAddress = currentContracts[contractSymbol];
|
|
77
76
|
acc.push({
|
|
78
77
|
name,
|
|
79
|
-
contractAddress,
|
|
80
78
|
creditManager,
|
|
81
79
|
creditManagerName,
|
|
82
80
|
});
|
package/lib/core/transactions.js
CHANGED
|
@@ -137,7 +137,7 @@ class TXSwap extends eventOrTx_1.EVMTx {
|
|
|
137
137
|
toPart = ` ⇒ ${(0, sdk_gov_1.formatBN)(this.amountTo, toDecimals || 18)} ${toSymbol}`;
|
|
138
138
|
}
|
|
139
139
|
const [fromSymbol, fromDecimals] = (0, sdk_gov_1.extractTokenData)(this.tokenFrom);
|
|
140
|
-
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: ${this.operation} ${(0, sdk_gov_1.formatBN)(this.amountFrom, fromDecimals || 18)} ${fromSymbol} ${toPart} on ${
|
|
140
|
+
return `Credit Account ${this.creditManagerName || (0, contractsRegister_1.getContractName)(this.creditManager)}: ${this.operation} ${(0, sdk_gov_1.formatBN)(this.amountFrom, fromDecimals || 18)} ${fromSymbol} ${toPart} on ${this.protocol}`;
|
|
141
141
|
}
|
|
142
142
|
serialize() {
|
|
143
143
|
return {
|