Skip to content

Commit 51c7ea4

Browse files
committed
feat: add router, modify pool info data model
1 parent 87b8f79 commit 51c7ea4

12 files changed

Lines changed: 2353 additions & 23 deletions

File tree

‎docs/queries/swap.md‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,16 @@ type PairInfo = {
327327
isStable: boolean,
328328
token0Amount: string,
329329
token1Amount: string,
330-
priceRatio: string | null,
331330
pairSettings: {
332331
lpFee: number,
333332
daoFee: number,
334-
stableLpFee: number,
335-
stableDaoFee: number,
336333
stableParams: StableParams | null
337334
},
338335
contractVersion: number,
339336
}
340337
341338
type StableParams = {
339+
priceRatio: string,
342340
alpha: string,
343341
gamma1: string,
344342
gamma2: string,
@@ -413,7 +411,6 @@ console.log(output)
413411
"token0Amount": "4268251730565",
414412
"token1Amount": "365239579269",
415413
"lpTokenAmount": "487393298891",
416-
"priceRatio": null,
417414
"pairSettings": {
418415
"lpFee": 0.0029,
419416
"daoFee": 0.0001,
@@ -448,7 +445,6 @@ console.log(output)
448445
"token0Amount": "95199329571",
449446
"token1Amount": "377657768",
450447
"lpTokenAmount": "5708789507",
451-
"priceRatio": null,
452448
"pairSettings": {
453449
"lpFee": 0.0029,
454450
"daoFee": 0.0001,

‎src/contracts/services/swap.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,13 @@ function parsePairInfo(
187187
token0Amount: pairInfo.amount_0,
188188
token1Amount: pairInfo.amount_1,
189189
lpTokenAmount: pairInfo.total_liquidity,
190-
priceRatio: stableInfo ? stableInfo.p : null,
191190
pairSettings: {
192-
lpFee: fees.lp_fee.nom / fees.lp_fee.denom,
193-
daoFee: fees.shade_dao_fee.nom / fees.shade_dao_fee.denom,
194-
stableLpFee: fees.stable_lp_fee.nom / fees.stable_lp_fee.denom,
195-
stableDaoFee: fees.stable_shade_dao_fee.nom / fees.stable_shade_dao_fee.denom,
196-
191+
lpFee: pairInfo.pair[2] ? fees.stable_lp_fee.nom / fees.stable_lp_fee.denom
192+
: fees.lp_fee.nom / fees.lp_fee.denom,
193+
daoFee: pairInfo.pair[2] ? fees.stable_shade_dao_fee.nom / fees.stable_shade_dao_fee.denom
194+
: fees.shade_dao_fee.nom / fees.shade_dao_fee.denom,
197195
stableParams: stableInfo ? {
196+
priceRatio: stableInfo.p!, // if stable params exist, we know price ratio will be available
198197
alpha: stableInfo.stable_params.a,
199198
gamma1: stableInfo.stable_params.gamma1,
200199
gamma2: stableInfo.stable_params.gamma2,

0 commit comments

Comments
 (0)