Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 12.04.2024 #168

Merged
merged 7 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/deploy-production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 'Deploy Production'
concurrency: prod
on:
push:
branches:
- main
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
deploy:
name: Build & Deploy production using SST
environment: production
runs-on: ubuntu-latest
env:
ONE_INCH_API_KEY: ${{ secrets.ONE_INCH_API_KEY }}
ONE_INCH_API_VERSION: ${{ secrets.ONE_INCH_API_VERSION }}
ONE_INCH_API_URL: ${{ secrets.ONE_INCH_API_URL }}
ONE_INCH_ALLOWED_SWAP_PROTOCOLS: ${{ secrets.ONE_INCH_ALLOWED_SWAP_PROTOCOLS }}
ONE_INCH_SWAP_CHAIN_IDS: ${{ secrets.ONE_INCH_SWAP_CHAIN_IDS }}
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
SUBGRAPH_BASE: ${{ secrets.SUBGRAPH_BASE }}
RPC_GATEWAY: ${{ secrets.RPC_GATEWAY }}
DEBANK_API_KEY: ${{ secrets.DEBANK_API_KEY }}
DEBANK_API_URL: ${{ secrets.DEBANK_API_URL }}
POWERTOOLS_LOG_LEVEL: ${{ vars.POWERTOOLS_LOG_LEVEL }}

steps:
- name: Git clone the repository
uses: actions/checkout@v3

- name: Cache turbo build setup
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

- uses: pnpm/action-setup@v2.0.1
with:
version: 8.14.1

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'pnpm'

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Install dependencies
run: pnpm install

- name: Prebuild
run: pnpm prebuild

- name: Build
run: pnpm build

- name: Deploy app
run: |
pnpm run sst:deploy:prod
6 changes: 6 additions & 0 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Prebuild
run: pnpm prebuild

- name: Build
run: pnpm build

- name: Deploy app
run: |
pnpm run sst:deploy:staging
35 changes: 0 additions & 35 deletions .github/workflows/merge-main.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions sdk/sdk-common/src/common/utils/TokenUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { IToken } from '../interfaces/IToken'

export function isSameTokens(a: IToken, b: IToken): boolean {
return a.address === b.address && a.chainInfo.chainId === b.chainInfo.chainId
}
1 change: 1 addition & 0 deletions sdk/sdk-common/src/common/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './PositionUtils'
export * from './PercentageUtils'
export * from './TokenUtils'
22 changes: 21 additions & 1 deletion sdk/sdk-server/src/handlers/getRefinanceSimulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ import type { ISimulation, SimulationType } from '@summerfi/sdk-common/simulatio
import {
refinanceLendingToLendingSamePair,
type IRefinanceDependencies,
refinanceLendingToLendingAnyPair,
} from '@summerfi/simulator-service/strategies'
import type { IRefinanceParameters } from '@summerfi/sdk-common/orders'
import { publicProcedure } from '../TRPC'
import { isSameTokens } from '@summerfi/sdk-common/common'

const inputSchema = z.custom<IRefinanceParameters>((parameters) => parameters !== undefined)

function isToSamePair(parameters: IRefinanceParameters): boolean {
return (
isSameTokens(
parameters.sourcePosition.debtAmount.token,
parameters.targetPosition.debtAmount.token,
) &&
isSameTokens(
parameters.sourcePosition.collateralAmount.token,
parameters.targetPosition.collateralAmount.token,
)
)
}

export const getRefinanceSimulation = publicProcedure
.input(inputSchema)
.query(async (opts): Promise<ISimulation<SimulationType.Refinance>> => {
Expand All @@ -19,5 +34,10 @@ export const getRefinanceSimulation = publicProcedure
protocolManager: opts.ctx.protocolManager,
}

return await refinanceLendingToLendingSamePair(args, dependencies)
// TODO: in the end we should use just any pair
if (isToSamePair(opts.input)) {
return refinanceLendingToLendingSamePair(args, dependencies)
}

return refinanceLendingToLendingAnyPair(args, dependencies)
})
Loading