@strkfarm/sdk 2.0.0-staging.49 → 2.0.0-staging.50
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/index.browser.global.js +18 -1155
- package/dist/index.browser.mjs +18 -1157
- package/dist/index.d.ts +6 -3
- package/dist/index.js +18 -1157
- package/dist/index.mjs +18 -1157
- package/package.json +1 -1
- package/src/strategies/yoloVault.ts +25 -16
- package/src/data/yoloVault.abi.json +0 -1141
package/package.json
CHANGED
|
@@ -31,7 +31,6 @@ import { Web3Number } from "@/dataTypes";
|
|
|
31
31
|
import { DualActionAmount } from "./base-strategy";
|
|
32
32
|
import { PricerBase } from "@/modules/pricerBase";
|
|
33
33
|
import { Call, Contract } from "starknet";
|
|
34
|
-
import YoloVaultAbi from "@/data/yoloVault.abi.json";
|
|
35
34
|
import ERC4626Abi from "@/data/erc4626.abi.json";
|
|
36
35
|
import { Global } from "@/global";
|
|
37
36
|
import { ERC20 } from "@/modules";
|
|
@@ -112,7 +111,8 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
112
111
|
readonly address: ContractAddr;
|
|
113
112
|
readonly metadata: IStrategyMetadata<YoloVaultSettings>;
|
|
114
113
|
readonly pricer: PricerBase;
|
|
115
|
-
|
|
114
|
+
/** Resolves to a `Contract` built from `provider.getClassAt` at the vault address (no checked-in vault ABI). */
|
|
115
|
+
readonly contract: Promise<Contract>;
|
|
116
116
|
readonly primaryToken : TokenInfo;
|
|
117
117
|
readonly secondaryToken : TokenInfo;
|
|
118
118
|
readonly erc4626: YoloErc4626RuntimeConfig;
|
|
@@ -129,11 +129,16 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
129
129
|
this.address = metadata.address;
|
|
130
130
|
this.pricer = pricer;
|
|
131
131
|
this.metadata = metadata;
|
|
132
|
-
this.contract =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
this.contract = this.config.provider
|
|
133
|
+
.getClassAt(this.address.address)
|
|
134
|
+
.then(
|
|
135
|
+
(cls) =>
|
|
136
|
+
new Contract({
|
|
137
|
+
abi: cls.abi,
|
|
138
|
+
address: this.address.address,
|
|
139
|
+
providerOrAccount: this.config.provider,
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
137
142
|
|
|
138
143
|
if (metadata.depositTokens.length < 1) {
|
|
139
144
|
throw new Error("Deposit tokens are not fully defined in metadata");
|
|
@@ -149,13 +154,15 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
149
154
|
};
|
|
150
155
|
}
|
|
151
156
|
|
|
152
|
-
|
|
157
|
+
/** Underlying (or base token) used for pricing / swap sell leg when base is ERC-4626. */
|
|
158
|
+
tokenForPrimaryPricing(): TokenInfo {
|
|
153
159
|
return this.erc4626.isBaseERC4626 && this.erc4626.baseUnderlying
|
|
154
160
|
? this.erc4626.baseUnderlying
|
|
155
161
|
: this.primaryToken;
|
|
156
162
|
}
|
|
157
163
|
|
|
158
|
-
|
|
164
|
+
/** Underlying (or second token) for price ratios when second leg is ERC-4626 (e.g. STRK for xSTRK). */
|
|
165
|
+
tokenForSecondaryPricing(): TokenInfo {
|
|
159
166
|
return this.erc4626.isSecondERC4626 && this.erc4626.secondUnderlying
|
|
160
167
|
? this.erc4626.secondUnderlying
|
|
161
168
|
: this.secondaryToken;
|
|
@@ -203,7 +210,7 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
203
210
|
secondaryTokenBalance: Web3Number;
|
|
204
211
|
claimableSecondaryTokens: Web3Number;
|
|
205
212
|
}> {
|
|
206
|
-
const userInfo = await this.contract.call("get_user_info", [user.address], {
|
|
213
|
+
const userInfo = await (await this.contract).call("get_user_info", [user.address], {
|
|
207
214
|
blockIdentifier,
|
|
208
215
|
});
|
|
209
216
|
const {
|
|
@@ -488,6 +495,7 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
488
495
|
receiver: ContractAddr,
|
|
489
496
|
): Promise<Call[]> {
|
|
490
497
|
try{
|
|
498
|
+
const vault = await this.contract;
|
|
491
499
|
if (this.erc4626.isBaseERC4626) {
|
|
492
500
|
if (!this.erc4626.baseUnderlying) {
|
|
493
501
|
throw new Error("baseUnderlying missing for ERC-4626 base YOLO vault");
|
|
@@ -497,7 +505,7 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
497
505
|
this.address.address,
|
|
498
506
|
amountInfo.amount,
|
|
499
507
|
);
|
|
500
|
-
const depositCall =
|
|
508
|
+
const depositCall = vault.populate("deposit_combined", [
|
|
501
509
|
uint256.bnToUint256(amountInfo.amount.toWei()),
|
|
502
510
|
receiver.address,
|
|
503
511
|
]);
|
|
@@ -505,7 +513,7 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
505
513
|
}
|
|
506
514
|
const primaryToken = amountInfo.tokenInfo;
|
|
507
515
|
const approvalCall = new ERC20(this.config).approve(primaryToken.address.address, this.address.address, amountInfo.amount);
|
|
508
|
-
const depositCall =
|
|
516
|
+
const depositCall = vault.populate("deposit", [
|
|
509
517
|
uint256.bnToUint256(amountInfo.amount.toWei()),
|
|
510
518
|
receiver.address,
|
|
511
519
|
]);
|
|
@@ -517,7 +525,7 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
517
525
|
}
|
|
518
526
|
|
|
519
527
|
async getVaultStatus(): Promise<YoloVaultStatus> {
|
|
520
|
-
const vaultStatus = await this.contract.call("get_vault_status", []);
|
|
528
|
+
const vaultStatus = await (await this.contract).call("get_vault_status", []);
|
|
521
529
|
return vaultStatus as YoloVaultStatus;
|
|
522
530
|
}
|
|
523
531
|
|
|
@@ -596,7 +604,8 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
596
604
|
}
|
|
597
605
|
const requiredShares = userShares.multipliedBy(withdrawRequest.sharesUsedFactor).floor();
|
|
598
606
|
const redeemFn = this.erc4626.isBaseERC4626 ? "redeem_combined" : "redeem";
|
|
599
|
-
|
|
607
|
+
const vault = await this.contract;
|
|
608
|
+
let withdrawCall = vault.populate(redeemFn, [
|
|
600
609
|
uint256.bnToUint256(requiredShares.toString()),
|
|
601
610
|
receiver.address,
|
|
602
611
|
]);
|
|
@@ -612,7 +621,7 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
612
621
|
}
|
|
613
622
|
|
|
614
623
|
async getSwapAmounts(spendUnits: Web3Number): Promise<{ grossSpend: Web3Number; netSpend: Web3Number; isReadyForNextSwap: boolean }> {
|
|
615
|
-
const swapAmounts: any = await this.contract.call("get_swap_amounts", [spendUnits.toUint256()]);
|
|
624
|
+
const swapAmounts: any = await (await this.contract).call("get_swap_amounts", [spendUnits.toUint256()]);
|
|
616
625
|
console.log("swapAmounts", swapAmounts);
|
|
617
626
|
return {
|
|
618
627
|
grossSpend: Web3Number.fromWei(swapAmounts[0].toString(), this.primaryToken.decimals),
|
|
@@ -622,7 +631,7 @@ export class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, D
|
|
|
622
631
|
}
|
|
623
632
|
|
|
624
633
|
getSettings = async (): Promise<YoloSettings> => {
|
|
625
|
-
const settings = await this.contract.call("get_settings", []);
|
|
634
|
+
const settings = await (await this.contract).call("get_settings", []);
|
|
626
635
|
return settings as YoloSettings;
|
|
627
636
|
};
|
|
628
637
|
|