Skip to content

Commit

Permalink
Merge pull request #432 from curvefi/fix/fix-withdraw-lite
Browse files Browse the repository at this point in the history
fix: fixed withdraw for litechains
  • Loading branch information
fedorovdg authored Dec 12, 2024
2 parents d46b308 + 6314958 commit 6832929
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@curvefi/api",
"version": "2.65.20",
"version": "2.65.21",
"description": "JavaScript library for curve.fi",
"main": "lib/index.js",
"author": "Macket",
Expand Down
39 changes: 36 additions & 3 deletions src/pools/PoolTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1374,9 +1374,25 @@ export class PoolTemplate extends CorePool {

public async withdrawImbalanceBonus(amounts: (number | string)[]): Promise<string> {
let pricesBN: BigNumber[] = [];

const multicallContract = curve.contracts[this.address].multicallContract;
if(this.isCrypto || this.id === 'wsteth') {
pricesBN = (await this._underlyingPrices()).map(BN);
if(curve.isLiteChain) {
const prices = this.id.includes('twocrypto')
? [
1,
Number(await curve.contracts[this.address].contract.price_oracle()) / (10 ** 18),
]
: [
1,
...(await curve.multicallProvider.all([
multicallContract.price_oracle(0),
multicallContract.price_oracle(1),
])).map((value) => Number(value) / (10 ** 18)),
]
pricesBN = prices.map(BN);
} else {
pricesBN = (await this._underlyingPrices()).map(BN);
}
} else {
pricesBN = await this._storedRatesBN(true);
}
Expand Down Expand Up @@ -1484,8 +1500,25 @@ export class PoolTemplate extends CorePool {
public async withdrawOneCoinBonus(lpTokenAmount: number | string, coin: string | number): Promise<string> {
let pricesBN: BigNumber[] = [];

const multicallContract = curve.contracts[this.address].multicallContract;
if(this.isCrypto || this.id === 'wsteth') {
pricesBN = (await this._underlyingPrices()).map(BN);
if(curve.isLiteChain) {
const prices = this.id.includes('twocrypto')
? [
1,
Number(await curve.contracts[this.address].contract.price_oracle()) / (10 ** 18),
]
: [
1,
...(await curve.multicallProvider.all([
multicallContract.price_oracle(0),
multicallContract.price_oracle(1),
])).map((value) => Number(value) / (10 ** 18)),
]
pricesBN = prices.map(BN);
} else {
pricesBN = (await this._underlyingPrices()).map(BN);
}
} else {
pricesBN = await this._storedRatesBN(true);
}
Expand Down

0 comments on commit 6832929

Please sign in to comment.