@strkfarm/sdk 1.1.70 → 2.0.0-dev.1

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.
Files changed (53) hide show
  1. package/dist/cli.js +2 -2
  2. package/dist/cli.mjs +2 -2
  3. package/dist/index.browser.global.js +66861 -59746
  4. package/dist/index.browser.mjs +24970 -18579
  5. package/dist/index.d.ts +1969 -776
  6. package/dist/index.js +25264 -18850
  7. package/dist/index.mjs +25463 -19089
  8. package/package.json +80 -76
  9. package/src/data/extended-deposit.abi.json +3613 -0
  10. package/src/data/universal-vault.abi.json +135 -20
  11. package/src/dataTypes/address.ts +8 -1
  12. package/src/global.ts +240 -193
  13. package/src/interfaces/common.tsx +26 -2
  14. package/src/modules/ExtendedWrapperSDk/index.ts +62 -0
  15. package/src/modules/ExtendedWrapperSDk/types.ts +311 -0
  16. package/src/modules/ExtendedWrapperSDk/wrapper.ts +395 -0
  17. package/src/modules/avnu.ts +17 -4
  18. package/src/modules/ekubo-quoter.ts +98 -10
  19. package/src/modules/erc20.ts +67 -21
  20. package/src/modules/harvests.ts +16 -29
  21. package/src/modules/index.ts +5 -1
  22. package/src/modules/lst-apr.ts +36 -0
  23. package/src/modules/midas.ts +159 -0
  24. package/src/modules/pricer-from-api.ts +2 -2
  25. package/src/modules/pricer-lst.ts +1 -1
  26. package/src/modules/pricer.ts +3 -38
  27. package/src/modules/token-market-data.ts +202 -0
  28. package/src/node/deployer.ts +1 -36
  29. package/src/strategies/autoCompounderStrk.ts +1 -1
  30. package/src/strategies/base-strategy.ts +20 -3
  31. package/src/strategies/ekubo-cl-vault.tsx +123 -306
  32. package/src/strategies/index.ts +4 -1
  33. package/src/strategies/svk-strategy.ts +247 -0
  34. package/src/strategies/universal-adapters/adapter-optimizer.ts +65 -0
  35. package/src/strategies/universal-adapters/adapter-utils.ts +5 -1
  36. package/src/strategies/universal-adapters/avnu-adapter.ts +418 -0
  37. package/src/strategies/universal-adapters/baseAdapter.ts +181 -153
  38. package/src/strategies/universal-adapters/common-adapter.ts +98 -77
  39. package/src/strategies/universal-adapters/extended-adapter.ts +544 -0
  40. package/src/strategies/universal-adapters/index.ts +5 -1
  41. package/src/strategies/universal-adapters/unused-balance-adapter.ts +109 -0
  42. package/src/strategies/universal-adapters/vesu-adapter.ts +220 -218
  43. package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +924 -0
  44. package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +58 -51
  45. package/src/strategies/universal-lst-muliplier-strategy.tsx +707 -774
  46. package/src/strategies/universal-strategy.tsx +1098 -1180
  47. package/src/strategies/vesu-extended-strategy/services/operationService.ts +28 -0
  48. package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +77 -0
  49. package/src/strategies/vesu-extended-strategy/utils/constants.ts +48 -0
  50. package/src/strategies/vesu-extended-strategy/utils/helper.ts +374 -0
  51. package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +992 -0
  52. package/src/strategies/vesu-rebalance.tsx +16 -19
  53. package/src/utils/health-factor-math.ts +11 -5
@@ -1,9 +1,9 @@
1
1
  import { Call, hash, num, shortString } from "starknet";
2
2
  import { SIMPLE_SANITIZER, toBigInt } from "./adapter-utils";
3
3
  import { ContractAddr, Web3Number } from "@/dataTypes";
4
- import { IConfig, TokenInfo } from "@/interfaces";
4
+ import { IConfig, IProtocol, TokenInfo } from "@/interfaces";
5
5
  import { PricerBase } from "@/modules/pricerBase";
6
- import { LeafData } from "@/utils";
6
+ import { LeafData, logger, StandardMerkleTree } from "@/utils";
7
7
  import { CacheClass } from "@/utils/cacheClass";
8
8
 
9
9
  export interface ManageCall {
@@ -15,10 +15,19 @@ export interface ManageCall {
15
15
  }
16
16
  }
