Skip to content

Commit

Permalink
feat: return oracle config in list drip config endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
sol-mocha committed Dec 12, 2022
1 parent 99ba1f1 commit be8e328
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 73 deletions.
3 changes: 3 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,9 @@ components:
tokenBMint:
type: string
example: "5r23oKMycxnnjAJ4cEEkh1bbCowcZwzL6HYmhLqRazQa"
oracleConfig:
type: string
example: "5r23oKMycxnnjAJ4cEEkh1bbCowcZwzL6HYmhLqRazQa"

splTokenSwapConfig:
type: object
Expand Down
143 changes: 72 additions & 71 deletions pkg/api/apispec/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/api/routes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func vaultTokenSwapToAPI(vault *model.Vault, tokenSwap *model.TokenSwap) apispec
VaultProtoConfig: vault.ProtoConfig,
VaultTokenAAccount: vault.TokenAAccount,
VaultTokenBAccount: vault.TokenBAccount,
OracleConfig: vault.OracleConfig,
},
}
}
Expand All @@ -196,6 +197,7 @@ func vaultWhirlpoolToAPI(vault *model.Vault, orcaWhirlpool *model.OrcaWhirlpool)
VaultProtoConfig: vault.ProtoConfig,
VaultTokenAAccount: vault.TokenAAccount,
VaultTokenBAccount: vault.TokenBAccount,
OracleConfig: vault.OracleConfig,
},
}
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/api/routes/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ func TestUtils(t *testing.T) {
MaxSlippageBps: 50,
TokenAMint: solana.NewWallet().PublicKey().String(),
TokenBMint: solana.NewWallet().PublicKey().String(),
OracleConfig: utils.GetStringPtr(solana.NewWallet().PublicKey().String()),
}
tokenSwap := model.TokenSwap{
Pubkey: solana.NewWallet().PublicKey().String(),
Expand Down Expand Up @@ -293,8 +294,9 @@ func TestUtils(t *testing.T) {
assert.Equal(t, vault.ProtoConfig, apiModel.VaultProtoConfig)
assert.Equal(t, vault.TokenAAccount, apiModel.DripCommon.VaultTokenAAccount)
assert.Equal(t, vault.TokenBAccount, apiModel.DripCommon.VaultTokenBAccount)
assert.Equal(t, *vault.OracleConfig, *apiModel.OracleConfig)
// if the line below needs to be updated, add the field assertion above
assert.Equal(t, reflect.TypeOf(apiModel.DripCommon).NumField(), 6)
assert.Equal(t, reflect.TypeOf(apiModel.DripCommon).NumField(), 7)
})

t.Run("vaultWhirlpoolToAPI should return correct apiSpec model", func(t *testing.T) {
Expand All @@ -312,6 +314,7 @@ func TestUtils(t *testing.T) {
MaxSlippageBps: 50,
TokenAMint: solana.NewWallet().PublicKey().String(),
TokenBMint: solana.NewWallet().PublicKey().String(),
OracleConfig: utils.GetStringPtr(solana.NewWallet().PublicKey().String()),
}
orcaWhirlpool := model.OrcaWhirlpool{
Pubkey: solana.NewWallet().PublicKey().String(),
Expand Down Expand Up @@ -350,8 +353,9 @@ func TestUtils(t *testing.T) {
assert.Equal(t, vault.ProtoConfig, apiModel.VaultProtoConfig)
assert.Equal(t, vault.TokenAAccount, apiModel.DripCommon.VaultTokenAAccount)
assert.Equal(t, vault.TokenBAccount, apiModel.DripCommon.VaultTokenBAccount)
assert.Equal(t, *vault.OracleConfig, *apiModel.OracleConfig)
// if the line below needs to be updated, add the field assertion above
assert.Equal(t, reflect.TypeOf(apiModel.DripCommon).NumField(), 6)
assert.Equal(t, reflect.TypeOf(apiModel.DripCommon).NumField(), 7)
})

}

0 comments on commit be8e328

Please sign in to comment.