@katanaperps/katana-perps-sdk 1.0.0 → 1.0.2-beta.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.
- package/README.md +1 -1
- package/dist/abis/ExchangeLayerZeroAdapter_v1.json +728 -0
- package/dist/abis/IVaultComposerSync.json +537 -0
- package/dist/abis/KatanaPerpsStargateForwarder_v1.json +563 -0
- package/dist/bridge/config.d.ts +46 -57
- package/dist/bridge/config.d.ts.map +1 -1
- package/dist/bridge/config.js +39 -48
- package/dist/bridge/deposit.d.ts +23 -3
- package/dist/bridge/deposit.d.ts.map +1 -1
- package/dist/bridge/deposit.js +114 -42
- package/dist/bridge/utils.d.ts +26 -32
- package/dist/bridge/utils.d.ts.map +1 -1
- package/dist/bridge/withdraw.d.ts +1 -1
- package/dist/bridge/withdraw.d.ts.map +1 -1
- package/dist/bridge/withdraw.js +13 -32
- package/dist/client/rest/authenticated.d.ts +1 -0
- package/dist/client/rest/authenticated.d.ts.map +1 -1
- package/dist/client/rest/authenticated.js +24 -13
- package/dist/client/rest/public.d.ts +23 -0
- package/dist/client/rest/public.d.ts.map +1 -1
- package/dist/client/rest/public.js +25 -0
- package/dist/typechain-types/{ExchangeLayerZeroAdapter_v3.d.ts → ExchangeLayerZeroAdapter_v1.d.ts} +32 -37
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v1.d.ts.map +1 -0
- package/dist/typechain-types/IVaultComposerSync.d.ts +247 -0
- package/dist/typechain-types/IVaultComposerSync.d.ts.map +1 -0
- package/dist/typechain-types/{KumaStargateForwarder_v2.d.ts → KatanaPerpsStargateForwarder_v1.d.ts} +38 -14
- package/dist/typechain-types/KatanaPerpsStargateForwarder_v1.d.ts.map +1 -0
- package/dist/typechain-types/factories/{ExchangeLayerZeroAdapter_v3__factory.d.ts → ExchangeLayerZeroAdapter_v1__factory.d.ts} +62 -36
- package/dist/typechain-types/factories/{ExchangeLayerZeroAdapter_v3__factory.d.ts.map → ExchangeLayerZeroAdapter_v1__factory.d.ts.map} +1 -1
- package/dist/typechain-types/factories/{ExchangeLayerZeroAdapter_v3__factory.js → ExchangeLayerZeroAdapter_v1__factory.js} +77 -42
- package/dist/typechain-types/factories/IVaultComposerSync__factory.d.ts +422 -0
- package/dist/typechain-types/factories/IVaultComposerSync__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/IVaultComposerSync__factory.js +554 -0
- package/dist/typechain-types/factories/{KumaStargateForwarder_v2__factory.d.ts → KatanaPerpsStargateForwarder_v1__factory.d.ts} +103 -31
- package/dist/typechain-types/factories/KatanaPerpsStargateForwarder_v1__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/{KumaStargateForwarder_v2__factory.js → KatanaPerpsStargateForwarder_v1__factory.js} +125 -31
- package/dist/typechain-types/factories/index.d.ts +3 -0
- package/dist/typechain-types/factories/index.d.ts.map +1 -1
- package/dist/typechain-types/factories/index.js +7 -1
- package/dist/typechain-types/index.d.ts +6 -0
- package/dist/typechain-types/index.d.ts.map +1 -1
- package/dist/typechain-types/index.js +7 -1
- package/dist/types/enums/request.d.ts +2 -4
- package/dist/types/enums/request.d.ts.map +1 -1
- package/dist/types/enums/request.js +1 -2
- package/dist/types/rest/endpoints/GetExchange.d.ts +10 -0
- package/dist/types/rest/endpoints/GetExchange.d.ts.map +1 -1
- package/dist/types/rest/endpoints/GetFundingRateSamples.d.ts +40 -0
- package/dist/types/rest/endpoints/GetFundingRateSamples.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetGasFees.d.ts +2 -0
- package/dist/types/rest/endpoints/GetGasFees.d.ts.map +1 -1
- package/dist/types/rest/endpoints/index.d.ts +1 -0
- package/dist/types/rest/endpoints/index.d.ts.map +1 -1
- package/dist/types/rest/endpoints/index.js +1 -0
- package/dist/types/rest/endpoints/internal.d.ts +3 -2
- package/dist/types/rest/endpoints/internal.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/typechain-types/ExchangeLayerZeroAdapter.d.ts +0 -253
- package/dist/typechain-types/ExchangeLayerZeroAdapter.d.ts.map +0 -1
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v2.d.ts +0 -338
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v2.d.ts.map +0 -1
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v3.d.ts.map +0 -1
- package/dist/typechain-types/Exchange_v2.d.ts +0 -2148
- package/dist/typechain-types/Exchange_v2.d.ts.map +0 -1
- package/dist/typechain-types/KumaStargateForwarder_v1.d.ts +0 -252
- package/dist/typechain-types/KumaStargateForwarder_v1.d.ts.map +0 -1
- package/dist/typechain-types/KumaStargateForwarder_v1.js +0 -2
- package/dist/typechain-types/KumaStargateForwarder_v2.d.ts.map +0 -1
- package/dist/typechain-types/KumaStargateForwarder_v2.js +0 -2
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter__factory.d.ts +0 -359
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter__factory.d.ts.map +0 -1
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter__factory.js +0 -471
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter_v2__factory.d.ts +0 -419
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter_v2__factory.d.ts.map +0 -1
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter_v2__factory.js +0 -545
- package/dist/typechain-types/factories/Exchange_v2__factory.d.ts +0 -2832
- package/dist/typechain-types/factories/Exchange_v2__factory.d.ts.map +0 -1
- package/dist/typechain-types/factories/Exchange_v2__factory.js +0 -3636
- package/dist/typechain-types/factories/KumaStargateForwarder_v1__factory.d.ts +0 -354
- package/dist/typechain-types/factories/KumaStargateForwarder_v1__factory.d.ts.map +0 -1
- package/dist/typechain-types/factories/KumaStargateForwarder_v1__factory.js +0 -464
- package/dist/typechain-types/factories/KumaStargateForwarder_v2__factory.d.ts.map +0 -1
- /package/dist/typechain-types/{ExchangeLayerZeroAdapter.js → ExchangeLayerZeroAdapter_v1.js} +0 -0
- /package/dist/typechain-types/{ExchangeLayerZeroAdapter_v2.js → IVaultComposerSync.js} +0 -0
- /package/dist/typechain-types/{ExchangeLayerZeroAdapter_v3.js → KatanaPerpsStargateForwarder_v1.js} +0 -0
- /package/dist/{typechain-types/Exchange_v2.js → types/rest/endpoints/GetFundingRateSamples.js} +0 -0
package/dist/bridge/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BridgeTarget } from '#types/enums/request';
|
|
2
|
-
export declare const BridgeTargetsArray: ("katana.katana" | "stargate.
|
|
2
|
+
export declare const BridgeTargetsArray: ("katana.katana" | "stargate.arbitrum" | "stargate.aurora" | "stargate.avalanche" | "stargate.base" | "stargate.berachain" | "stargate.ethereum" | "stargate.optimism" | "stargate.rari" | "stargate.scroll" | "stargate.taiko")[];
|
|
3
3
|
/**
|
|
4
4
|
* TODO_IKON - These configs need to be completed in some areas and should be confirmed as valid
|
|
5
5
|
*
|
|
@@ -9,9 +9,10 @@ export declare const BridgeTargetsArray: ("katana.katana" | "stargate.berachain"
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const BridgeConfig: {
|
|
11
11
|
readonly settings: {
|
|
12
|
-
readonly
|
|
12
|
+
readonly addManagedAccountComposeGasLimit: 650000;
|
|
13
|
+
readonly depositComposeGasLimit: 350000;
|
|
13
14
|
readonly depositSourceChainGasLimit: 450000;
|
|
14
|
-
readonly stargateBridgeForwarderGasLimit:
|
|
15
|
+
readonly stargateBridgeForwarderGasLimit: 1200000;
|
|
15
16
|
readonly localBridgeTarget: "katana.katana";
|
|
16
17
|
};
|
|
17
18
|
readonly mainnet: {
|
|
@@ -19,17 +20,9 @@ export declare const BridgeConfig: {
|
|
|
19
20
|
readonly target: "katana.katana";
|
|
20
21
|
readonly evmChainId: 747474;
|
|
21
22
|
readonly layerZeroEndpointId: 30375;
|
|
22
|
-
readonly layerzeroOFTAddress: "
|
|
23
|
+
readonly layerzeroOFTAddress: "0x807275727Dd3E640c5F2b5DE7d1eC72B4Dd293C0";
|
|
23
24
|
readonly tokenDecimals: 6;
|
|
24
|
-
readonly usdcAddress: "
|
|
25
|
-
};
|
|
26
|
-
readonly "stargate.berachain": {
|
|
27
|
-
readonly target: "stargate.berachain";
|
|
28
|
-
readonly evmChainId: 80094;
|
|
29
|
-
readonly layerZeroEndpointId: 30362;
|
|
30
|
-
readonly layerzeroOFTAddress: "0xAF54BE5B6eEc24d6BFACf1cce4eaF680A8239398";
|
|
31
|
-
readonly tokenDecimals: 6;
|
|
32
|
-
readonly usdcAddress: "0x549943e04f40284185054145c6E4e9568C1D3241";
|
|
25
|
+
readonly usdcAddress: "0x203A662b0BD271A6ed5a60EdFbd04bFce608FD36";
|
|
33
26
|
};
|
|
34
27
|
readonly "stargate.arbitrum": {
|
|
35
28
|
readonly target: "stargate.arbitrum";
|
|
@@ -63,19 +56,20 @@ export declare const BridgeConfig: {
|
|
|
63
56
|
readonly tokenDecimals: 6;
|
|
64
57
|
readonly usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
65
58
|
};
|
|
66
|
-
readonly "stargate.
|
|
67
|
-
readonly target: "stargate.
|
|
68
|
-
readonly evmChainId:
|
|
69
|
-
readonly layerZeroEndpointId:
|
|
70
|
-
readonly layerzeroOFTAddress: "
|
|
71
|
-
readonly tokenDecimals:
|
|
72
|
-
readonly usdcAddress: "
|
|
59
|
+
readonly "stargate.berachain": {
|
|
60
|
+
readonly target: "stargate.berachain";
|
|
61
|
+
readonly evmChainId: 80094;
|
|
62
|
+
readonly layerZeroEndpointId: 30362;
|
|
63
|
+
readonly layerzeroOFTAddress: "0xAF54BE5B6eEc24d6BFACf1cce4eaF680A8239398";
|
|
64
|
+
readonly tokenDecimals: 6;
|
|
65
|
+
readonly usdcAddress: "0x549943e04f40284185054145c6E4e9568C1D3241";
|
|
73
66
|
};
|
|
74
67
|
readonly "stargate.ethereum": {
|
|
75
68
|
readonly target: "stargate.ethereum";
|
|
76
69
|
readonly evmChainId: 1;
|
|
77
70
|
readonly layerZeroEndpointId: 30101;
|
|
78
|
-
readonly layerzeroOFTAddress: "
|
|
71
|
+
readonly layerzeroOFTAddress: "0xb5bADA33542a05395d504a25885e02503A957Bb3";
|
|
72
|
+
readonly layerZeroVaultComposerSyncAddress: "0x75B4cA53d62cd4274ACBce30487A74de87f0D661";
|
|
79
73
|
readonly tokenDecimals: 6;
|
|
80
74
|
readonly usdcAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
81
75
|
};
|
|
@@ -116,19 +110,11 @@ export declare const BridgeConfig: {
|
|
|
116
110
|
readonly "katana.katana": {
|
|
117
111
|
readonly target: "katana.katana";
|
|
118
112
|
readonly isSupported: true;
|
|
119
|
-
readonly evmChainId:
|
|
120
|
-
readonly layerZeroEndpointId:
|
|
121
|
-
readonly layerzeroOFTAddress: "
|
|
113
|
+
readonly evmChainId: 737373;
|
|
114
|
+
readonly layerZeroEndpointId: -1;
|
|
115
|
+
readonly layerzeroOFTAddress: "0x0000000000000000000000000000000000000000";
|
|
122
116
|
readonly tokenDecimals: 6;
|
|
123
|
-
readonly usdcAddress: "
|
|
124
|
-
};
|
|
125
|
-
readonly "stargate.berachain": {
|
|
126
|
-
readonly target: "stargate.berachain";
|
|
127
|
-
readonly evmChainId: 11155111;
|
|
128
|
-
readonly layerZeroEndpointId: 40161;
|
|
129
|
-
readonly layerzeroOFTAddress: "0x21F1caDDBED3Cd50e6B30644459BFB80c367076c";
|
|
130
|
-
readonly tokenDecimals: 6;
|
|
131
|
-
readonly usdcAddress: "0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590";
|
|
117
|
+
readonly usdcAddress: "0xc2a4C310F2512A17Ac0047cf871aCAed3E62bB4B";
|
|
132
118
|
};
|
|
133
119
|
readonly "stargate.arbitrum": {
|
|
134
120
|
readonly target: "stargate.arbitrum";
|
|
@@ -138,18 +124,19 @@ export declare const BridgeConfig: {
|
|
|
138
124
|
readonly tokenDecimals: 6;
|
|
139
125
|
readonly usdcAddress: "0x3253a335E7bFfB4790Aa4C25C4250d206E9b9773";
|
|
140
126
|
};
|
|
127
|
+
readonly "stargate.ethereum": {
|
|
128
|
+
readonly target: "stargate.ethereum";
|
|
129
|
+
readonly evmChainId: 11155111;
|
|
130
|
+
readonly layerZeroEndpointId: 40161;
|
|
131
|
+
readonly layerzeroOFTAddress: "0x0000000000000000000000000000000000000000";
|
|
132
|
+
readonly layerZeroVaultComposerSync: "0x0000000000000000000000000000000000000000";
|
|
133
|
+
readonly tokenDecimals: 6;
|
|
134
|
+
readonly usdcAddress: "0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590";
|
|
135
|
+
};
|
|
141
136
|
};
|
|
142
137
|
};
|
|
143
138
|
export declare const BridgeConfigByLayerZeroEndpointId: {
|
|
144
139
|
mainnet: {
|
|
145
|
-
30362: {
|
|
146
|
-
readonly target: "stargate.berachain";
|
|
147
|
-
readonly evmChainId: 80094;
|
|
148
|
-
readonly layerZeroEndpointId: 30362;
|
|
149
|
-
readonly layerzeroOFTAddress: "0xAF54BE5B6eEc24d6BFACf1cce4eaF680A8239398";
|
|
150
|
-
readonly tokenDecimals: 6;
|
|
151
|
-
readonly usdcAddress: "0x549943e04f40284185054145c6E4e9568C1D3241";
|
|
152
|
-
};
|
|
153
140
|
30110: {
|
|
154
141
|
readonly target: "stargate.arbitrum";
|
|
155
142
|
readonly evmChainId: 42161;
|
|
@@ -182,19 +169,20 @@ export declare const BridgeConfigByLayerZeroEndpointId: {
|
|
|
182
169
|
readonly tokenDecimals: 6;
|
|
183
170
|
readonly usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
184
171
|
};
|
|
185
|
-
|
|
186
|
-
readonly target: "stargate.
|
|
187
|
-
readonly evmChainId:
|
|
188
|
-
readonly layerZeroEndpointId:
|
|
189
|
-
readonly layerzeroOFTAddress: "
|
|
190
|
-
readonly tokenDecimals:
|
|
191
|
-
readonly usdcAddress: "
|
|
172
|
+
30362: {
|
|
173
|
+
readonly target: "stargate.berachain";
|
|
174
|
+
readonly evmChainId: 80094;
|
|
175
|
+
readonly layerZeroEndpointId: 30362;
|
|
176
|
+
readonly layerzeroOFTAddress: "0xAF54BE5B6eEc24d6BFACf1cce4eaF680A8239398";
|
|
177
|
+
readonly tokenDecimals: 6;
|
|
178
|
+
readonly usdcAddress: "0x549943e04f40284185054145c6E4e9568C1D3241";
|
|
192
179
|
};
|
|
193
180
|
30101: {
|
|
194
181
|
readonly target: "stargate.ethereum";
|
|
195
182
|
readonly evmChainId: 1;
|
|
196
183
|
readonly layerZeroEndpointId: 30101;
|
|
197
|
-
readonly layerzeroOFTAddress: "
|
|
184
|
+
readonly layerzeroOFTAddress: "0xb5bADA33542a05395d504a25885e02503A957Bb3";
|
|
185
|
+
readonly layerZeroVaultComposerSyncAddress: "0x75B4cA53d62cd4274ACBce30487A74de87f0D661";
|
|
198
186
|
readonly tokenDecimals: 6;
|
|
199
187
|
readonly usdcAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
200
188
|
};
|
|
@@ -232,14 +220,6 @@ export declare const BridgeConfigByLayerZeroEndpointId: {
|
|
|
232
220
|
};
|
|
233
221
|
};
|
|
234
222
|
testnet: {
|
|
235
|
-
40161: {
|
|
236
|
-
readonly target: "stargate.berachain";
|
|
237
|
-
readonly evmChainId: 11155111;
|
|
238
|
-
readonly layerZeroEndpointId: 40161;
|
|
239
|
-
readonly layerzeroOFTAddress: "0x21F1caDDBED3Cd50e6B30644459BFB80c367076c";
|
|
240
|
-
readonly tokenDecimals: 6;
|
|
241
|
-
readonly usdcAddress: "0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590";
|
|
242
|
-
};
|
|
243
223
|
40231: {
|
|
244
224
|
readonly target: "stargate.arbitrum";
|
|
245
225
|
readonly evmChainId: 421614;
|
|
@@ -248,6 +228,15 @@ export declare const BridgeConfigByLayerZeroEndpointId: {
|
|
|
248
228
|
readonly tokenDecimals: 6;
|
|
249
229
|
readonly usdcAddress: "0x3253a335E7bFfB4790Aa4C25C4250d206E9b9773";
|
|
250
230
|
};
|
|
231
|
+
30101: {
|
|
232
|
+
readonly target: "stargate.ethereum";
|
|
233
|
+
readonly evmChainId: 1;
|
|
234
|
+
readonly layerZeroEndpointId: 30101;
|
|
235
|
+
readonly layerzeroOFTAddress: "0xb5bADA33542a05395d504a25885e02503A957Bb3";
|
|
236
|
+
readonly layerZeroVaultComposerSyncAddress: "0x75B4cA53d62cd4274ACBce30487A74de87f0D661";
|
|
237
|
+
readonly tokenDecimals: 6;
|
|
238
|
+
readonly usdcAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
239
|
+
};
|
|
251
240
|
};
|
|
252
241
|
};
|
|
253
242
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/bridge/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/bridge/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,kBAAkB,oOAA8B,CAAC;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwKf,CAAC;AAEX,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B7C,CAAC;AAEF;;;;;;;GAOG;AAEH,wBAAgB,mBAAmB,CAEjC,KAAK,EAAE,GAAG,GACT,KAAK,IAAI,YAAY,CAEvB"}
|
package/dist/bridge/config.js
CHANGED
|
@@ -12,9 +12,10 @@ exports.BridgeTargetsArray = Object.values(request_1.BridgeTarget);
|
|
|
12
12
|
*/
|
|
13
13
|
exports.BridgeConfig = {
|
|
14
14
|
settings: {
|
|
15
|
-
|
|
15
|
+
addManagedAccountComposeGasLimit: 650_000,
|
|
16
|
+
depositComposeGasLimit: 350_000,
|
|
16
17
|
depositSourceChainGasLimit: 450_000,
|
|
17
|
-
stargateBridgeForwarderGasLimit:
|
|
18
|
+
stargateBridgeForwarderGasLimit: 1_200_000,
|
|
18
19
|
localBridgeTarget: request_1.BridgeTarget.KATANA_KATANA,
|
|
19
20
|
},
|
|
20
21
|
mainnet: {
|
|
@@ -23,22 +24,11 @@ exports.BridgeConfig = {
|
|
|
23
24
|
// https://docs.layerzero.network/v2/deployments/deployed-contracts?chains=katana
|
|
24
25
|
evmChainId: 747474,
|
|
25
26
|
layerZeroEndpointId: 30375,
|
|
26
|
-
//
|
|
27
|
-
layerzeroOFTAddress: '
|
|
27
|
+
// OFTAdapter https://github.com/agglayer/vault-bridge/tree/ab1c49f1ba3a8632657856e4be6a6b351043ed69/broadcast#mainnet
|
|
28
|
+
layerzeroOFTAddress: '0x807275727Dd3E640c5F2b5DE7d1eC72B4Dd293C0',
|
|
28
29
|
// vbUSDC
|
|
29
30
|
tokenDecimals: 6,
|
|
30
|
-
usdcAddress: '
|
|
31
|
-
},
|
|
32
|
-
[request_1.BridgeTarget.LAYERZERO_BERACHAIN]: {
|
|
33
|
-
target: request_1.BridgeTarget.LAYERZERO_BERACHAIN,
|
|
34
|
-
// https://docs.layerzero.network/v2/deployments/deployed-contracts?chains=bera
|
|
35
|
-
evmChainId: 80094,
|
|
36
|
-
layerZeroEndpointId: 30362,
|
|
37
|
-
// https://stargateprotocol.gitbook.io/stargate/v2-developer-docs/technical-reference/mainnet-contracts#berachain
|
|
38
|
-
layerzeroOFTAddress: '0xAF54BE5B6eEc24d6BFACf1cce4eaF680A8239398',
|
|
39
|
-
// https://stargateprotocol.gitbook.io/stargate/v2-developer-docs/technical-reference/v2-supported-networks-and-assets#bera
|
|
40
|
-
tokenDecimals: 6,
|
|
41
|
-
usdcAddress: '0x549943e04f40284185054145c6E4e9568C1D3241',
|
|
31
|
+
usdcAddress: '0x203A662b0BD271A6ed5a60EdFbd04bFce608FD36',
|
|
42
32
|
},
|
|
43
33
|
[request_1.BridgeTarget.STARGATE_ARBITRUM]: {
|
|
44
34
|
target: request_1.BridgeTarget.STARGATE_ARBITRUM,
|
|
@@ -84,24 +74,25 @@ exports.BridgeConfig = {
|
|
|
84
74
|
tokenDecimals: 6,
|
|
85
75
|
usdcAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
86
76
|
},
|
|
87
|
-
[request_1.BridgeTarget.
|
|
88
|
-
target: request_1.BridgeTarget.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
layerZeroEndpointId:
|
|
92
|
-
// https://stargateprotocol.gitbook.io/stargate/v/v2-developer-docs/technical-reference/mainnet-contracts#
|
|
93
|
-
layerzeroOFTAddress: '
|
|
94
|
-
// https://stargateprotocol.gitbook.io/stargate/v2-developer-docs/technical-reference/v2-supported-networks-and-assets#
|
|
95
|
-
tokenDecimals:
|
|
96
|
-
usdcAddress: '
|
|
77
|
+
[request_1.BridgeTarget.STARGATE_BERACHAIN]: {
|
|
78
|
+
target: request_1.BridgeTarget.STARGATE_BERACHAIN,
|
|
79
|
+
evmChainId: 80094,
|
|
80
|
+
// https://docs.layerzero.network/v2/developers/evm/technical-reference/deployed-contracts#bera
|
|
81
|
+
layerZeroEndpointId: 30362,
|
|
82
|
+
// https://stargateprotocol.gitbook.io/stargate/v/v2-developer-docs/technical-reference/mainnet-contracts#berachain
|
|
83
|
+
layerzeroOFTAddress: '0xAF54BE5B6eEc24d6BFACf1cce4eaF680A8239398',
|
|
84
|
+
// https://stargateprotocol.gitbook.io/stargate/v2-developer-docs/technical-reference/v2-supported-networks-and-assets#bera
|
|
85
|
+
tokenDecimals: 6,
|
|
86
|
+
usdcAddress: '0x549943e04f40284185054145c6E4e9568C1D3241',
|
|
97
87
|
},
|
|
98
88
|
[request_1.BridgeTarget.STARGATE_ETHEREUM]: {
|
|
99
89
|
target: request_1.BridgeTarget.STARGATE_ETHEREUM,
|
|
100
90
|
// https://docs.layerzero.network/v2/deployments/deployed-contracts?chains=ethereum
|
|
101
91
|
evmChainId: 1,
|
|
102
92
|
layerZeroEndpointId: 30101,
|
|
103
|
-
// https://
|
|
104
|
-
layerzeroOFTAddress: '
|
|
93
|
+
// vbUSDC OFTAdapter https://github.com/agglayer/vault-bridge/tree/main/broadcast#mainnet
|
|
94
|
+
layerzeroOFTAddress: '0xb5bADA33542a05395d504a25885e02503A957Bb3',
|
|
95
|
+
layerZeroVaultComposerSyncAddress: '0x75B4cA53d62cd4274ACBce30487A74de87f0D661',
|
|
105
96
|
// https://stargateprotocol.gitbook.io/stargate/v2-developer-docs/technical-reference/v2-supported-networks-and-assets#ethereum
|
|
106
97
|
tokenDecimals: 6,
|
|
107
98
|
usdcAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
@@ -155,22 +146,14 @@ exports.BridgeConfig = {
|
|
|
155
146
|
[request_1.BridgeTarget.KATANA_KATANA]: {
|
|
156
147
|
target: request_1.BridgeTarget.KATANA_KATANA,
|
|
157
148
|
isSupported: true,
|
|
158
|
-
evmChainId:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
[request_1.BridgeTarget.LAYERZERO_BERACHAIN]: {
|
|
165
|
-
target: request_1.BridgeTarget.LAYERZERO_BERACHAIN,
|
|
166
|
-
// TODO There is currently no testnet for Berachain so we are using
|
|
167
|
-
// Sepolia as a substitute for testing purposes
|
|
168
|
-
// https://docs.layerzero.network/v2/deployments/deployed-contracts?chains=sepolia
|
|
169
|
-
evmChainId: 11155111,
|
|
170
|
-
layerZeroEndpointId: 40161,
|
|
171
|
-
layerzeroOFTAddress: '0x21F1caDDBED3Cd50e6B30644459BFB80c367076c',
|
|
149
|
+
evmChainId: 737373,
|
|
150
|
+
// No LZ connection yet on Bokuto testnet
|
|
151
|
+
layerZeroEndpointId: -1,
|
|
152
|
+
// No OFT currently supported on Bokuto testnet
|
|
153
|
+
layerzeroOFTAddress: '0x0000000000000000000000000000000000000000',
|
|
172
154
|
tokenDecimals: 6,
|
|
173
|
-
|
|
155
|
+
// vbUSDC
|
|
156
|
+
usdcAddress: '0xc2a4C310F2512A17Ac0047cf871aCAed3E62bB4B',
|
|
174
157
|
},
|
|
175
158
|
[request_1.BridgeTarget.STARGATE_ARBITRUM]: {
|
|
176
159
|
target: request_1.BridgeTarget.STARGATE_ARBITRUM,
|
|
@@ -182,17 +165,26 @@ exports.BridgeConfig = {
|
|
|
182
165
|
tokenDecimals: 6,
|
|
183
166
|
usdcAddress: '0x3253a335E7bFfB4790Aa4C25C4250d206E9b9773',
|
|
184
167
|
},
|
|
168
|
+
[request_1.BridgeTarget.STARGATE_ETHEREUM]: {
|
|
169
|
+
target: request_1.BridgeTarget.STARGATE_ETHEREUM,
|
|
170
|
+
// https://docs.layerzero.network/v2/deployments/deployed-contracts?chains=sepolia
|
|
171
|
+
evmChainId: 11155111,
|
|
172
|
+
layerZeroEndpointId: 40161,
|
|
173
|
+
// No OFT currently supported on Sepolia testnet
|
|
174
|
+
layerzeroOFTAddress: '0x0000000000000000000000000000000000000000',
|
|
175
|
+
layerZeroVaultComposerSync: '0x0000000000000000000000000000000000000000',
|
|
176
|
+
tokenDecimals: 6,
|
|
177
|
+
usdcAddress: '0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590',
|
|
178
|
+
},
|
|
185
179
|
},
|
|
186
180
|
};
|
|
187
181
|
exports.BridgeConfigByLayerZeroEndpointId = {
|
|
188
182
|
mainnet: {
|
|
189
|
-
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.LAYERZERO_BERACHAIN]
|
|
190
|
-
.layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.LAYERZERO_BERACHAIN],
|
|
191
183
|
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_ARBITRUM].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_ARBITRUM],
|
|
192
184
|
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_AURORA].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_AURORA],
|
|
193
185
|
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_AVALANCHE].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_AVALANCHE],
|
|
194
186
|
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_BASE].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_BASE],
|
|
195
|
-
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.
|
|
187
|
+
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_BERACHAIN].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_BERACHAIN],
|
|
196
188
|
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_ETHEREUM].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_ETHEREUM],
|
|
197
189
|
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_OPTIMISM].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_OPTIMISM],
|
|
198
190
|
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_RARI].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_RARI],
|
|
@@ -200,9 +192,8 @@ exports.BridgeConfigByLayerZeroEndpointId = {
|
|
|
200
192
|
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_TAIKO].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_TAIKO],
|
|
201
193
|
},
|
|
202
194
|
testnet: {
|
|
203
|
-
[exports.BridgeConfig.testnet[request_1.BridgeTarget.LAYERZERO_BERACHAIN]
|
|
204
|
-
.layerZeroEndpointId]: exports.BridgeConfig.testnet[request_1.BridgeTarget.LAYERZERO_BERACHAIN],
|
|
205
195
|
[exports.BridgeConfig.testnet[request_1.BridgeTarget.STARGATE_ARBITRUM].layerZeroEndpointId]: exports.BridgeConfig.testnet[request_1.BridgeTarget.STARGATE_ARBITRUM],
|
|
196
|
+
[exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_ETHEREUM].layerZeroEndpointId]: exports.BridgeConfig.mainnet[request_1.BridgeTarget.STARGATE_ETHEREUM],
|
|
206
197
|
},
|
|
207
198
|
};
|
|
208
199
|
/**
|
package/dist/bridge/deposit.d.ts
CHANGED
|
@@ -88,16 +88,36 @@ export declare function decodeDepositBridgeAdapterPayload(payload: EncodedDeposi
|
|
|
88
88
|
* Deposit funds cross-chain into the Exchange using a LayerZero OFT or Stargate
|
|
89
89
|
*/
|
|
90
90
|
export declare function depositViaBridge(parameters: AddManagedAccountParameters | DepositToManagedAccountParameters | DepositToWalletParameters, providers: {
|
|
91
|
-
|
|
91
|
+
ethereum: ethers.Provider;
|
|
92
92
|
sourceChain: ethers.Provider;
|
|
93
|
-
}, sourceSigner: ethers.Signer, sandbox: boolean, extraRequestParams?: Pick<TransactionRequest, 'nonce'
|
|
93
|
+
}, sourceSigner: ethers.Signer, sandbox: boolean, extraRequestParams?: Pick<TransactionRequest, 'nonce'>,
|
|
94
|
+
/** Let software wallet show estimate to the user. Even on expected TX failure. */
|
|
95
|
+
ignoreEstimateError?: boolean): Promise<string>;
|
|
96
|
+
/**
|
|
97
|
+
* Deposit funds cross-chain into the Exchange using a LayerZero OFT or Stargate
|
|
98
|
+
*/
|
|
99
|
+
export declare function depositViaVaultComposerSync(parameters: AddManagedAccountParameters | DepositToManagedAccountParameters | DepositToWalletParameters, providers: {
|
|
100
|
+
ethereum: ethers.Provider;
|
|
101
|
+
sourceChain: ethers.Provider;
|
|
102
|
+
}, sourceSigner: ethers.Signer, sandbox: boolean, extraRequestParams?: Pick<TransactionRequest, 'nonce'>,
|
|
103
|
+
/** Let software wallet show estimate to the user. Even on expected TX failure. */
|
|
104
|
+
ignoreEstimateError?: boolean): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Deposit funds cross-chain into the Exchange using a LayerZero OFT or Stargate
|
|
107
|
+
*/
|
|
108
|
+
export declare function depositViaForwarder(parameters: AddManagedAccountParameters | DepositToManagedAccountParameters | DepositToWalletParameters, providers: {
|
|
109
|
+
ethereum: ethers.Provider;
|
|
110
|
+
sourceChain: ethers.Provider;
|
|
111
|
+
}, sourceSigner: ethers.Signer, sandbox: boolean, extraRequestParams?: Pick<TransactionRequest, 'nonce'>,
|
|
112
|
+
/** Let software wallet show estimate to the user. Even on expected TX failure. */
|
|
113
|
+
ignoreEstimateError?: boolean): Promise<string>;
|
|
94
114
|
export declare function encodeDepositBridgeAdapterPayload(sourceConfig: ReturnType<typeof getBridgeTargetConfig>, parameters: AddManagedAccountParameters | DepositToManagedAccountParameters | DepositToWalletParameters): EncodedDepositBridgeAdapterPayload;
|
|
95
115
|
export declare function encodeFixedIncomeVaultConfigurationFields(configurationFields: FixedIncomeVaultConfigurationFields): string;
|
|
96
116
|
/**
|
|
97
117
|
* Estimate native gas fee needed to deposit USDC cross-chain into the Exchange
|
|
98
118
|
*/
|
|
99
119
|
export declare function estimateDepositFees(parameters: AddManagedAccountParameters | DepositToManagedAccountParameters | DepositToWalletParameters, providers: {
|
|
100
|
-
|
|
120
|
+
ethereum: ethers.Provider;
|
|
101
121
|
sourceChain: ethers.Provider;
|
|
102
122
|
}, sandbox: boolean): Promise<{
|
|
103
123
|
gasFee: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deposit.d.ts","sourceRoot":"","sources":["../../src/bridge/deposit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,kBAAkB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"deposit.d.ts","sourceRoot":"","sources":["../../src/bridge/deposit.ts"],"names":[],"mappings":"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"}
|
package/dist/bridge/deposit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDestinationWallet = exports.estimateDepositFees = exports.encodeFixedIncomeVaultConfigurationFields = exports.encodeDepositBridgeAdapterPayload = exports.depositViaBridge = exports.decodeDepositBridgeAdapterPayload = exports.decodeDepositBridgeAdapterPayloadType = exports.depositBridgeAdapterPayloadLengths = exports.fixedIncomeVaultConfigurationFieldsLength = exports.DepositBridgeAdapterPayloadType = void 0;
|
|
3
|
+
exports.getDestinationWallet = exports.estimateDepositFees = exports.encodeFixedIncomeVaultConfigurationFields = exports.encodeDepositBridgeAdapterPayload = exports.depositViaForwarder = exports.depositViaVaultComposerSync = exports.depositViaBridge = exports.decodeDepositBridgeAdapterPayload = exports.decodeDepositBridgeAdapterPayloadType = exports.depositBridgeAdapterPayloadLengths = exports.fixedIncomeVaultConfigurationFieldsLength = exports.DepositBridgeAdapterPayloadType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
|
|
6
6
|
const ethers_1 = require("ethers");
|
|
@@ -64,25 +64,88 @@ exports.decodeDepositBridgeAdapterPayload = decodeDepositBridgeAdapterPayload;
|
|
|
64
64
|
/**
|
|
65
65
|
* Deposit funds cross-chain into the Exchange using a LayerZero OFT or Stargate
|
|
66
66
|
*/
|
|
67
|
-
async function depositViaBridge(parameters, providers, sourceSigner, sandbox, extraRequestParams
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
async function depositViaBridge(parameters, providers, sourceSigner, sandbox, extraRequestParams,
|
|
68
|
+
/** Let software wallet show estimate to the user. Even on expected TX failure. */
|
|
69
|
+
ignoreEstimateError) {
|
|
70
|
+
return parameters.sourceBridgeTarget === request_1.BridgeTarget.STARGATE_ETHEREUM ?
|
|
71
|
+
depositViaVaultComposerSync(parameters, providers, sourceSigner, sandbox, extraRequestParams, ignoreEstimateError)
|
|
72
|
+
: depositViaForwarder(parameters, providers, sourceSigner, sandbox, extraRequestParams, ignoreEstimateError);
|
|
73
|
+
}
|
|
74
|
+
exports.depositViaBridge = depositViaBridge;
|
|
75
|
+
/**
|
|
76
|
+
* Deposit funds cross-chain into the Exchange using a LayerZero OFT or Stargate
|
|
77
|
+
*/
|
|
78
|
+
async function depositViaVaultComposerSync(parameters, providers, sourceSigner, sandbox, extraRequestParams,
|
|
79
|
+
/** Let software wallet show estimate to the user. Even on expected TX failure. */
|
|
80
|
+
ignoreEstimateError) {
|
|
81
|
+
const [{ sendParam, sourceConfig }, { gasFee }] = await Promise.all([
|
|
82
|
+
getDepositFromEthereumSendParamAndSourceConfig(parameters, sandbox),
|
|
83
|
+
estimateDepositFromEthereumFees(parameters, providers, sandbox),
|
|
84
|
+
]);
|
|
85
|
+
let gasLimit = config_1.BridgeConfig.settings.depositSourceChainGasLimit;
|
|
86
|
+
const vaultComposerSync = index_1.IVaultComposerSync__factory.connect(sourceConfig.layerZeroVaultComposerSyncAddress, sourceSigner);
|
|
87
|
+
const sourceWallet = await sourceSigner.getAddress();
|
|
88
|
+
try {
|
|
89
|
+
// Estimate gas
|
|
90
|
+
const estimatedGasLimit = await vaultComposerSync.depositAndSend.estimateGas(parameters.quantityInAssetUnits, sendParam, sourceWallet, // Refund address - extra gas (if any) is returned to this address
|
|
91
|
+
{
|
|
92
|
+
...extraRequestParams,
|
|
93
|
+
from: sourceWallet,
|
|
94
|
+
// Native gas to pay for the cross chain message fee
|
|
95
|
+
value: gasFee,
|
|
96
|
+
});
|
|
97
|
+
// Add 20% buffer for safety
|
|
98
|
+
gasLimit = Number(new bignumber_js_1.default(estimatedGasLimit.toString())
|
|
99
|
+
.times(new bignumber_js_1.default(1.2))
|
|
100
|
+
.toFixed(0));
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// ethers.js will perform the estimation at the block gas limit, which is much higher than the
|
|
104
|
+
// gas actually needed by the tx. If the wallet does not have the funds to cover the tx at this
|
|
105
|
+
// high gas limit then the RPC will throw an INSUFFICIENT_FUNDS error; however the wallet may
|
|
106
|
+
// still have enough funds to successfully bridge at the actual gas limit. In this case simply
|
|
107
|
+
// fall through and use the configured default gas limit. The wallet software in use should
|
|
108
|
+
// still show if that limit is insufficient, which is only an issue for blockchains with
|
|
109
|
+
// variable gas costs such as Arbitrum One
|
|
110
|
+
if (error?.code === 'INSUFFICIENT_FUNDS') {
|
|
111
|
+
console.log('[depositViaVaultComposerSync] Insufficient funds - continue with default gas');
|
|
112
|
+
}
|
|
113
|
+
else if (ignoreEstimateError) {
|
|
114
|
+
// TODO: In latest contract it throws 'CALL_EXCEPTION' instead of 'INSUFFICIENT_FUNDS'
|
|
115
|
+
console.log('[depositViaVaultComposerSync] Estimate failed - continue with default gas', error);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const response = await vaultComposerSync.depositAndSend.send(parameters.quantityInAssetUnits, sendParam, sourceWallet, // Refund address - extra gas (if any) is returned to this address
|
|
122
|
+
{
|
|
123
|
+
from: sourceWallet,
|
|
124
|
+
gasLimit,
|
|
125
|
+
value: gasFee,
|
|
126
|
+
});
|
|
127
|
+
return response.hash;
|
|
128
|
+
}
|
|
129
|
+
exports.depositViaVaultComposerSync = depositViaVaultComposerSync;
|
|
130
|
+
/**
|
|
131
|
+
* Deposit funds cross-chain into the Exchange using a LayerZero OFT or Stargate
|
|
132
|
+
*/
|
|
133
|
+
async function depositViaForwarder(parameters, providers, sourceSigner, sandbox, extraRequestParams,
|
|
134
|
+
/** Let software wallet show estimate to the user. Even on expected TX failure. */
|
|
135
|
+
ignoreEstimateError) {
|
|
136
|
+
const [{ sendParam, sourceConfig }, { gasFee }] = await Promise.all([
|
|
137
|
+
getDepositViaForwarderSendParamAndSourceConfig(parameters, providers, sandbox),
|
|
138
|
+
estimateDepositViaForwarderFees(parameters, providers, sandbox),
|
|
139
|
+
]);
|
|
77
140
|
let gasLimit = config_1.BridgeConfig.settings.depositSourceChainGasLimit;
|
|
78
141
|
const oft = index_1.IOFT__factory.connect(sourceConfig.layerzeroOFTAddress, sourceSigner);
|
|
79
|
-
const
|
|
142
|
+
const sourceWallet = await sourceSigner.getAddress();
|
|
80
143
|
try {
|
|
81
144
|
// Estimate gas
|
|
82
|
-
const estimatedGasLimit = await oft.send.estimateGas(sendParam, { nativeFee: gasFee, lzTokenFee: 0 },
|
|
145
|
+
const estimatedGasLimit = await oft.send.estimateGas(sendParam, { nativeFee: gasFee, lzTokenFee: 0 }, sourceWallet, // Refund address - extra gas (if any) is returned to this address
|
|
83
146
|
{
|
|
84
147
|
...extraRequestParams,
|
|
85
|
-
from:
|
|
148
|
+
from: sourceWallet,
|
|
86
149
|
// Native gas to pay for the cross chain message fee
|
|
87
150
|
value: gasFee,
|
|
88
151
|
});
|
|
@@ -99,19 +162,26 @@ async function depositViaBridge(parameters, providers, sourceSigner, sandbox, ex
|
|
|
99
162
|
// fall through and use the configured default gas limit. The wallet software in use should
|
|
100
163
|
// still show if that limit is insufficient, which is only an issue for blockchains with
|
|
101
164
|
// variable gas costs such as Arbitrum One
|
|
102
|
-
if (
|
|
165
|
+
if (error?.code === 'INSUFFICIENT_FUNDS') {
|
|
166
|
+
console.log('[depositViaForwarder] Insufficient funds - continue with default gas');
|
|
167
|
+
}
|
|
168
|
+
else if (ignoreEstimateError) {
|
|
169
|
+
// TODO: In latest contract it throws 'CALL_EXCEPTION' instead of 'INSUFFICIENT_FUNDS'
|
|
170
|
+
console.log('[depositViaForwarder] Estimate failed - continue with default gas', error);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
103
173
|
throw error;
|
|
104
174
|
}
|
|
105
175
|
}
|
|
106
|
-
const response = await oft.send(sendParam, { nativeFee: gasFee, lzTokenFee: 0 },
|
|
176
|
+
const response = await oft.send(sendParam, { nativeFee: gasFee, lzTokenFee: 0 }, sourceWallet, // Refund address - extra gas (if any) is returned to this address
|
|
107
177
|
{
|
|
108
|
-
from:
|
|
178
|
+
from: sourceWallet,
|
|
109
179
|
gasLimit,
|
|
110
180
|
value: gasFee,
|
|
111
181
|
});
|
|
112
182
|
return response.hash;
|
|
113
183
|
}
|
|
114
|
-
exports.
|
|
184
|
+
exports.depositViaForwarder = depositViaForwarder;
|
|
115
185
|
function encodeDepositBridgeAdapterPayload(sourceConfig, parameters) {
|
|
116
186
|
if (parameters.bridgePayloadType ===
|
|
117
187
|
DepositBridgeAdapterPayloadType.addManagedAccount) {
|
|
@@ -169,8 +239,8 @@ exports.encodeFixedIncomeVaultConfigurationFields = encodeFixedIncomeVaultConfig
|
|
|
169
239
|
* Estimate native gas fee needed to deposit USDC cross-chain into the Exchange
|
|
170
240
|
*/
|
|
171
241
|
async function estimateDepositFees(parameters, providers, sandbox) {
|
|
172
|
-
if (parameters.sourceBridgeTarget === request_1.BridgeTarget.
|
|
173
|
-
return
|
|
242
|
+
if (parameters.sourceBridgeTarget === request_1.BridgeTarget.STARGATE_ETHEREUM) {
|
|
243
|
+
return estimateDepositFromEthereumFees(parameters, providers, sandbox);
|
|
174
244
|
}
|
|
175
245
|
return estimateDepositViaForwarderFees(parameters, providers, sandbox);
|
|
176
246
|
}
|
|
@@ -191,11 +261,11 @@ function getDestinationWallet(parameters) {
|
|
|
191
261
|
exports.getDestinationWallet = getDestinationWallet;
|
|
192
262
|
/**
|
|
193
263
|
* Estimate native gas fee needed to deposit USDC cross-chain into the Exchange
|
|
194
|
-
* from
|
|
264
|
+
* from Ethereum using the OFT pathway
|
|
195
265
|
*/
|
|
196
|
-
async function
|
|
197
|
-
const { sendParam, sourceConfig } = await
|
|
198
|
-
const oft = index_1.IOFT__factory.connect(sourceConfig.layerzeroOFTAddress, providers.
|
|
266
|
+
async function estimateDepositFromEthereumFees(parameters, providers, sandbox) {
|
|
267
|
+
const { sendParam, sourceConfig } = await getDepositFromEthereumSendParamAndSourceConfig(parameters, sandbox);
|
|
268
|
+
const oft = index_1.IOFT__factory.connect(sourceConfig.layerzeroOFTAddress, providers.ethereum);
|
|
199
269
|
const [[gasFee], [, , receipt]] = await Promise.all([
|
|
200
270
|
oft.quoteSend(sendParam, false, {
|
|
201
271
|
from: getDestinationWallet(parameters),
|
|
@@ -216,25 +286,24 @@ async function estimateDepositViaForwarderFees(parameters, providers, sandbox) {
|
|
|
216
286
|
}),
|
|
217
287
|
ioft.quoteOFT(sendParam),
|
|
218
288
|
]);
|
|
219
|
-
// Once we obtain the quantity delivered after slippage to
|
|
289
|
+
// Once we obtain the quantity delivered after slippage to Ethereum, calculate
|
|
220
290
|
// the quantity subsequently delivered to Katana after any additional slippage
|
|
221
|
-
const { quantityDeliveredInAssetUnits } = await
|
|
291
|
+
const { quantityDeliveredInAssetUnits } = await estimateDepositFromEthereumFees({ ...parameters, quantityInAssetUnits: receipt.amountReceivedLD }, providers, sandbox);
|
|
222
292
|
return {
|
|
223
293
|
gasFee,
|
|
224
294
|
quantityDeliveredInAssetUnits,
|
|
225
295
|
};
|
|
226
296
|
}
|
|
227
|
-
async function
|
|
228
|
-
const { sourceConfig, destinationConfig } = getSourceAndDestinationConfigs(request_1.BridgeTarget.
|
|
297
|
+
async function getDepositFromEthereumSendParamAndSourceConfig(parameters, sandbox) {
|
|
298
|
+
const { sourceConfig, destinationConfig } = getSourceAndDestinationConfigs(request_1.BridgeTarget.STARGATE_ETHEREUM, request_1.BridgeTarget.KATANA_KATANA, sandbox);
|
|
229
299
|
const exchangeLayerZeroAdapterAddress = await (0, utils_1.loadExchangeLayerZeroAddressFromApiIfNeeded)(parameters.exchangeLayerZeroAdapterAddress);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
300
|
+
const { Options } = await import('@layerzerolabs/lz-v2-utilities');
|
|
301
|
+
const extraOptions = Options.newOptions()
|
|
302
|
+
.addExecutorComposeOption(0, (parameters.bridgePayloadType ===
|
|
303
|
+
DepositBridgeAdapterPayloadType.addManagedAccount) ?
|
|
304
|
+
config_1.BridgeConfig.settings.addManagedAccountComposeGasLimit
|
|
305
|
+
: config_1.BridgeConfig.settings.depositComposeGasLimit, 0)
|
|
306
|
+
.toBytes();
|
|
238
307
|
const sendParam = {
|
|
239
308
|
dstEid: destinationConfig.layerZeroEndpointId, // Destination endpoint ID
|
|
240
309
|
to: ethers_1.ethers.zeroPadValue(exchangeLayerZeroAdapterAddress, 32), // Recipient address
|
|
@@ -244,24 +313,27 @@ async function getDepositFromBerachainSendParamAndSourceConfig(parameters, sandb
|
|
|
244
313
|
composeMsg: encodeDepositBridgeAdapterPayload(sourceConfig, parameters), // Additional options supplied by the caller to be used in the LayerZero message
|
|
245
314
|
oftCmd: '0x', // The OFT command to be executed, unused in default OFT implementations
|
|
246
315
|
};
|
|
247
|
-
return {
|
|
316
|
+
return {
|
|
317
|
+
sendParam,
|
|
318
|
+
sourceConfig: sourceConfig,
|
|
319
|
+
};
|
|
248
320
|
}
|
|
249
321
|
async function getDepositViaForwarderSendParamAndSourceConfig(parameters, providers, sandbox) {
|
|
250
|
-
const { sourceConfig, destinationConfig:
|
|
251
|
-
const { gasFee:
|
|
322
|
+
const { sourceConfig, destinationConfig: ethereumConfig } = getSourceAndDestinationConfigs(parameters.sourceBridgeTarget, request_1.BridgeTarget.STARGATE_ETHEREUM, sandbox);
|
|
323
|
+
const { gasFee: ethereumGasFee } = await estimateDepositFromEthereumFees(parameters, providers, sandbox);
|
|
252
324
|
// Add 20% buffer for safety
|
|
253
|
-
const additionalNativeDrop = new bignumber_js_1.default(
|
|
325
|
+
const additionalNativeDrop = new bignumber_js_1.default(ethereumGasFee.toString())
|
|
254
326
|
.times(new bignumber_js_1.default(1.2))
|
|
255
327
|
.toFixed(0);
|
|
256
328
|
const stargateBridgeForwarderContractAddress = await (0, utils_1.loadStargateBridgeForwarderContractAddressFromApiIfNeeded)(parameters.stargateBridgeForwarderContractAddress);
|
|
257
329
|
// FIXME CJS dynamic import
|
|
258
330
|
const { Options } = await import('@layerzerolabs/lz-v2-utilities');
|
|
259
331
|
const extraOptions = Options.newOptions()
|
|
260
|
-
// Native drop is specified in
|
|
332
|
+
// Native drop is specified in ETH wei
|
|
261
333
|
.addExecutorComposeOption(0, config_1.BridgeConfig.settings.stargateBridgeForwarderGasLimit, additionalNativeDrop)
|
|
262
334
|
.toHex();
|
|
263
335
|
const sendParam = {
|
|
264
|
-
dstEid:
|
|
336
|
+
dstEid: ethereumConfig.layerZeroEndpointId, // Destination endpoint ID
|
|
265
337
|
to: ethers_1.ethers.zeroPadValue(stargateBridgeForwarderContractAddress, 32), // Recipient address
|
|
266
338
|
amountLD: parameters.quantityInAssetUnits, // Amount to send in local decimals
|
|
267
339
|
minAmountLD: (0, _pipmath_1.multiplyPips)(parameters.quantityInAssetUnits, parameters.minimumForwardQuantityMultiplierInPips), // Minimum amount to send in local decimals
|