17
17
 
18
- export type GenerateCallFn<T> = (params: T) => ManageCall;
19
- export type AdapterLeafType<T> = {leaf: LeafData, callConstructor: GenerateCallFn<T>}
20
- // export type GenerateCallFn<T> = (params: T) => ManageCall[];
21
- // export type AdapterLeafType<T> = {leaves: LeafData[], callConstructor: GenerateCallFn<T>}
18
+
19
+ export interface DepositParams {
20
+ amount: Web3Number;
21
+ }
22
+
23
+ export interface WithdrawParams {
24
+ amount: Web3Number;
25
+ }
26
+
27
+ // export type GenerateCallFn<T> = (params: T) => ManageCall;
28
+ // export type AdapterLeafType<T> = {leaf: LeafData, callConstructor: GenerateCallFn<T>}
29
+ export type GenerateCallFn<T> = (params: T) => Promise<ManageCall[]>;
30
+ export type AdapterLeafType<T> = {leaves: LeafData[], callConstructor: GenerateCallFn<T>}
22
31
  export type LeafAdapterFn<T> = () => AdapterLeafType<T>;
23
32
 
24
33
  export enum APYType {
@@ -43,68 +52,73 @@ export interface BaseAdapterConfig {
43
52
 
44
53
  export type PositionAPY = { apy: number, type: APYType };
45
54
  export type PositionInfo = {
55
+ tokenInfo: TokenInfo,
46
56
  amount: Web3Number,
47
57
  usdValue: number,
48
- remarks?: string,
49
- apy: PositionAPY
58
+ remarks: string,
59
+ apy: PositionAPY,
60
+ protocol: IProtocol
50
61
  };
51
62
 
52
- // export abstract class BaseAdapter<T1, T2> extends CacheClass {
53
- export abstract class BaseAdapter extends CacheClass {
54
-
55
- // readonly config: BaseAdapterConfig;
63
+ export type PositionAmount = {
64
+ amount: Web3Number,
65
+ remarks: string,
66
+ }
56
67
 
57
- // constructor(config: BaseAdapterConfig) {
58
- // super();
59
- // this.config = config;
60
- // }
68
+ export abstract class BaseAdapter<DepositParams, WithdrawParams> extends CacheClass {
69
+ readonly name: string;
70
+ readonly config: BaseAdapterConfig;
71
+ readonly protocol: IProtocol;
61
72
 
62
- constructor() {
73
+ constructor(config: BaseAdapterConfig, name: string, protocol: IProtocol) {
63
74
  super();
75
+ this.config = config;
76
+ this.name = name;
77
+ this.protocol = protocol;
78
+ }
79
+
80
+ /**
81
+ * Loop through all supported positions and return amount, usd value, remarks and apy for each
82
+ */
83
+ async getPositions(): Promise<PositionInfo[]> {
84
+ const results: PositionInfo[] = [];
85
+ for (const supported of this.config.supportedPositions) {
86
+ const amount = await this.getPosition(supported);
87
+ const usdValue = await this.getUSDValue(supported.asset, amount.amount);
88
+ const apy = await this.getAPY(supported);
89
+ results.push({ tokenInfo: supported.asset, amount: amount.amount, usdValue, apy, protocol: this.protocol, remarks: amount.remarks });
90
+ }
91
+ return results;
64
92
  }
65
93
 
66
- // /**
67
- // * Loop through all supported positions and return amount, usd value, remarks and apy for each
68
- // */
69
- // async getPositions(): Promise<PositionInfo[]> {
70
- // const results: PositionInfo[] = [];
71
- // for (const supported of this.config.supportedPositions) {
72
- // const amount = await this.getPosition(supported);
73
- // const usdValue = await this.getUSDValue(supported.asset, amount);
74
- // const apy = await this.getAPY(supported);
75
- // results.push({ amount, usdValue, apy });
76
- // }
77
- // return results;
78
- // }
79
-
80
- // /**
81
- // * Implemented by child adapters to compute APY for a given supported position
82
- // */
83
- // protected abstract getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
84
-
85
- // /**
86
- // * Implemented by child adapters to fetch amount for a given supported position
87
- // */
88
- // protected abstract getPosition(supportedPosition: SupportedPosition): Promise<Web3Number>;
89
-
90
- // /**
91
- // * Implemented by child adapters to calculate maximum deposit positions
92
- // * @param amount Optional amount in baseToken to deposit
93
- // */
94
- // protected abstract maxDeposit(amount?: Web3Number): Promise<PositionInfo[]>;
95
-
96
- // /**
97
- // * Implemented by child adapters to calculate maximum withdraw positions
98
- // */
99
- // protected abstract maxWithdraw(): Promise<PositionInfo[]>;
100
-
101
- // /**
102
- // * Uses pricer to convert an amount of an asset to USD value
103
- // */
104
- // protected async getUSDValue(asset: TokenInfo, amount: Web3Number): Promise<number> {
105
- // const priceInfo = await this.config.pricer.getPrice(asset.symbol);
106
- // return amount.toNumber() * priceInfo.price;
107
- // }
94
+ /**
95
+ * Implemented by child adapters to compute APY for a given supported position
96
+ */
97
+ protected abstract getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
98
+
99
+ /**
100
+ * Implemented by child adapters to fetch amount for a given supported position
101
+ */
102
+ protected abstract getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
103
+
104
+ /**
105
+ * Implemented by child adapters to calculate maximum deposit positions
106
+ * @param amount Optional amount in baseToken to deposit
107
+ */
108
+ abstract maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
109
+
110
+ /**
111
+ * Implemented by child adapters to calculate maximum withdraw positions
112
+ */
113
+ abstract maxWithdraw(): Promise<PositionInfo>;
114
+
115
+ /**
116
+ * Uses pricer to convert an amount of an asset to USD value
117
+ */
118
+ protected async getUSDValue(asset: TokenInfo, amount: Web3Number): Promise<number> {
119
+ const priceInfo = await this.config.pricer.getPrice(asset.symbol);
120
+ return amount.toNumber() * priceInfo.price;
121
+ }
108
122
 
109
123
 
110
124
  protected constructSimpleLeafData(params: {
@@ -127,97 +141,111 @@ export type PositionInfo = {
127
141
  };
128
142
  }
129
143
 
130
- // /**
131
- // * Implementor must provide target/method/packedArguments/sanitizer for deposit leaf construction
132
- // */
133
- // protected abstract _getDepositLeaf(): {
134
- // target: ContractAddr,
135
- // method: string,
136
- // packedArguments: bigint[],
137
- // sanitizer: ContractAddr,
138
- // id: string
139
- // }[];
140
-
141
- // /**
142
- // * Implementor must provide target/method/packedArguments/sanitizer for withdraw leaf construction
143
- // */
144
- // protected abstract _getWithdrawLeaf(): {
145
- // target: ContractAddr,
146
- // method: string,
147
- // packedArguments: bigint[],
148
- // sanitizer: ContractAddr,
149
- // id: string
150
- // }[];
151
-
152
- // /**
153
- // * Returns deposit leaf adapter using configured proof id
154
- // */
155
- // getDepositLeaf(): AdapterLeafType<T1> {
156
- // const leafConfigs = this._getDepositLeaf();
157
- // const leaves = leafConfigs.map(config => {
158
- // const { target, method, packedArguments, sanitizer, id } = config;
159
- // const leaf = this.constructSimpleLeafData({
160
- // id: id,
161
- // target,
162
- // method,
163
- // packedArguments
164
- // }, sanitizer);
165
- // return leaf;
166
- // });
167
- // return { leaves, callConstructor: this.getDepositCall.bind(this) as unknown as GenerateCallFn<T1> };
168
- // }
169
-
170
- // /**
171
- // * Returns withdraw leaf adapter using configured proof id
172
- // */
173
- // getWithdrawLeaf(): AdapterLeafType<T2> {
174
- // const leafConfigs = this._getWithdrawLeaf();
175
- // const leaves = leafConfigs.map(config => {
176
- // const { target, method, packedArguments, sanitizer, id } = config;
177
- // const leaf = this.constructSimpleLeafData({
178
- // id: id,
179
- // target,
180
- // method,
181
- // packedArguments
182
- // }, sanitizer ?? SIMPLE_SANITIZER);
183
- // return leaf;
184
- // });
185
- // return { leaves, callConstructor: this.getWithdrawCall.bind(this) as unknown as GenerateCallFn<T2> };
186
- // }
187
-
188
- // /**
189
- // * Default deposit callConstructor: expects params as calldata (bigint[])
190
- // */
191
- // protected getDepositCall<T1 = bigint[]>(params: T1): ManageCall[] {
192
- // const leafConfigs = this._getDepositLeaf();
193
- // return leafConfigs.map(config => {
194
- // const { target, method, sanitizer } = config;
195
- // return {
196
- // sanitizer: sanitizer ?? SIMPLE_SANITIZER,
197
- // call: {
198
- // contractAddress: target,
199
- // selector: hash.getSelectorFromName(method),
200
- // calldata: params as unknown as bigint[]
201
- // }
202
- // };
203
- // });
204
- // }
205
-
206
- // /**
207
- // * Default withdraw callConstructor: expects params as calldata (bigint[])
208
- // */
209
- // protected getWithdrawCall<T2 = bigint[]>(params: T2): ManageCall[] {
210
- // const leafConfigs = this._getWithdrawLeaf();
211
- // return leafConfigs.map(config => {
212
- // const { target, method, sanitizer } = config;
213
- // return {
214
- // sanitizer: sanitizer ?? SIMPLE_SANITIZER,
215
- // call: {
216
- // contractAddress: target,
217
- // selector: hash.getSelectorFromName(method),
218
- // calldata: params as unknown as bigint[]
219
- // }
220
- // };
221
- // });
222
- // }
223
- }
144
+ /**
145
+ * Implementor must provide target/method/packedArguments/sanitizer for deposit leaf construction
146
+ */
147
+ protected abstract _getDepositLeaf(): {
148
+ target: ContractAddr,
149
+ method: string,
150
+ packedArguments: bigint[],
151
+ sanitizer: ContractAddr,
152
+ id: string
153
+ }[];
154
+
155
+ /**
156
+ * Implementor must provide target/method/packedArguments/sanitizer for withdraw leaf construction
157
+ */
158
+ protected abstract _getWithdrawLeaf(): {
159
+ target: ContractAddr,
160
+ method: string,
161
+ packedArguments: bigint[],
162
+ sanitizer: ContractAddr,
163
+ id: string
164
+ }[];
165
+
166
+ /**
167
+ * Returns deposit leaf adapter using configured proof id
168
+ */
169
+ getDepositLeaf(): AdapterLeafType<DepositParams> {
170
+ const leafConfigs = this._getDepositLeaf();
171
+ const leaves = leafConfigs.map(config => {
172
+ const { target, method, packedArguments, sanitizer, id } = config;
173
+ const leaf = this.constructSimpleLeafData({
174
+ id: id,
175
+ target,
176
+ method,
177
+ packedArguments
178
+ }, sanitizer);
179
+ return leaf;
180
+ });
181
+ return { leaves, callConstructor: this.getDepositCall.bind(this) as unknown as GenerateCallFn<DepositParams> };
182
+ }
183
+
184
+ /**
185
+ * Returns withdraw leaf adapter using configured proof id
186
+ */
187
+ getWithdrawLeaf(): AdapterLeafType<WithdrawParams> {
188
+ const leafConfigs = this._getWithdrawLeaf();
189
+ const leaves = leafConfigs.map(config => {
190
+ const { target, method, packedArguments, sanitizer, id } = config;
191
+ const leaf = this.constructSimpleLeafData({
192
+ id: id,
193
+ target,
194
+ method,
195
+ packedArguments
196
+ }, sanitizer ?? SIMPLE_SANITIZER);
197
+ return leaf;
198
+ });
199
+ return { leaves, callConstructor: this.getWithdrawCall.bind(this) as unknown as GenerateCallFn<WithdrawParams> };
200
+ }
201
+
202
+ /**
203
+ * Implementor must provide deposit call
204
+ * @param params
205
+ */
206
+ abstract getDepositCall(params: DepositParams): Promise<ManageCall[]>;
207
+
208
+ /**
209
+ * Implementor must provide withdraw call
210
+ * @param params
211
+ */
212
+ abstract getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
213
+
214
+
215
+ getProofs<T>(isDeposit: boolean, tree: StandardMerkleTree): { proofs: string[][], callConstructor: GenerateCallFn<DepositParams> | GenerateCallFn<WithdrawParams> } {
216
+ let proofGroups: string[][] = [];
217
+
218
+ const ids = isDeposit ? this.getDepositLeaf().leaves.map(l => l.readableId) : this.getWithdrawLeaf().leaves.map(l => l.readableId);
219
+ // console.log(`${this.name}::getProofs ids: ${ids}`);
220
+ for (const [i, v] of tree.entries()) {
221
+ // console.log(`${this.name}::getProofs v: ${v.readableId}`);
222
+ if (ids.includes(v.readableId)) {
223
+ // console.log(`${this.name}::getProofs found id: ${v.readableId}`);
224
+ proofGroups.push(tree.getProof(i));
225
+ }
226
+ }
227
+ if (proofGroups.length != ids.length) {
228
+ throw new Error(`Not all proofs found for IDs: ${ids.join(', ')}`);
229
+ }
230
+
231
+ // find leaf adapter
232
+ return {
233
+ proofs: proofGroups,
234
+ callConstructor: isDeposit ?
235
+ this.getDepositCall.bind(this) :
236
+ this.getWithdrawCall.bind(this)
237
+ };
238
+ }
239
+
240
+ async getNetAPY(): Promise<number> {
241
+ const positions = await this.getPositions();
242
+ logger.verbose(`${this.name}::getNetAPY: positions: ${JSON.stringify(positions)}`);
243
+ const netAmount = positions.reduce((acc, curr) => acc + curr.usdValue, 0);
244
+ const netAPY = positions.reduce((acc, curr) => acc + curr.apy.apy * curr.usdValue, 0) / netAmount;
245
+ logger.verbose(`${this.name}::getNetAPY: netAPY: ${netAPY}`);
246
+ return netAPY;
247
+ }
248
+
249
+ abstract getHealthFactor(): Promise<number>;
250
+ }
251
+
@@ -24,15 +24,34 @@ export interface CommonAdapterConfig {
24
24
  asset: ContractAddr
25
25
  }
26
26
 
27
- export class CommonAdapter extends BaseAdapter {
27
+ export class CommonAdapter {
28
28
  config: CommonAdapterConfig;
29
29
 
30
30
  constructor(config: CommonAdapterConfig) {
31
- super();
32
31
  this.config = config;
33
32
  }
34
33
 
35
- getFlashloanAdapter(): AdapterLeafType<FlashloanCallParams> {
34
+ protected constructSimpleLeafData(params: {
35
+ id: string,
36
+ target: ContractAddr,
37
+ method: string,
38
+ packedArguments: bigint[],
39
+ }, sanitizer: ContractAddr = SIMPLE_SANITIZER): LeafData {
40
+ const { id, target, method, packedArguments } = params;
41
+ return {
42
+ id: BigInt(num.getDecimalString(shortString.encodeShortString(id))),
43
+ readableId: id,
44
+ data: [
45
+ sanitizer.toBigInt(), // sanitizer address
46
+ target.toBigInt(), // contract
47
+ toBigInt(hash.getSelectorFromName(method)), // method name
48
+ BigInt(packedArguments.length),
49
+ ...packedArguments
50
+ ]
51
+ };
52
+ }
53
+
54
+ async getFlashloanAdapter(): Promise<AdapterLeafType<FlashloanCallParams>> {
36
55
  const manageCall = this.getFlashloanCall.bind(this)({amount: Web3Number.fromWei('0', 6), data: []});
37
56
  const packedArguments: bigint[] = [
38
57
  this.config.manager.toBigInt(), // receiver
@@ -41,16 +60,16 @@ export class CommonAdapter extends BaseAdapter {
41
60
  ];
42
61
  const leaf = this.constructSimpleLeafData({
43
62
  id: this.config.id,
44
- target: manageCall.call.contractAddress,
63
+ target: (await manageCall)[0].call.contractAddress,
45
64
  method: 'flash_loan',
46
65
  packedArguments
47
66
  });
48
- return { leaf, callConstructor: this.getFlashloanCall.bind(this) };
67
+ return { leaves: [leaf], callConstructor: this.getFlashloanCall.bind(this) };
49
68
  }
50
69
 
51
- getFlashloanCall(params: FlashloanCallParams): ManageCall {
70
+ async getFlashloanCall(params: FlashloanCallParams): Promise<ManageCall[]> {
52
71
  const uint256Amount = uint256.bnToUint256(params.amount.toWei());
53
- return {
72
+ return [{
54
73
  sanitizer: SIMPLE_SANITIZER,
55
74
  call: {
56
75
  contractAddress: this.config.manager,
@@ -65,27 +84,40 @@ export class CommonAdapter extends BaseAdapter {
65
84
  ...params.data
66
85
  ]
67
86
  }
68
- }
87
+ }]
88
+ }
89
+
90
+ getBringLiquidityAdapter(id: string): () => AdapterLeafType<ApproveCallParams> {
91
+ return () => ({
92
+ leaves: [this.constructSimpleLeafData({
93
+ id: id,
94
+ target: this.config.vaultAddress,
95
+ method: 'bring_liquidity',
96
+ packedArguments: []
97
+ })],
98
+ callConstructor: this.getBringLiquidityCall().bind(this)
99
+ });
69
100
  }
70
101
 
71
102
  getApproveAdapter(token: ContractAddr, spender: ContractAddr, id: string): () => AdapterLeafType<ApproveCallParams> {
72
103
  return () => ({
73
- leaf: this.constructSimpleLeafData({
104
+ leaves: [this.constructSimpleLeafData({
74
105
  id: id,
75
106
  target: token,
76
107
  method: 'approve',
77
108
  packedArguments: [
78
109
  spender.toBigInt(), // spender
79
110
  ]
80
- }),
111
+ })],
81
112
  callConstructor: this.getApproveCall(token, spender).bind(this)
82
113
  });
83
114
  }
84
115
 
85
116
  getApproveCall(token: ContractAddr, spender: ContractAddr) {
86
- return (params: ApproveCallParams) => {
117
+ return async (params: ApproveCallParams) => {
87
118
  const uint256Amount = uint256.bnToUint256(params.amount.toWei());
88
- return {
119
+ console.log(`${CommonAdapter.name}::getApproveCall token: ${token}, spender: ${spender}, amount: ${params.amount}`);
120
+ return [{
89
121
  sanitizer: SIMPLE_SANITIZER,
90
122
  call: {
91
123
  contractAddress: token,
@@ -96,26 +128,15 @@ export class CommonAdapter extends BaseAdapter {
96
128
  toBigInt(uint256Amount.high.toString()), // amount high
97
129
  ]
98
130
  }
99
- }
131
+ }]
100
132
  }
101
133
  }
102
134
 
103
- getBringLiquidityAdapter(id: string): () => AdapterLeafType<ApproveCallParams> {
104
- return () => ({
105
- leaf: this.constructSimpleLeafData({
106
- id: id,
107
- target: this.config.vaultAddress,
108
- method: 'bring_liquidity',
109
- packedArguments: []
110
- }),
111
- callConstructor: this.getBringLiquidityCall().bind(this)
112
- });
113
- }
114
135
 
115
- getBringLiquidityCall() {
116
- return (params: ApproveCallParams) => {
136
+ getBringLiquidityCall(): GenerateCallFn<ApproveCallParams> {
137
+ return async (params: ApproveCallParams) => {
117
138
  const uint256Amount = uint256.bnToUint256(params.amount.toWei());
118
- return {
139
+ return [{
119
140
  sanitizer: SIMPLE_SANITIZER,
120
141
  call: {
121
142
  contractAddress: this.config.vaultAddress,
@@ -125,59 +146,59 @@ export class CommonAdapter extends BaseAdapter {
125
146
  toBigInt(uint256Amount.high.toString()), // amount high
126
147
  ]
127
148
  }
128
- }
149
+ }]
129
150
  }
130
151
  }
131
152
 
132
- getAvnuAdapter(fromToken: ContractAddr, toToken: ContractAddr, id: string, isMiddleware: boolean): () => AdapterLeafType<AvnuSwapCallParams> {
133
- return () => ({
134
- leaf: this.constructSimpleLeafData({
135
- id: id,
136
- target: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
137
- method: 'multi_route_swap',
138
- packedArguments: [
139
- fromToken.toBigInt(),
140
- toToken.toBigInt(),
141
- this.config.vaultAllocator.toBigInt(),
142
- ]
143
- }),
144
- callConstructor: this.getAvnuCall(fromToken, toToken, isMiddleware).bind(this)
145
- });
146
- }
153
+ // getAvnuAdapter(fromToken: ContractAddr, toToken: ContractAddr, id: string, isMiddleware: boolean): () => AdapterLeafType<AvnuSwapCallParams> {
154
+ // return () => ({
155
+ // leaf: this.constructSimpleLeafData({
156
+ // id: id,
157
+ // target: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
158
+ // method: 'multi_route_swap',
159
+ // packedArguments: [
160
+ // fromToken.toBigInt(),
161
+ // toToken.toBigInt(),
162
+ // this.config.vaultAllocator.toBigInt(),
163
+ // ]
164
+ // }),
165
+ // callConstructor: this.getAvnuCall(fromToken, toToken, isMiddleware).bind(this)
166
+ // });
167
+ // }
147
168
 
148
- getAvnuCall(fromToken: ContractAddr, toToken: ContractAddr, isMiddleware: boolean): GenerateCallFn<AvnuSwapCallParams> {
149
- return (params: AvnuSwapCallParams): ManageCall => {
150
- return {
151
- sanitizer: SIMPLE_SANITIZER,
152
- call: {
153
- contractAddress: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
154
- selector: hash.getSelectorFromName('multi_route_swap'),
155
- calldata: [
156
- fromToken.toBigInt(), // sell_token_address
157
- toBigInt(params.props.token_from_amount.low.toString()), // sell_token_amount low
158
- toBigInt(params.props.token_from_amount.high.toString()), // sell_token_amount high
159
- toToken.toBigInt(), // buy_token_address
160
- toBigInt(params.props.token_to_amount.low.toString()), // buy_token_amount low
161
- toBigInt(params.props.token_to_amount.high.toString()), // buy_token_amount high
162
- toBigInt(params.props.token_to_min_amount.low.toString()), // buy_token_min_amount low
163
- toBigInt(params.props.token_to_min_amount.high.toString()), // buy_token_min_amount high
164
- this.config.vaultAllocator.toBigInt(), // beneficiary
165
- toBigInt(0), // integrator_fee_amount_bps
166
- this.config.vaultAllocator.toBigInt(), // integrator_fee_recipient
169
+ // getAvnuCall(fromToken: ContractAddr, toToken: ContractAddr, isMiddleware: boolean): GenerateCallFn<AvnuSwapCallParams> {
170
+ // return (params: AvnuSwapCallParams): ManageCall => {
171
+ // return {
172
+ // sanitizer: SIMPLE_SANITIZER,
173
+ // call: {
174
+ // contractAddress: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
175
+ // selector: hash.getSelectorFromName('multi_route_swap'),
176
+ // calldata: [
177
+ // fromToken.toBigInt(), // sell_token_address
178
+ // toBigInt(params.props.token_from_amount.low.toString()), // sell_token_amount low
179
+ // toBigInt(params.props.token_from_amount.high.toString()), // sell_token_amount high
180
+ // toToken.toBigInt(), // buy_token_address
181
+ // toBigInt(params.props.token_to_amount.low.toString()), // buy_token_amount low
182
+ // toBigInt(params.props.token_to_amount.high.toString()), // buy_token_amount high
183
+ // toBigInt(params.props.token_to_min_amount.low.toString()), // buy_token_min_amount low
184
+ // toBigInt(params.props.token_to_min_amount.high.toString()), // buy_token_min_amount high
185
+ // this.config.vaultAllocator.toBigInt(), // beneficiary
186
+ // toBigInt(0), // integrator_fee_amount_bps
187
+ // this.config.vaultAllocator.toBigInt(), // integrator_fee_recipient
167
188
 
168
- // unpack routes
169
- BigInt(params.props.routes.length),
170
- ...params.props.routes.map(r => ([
171
- BigInt(num.hexToDecimalString(r.token_from)),
172
- BigInt(num.hexToDecimalString(r.token_to)),
173
- BigInt(num.hexToDecimalString(r.exchange_address)),
174
- BigInt(r.percent),
175
- BigInt(r.additional_swap_params.length),
176
- ...r.additional_swap_params.map(p => BigInt(num.hexToDecimalString(p)))
177
- ])).flat()
178
- ]
179
- }
180
- }
181
- }
182
- }
189
+ // // unpack routes
190
+ // BigInt(params.props.routes.length),
191
+ // ...params.props.routes.map(r => ([
192
+ // BigInt(num.hexToDecimalString(r.token_from)),
193
+ // BigInt(num.hexToDecimalString(r.token_to)),
194
+ // BigInt(num.hexToDecimalString(r.exchange_address)),
195
+ // BigInt(r.percent),
196
+ // BigInt(r.additional_swap_params.length),
197
+ // ...r.additional_swap_params.map(p => BigInt(num.hexToDecimalString(p)))
198
+ // ])).flat()
199
+ // ]
200
+ // }
201
+ // }
202
+ // }
203
+ // }
183
204
  }