@dripfi/drip-sdk 1.4.28-bridge-perq-1 → 1.4.28-silo-sdk

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 (41) hide show
  1. package/README.md +45 -48
  2. package/dist/PerqSdk.d.ts +5 -3
  3. package/dist/PerqSdk.js +8 -5
  4. package/dist/abi/index.d.ts +0 -286
  5. package/dist/abi/index.js +4 -8
  6. package/dist/contracts/{BasePerqContract.d.ts → BaseContract.d.ts} +1 -1
  7. package/dist/contracts/{BasePerqContract.js → BaseContract.js} +2 -2
  8. package/dist/contracts/index.d.ts +6 -8
  9. package/dist/contracts/index.js +7 -11
  10. package/dist/contracts/{PerqSwapAndRecyclerContract.d.ts → perq/PerqSwapAndRecyclerContract.d.ts} +3 -3
  11. package/dist/contracts/{PerqSwapAndRecyclerContract.js → perq/PerqSwapAndRecyclerContract.js} +3 -3
  12. package/dist/contracts/{PerqTokenContract.d.ts → perq/PerqTokenContract.d.ts} +2 -2
  13. package/dist/contracts/{PerqTokenContract.js → perq/PerqTokenContract.js} +3 -3
  14. package/dist/contracts/{PerqTokenRecyclerContract.d.ts → perq/PerqTokenRecyclerContract.d.ts} +3 -3
  15. package/dist/contracts/{PerqTokenRecyclerContract.js → perq/PerqTokenRecyclerContract.js} +3 -3
  16. package/dist/contracts/{PerqVestingContract.d.ts → perq/PerqVestingContract.d.ts} +3 -3
  17. package/dist/contracts/{PerqVestingContract.js → perq/PerqVestingContract.js} +3 -3
  18. package/dist/subpackages/SiloPackage.d.ts +18 -0
  19. package/dist/subpackages/SiloPackage.js +115 -0
  20. package/dist/subpackages/VaultHandlerPackage.d.ts +37 -0
  21. package/dist/subpackages/VaultHandlerPackage.js +154 -0
  22. package/dist/types/DeployedProject.d.ts +1 -0
  23. package/dist/types/PerqConfig.d.ts +0 -2
  24. package/dist/types/PerqConfig.js +0 -4
  25. package/dist/types/SdkType.d.ts +2 -0
  26. package/dist/types/VaultData.d.ts +2 -0
  27. package/package.json +2 -1
  28. package/dist/abi/BridgeMainnetPerqToSonicAbi.json +0 -598
  29. package/dist/abi/BridgeSonicPerqToMainnetAbi.json +0 -733
  30. package/dist/contracts/BridgeMainnetPerqToSonicContract.d.ts +0 -9
  31. package/dist/contracts/BridgeMainnetPerqToSonicContract.js +0 -48
  32. package/dist/contracts/BridgeSonicPerqToMainnetContract.d.ts +0 -9
  33. package/dist/contracts/BridgeSonicPerqToMainnetContract.js +0 -47
  34. package/dist/subpackages/BridgePerqPackage.d.ts +0 -36
  35. package/dist/subpackages/BridgePerqPackage.js +0 -207
  36. package/dist/types/BridgePerq.d.ts +0 -14
  37. /package/dist/abi/{PerqSwapAndRecyclerAbi.json → perq/PerqSwapAndRecyclerAbi.json} +0 -0
  38. /package/dist/abi/{PerqTokenAbi.json → perq/PerqTokenAbi.json} +0 -0
  39. /package/dist/abi/{PerqVestingAbi.json → perq/PerqVestingAbi.json} +0 -0
  40. /package/dist/abi/{TokenRecyclerAbi.json → perq/TokenRecyclerAbi.json} +0 -0
  41. /package/dist/types/{BridgePerq.js → SdkType.js} +0 -0
