@strkfarm/sdk 1.0.63 → 1.1.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.
@@ -113,17 +113,17 @@ export class EkuboCLVault extends BaseStrategy<
113
113
  this.metadata = metadata;
114
114
  this.address = metadata.address;
115
115
 
116
- this.contract = new Contract(
117
- CLVaultAbi,
118
- this.address.address,
119
- this.config.provider
120
- );
116
+ this.contract = new Contract({
117
+ abi: CLVaultAbi,
118
+ address: this.address.address,
119
+ providerOrAccount: this.config.provider
120
+ });
121
121
  if (this.metadata.additionalInfo.lstContract) {
122
- this.lstContract = new Contract(
123
- ERC4626Abi,
124
- this.metadata.additionalInfo.lstContract.address,
125
- this.config.provider
126
- );
122
+ this.lstContract = new Contract({
123
+ abi: ERC4626Abi,
124
+ address: this.metadata.additionalInfo.lstContract.address,
125
+ providerOrAccount: this.config.provider
126
+ });
127
127
  } else {
128
128
  this.lstContract = null;
129
129
  }
@@ -131,18 +131,18 @@ export class EkuboCLVault extends BaseStrategy<
131
131
  // ekubo positions contract
132
132
  const EKUBO_POSITION =
133
133
  "0x02e0af29598b407c8716b17f6d2795eca1b471413fa03fb145a5e33722184067";
134
- this.ekuboPositionsContract = new Contract(
135
- EkuboPositionsAbi,
136
- EKUBO_POSITION,
137
- this.config.provider
138
- );
134
+ this.ekuboPositionsContract = new Contract({
135
+ abi: EkuboPositionsAbi,
136
+ address: EKUBO_POSITION,
137
+ providerOrAccount: this.config.provider
138
+ });
139
139
  const EKUBO_MATH =
140
140
  "0x04a72e9e166f6c0e9d800af4dc40f6b6fb4404b735d3f528d9250808b2481995";
141
- this.ekuboMathContract = new Contract(
142
- EkuboMathAbi,
143
- EKUBO_MATH,
144
- this.config.provider
145
- );
141
+ this.ekuboMathContract = new Contract({
142
+ abi: EkuboMathAbi,
143
+ address: EKUBO_MATH,
144
+ providerOrAccount: this.config.provider
145
+ });
146
146
 
147
147
  this.avnu = new AvnuWrapper();
148
148
  }
@@ -207,16 +207,16 @@ export class EkuboCLVault extends BaseStrategy<
207
207
  const updateAmountInfo = await this.getMinDepositAmounts(amountInfo);
208
208
  // Technically its not erc4626 abi, but we just need approve call
209
209
  // so, its ok to use it
