@strkfarm/sdk 2.0.0-dev.27 → 2.0.0-dev.28
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/dist/cli.js +190 -36
- package/dist/cli.mjs +188 -34
- package/dist/index.browser.global.js +79130 -49357
- package/dist/index.browser.mjs +18039 -11434
- package/dist/index.d.ts +2869 -898
- package/dist/index.js +19036 -12210
- package/dist/index.mjs +18942 -12161
- package/package.json +1 -1
- package/src/data/avnu.abi.json +840 -0
- package/src/data/ekubo-price-fethcer.abi.json +265 -0
- package/src/dataTypes/_bignumber.ts +13 -4
- package/src/dataTypes/index.ts +3 -2
- package/src/dataTypes/mynumber.ts +141 -0
- package/src/global.ts +76 -41
- package/src/index.browser.ts +2 -1
- package/src/interfaces/common.tsx +167 -2
- package/src/modules/ExtendedWrapperSDk/types.ts +26 -4
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +110 -67
- package/src/modules/apollo-client-config.ts +28 -0
- package/src/modules/avnu.ts +4 -4
- package/src/modules/ekubo-pricer.ts +79 -0
- package/src/modules/ekubo-quoter.ts +46 -30
- package/src/modules/erc20.ts +17 -0
- package/src/modules/harvests.ts +43 -29
- package/src/modules/pragma.ts +23 -8
- package/src/modules/pricer-from-api.ts +156 -15
- package/src/modules/pricer-lst.ts +1 -1
- package/src/modules/pricer.ts +40 -4
- package/src/modules/pricerBase.ts +2 -1
- package/src/node/deployer.ts +36 -1
- package/src/node/pricer-redis.ts +2 -1
- package/src/strategies/base-strategy.ts +78 -10
- package/src/strategies/ekubo-cl-vault.tsx +906 -347
- package/src/strategies/factory.ts +159 -0
- package/src/strategies/index.ts +6 -1
- package/src/strategies/registry.ts +239 -0
- package/src/strategies/sensei.ts +335 -7
- package/src/strategies/svk-strategy.ts +97 -27
- package/src/strategies/types.ts +4 -0
- package/src/strategies/universal-adapters/adapter-utils.ts +2 -1
- package/src/strategies/universal-adapters/avnu-adapter.ts +177 -268
- package/src/strategies/universal-adapters/baseAdapter.ts +263 -251
- package/src/strategies/universal-adapters/common-adapter.ts +206 -203
- package/src/strategies/universal-adapters/extended-adapter.ts +155 -336
- package/src/strategies/universal-adapters/index.ts +9 -8
- package/src/strategies/universal-adapters/token-transfer-adapter.ts +200 -0
- package/src/strategies/universal-adapters/usdc<>usdce-adapter.ts +200 -0
- package/src/strategies/universal-adapters/vesu-adapter.ts +110 -75
- package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +476 -0
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +762 -844
- package/src/strategies/universal-adapters/vesu-position-common.ts +251 -0
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +18 -3
- package/src/strategies/universal-lst-muliplier-strategy.tsx +396 -204
- package/src/strategies/universal-strategy.tsx +1426 -1178
- package/src/strategies/vesu-extended-strategy/services/executionService.ts +2251 -0
- package/src/strategies/vesu-extended-strategy/services/extended-vesu-state-manager.ts +2941 -0
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +12 -1
- package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +52 -0
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +1 -0
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +2 -0
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +158 -124
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +377 -1788
- package/src/strategies/vesu-rebalance.tsx +255 -152
- package/src/utils/health-factor-math.ts +4 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/logger.browser.ts +22 -4
- package/src/utils/logger.node.ts +259 -24
- package/src/utils/starknet-call-parser.ts +1036 -0
- package/src/utils/strategy-utils.ts +61 -0
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from "./baseAdapter";
|
|
2
|
-
export * from "./common-adapter";
|
|
3
|
-
export * from "./vesu-adapter";
|
|
4
|
-
export * from "./vesu-supply-only-adapter";
|
|
5
|
-
export * from "./vesu-multiply-adapter";
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./adapter
|
|
8
|
-
export * from "./
|
|
1
|
+
export * from "./baseAdapter";
|
|
2
|
+
export * from "./common-adapter";
|
|
3
|
+
export * from "./vesu-adapter";
|
|
4
|
+
export * from "./vesu-supply-only-adapter";
|
|
5
|
+
export * from "./vesu-multiply-adapter";
|
|
6
|
+
export * from "./vesu-modify-position-adapter";
|
|
7
|
+
export * from "./extended-adapter";
|
|
8
|
+
export * from "./adapter-utils";
|
|
9
|
+
export * from "./token-transfer-adapter";
|
|
9
10
|
export * from "./avnu-adapter";
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { ContractAddr, Web3Number } from "@/dataTypes";
|
|
2
|
+
import {
|
|
3
|
+
APYType,
|
|
4
|
+
BaseAdapter,
|
|
5
|
+
BaseAdapterConfig,
|
|
6
|
+
DepositParams,
|
|
7
|
+
ManageCall,
|
|
8
|
+
PositionAmount,
|
|
9
|
+
PositionAPY,
|
|
10
|
+
PositionInfo,
|
|
11
|
+
SupportedPosition,
|
|
12
|
+
WithdrawParams,
|
|
13
|
+
} from "./baseAdapter";
|
|
14
|
+
import { hash, uint256 } from "starknet";
|
|
15
|
+
import { ERC20, TokenMarketData } from "@/modules";
|
|
16
|
+
import { Protocols } from "@/interfaces";
|
|
17
|
+
import { SIMPLE_SANITIZER, toBigInt, TRANSFER_SANITIZER } from "./adapter-utils";
|
|
18
|
+
import { logger } from "@/utils";
|
|
19
|
+
|
|
20
|
+
export interface TokenTransferAdapterConfig extends BaseAdapterConfig {
|
|
21
|
+
/** Address that funds are sent FROM during deposit (and returned TO during withdraw) */
|
|
22
|
+
fromAddress: ContractAddr;
|
|
23
|
+
/** Address that funds are sent TO during deposit (and pulled FROM during withdraw) */
|
|
24
|
+
toAddress: ContractAddr;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Adapter for transferring a single token between two fixed addresses.
|
|
29
|
+
*
|
|
30
|
+
* Deposit: transfers baseToken from `fromAddress` → `toAddress`
|
|
31
|
+
* Withdraw: transfers baseToken from `toAddress` → `fromAddress` (requires toAddress to approve fromAddress/VA)
|
|
32
|
+
*
|
|
33
|
+
* Proof IDs are derived from `tr_<symbol>_<toAddrShort>` to be unique per token+destination pair.
|
|
34
|
+
*/
|
|
35
|
+
export class TokenTransferAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
36
|
+
readonly config: TokenTransferAdapterConfig;
|
|
37
|
+
readonly tokenMarketData: TokenMarketData;
|
|
38
|
+
|
|
39
|
+
constructor(config: TokenTransferAdapterConfig) {
|
|
40
|
+
super(config, TokenTransferAdapter.name, Protocols.NONE);
|
|
41
|
+
this.config = config;
|
|
42
|
+
this.tokenMarketData = new TokenMarketData(this.config.pricer, this.config.networkConfig);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private _idBase(): string {
|
|
46
|
+
return `tr_${this.config.baseToken.symbol}_${this.config.toAddress.shortString()}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private _depositCallProofReadableId(): string {
|
|
50
|
+
return `${this._idBase()}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private _withdrawCallProofReadableId(): string {
|
|
54
|
+
return `tr_wd_${this.config.baseToken.symbol}_${this.config.toAddress.shortString()}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected async getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY> {
|
|
58
|
+
const isSupported = this.tokenMarketData.isAPYSupported(this.config.baseToken);
|
|
59
|
+
const apy = isSupported ? await this.tokenMarketData.getAPY(this.config.baseToken) : 0;
|
|
60
|
+
return { apy, type: isSupported ? APYType.LST : APYType.BASE };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
protected async getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount> {
|
|
64
|
+
// only measure balance of toAddress, bcz fromAddress usually gets trakced in unused balance or a previous token transfer adapter
|
|
65
|
+
try {
|
|
66
|
+
const balance = await new ERC20(this.config.networkConfig).balanceOf(
|
|
67
|
+
supportedPosition.asset.address,
|
|
68
|
+
this.config.toAddress.address,
|
|
69
|
+
supportedPosition.asset.decimals,
|
|
70
|
+
);
|
|
71
|
+
return { amount: balance, remarks: `Unused balance [${this.config.toAddress.shortString()}]` };
|
|
72
|
+
} catch (_e) {
|
|
73
|
+
logger.error(`${TokenTransferAdapter.name}::getPosition: failed for ${supportedPosition.asset.symbol}`);
|
|
74
|
+
throw new Error(`${TokenTransferAdapter.name}: failed to get balance for ${supportedPosition.asset.symbol}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async maxDeposit(amount?: Web3Number): Promise<PositionInfo> {
|
|
79
|
+
const baseToken = this.config.baseToken;
|
|
80
|
+
const fromBalance = await new ERC20(this.config.networkConfig).balanceOf(
|
|
81
|
+
baseToken.address,
|
|
82
|
+
this.config.fromAddress.address,
|
|
83
|
+
baseToken.decimals,
|
|
84
|
+
);
|
|
85
|
+
const depositable = amount && amount.toNumber() <= fromBalance.toNumber() ? amount : fromBalance;
|
|
86
|
+
const usdValue = await this.getUSDValue(baseToken, depositable);
|
|
87
|
+
return {
|
|
88
|
+
tokenInfo: baseToken,
|
|
89
|
+
amount: depositable,
|
|
90
|
+
usdValue,
|
|
91
|
+
remarks: "Max deposit (from-address balance)",
|
|
92
|
+
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
93
|
+
protocol: this.protocol,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async maxWithdraw(): Promise<PositionInfo> {
|
|
98
|
+
const baseToken = this.config.baseToken;
|
|
99
|
+
const toBalance = await new ERC20(this.config.networkConfig).balanceOf(
|
|
100
|
+
baseToken.address,
|
|
101
|
+
this.config.toAddress.address,
|
|
102
|
+
baseToken.decimals,
|
|
103
|
+
);
|
|
104
|
+
const usdValue = await this.getUSDValue(baseToken, toBalance);
|
|
105
|
+
return {
|
|
106
|
+
tokenInfo: baseToken,
|
|
107
|
+
amount: toBalance,
|
|
108
|
+
usdValue,
|
|
109
|
+
remarks: "Max withdraw (to-address balance)",
|
|
110
|
+
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
111
|
+
protocol: this.protocol,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
protected _getDepositLeaf(): {
|
|
116
|
+
target: ContractAddr;
|
|
117
|
+
method: string;
|
|
118
|
+
packedArguments: bigint[];
|
|
119
|
+
sanitizer: ContractAddr;
|
|
120
|
+
id: string;
|
|
121
|
+
}[] {
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
target: this.config.baseToken.address,
|
|
125
|
+
method: "transfer",
|
|
126
|
+
packedArguments: [this.config.toAddress.toBigInt()],
|
|
127
|
+
sanitizer: TRANSFER_SANITIZER,
|
|
128
|
+
id: this._depositCallProofReadableId(),
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
protected _getWithdrawLeaf(): {
|
|
134
|
+
target: ContractAddr;
|
|
135
|
+
method: string;
|
|
136
|
+
packedArguments: bigint[];
|
|
137
|
+
sanitizer: ContractAddr;
|
|
138
|
+
id: string;
|
|
139
|
+
}[] {
|
|
140
|
+
// note, to address should have given allowance to from address
|
|
141
|
+
return [
|
|
142
|
+
{
|
|
143
|
+
target: this.config.baseToken.address,
|
|
144
|
+
method: "transfer_from",
|
|
145
|
+
packedArguments: [
|
|
146
|
+
this.config.toAddress.toBigInt(), // from
|
|
147
|
+
this.config.fromAddress.toBigInt(), // to
|
|
148
|
+
],
|
|
149
|
+
sanitizer: TRANSFER_SANITIZER,
|
|
150
|
+
id: this._withdrawCallProofReadableId(),
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async getDepositCall(params: DepositParams): Promise<ManageCall[]> {
|
|
156
|
+
const amount = params.amount;
|
|
157
|
+
const uint256Amount = uint256.bnToUint256(amount.toWei());
|
|
158
|
+
return [
|
|
159
|
+
{
|
|
160
|
+
proofReadableId: this._depositCallProofReadableId(),
|
|
161
|
+
sanitizer: TRANSFER_SANITIZER,
|
|
162
|
+
call: {
|
|
163
|
+
contractAddress: this.config.baseToken.address,
|
|
164
|
+
selector: hash.getSelectorFromName("transfer"),
|
|
165
|
+
calldata: [
|
|
166
|
+
this.config.toAddress.toBigInt(),
|
|
167
|
+
toBigInt(uint256Amount.low.toString()),
|
|
168
|
+
toBigInt(uint256Amount.high.toString()),
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]> {
|
|
176
|
+
const amount = params.amount;
|
|
177
|
+
const uint256Amount = uint256.bnToUint256(amount.toWei());
|
|
178
|
+
// note, from address should have given allowance to to address
|
|
179
|
+
return [
|
|
180
|
+
{
|
|
181
|
+
proofReadableId: this._withdrawCallProofReadableId(),
|
|
182
|
+
sanitizer: TRANSFER_SANITIZER,
|
|
183
|
+
call: {
|
|
184
|
+
contractAddress: this.config.baseToken.address,
|
|
185
|
+
selector: hash.getSelectorFromName("transfer_from"),
|
|
186
|
+
calldata: [
|
|
187
|
+
this.config.toAddress.toBigInt(), // from
|
|
188
|
+
this.config.fromAddress.toBigInt(), // to
|
|
189
|
+
toBigInt(uint256Amount.low.toString()),
|
|
190
|
+
toBigInt(uint256Amount.high.toString()),
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async getHealthFactor(): Promise<number> {
|
|
198
|
+
return Promise.resolve(10);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseAdapter,
|
|
3
|
+
DepositParams,
|
|
4
|
+
WithdrawParams,
|
|
5
|
+
BaseAdapterConfig,
|
|
6
|
+
} from "./baseAdapter";
|
|
7
|
+
import { toBigInt } from "./adapter-utils";
|
|
8
|
+
import { Protocols } from "@/interfaces";
|
|
9
|
+
import { SupportedPosition } from "./baseAdapter";
|
|
10
|
+
import { PositionAPY, APYType, PositionAmount } from "./baseAdapter";
|
|
11
|
+
import { Web3Number } from "@/dataTypes";
|
|
12
|
+
import { PositionInfo } from "./baseAdapter";
|
|
13
|
+
import { ManageCall } from "./baseAdapter";
|
|
14
|
+
import { ContractAddr } from "@/dataTypes";
|
|
15
|
+
import { AVNU_EXCHANGE } from "./adapter-utils";
|
|
16
|
+
import { hash, uint256 } from "starknet";
|
|
17
|
+
import { AVNU_EXCHANGE_FOR_LEGACY_USDC } from "./adapter-utils";
|
|
18
|
+
import { AVNU_LEGACY_SANITIZER } from "./adapter-utils";
|
|
19
|
+
import { assert, logger } from "@/utils";
|
|
20
|
+
import { ERC20 } from "@/modules";
|
|
21
|
+
|
|
22
|
+
export class UsdcToUsdceAdapter extends BaseAdapter<
|
|
23
|
+
DepositParams,
|
|
24
|
+
WithdrawParams
|
|
25
|
+
> {
|
|
26
|
+
readonly config: BaseAdapterConfig;
|
|
27
|
+
|
|
28
|
+
private _approveProofReadableId(usdcToUsdce: boolean): string {
|
|
29
|
+
const method = usdcToUsdce ? "swap_to_legacy" : "swap_to_new";
|
|
30
|
+
return `approve_${method}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private _swapProofReadableId(usdcToUsdce: boolean): string {
|
|
34
|
+
const method = usdcToUsdce ? "swap_to_legacy" : "swap_to_new";
|
|
35
|
+
const target = usdcToUsdce
|
|
36
|
+
? this.config.supportedPositions[0].asset
|
|
37
|
+
: this.config.supportedPositions[1].asset;
|
|
38
|
+
return `${method}_${target.symbol}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private buildSwapLeafConfigs(usdcToUsdce: boolean): {
|
|
42
|
+
target: ContractAddr;
|
|
43
|
+
method: string;
|
|
44
|
+
packedArguments: bigint[];
|
|
45
|
+
sanitizer: ContractAddr;
|
|
46
|
+
id: string;
|
|
47
|
+
}[] {
|
|
48
|
+
const method = usdcToUsdce ? "swap_to_legacy" : "swap_to_new";
|
|
49
|
+
const target = usdcToUsdce
|
|
50
|
+
? this.config.supportedPositions[0].asset
|
|
51
|
+
: this.config.supportedPositions[1].asset;
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
target: target.address,
|
|
55
|
+
method: "approve",
|
|
56
|
+
packedArguments: [AVNU_EXCHANGE_FOR_LEGACY_USDC.toBigInt()],
|
|
57
|
+
id: this._approveProofReadableId(usdcToUsdce),
|
|
58
|
+
sanitizer: AVNU_LEGACY_SANITIZER,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
target: AVNU_EXCHANGE_FOR_LEGACY_USDC,
|
|
62
|
+
method: method,
|
|
63
|
+
packedArguments: [],
|
|
64
|
+
id: this._swapProofReadableId(usdcToUsdce),
|
|
65
|
+
sanitizer: AVNU_LEGACY_SANITIZER,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private async buildSwapCalls(
|
|
71
|
+
params: DepositParams | WithdrawParams,
|
|
72
|
+
usdcToUsdce: boolean,
|
|
73
|
+
): Promise<ManageCall[]> {
|
|
74
|
+
const approveAmount = uint256.bnToUint256(params.amount.toWei());
|
|
75
|
+
const target = usdcToUsdce
|
|
76
|
+
? this.config.supportedPositions[0].asset
|
|
77
|
+
: this.config.supportedPositions[1].asset;
|
|
78
|
+
const method = usdcToUsdce ? "swap_to_legacy" : "swap_to_new";
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
proofReadableId: this._approveProofReadableId(usdcToUsdce),
|
|
82
|
+
sanitizer: AVNU_LEGACY_SANITIZER,
|
|
83
|
+
call: {
|
|
84
|
+
contractAddress: target.address,
|
|
85
|
+
selector: hash.getSelectorFromName("approve"),
|
|
86
|
+
calldata: [
|
|
87
|
+
AVNU_EXCHANGE_FOR_LEGACY_USDC.toBigInt(),
|
|
88
|
+
toBigInt(approveAmount.low.toString()),
|
|
89
|
+
toBigInt(approveAmount.high.toString()),
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
proofReadableId: this._swapProofReadableId(usdcToUsdce),
|
|
95
|
+
sanitizer: AVNU_LEGACY_SANITIZER,
|
|
96
|
+
call: {
|
|
97
|
+
contractAddress: AVNU_EXCHANGE_FOR_LEGACY_USDC,
|
|
98
|
+
selector: hash.getSelectorFromName(method),
|
|
99
|
+
calldata: [
|
|
100
|
+
toBigInt(approveAmount.low.toString()), // amount low
|
|
101
|
+
toBigInt(approveAmount.high.toString()), // amount high
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
constructor(config: BaseAdapterConfig) {
|
|
109
|
+
super(config, UsdcToUsdceAdapter.name, Protocols.AVNU);
|
|
110
|
+
this.config = config as BaseAdapterConfig;
|
|
111
|
+
assert(this.config.supportedPositions.length === 2, "UsdcToUsdceAdapter must have 2 supported positions");
|
|
112
|
+
assert(this.config.supportedPositions[0].asset.symbol === "USDC", "UsdcToUsdceAdapter must have USDC as the first supported position");
|
|
113
|
+
assert(this.config.supportedPositions[1].asset.symbol === "USDC.e", "UsdcToUsdceAdapter must have USDCE as the second supported position");
|
|
114
|
+
}
|
|
115
|
+
//abstract means the method has no implementation in this class; instead, child classes must implement it.
|
|
116
|
+
protected async getAPY(
|
|
117
|
+
supportedPosition: SupportedPosition,
|
|
118
|
+
): Promise<PositionAPY> {
|
|
119
|
+
return Promise.resolve({ apy: 0, type: APYType.BASE });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
protected async getPosition(
|
|
123
|
+
supportedPosition: SupportedPosition,
|
|
124
|
+
): Promise<PositionAmount | null> {
|
|
125
|
+
const toToken = this.config.supportedPositions[1].asset;
|
|
126
|
+
if (supportedPosition.asset.symbol != toToken.symbol) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
// only measure balance of toToken, bcz from token usually gets trakced in unused balance or a previous avnu adapter
|
|
131
|
+
const balance = await new ERC20(this.config.networkConfig).balanceOf(
|
|
132
|
+
toToken.address,
|
|
133
|
+
this.config.vaultAllocator.address,
|
|
134
|
+
toToken.decimals,
|
|
135
|
+
);
|
|
136
|
+
return { amount: balance, remarks: `USDC.e unused balance (VA)` };
|
|
137
|
+
} catch (_e) {
|
|
138
|
+
logger.error(`${UsdcToUsdceAdapter.name}::getPosition: failed for ${toToken.symbol}`);
|
|
139
|
+
throw new Error(`${UsdcToUsdceAdapter.name}: failed to get balance for ${toToken.symbol}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async maxDeposit(amount?: Web3Number): Promise<PositionInfo> {
|
|
144
|
+
return Promise.resolve({
|
|
145
|
+
tokenInfo: this.config.baseToken,
|
|
146
|
+
amount: new Web3Number(0, 0),
|
|
147
|
+
usdValue: 0,
|
|
148
|
+
apy: { apy: 0, type: APYType.BASE },
|
|
149
|
+
protocol: Protocols.AVNU,
|
|
150
|
+
remarks: "",
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async maxWithdraw(): Promise<PositionInfo> {
|
|
155
|
+
return Promise.resolve({
|
|
156
|
+
tokenInfo: this.config.baseToken,
|
|
157
|
+
amount: new Web3Number(0, 0),
|
|
158
|
+
usdValue: 0,
|
|
159
|
+
apy: { apy: 0, type: APYType.BASE },
|
|
160
|
+
protocol: Protocols.AVNU,
|
|
161
|
+
remarks: "",
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
protected _getDepositLeaf(): {
|
|
166
|
+
// considering deposit is converting usdc to usdce
|
|
167
|
+
target: ContractAddr;
|
|
168
|
+
method: string;
|
|
169
|
+
packedArguments: bigint[];
|
|
170
|
+
sanitizer: ContractAddr;
|
|
171
|
+
id: string;
|
|
172
|
+
}[] {
|
|
173
|
+
return this.buildSwapLeafConfigs(true);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
protected _getWithdrawLeaf(): {
|
|
177
|
+
target: ContractAddr;
|
|
178
|
+
method: string;
|
|
179
|
+
packedArguments: bigint[];
|
|
180
|
+
sanitizer: ContractAddr;
|
|
181
|
+
id: string;
|
|
182
|
+
}[] {
|
|
183
|
+
return this.buildSwapLeafConfigs(false);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async getDepositCall(params: DepositParams): Promise<ManageCall[]> {
|
|
187
|
+
const calls = await this.buildSwapCalls(params, true);
|
|
188
|
+
return calls;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//Swap wbtc to usdc
|
|
192
|
+
async getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]> {
|
|
193
|
+
const calls = await this.buildSwapCalls(params, false);
|
|
194
|
+
return calls;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async getHealthFactor(): Promise<number> {
|
|
198
|
+
return Promise.resolve(1);
|
|
199
|
+
}
|
|
200
|
+
}
|