Skip to content

Commit

Permalink
Merge pull request #987 from oraichain/feat/update-apr-calculation
Browse files Browse the repository at this point in the history
update apr & zapper
  • Loading branch information
vuonghuuhung authored Oct 3, 2024
2 parents 01e4807 + e356cb4 commit 69e0bd4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@oraichain/common-contracts-build": "1.0.35",
"@oraichain/cw-simulate": "^2.8.75",
"@oraichain/oraidex-contracts-build": "1.0.22",
"@oraichain/oraiswap-v3": "0.1.19",
"@oraichain/oraiswap-v3": "0.1.20-beta.2",
"@sentry/webpack-plugin": "^2.10.3",
"@types/classnames": "^2.2.10",
"@types/jest": "^29.5.10",
Expand Down
6 changes: 3 additions & 3 deletions src/libs/contractSingleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ export function simulateAprPosition(
BigInt(positionLiquidity),
false,
pool.current_tick_index + tick_spacing,
pool.current_tick_index - tick_spacing ? pool.current_tick_index - tick_spacing : 0
pool.current_tick_index ? pool.current_tick_index : 0
);

const tokenX = oraichainTokens.find((token) => extractAddress(token) === poolKey.token_x);
Expand Down Expand Up @@ -821,8 +821,8 @@ export function simulateAprPosition(
BigInt(pool.sqrt_price),
BigInt(positionLiquidity2),
false,
pool.current_tick_index + tick_spacing * 20,
pool.current_tick_index - tick_spacing * 20 ? pool.current_tick_index - tick_spacing * 20 : 0
getMaxTick(tick_spacing),
getMinTick(tick_spacing)
);

const positionLiquidityUsdX2 = ((prices[tokenX.coinGeckoId] ?? 0) * Number(res2.x)) / 10 ** tokenX.decimals;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Pool-V3/components/CreatePositionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ const CreatePositionForm: FC<CreatePoolFormProps> = ({
const upperTick = Math.max(leftRange, rightRange);

const result = await zapper.processZapInPositionLiquidity({
pool: poolData,
poolKey: poolData.pool_key,
tokenIn: tokenZap,
amountIn: amountIn,
lowerTick,
Expand Down
8 changes: 3 additions & 5 deletions src/pages/Pool-V3/components/ZapOutForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ const ZapOutForm: FC<ZapOutFormProps> = ({
client = await CosmWasmClient.connect(network.rpc);
const zap = new ZapperQueryClient(client, ZAPPER_CONTRACT);
zapFee = Number((await zap.protocolFee()).percent);
} catch (error) {
console.error('Error handleSimulateZapOut fee:', error);
}
} catch (error) {}

try {
const zapper = new ZapConsumer({
Expand Down Expand Up @@ -260,7 +258,7 @@ const ZapOutForm: FC<ZapOutFormProps> = ({
const priceImpact = (Math.abs(inputUsd - outputUsd) / inputUsd) * 100;

const totalAmountOut =
Number(res.amountToX) / 10 ** tokenFrom.decimals + Number(res.amountToY) / 10 ** tokenTo.decimals;
Number(res.amountToX) / 10 ** tokenZap.decimals + Number(res.amountToY) / 10 ** tokenZap.decimals;

const zapFeeX = Number(position.tokenXLiq) * zapFee;
const zapFeeY = Number(position.tokenYLiq) * zapFee;
Expand All @@ -276,7 +274,7 @@ const ZapOutForm: FC<ZapOutFormProps> = ({
setZapFeeY(zapFeeY);
setSwapFee(swapFee);
setZapOutResponse(res);
setAmountFrom(Number(res.amountToX) / 10 ** tokenFrom.decimals + Number(res.amountToY) / 10 ** tokenTo.decimals);
setAmountFrom(Number(res.amountToX) / 10 ** tokenZap.decimals + Number(res.amountToY) / 10 ** tokenZap.decimals);
setSimulating(false);
} catch (error) {
// console.error(error);
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4406,16 +4406,16 @@
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.51-beta.3.tgz#cb7c369081bcb036cc78d91a35a51ff4fb2b42d0"
integrity sha512-r1g0Ikzi21TAVIrB4I3MVF6rVTPdSHeBiQnwZTZuv0tw/muciuZHsiGSF5O2M5rcyMVHWjck9cQ3VVbAN+gFLg==

"@oraichain/oraidex-contracts-sdk@1.0.53-beta.2":
version "1.0.53-beta.2"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.53-beta.2.tgz#67e70c81e86f6b3efe8c77a291844a20c8768413"
integrity sha512-qOJZWkYx8mTWKdkqpjaV2GowLHBq6z/+v7jP1UTx1c1Vz6MchnePFLgKS115oSkC5VjD5N1Zl9kv9le9g28a8g==

"@oraichain/oraidex-contracts-sdk@^1.0.49":
version "1.0.49"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.49.tgz#093221564552e92901c73f6043ce4dc72208d857"
integrity sha512-J15JR0+wueYMLMFjz/Omg5ADSKOmmTvsBstVf76NQjrvYpekzdlIGvoTIUCGjyf+DOdzu8MevOk5HDAnOrj3Fw==

"@oraichain/oraidex-contracts-sdk@^1.0.52":
version "1.0.52"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.52.tgz#a53cf66ec2bd79f1c881d14a8b3b71ea2db4413a"
integrity sha512-qvhSSMMB59QAbgbAbgSMTfD5BtaVk2jUisjwrh+F2TY13JAH5KZq2CIHNTQ+OywfvsW2QTk4oynv/K1mSmUvaQ==

"@oraichain/oraidex-contracts-sdk@latest":
version "1.0.45"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.45.tgz#42dae0fdd9e005f920ba305b987009f791acc365"
Expand All @@ -4434,14 +4434,14 @@
tronweb "5.3.2"
ts-protoc-gen "^0.15.0"

"@oraichain/oraiswap-v3@0.1.19":
version "0.1.19"
resolved "https://registry.yarnpkg.com/@oraichain/oraiswap-v3/-/oraiswap-v3-0.1.19.tgz#2e23236d0fa7a56c32c1f2d05278de3c3780b278"
integrity sha512-wLdGtzEl9WpxdHZwqiFGH/R5ULAYQlCyk/o6Wjbr7be5+c/efmgCQ/AQ+2klWNVF0K2DP9BkJInXedhlgFcCBg==
"@oraichain/oraiswap-v3@0.1.20-beta.2":
version "0.1.20-beta.2"
resolved "https://registry.yarnpkg.com/@oraichain/oraiswap-v3/-/oraiswap-v3-0.1.20-beta.2.tgz#a5721f961b77ab8d0b69285d096e1d5c6b04ea14"
integrity sha512-BCW/P/BWrKo52C1kQLpoTevVAcAAccVOvQg/QQYImMc+XexGyiwlK7O4P/f+EWxb7rJYCJqJ9vwzunCsIgWaow==
dependencies:
"@cosmjs/cosmwasm-stargate" "^0.31.0"
"@oraichain/oraidex-common" "^1.1.21"
"@oraichain/oraidex-contracts-sdk" "^1.0.52"
"@oraichain/oraidex-contracts-sdk" "1.0.53-beta.2"

"@oraichain/wasm-json-toolkit@^1.0.24":
version "1.0.24"
Expand Down

0 comments on commit 69e0bd4

Please sign in to comment.