210
- const token0Contract = new Contract(
211
- ERC4626Abi,
212
- amountInfo.token0.tokenInfo.address.address,
213
- this.config.provider
214
- );
215
- const token1Contract = new Contract(
216
- ERC4626Abi,
217
- amountInfo.token1.tokenInfo.address.address,
218
- this.config.provider
219
- );
210
+ const token0Contract = new Contract({
211
+ abi: ERC4626Abi,
212
+ address: amountInfo.token0.tokenInfo.address.address,
213
+ providerOrAccount: this.config.provider
214
+ });
215
+ const token1Contract = new Contract({
216
+ abi: ERC4626Abi,
217
+ address: amountInfo.token1.tokenInfo.address.address,
218
+ providerOrAccount: this.config.provider
219
+ });
220
220
  const call1 = token0Contract.populate("approve", [
221
221
  this.address.address,
222
222
  uint256.bnToUint256(updateAmountInfo.token0.amount.toWei()),
@@ -286,7 +286,7 @@ export class EkuboCLVault extends BaseStrategy<
286
286
  * @returns {Promise<number>} The weighted average APY across all pools
287
287
  */
288
288
  async netAPY(
289
- blockIdentifier: BlockIdentifier = "pending",
289
+ blockIdentifier: BlockIdentifier = "latest",
290
290
  sinceBlocks = 20000
291
291
  ): Promise<number> {
292
292
  // no special provisions required to account for defi spring rewards
@@ -376,7 +376,7 @@ export class EkuboCLVault extends BaseStrategy<
376
376
 
377
377
  async balanceOf(
378
378
  user: ContractAddr,
379
- blockIdentifier: BlockIdentifier = "pending"
379
+ blockIdentifier: BlockIdentifier = "latest"
380
380
  ): Promise<Web3Number> {
381
381
  let bal = await this.contract.call("balance_of", [user.address], {
382
382
  blockIdentifier,
@@ -386,7 +386,7 @@ export class EkuboCLVault extends BaseStrategy<
386
386
 
387
387
  async getUserTVL(
388
388
  user: ContractAddr,
389
- blockIdentifier: BlockIdentifier = "pending"
389
+ blockIdentifier: BlockIdentifier = "latest"
390
390
  ): Promise<DualTokenInfo> {
391
391
  let bal = await this.balanceOf(user, blockIdentifier);
392
392
  const assets: any = await this.contract.call(
@@ -428,7 +428,7 @@ export class EkuboCLVault extends BaseStrategy<
428
428
  };
429
429
  }
430
430
 
431
- async _getTVL(blockIdentifier: BlockIdentifier = "pending") {
431
+ async _getTVL(blockIdentifier: BlockIdentifier = "latest") {
432
432
  const result = await this.contract.call("total_liquidity", [], {
433
433
  blockIdentifier,
434
434
  });
@@ -443,7 +443,7 @@ export class EkuboCLVault extends BaseStrategy<
443
443
  }
444
444
 
445
445
  async totalSupply(
446
- blockIdentifier: BlockIdentifier = "pending"
446
+ blockIdentifier: BlockIdentifier = "latest"
447
447
  ): Promise<Web3Number> {
448
448
  const res = await this.contract.call("total_supply", [], {
449
449
  blockIdentifier,
@@ -464,7 +464,7 @@ export class EkuboCLVault extends BaseStrategy<
464
464
  }
465
465
 
466
466
  async getTVL(
467
- blockIdentifier: BlockIdentifier = "pending"
467
+ blockIdentifier: BlockIdentifier = "latest"
468
468
  ): Promise<DualTokenInfo> {
469
469
  const { amount0, amount1 } = await this._getTVL(blockIdentifier);
470
470
  const poolKey = await this.getPoolKey(blockIdentifier);
@@ -561,14 +561,14 @@ export class EkuboCLVault extends BaseStrategy<
561
561
  throw new Error("No true price available");
562
562
  }
563
563
 
564
- async getCurrentPrice(blockIdentifier: BlockIdentifier = "pending") {
564
+ async getCurrentPrice(blockIdentifier: BlockIdentifier = "latest") {
565
565
  const poolKey = await this.getPoolKey(blockIdentifier);
566
566
  return this._getCurrentPrice(poolKey, blockIdentifier);
567
567
  }
568
568
 
569
569
  async _getCurrentPrice(
570
570
  poolKey: EkuboPoolKey,
571
- blockIdentifier: BlockIdentifier = "pending"
571
+ blockIdentifier: BlockIdentifier = "latest"
572
572
  ) {
573
573
  const priceInfo: any = await this.ekuboPositionsContract.call(
574
574
  "get_pool_price",
@@ -606,7 +606,7 @@ export class EkuboCLVault extends BaseStrategy<
606
606
  }
607
607
 
608
608
  async getCurrentBounds(
609
- blockIdentifier: BlockIdentifier = "pending"
609
+ blockIdentifier: BlockIdentifier = "latest"
610
610
  ): Promise<EkuboBounds> {
611
611
  const result: any = await this.contract.call("get_position_key", [], {
612
612
  blockIdentifier,
@@ -632,7 +632,7 @@ export class EkuboCLVault extends BaseStrategy<
632
632
  }
633
633
 
634
634
  async getPoolKey(
635
- blockIdentifier: BlockIdentifier = "pending"
635
+ blockIdentifier: BlockIdentifier = "latest"
636
636
  ): Promise<EkuboPoolKey> {
637
637
  if (this.poolKey) {
638
638
  return this.poolKey;
@@ -1345,7 +1345,7 @@ export class EkuboCLVault extends BaseStrategy<
1345
1345
  async getLiquidityToAmounts(
1346
1346
  liquidity: Web3Number,
1347
1347
  bounds: EkuboBounds,
1348
- blockIdentifier: BlockIdentifier = "pending",
1348
+ blockIdentifier: BlockIdentifier = "latest",
1349
1349
  _poolKey: EkuboPoolKey | null = null,
1350
1350
  _currentPrice: {
1351
1351
  price: number;
@@ -30,7 +30,7 @@ export class SenseiVault extends BaseStrategy<
30
30
  this.address = metadata.address;
31
31
  this.pricer = pricer;
32
32
  this.metadata = metadata;
33
- this.contract = new Contract(SenseiABI, this.address.address, this.config.provider);
33
+ this.contract = new Contract({abi: SenseiABI, address: this.address.address, providerOrAccount: this.config.provider});
34
34
 
35
35
  if (metadata.depositTokens.length === 0) {
36
36
  throw new Error("Deposit tokens are not defined in metadata");
@@ -90,11 +90,11 @@ export class SenseiVault extends BaseStrategy<
90
90
  }
91
91
 
92
92
  async depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]> {
93
- const mainTokenContract = new Contract(
94
- ERC20ABI,
95
- this.metadata.depositTokens[0].address.address,
96
- this.config.provider,
97
- );
93
+ const mainTokenContract = new Contract({
94
+ abi: ERC20ABI,
95
+ address: this.metadata.depositTokens[0].address.address,
96
+ providerOrAccount: this.config.provider,
97
+ });
98
98
  const call1 = mainTokenContract.populate('approve', [
99
99
  this.address.address,
100
100
  uint256.bnToUint256(amountInfo.amount.toWei()),
@@ -139,7 +139,7 @@ export class VesuAdapter extends BaseAdapter {
139
139
  }
140
140
  };
141
141
  logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`)
142
- const singletonContract = new Contract(VesuSingletonAbi, this.VESU_SINGLETON.toString(), new RpcProvider({nodeUrl: ''}));
142
+ const singletonContract = new Contract({abi: VesuSingletonAbi, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider({nodeUrl: ''})});
143
143
  const call = singletonContract.populate('modify_position', {
144
144
  params: {
145
145
  pool_id: this.config.poolId.toBigInt(),
@@ -217,7 +217,7 @@ export class VesuAdapter extends BaseAdapter {
217
217
  }
218
218
 
219
219
  getVesuSingletonContract(config: IConfig) {
220
- return new Contract(VesuSingletonAbi, this.VESU_SINGLETON.address, config.provider);
220
+ return new Contract({abi: VesuSingletonAbi, address: this.VESU_SINGLETON.address, providerOrAccount: config.provider});
221
221
  }
222
222
 
223
223
  async getLTVConfig(config: IConfig) {
@@ -63,16 +63,16 @@ export class UniversalStrategy<
63
63
  this.metadata = metadata;
64
64
  this.address = metadata.address;
65
65
 
66
- this.contract = new Contract(
67
- UniversalVaultAbi,
68
- this.address.address,
69
- this.config.provider
70
- );
71
- this.managerContract = new Contract(
72
- ManagerAbi,
73
- this.metadata.additionalInfo.manager.address,
74
- this.config.provider
75
- );
66
+ this.contract = new Contract({
67
+ abi: UniversalVaultAbi,
68
+ address: this.address.address,
69
+ providerOrAccount: this.config.provider
70
+ });
71
+ this.managerContract = new Contract({
72
+ abi: ManagerAbi,
73
+ address: this.metadata.additionalInfo.manager.address,
74
+ providerOrAccount: this.config.provider
75
+ });
76
76
  }
77
77
 
78
78
  getMerkleTree() {
@@ -132,11 +132,11 @@ export class UniversalStrategy<
132
132
  amountInfo.tokenInfo.address.eq(this.asset().address),
133
133
  "Deposit token mismatch"
134
134
  );
135
- const assetContract = new Contract(
136
- UniversalVaultAbi,
137
- this.asset().address.address,
138
- this.config.provider
139
- );
135
+ const assetContract = new Contract({
136
+ abi: UniversalVaultAbi,
137
+ address: this.asset().address.address,
138
+ providerOrAccount: this.config.provider
139
+ });
140
140
  const call1 = assetContract.populate("approve", [
141
141
  this.address.address,
142
142
  uint256.bnToUint256(amountInfo.amount.toWei())
@@ -103,11 +103,11 @@ export class VesuRebalance extends BaseStrategy<
103
103
  this.metadata = metadata;
104
104
  this.address = metadata.address;
105
105
 
106
- this.contract = new Contract(
107
- VesuRebalanceAbi,
108
- this.address.address,
109
- this.config.provider
110
- );
106
+ this.contract = new Contract({
107
+ abi: VesuRebalanceAbi,
108
+ address: this.address.address,
109
+ providerOrAccount: this.config.provider
110
+ });
111
111
  }
112
112
 
113
113
  /**
@@ -123,11 +123,11 @@ export class VesuRebalance extends BaseStrategy<
123
123
  amountInfo.tokenInfo.address.eq(this.asset().address),
124
124
  "Deposit token mismatch"
125
125
  );
126
- const assetContract = new Contract(
127
- VesuRebalanceAbi,
128
- this.asset().address.address,
129
- this.config.provider
130
- );
126
+ const assetContract = new Contract({
127
+ abi: VesuRebalanceAbi,
128
+ address: this.asset().address.address,
129
+ providerOrAccount: this.config.provider
130
+ });
131
131
  const call1 = assetContract.populate("approve", [
132
132
  this.address.address,
133
133
  uint256.bnToUint256(amountInfo.amount.toWei())
@@ -284,11 +284,11 @@ export class VesuRebalance extends BaseStrategy<
284
284
  `Asset ${this.asset().address.toString()} not found in pool ${p.pool_id.address.toString()}`
285
285
  );
286
286
  }
287
- let vTokenContract = new Contract(
288
- VesuRebalanceAbi,
289
- p.v_token.address,
290
- this.config.provider
291
- );
287
+ let vTokenContract = new Contract({
288
+ abi: VesuRebalanceAbi,
289
+ address: p.v_token.address,
290
+ providerOrAccount: this.config.provider
291
+ });
292
292
  const bal = await vTokenContract.balanceOf(this.address.address);
293
293
  const assets = await vTokenContract.convert_to_assets(
294
294
  uint256.bnToUint256(bal.toString())
@@ -96,7 +96,7 @@ export class Store {
96
96
  logger.warn(`⚠️=========================================⚠️`);
97
97
  }
98
98
 
99
- getAccount(accountKey: string, txVersion: "0x2" | "0x3" = constants.TRANSACTION_VERSION.V2) {
99
+ getAccount(accountKey: string, txVersion: undefined | "0x3") {
100
100
  const accounts = this.loadAccounts();
101
101
  logger.verbose(`nAccounts loaded for network: ${Object.keys(accounts).length}`);
102
102
  const data = accounts[accountKey];
@@ -105,7 +105,14 @@ export class Store {
105
105
  }
106
106
  logger.verbose(`Account loaded: ${accountKey} from network: ${this.config.network}`);
107
107
  logger.verbose(`Address: ${data.address}`);
108
- const acc = new Account(<any>this.config.provider, data.address, data.pk, undefined, txVersion);
108
+
109
+ const acc = new Account({
110
+ provider: <any>this.config.provider,
111
+ address: data.address,
112
+ signer: data.pk,
113
+ cairoVersion: undefined,
114
+ transactionVersion: txVersion
115
+ });
109
116
  return acc;
110
117
  }
111
118