Skip to content

Commit

Permalink
fix(resolve rabbit comments): comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilbe27 committed Nov 30, 2023
1 parent 5690d98 commit 69ccefa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/nibijs/docs/classes/StableSwap.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ y()
Calculate x[j] if one makes x[i] = x

Done by solving quadratic equation iteratively.
x*1\*\*2 + x1 * (sum' - (A*n\*\*n - 1) * D / (A _ n**n)) = D ** (n+1)/(n \*\* (2 _ n) \_ prod' \* A)
x*1\*\*2 + x1 * (sum' - (A*n\*\*n - 1) * D / (A _ n**n)) = D ** (n+1)/(n \*\* (2 _ n) _ prod' _ A)
x_1\*\*2 + b\*x_1 = c

x_1 = (x_1\**2 + c) / (2*x_1 + b)
Expand Down
23 changes: 11 additions & 12 deletions packages/nibijs/src/query/perp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ export interface PerpExtension {
}>
}

const transformPositions = (
resp: QueryPositionsResponse
): QueryPositionsResponse => {
const { positions } = resp
resp.positions = positions.map((position: QueryPositionResponse) =>
transformPosition(position)
)
return resp
}

export function setupPerpExtension(base: QueryClient): PerpExtension {
const rpcClient = createProtobufRpcClient(base)
const queryService = new QueryClientImpl(rpcClient)
Expand All @@ -52,22 +62,11 @@ export function setupPerpExtension(base: QueryClient): PerpExtension {
const req = QueryPositionsRequest.fromPartial(args)
const resp = await queryService.QueryPositions(req)

function transformPositions(
resp: QueryPositionsResponse
): QueryPositionsResponse {
const { positions } = resp
resp.positions = positions.map((position: QueryPositionResponse) =>
transformPosition(position)
)
return resp
}

return transformPositions(resp)
},
markets: async () => {
const req = QueryMarketsRequest.fromPartial({})
const resp = queryService.QueryMarkets(req)
return resp
return queryService.QueryMarkets(req)
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions packages/nibijs/src/test/query.tests/perp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ describe("setupPerpExtension", () => {
trader: "Test Trader",
})
expect(result).toEqual({
positionNotional: "1e-16",
unrealizedPnl: "5e-17",
marginRatio: "5e-18",
positionNotional: "100",
unrealizedPnl: "50",
marginRatio: "5",
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/nibijs/src/tx/signingClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe("nibid tx perp", () => {
expect(txLogs).toHaveLength(1)

// perp tx close-position events
assertHasMsgType("MsgClosePosition", txLogs[0].events)
assertHasMsgType(PERP_MSG_TYPE_URLS.MsgClosePosition, txLogs[0].events)
assertHasEventType(
"nibiru.perp.v1.PositionChangedEvent",
txLogs[0].events
Expand Down

0 comments on commit 69ccefa

Please sign in to comment.