@@ -1,9 +0,0 @@
1
- import { ContractTransaction, ethers } from 'ethers';
2
- import BasePerqContract from './BasePerqContract';
3
- import PerqSdk from '../PerqSdk';
4
- import { MessagingFee, SendParam } from '../types/BridgePerq';
5
- export default class BridgeMainnetPerqToSonicContract extends BasePerqContract {
6
- constructor(perqSdk: PerqSdk);
7
- send(sendParam: SendParam, fee: MessagingFee, refundAddress: string, overrides?: ethers.PayableOverrides): Promise<ContractTransaction>;
8
- quoteSend(sendParam: SendParam, payInLzToken: boolean): Promise<MessagingFee>;
9
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const ethers_1 = require("ethers");
7
- const BridgeMainnetPerqToSonicAbi_json_1 = __importDefault(require("../abi/BridgeMainnetPerqToSonicAbi.json"));
8
- const BasePerqContract_1 = __importDefault(require("./BasePerqContract"));
9
- class BridgeMainnetPerqToSonicContract extends BasePerqContract_1.default {
10
- constructor(perqSdk) {
11
- super(perqSdk.perqConfig.bridgeMainnetPerqToSonicAddress, new ethers_1.ethers.utils.Interface(BridgeMainnetPerqToSonicAbi_json_1.default), perqSdk.signer);
12
- }
13
- async send(sendParam, fee, refundAddress, overrides) {
14
- if (!this.contract.signer) {
15
- throw Error('No signer provided');
16
- }
17
- // Convert the parameters to the format expected by the contract
18
- const sendParamTuple = [
19
- sendParam.dstEid,
20
- sendParam.to,
21
- sendParam.amountLD,
22
- sendParam.minAmountLD,
23
- sendParam.extraOptions,
24
- sendParam.composeMsg,
25
- sendParam.oftCmd,
26
- ];
27
- const feeTuple = [fee.nativeFee, fee.lzTokenFee];
28
- return await this.contract.send(sendParamTuple, feeTuple, refundAddress, overrides);
29
- }
30
- // Used for getting the fee estimation for the send operation
31
- async quoteSend(sendParam, payInLzToken) {
32
- const sendParamTuple = [
33
- sendParam.dstEid,
34
- sendParam.to,
35
- sendParam.amountLD,
36
- sendParam.minAmountLD,
37
- sendParam.extraOptions,
38
- sendParam.composeMsg,
39
- sendParam.oftCmd,
40
- ];
41
- const result = await this.contract.quoteSend(sendParamTuple, payInLzToken);
42
- return {
43
- nativeFee: result.nativeFee,
44
- lzTokenFee: result.lzTokenFee,
45
- };
46
- }
47
- }
48
- exports.default = BridgeMainnetPerqToSonicContract;
@@ -1,9 +0,0 @@
1
- import { ContractTransaction, ethers } from 'ethers';
2
- import BasePerqContract from './BasePerqContract';
3
- import PerqSdk from '../PerqSdk';
4
- import { MessagingFee, SendParam } from '../types/BridgePerq';
5
- export default class BridgeSonicPerqToMainnetContract extends BasePerqContract {
6
- constructor(perqSdk: PerqSdk);
7
- send(sendParam: SendParam, fee: MessagingFee, refundAddress: string, overrides?: ethers.PayableOverrides): Promise<ContractTransaction>;
8
- quoteSend(sendParam: SendParam, payInLzToken: boolean): Promise<MessagingFee>;
9
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const ethers_1 = require("ethers");
7
- const BridgeSonicPerqToMainnetAbi_json_1 = __importDefault(require("../abi/BridgeSonicPerqToMainnetAbi.json"));
8
- const BasePerqContract_1 = __importDefault(require("./BasePerqContract"));
9
- class BridgeSonicPerqToMainnetContract extends BasePerqContract_1.default {
10
- constructor(perqSdk) {
11
- super(perqSdk.perqConfig.bridgeSonicPerqToMainnetAddress, new ethers_1.ethers.utils.Interface(BridgeSonicPerqToMainnetAbi_json_1.default), perqSdk.signer);
12
- }
13
- async send(sendParam, fee, refundAddress, overrides) {
14
- if (!this.contract.signer) {
15
- throw Error('No signer provided');
16
- }
17
- const sendParamTuple = [
18
- sendParam.dstEid,
19
- sendParam.to,
20
- sendParam.amountLD,
21
- sendParam.minAmountLD,
22
- sendParam.extraOptions,
23
- sendParam.composeMsg,
24
- sendParam.oftCmd,
25
- ];
26
- const feeTuple = [fee.nativeFee, fee.lzTokenFee];
27
- return await this.contract.send(sendParamTuple, feeTuple, refundAddress, overrides);
28
- }
29
- // Used for getting the fee estimation for the send operation
30
- async quoteSend(sendParam, payInLzToken) {
31
- const sendParamTuple = [
32
- sendParam.dstEid,
33
- sendParam.to,
34
- sendParam.amountLD,
35
- sendParam.minAmountLD,
36
- sendParam.extraOptions,
37
- sendParam.composeMsg,
38
- sendParam.oftCmd,
39
- ];
40
- const result = await this.contract.quoteSend(sendParamTuple, payInLzToken);
41
- return {
42
- nativeFee: result.nativeFee,
43
- lzTokenFee: result.lzTokenFee,
44
- };
45
- }
46
- }
47
- exports.default = BridgeSonicPerqToMainnetContract;
@@ -1,36 +0,0 @@
1
- import PerqSdk from '../PerqSdk';
2
- import { BridgeMainnetPerqToSonicContract, BridgeSonicPerqToMainnetContract } from '../contracts';
3
- export interface BridgeQuote {
4
- nativeFee: string;
5
- lzTokenFee: string;
6
- }
7
- export default class BridgePerqPackage {
8
- perqSdk: PerqSdk;
9
- bridgeMainnetPerqToSonicContract: BridgeMainnetPerqToSonicContract;
10
- bridgeSonicPerqToMainnetContract: BridgeSonicPerqToMainnetContract;
11
- constructor(perqSdk: PerqSdk);
12
- /**
13
- * Bridge PERQ tokens from Mainnet to Sonic
14
- */
15
- bridgeMainnetToSonic(amount: string): Promise<string>;
16
- /**
17
- * Bridge PERQ tokens from Sonic to Mainnet
18
- */
19
- bridgeSonicToMainnet(amount: string): Promise<string>;
20
- /**
21
- * Check if the Mainnet to Sonic bridge contract has approval to spend PERQ tokens
22
- */
23
- checkMainnetToSonicBridgeApproval(amount: string): Promise<boolean>;
24
- /**
25
- * Approve the Mainnet to Sonic bridge contract to spend PERQ tokens
26
- */
27
- approveMainnetToSonicBridge(amount: string): Promise<string>;
28
- /**
29
- * Quote the fees for bridging PERQ from Mainnet to Sonic
30
- */
31
- private quoteMainnetToSonic;
32
- /**
33
- * Quote the fees for bridging PERQ from Sonic to Mainnet
34
- */
35
- private quoteSonicToMainnet;
36
- }
@@ -1,207 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ethers_1 = require("ethers");
4
- const utils_1 = require("ethers/lib/utils");
5
- const contracts_1 = require("../contracts");
6
- // Chain IDs for LayerZero
7
- const ENDPOINT_IDS = {
8
- ETHEREUM_MAINNET: 30101,
9
- SONIC_MAINNET: 30332,
10
- };
11
- class BridgePerqPackage {
12
- perqSdk;
13
- bridgeMainnetPerqToSonicContract;
14
- bridgeSonicPerqToMainnetContract;
15
- constructor(perqSdk) {
16
- this.perqSdk = perqSdk;
17
- this.bridgeMainnetPerqToSonicContract = new contracts_1.BridgeMainnetPerqToSonicContract(perqSdk);
18
- this.bridgeSonicPerqToMainnetContract = new contracts_1.BridgeSonicPerqToMainnetContract(perqSdk);
19
- }
20
- /**
21
- * Bridge PERQ tokens from Mainnet to Sonic
22
- */
23
- async bridgeMainnetToSonic(amount) {
24
- try {
25
- if (!this.perqSdk.signer) {
26
- throw new Error('No signer provided');
27
- }
28
- // Get signer address for bridged tokens
29
- const recipientAddress = await this.perqSdk.signer.getAddress();
30
- // Check and handle approval first
31
- const hasApproval = await this.checkMainnetToSonicBridgeApproval(amount);
32
- if (!hasApproval) {
33
- await this.approveMainnetToSonicBridge(amount);
34
- }
35
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
36
- const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
37
- const sendParam = {
38
- dstEid: ENDPOINT_IDS.SONIC_MAINNET,
39
- to: recipientBytes32,
40
- amountLD,
41
- minAmountLD: amountLD, // No slippage for now
42
- extraOptions: '0x',
43
- composeMsg: '0x',
44
- oftCmd: '0x',
45
- };
46
- // Get fee quote first
47
- const feeQuote = await this.quoteMainnetToSonic(amount, recipientAddress, false);
48
- const fee = {
49
- nativeFee: (0, utils_1.parseUnits)(feeQuote.nativeFee, 18),
50
- lzTokenFee: (0, utils_1.parseUnits)(feeQuote.lzTokenFee, 18),
51
- };
52
- // Send the transaction
53
- const tx = await this.bridgeMainnetPerqToSonicContract.send(sendParam, fee, recipientAddress, {
54
- value: fee.nativeFee,
55
- });
56
- const txReceipt = await tx.wait();
57
- return txReceipt.transactionHash;
58
- }
59
- catch (error) {
60
- if (error instanceof Error) {
61
- throw new Error(`Failed to bridge Mainnet to Sonic: ${error.message}`);
62
- }
63
- throw new Error('Failed to bridge Mainnet to Sonic: Unknown error');
64
- }
65
- }
66
- /**
67
- * Bridge PERQ tokens from Sonic to Mainnet
68
- */
69
- async bridgeSonicToMainnet(amount) {
70
- try {
71
- if (!this.perqSdk.signer) {
72
- throw new Error('No signer provided');
73
- }
74
- // Get signer address for bridged tokens
75
- const recipientAddress = await this.perqSdk.signer.getAddress();
76
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
77
- const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
78
- const sendParam = {
79
- dstEid: ENDPOINT_IDS.ETHEREUM_MAINNET,
80
- to: recipientBytes32,
81
- amountLD,
82
- minAmountLD: amountLD, // No slippage for now
83
- extraOptions: '0x',
84
- composeMsg: '0x',
85
- oftCmd: '0x',
86
- };
87
- // Get fee quote first
88
- const feeQuote = await this.quoteSonicToMainnet(amount, recipientAddress, false);
89
- const fee = {
90
- nativeFee: (0, utils_1.parseUnits)(feeQuote.nativeFee, 18),
91
- lzTokenFee: (0, utils_1.parseUnits)(feeQuote.lzTokenFee, 18),
92
- };
93
- const tx = await this.bridgeSonicPerqToMainnetContract.send(sendParam, fee, recipientAddress, {
94
- value: fee.nativeFee,
95
- });
96
- const txReceipt = await tx.wait();
97
- return txReceipt.transactionHash;
98
- }
99
- catch (error) {
100
- if (error instanceof Error) {
101
- throw new Error(`Failed to bridge Sonic to Mainnet: ${error.message}`);
102
- }
103
- throw new Error('Failed to bridge Sonic to Mainnet: Unknown error');
104
- }
105
- }
106
- /**
107
- * Check if the Mainnet to Sonic bridge contract has approval to spend PERQ tokens
108
- */
109
- async checkMainnetToSonicBridgeApproval(amount) {
110
- try {
111
- if (!this.perqSdk.signer) {
112
- throw new Error('No signer provided');
113
- }
114
- const perqTokenContract = new contracts_1.PerqTokenContract(this.perqSdk.perqConfig.perqTokenAddress, this.perqSdk.signer);
115
- const bridgeAddress = this.bridgeMainnetPerqToSonicContract.getContractAddress();
116
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
117
- const allowance = await perqTokenContract.getAllowance(bridgeAddress);
118
- return allowance.gte(amountLD);
119
- }
120
- catch (error) {
121
- if (error instanceof Error) {
122
- throw new Error(`Failed to check Mainnet to Sonic bridge approval: ${error.message}`);
123
- }
124
- throw new Error('Failed to check Mainnet to Sonic bridge approval: Unknown error');
125
- }
126
- }
127
- /**
128
- * Approve the Mainnet to Sonic bridge contract to spend PERQ tokens
129
- */
130
- async approveMainnetToSonicBridge(amount) {
131
- try {
132
- const bridgeAddress = this.bridgeMainnetPerqToSonicContract.getContractAddress();
133
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
134
- const perqTokenContract = new contracts_1.PerqTokenContract(this.perqSdk.perqConfig.perqTokenAddress, this.perqSdk.signer);
135
- const tx = await perqTokenContract.approve(bridgeAddress, amountLD);
136
- const txReceipt = await tx.wait();
137
- return txReceipt.transactionHash;
138
- }
139
- catch (error) {
140
- if (error instanceof Error) {
141
- throw new Error(`Failed to approve Mainnet to Sonic bridge: ${error.message}`);
142
- }
143
- throw new Error('Failed to approve Mainnet to Sonic bridge: Unknown error');
144
- }
145
- }
146
- /**
147
- * Quote the fees for bridging PERQ from Mainnet to Sonic
148
- */
149
- async quoteMainnetToSonic(amount, recipientAddress, payInLzToken = false) {
150
- try {
151
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
152
- const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
153
- const sendParam = {
154
- dstEid: ENDPOINT_IDS.SONIC_MAINNET,
155
- to: recipientBytes32,
156
- amountLD,
157
- minAmountLD: amountLD, // No slippage for now
158
- extraOptions: '0x',
159
- composeMsg: '0x',
160
- oftCmd: '0x',
161
- };
162
- console.log('trying to quoteSend from mainnet to sonic with sendParam:', sendParam, ' and payInLzToken:', payInLzToken);
163
- const fee = await this.bridgeMainnetPerqToSonicContract.quoteSend(sendParam, payInLzToken);
164
- return {
165
- nativeFee: (0, utils_1.formatUnits)(fee.nativeFee, 18),
166
- lzTokenFee: (0, utils_1.formatUnits)(fee.lzTokenFee, 18),
167
- };
168
- }
169
- catch (error) {
170
- if (error instanceof Error) {
171
- throw new Error(`Failed to quote Mainnet to Sonic bridge: ${error.message}`);
172
- }
173
- throw new Error('Failed to quote Mainnet to Sonic bridge: Unknown error');
174
- }
175
- }
176
- /**
177
- * Quote the fees for bridging PERQ from Sonic to Mainnet
178
- */
179
- async quoteSonicToMainnet(amount, recipientAddress, payInLzToken = false) {
180
- try {
181
- const amountLD = (0, utils_1.parseUnits)(amount, 18);
182
- const recipientBytes32 = ethers_1.ethers.utils.hexZeroPad(recipientAddress, 32);
183
- const sendParam = {
184
- dstEid: ENDPOINT_IDS.ETHEREUM_MAINNET,
185
- to: recipientBytes32,
186
- amountLD,
187
- minAmountLD: amountLD, // No slippage for now
188
- extraOptions: '0x',
189
- composeMsg: '0x',
190
- oftCmd: '0x',
191
- };
192
- console.log('trying to quoteSend from sonic to mainnet with sendParam:', sendParam, ' and payInLzToken:', payInLzToken);
193
- const fee = await this.bridgeSonicPerqToMainnetContract.quoteSend(sendParam, payInLzToken);
194
- return {
195
- nativeFee: (0, utils_1.formatUnits)(fee.nativeFee, 18),
196
- lzTokenFee: (0, utils_1.formatUnits)(fee.lzTokenFee, 18),
197
- };
198
- }
199
- catch (error) {
200
- if (error instanceof Error) {
201
- throw new Error(`Failed to quote Sonic to Mainnet bridge: ${error.message}`);
202
- }
203
- throw new Error('Failed to quote Sonic to Mainnet bridge: Unknown error');
204
- }
205
- }
206
- }
207
- exports.default = BridgePerqPackage;
@@ -1,14 +0,0 @@
1
- import { ethers } from 'ethers';
2
- export interface SendParam {
3
- dstEid: number;
4
- to: string;
5
- amountLD: ethers.BigNumber;
6
- minAmountLD: ethers.BigNumber;
7
- extraOptions: string;
8
- composeMsg: string;
9
- oftCmd: string;
10
- }
11
- export interface MessagingFee {
12
- nativeFee: ethers.BigNumber;
13
- lzTokenFee: ethers.BigNumber;
14
- }
File without changes